> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # UpsertFunctionActivation # Package: functions # Namespace: FunctionActivations # Method link: https://dev.wix.com/docs/api-reference/business-management/functions/function-activations/upsert-function-activation.md ## Permission Scopes: Manage Functions: SCOPE.DC-FUNCTIONS.MANAGE-FUNCTIONS ## Introduction Activates a function or publishes changes to an already active function (reactivates). This method also creates or updates a function activation object. This method's behavior depends on the function specified: - **Functions that aren't already activated**: Calling this method activates the specified function and creates a function activation object. - **Functions that are already activated**: Calling this method reactivates the specified function, meaning it publishes any changes made to function, and updates the function activation associated with the function. > **Note:** If the function hasn't changed since its last activation, nothing happens to the function. However, the function activation object is still updated, meaning its `revision` increases by 1. --- ## REST API ### Schema ``` Method: upsertFunctionActivation Description: Activates a function or publishes changes to an already active function (reactivates). This method also creates or updates a function activation object. This method's behavior depends on the function specified: - **Functions that aren't already activated**: Calling this method activates the specified function and creates a function activation object. - **Functions that are already activated**: Calling this method reactivates the specified function, meaning it publishes any changes made to function, and updates the function activation associated with the function. > **Note:** If the function hasn't changed since its last activation, nothing happens to the function. However, the function activation object is still updated, meaning its `revision` increases by 1. URL: https://www.wixapis.com/functions/v1/function-activations/upsert Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: functionActivation, functionActivation.functionId Method parameters: param name: functionActivation | type: FunctionActivation | description: A function activation is an object that represents the activation of a function. | required: true - name: functionId | type: string | description: GUID of the function activated by this function activation. | required: true Return type: UpsertFunctionActivationResponse - name: functionActivation | type: FunctionActivation | description: The created or updated function activation. - name: id | type: string | description: Function activation GUID. - name: functionId | type: string | description: GUID of the function activated by this function activation. - name: extensionId | type: string | description: GUID of the service plugin extension created upon function activation. This happens automatically and the field is primarily used in the background. - name: appId | type: string | description: App GUID of the business solution that created the function type that the activated function is based on. - name: createdDate | type: string | description: Date and time the function activation was created. - name: updatedDate | type: string | description: Date and time the function activation was last updated. - name: functionExtensionId | type: string | description: GUID of the function type that the activated function is based on. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: ACTIVATION_APP_NOT_FOUND_RETRY | Description: Couldn't find the activation app. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_AUTOMATION | Description: The automation is invalid. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SPI_CONFIG_SCHEMA_MISMATCH | Description: The SPI configuration doesn't match the expected schema. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SPI_CONFIG_TYPE_MISMATCH | Description: The SPI configuration has a type mismatch. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SPI_CONFIG_MISSING_REQUIRED_FIELD | Description: The SPI configuration is missing a required field. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SPI_CONFIG_INVALID | Description: The SPI configuration is invalid. HTTP Code: 429 | Status Code: RESOURCE_EXHAUSTED | Application Code: FUNCTION_ACTIVATIONS_LIMIT_EXCEEDED | Description: FunctionActivations limit exceeded. ``` ### Examples ### Create Function Activation ```curl curl -X POST \ https://www.wixapis.com/functions/v1/activations/upsert \ -H "Authorization: \ -H "Content-Type: application/json" \ -d '{ "functionActivation": { "functionId": "0481a48d-0dff-40a9-abd1-6267a3355e70" } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.functions.FunctionActivations.upsertFunctionActivation(functionActivation) Description: Activates a function or publishes changes to an already active function (reactivates). This method also creates or updates a function activation object. This method's behavior depends on the function specified: - **Functions that aren't already activated**: Calling this method activates the specified function and creates a function activation object. - **Functions that are already activated**: Calling this method reactivates the specified function, meaning it publishes any changes made to function, and updates the function activation associated with the function. > **Note:** If the function hasn't changed since its last activation, nothing happens to the function. However, the function activation object is still updated, meaning its `revision` increases by 1. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: functionActivation, functionActivation.functionId Method parameters: param name: functionActivation | type: FunctionActivation | description: A function activation is an object that represents the activation of a function. | required: true - name: functionId | type: string | description: GUID of the function activated by this function activation. | required: true Return type: PROMISE - name: functionActivation | type: FunctionActivation | description: The created or updated function activation. - name: _id | type: string | description: Function activation GUID. - name: functionId | type: string | description: GUID of the function activated by this function activation. - name: extensionId | type: string | description: GUID of the service plugin extension created upon function activation. This happens automatically and the field is primarily used in the background. - name: appId | type: string | description: App GUID of the business solution that created the function type that the activated function is based on. - name: _createdDate | type: Date | description: Date and time the function activation was created. - name: _updatedDate | type: Date | description: Date and time the function activation was last updated. - name: functionExtensionId | type: string | description: GUID of the function type that the activated function is based on. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: ACTIVATION_APP_NOT_FOUND_RETRY | Description: Couldn't find the activation app. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_AUTOMATION | Description: The automation is invalid. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SPI_CONFIG_SCHEMA_MISMATCH | Description: The SPI configuration doesn't match the expected schema. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SPI_CONFIG_TYPE_MISMATCH | Description: The SPI configuration has a type mismatch. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SPI_CONFIG_MISSING_REQUIRED_FIELD | Description: The SPI configuration is missing a required field. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SPI_CONFIG_INVALID | Description: The SPI configuration is invalid. HTTP Code: 429 | Status Code: RESOURCE_EXHAUSTED | Application Code: FUNCTION_ACTIVATIONS_LIMIT_EXCEEDED | Description: FunctionActivations limit exceeded. ``` ### Examples ### upsertFunctionActivation ```javascript import { functionActivations } from '@wix/functions'; async function upsertFunctionActivation(functionActivation) { const response = await functionActivations.upsertFunctionActivation(functionActivation); }; ``` ### upsertFunctionActivation (with elevated permissions) ```javascript import { functionActivations } from '@wix/functions'; import { auth } from '@wix/essentials'; async function myUpsertFunctionActivationMethod(functionActivation) { const elevatedUpsertFunctionActivation = auth.elevate(functionActivations.upsertFunctionActivation); const response = await elevatedUpsertFunctionActivation(functionActivation); } ``` ### upsertFunctionActivation (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { functionActivations } from '@wix/functions'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { functionActivations }, // Include the auth strategy and host as relevant }); async function upsertFunctionActivation(functionActivation) { const response = await myWixClient.functionActivations.upsertFunctionActivation(functionActivation); }; ``` ---