> 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 # UpdateCustomEmbed # Package: customEmbeds # Namespace: CustomEmbedsService # Method link: https://dev.wix.com/docs/api-reference/business-management/custom-embeds/update-custom-embed.md ## Permission Scopes: SCOPE.EDITOR.MANAGE_CUSTOM_EMBEDS: SCOPE.EDITOR.MANAGE_CUSTOM_EMBEDS ## Introduction Updates a custom embed. To prevent conflicting changes, you must pass the current revision number. --- ## REST API ### Schema ``` Method: updateCustomEmbed Description: Updates a custom embed. To prevent conflicting changes, you must pass the current revision number. URL: https://www.wixapis.com/embeds/v1/custom-embeds/{customEmbed.id} Method: PATCH # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: customEmbed, customEmbed.id, customEmbed.revision Method parameters: param name: customEmbed | type: CustomEmbed | description: A custom embed is an entity that manages custom HTML and JavaScript code embedded in a site, along with its placement and properties. | required: true - name: id | type: string | description: Custom embed GUID. | required: true - name: revision | type: string | description: Revision number, which increments by 1 each time the custom embed is updated. To prevent conflicting changes, the current revision must be passed when updating a custom embed. | required: true - name: name | type: string | description: Custom embed name, as displayed to Wix users. - name: enabled | type: boolean | description: Whether the custom embed is enabled on the site. Default: `true`. - name: loadOnce | type: boolean | description: Whether to load the custom embed once during initial site rendering, rather than on each page navigation. This setting affects performance and should be chosen based on the embed's functionality. Default: `true`. - name: domain | type: string | description: Site domain that's connected to the site, if relevant. - name: position | type: PositionOnPage | description: Position where the custom embed code is placed on the page. - enum: - UNKNOWN_POSITION: Illegal value, exception will be thrown if used - HEAD: HEAD position - BODY_START: BODY_START position - BODY_END: BODY_END position - name: embedData | type: CustomEmbed | description: Custom embed data. - name: category | type: Category | description: CustomEmbed's category - enum: - UNKNOWN_CATEGORY: Illegal type, exception will be thrown if used - ESSENTIAL: Essential category - FUNCTIONAL: Functional category - ANALYTICS: Analytics category - ADVERTISING: Advertising category - DATA_TO_THIRD_PARTY: Data to third party category - name: html | type: string | description: CustomEmbed's html Return type: UpdateCustomEmbedResponse - name: customEmbed | type: CustomEmbed | description: Updated custom embed. - name: id | type: string | description: Custom embed GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the custom embed is updated. To prevent conflicting changes, the current revision must be passed when updating a custom embed. - name: name | type: string | description: Custom embed name, as displayed to Wix users. - name: enabled | type: boolean | description: Whether the custom embed is enabled on the site. Default: `true`. - name: loadOnce | type: boolean | description: Whether to load the custom embed once during initial site rendering, rather than on each page navigation. This setting affects performance and should be chosen based on the embed's functionality. Default: `true`. - name: domain | type: string | description: Site domain that's connected to the site, if relevant. - name: position | type: PositionOnPage | description: Position where the custom embed code is placed on the page. - enum: - UNKNOWN_POSITION: Illegal value, exception will be thrown if used - HEAD: HEAD position - BODY_START: BODY_START position - BODY_END: BODY_END position - name: embedData | type: CustomEmbed | description: Custom embed data. - name: category | type: Category | description: CustomEmbed's category - enum: - UNKNOWN_CATEGORY: Illegal type, exception will be thrown if used - ESSENTIAL: Essential category - FUNCTIONAL: Functional category - ANALYTICS: Analytics category - ADVERTISING: Advertising category - DATA_TO_THIRD_PARTY: Data to third party category - name: html | type: string | description: CustomEmbed's html - name: pageFilter | type: PageFilter | description: Page GUIDs where the custom embed should be loaded. By default, custom embeds are applied to all site pages. - name: pageIds | type: array | description: Pages where the site embed will be loaded. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: CUSTOM_EMBED_NOT_FOUND | Description: Couldn't find the custom embed. ``` ### Examples ### Update Custom Embed ```curl curl -X PATCH \ 'https://www.wixapis.com/embeds/v1/custom-embeds/8046df3c-7575-4098-a5ab-c91ad8f33c47' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -d '{ "customEmbed": { "id": "8046df3c-7575-4098-a5ab-c91ad8f33c47", "revision": "1", "name": "Updated Custom Embed", "enabled": true, "position": "BODY_END", "embedData": { "category": "ANALYTICS", "html": "" } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.customEmbeds.CustomEmbedsService.updateCustomEmbed(_id, customEmbed) Description: Updates a custom embed. To prevent conflicting changes, you must pass the current revision number. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: customEmbed, _id, customEmbed.revision Method parameters: param name: _id | type: string | description: Custom embed GUID. | required: true param name: customEmbed | type: UpdateCustomEmbed | description: A custom embed is an entity that manages custom HTML and JavaScript code embedded in a site, along with its placement and properties. | required: true - name: revision | type: string | description: Revision number, which increments by 1 each time the custom embed is updated. To prevent conflicting changes, the current revision must be passed when updating a custom embed. | required: true - name: name | type: string | description: Custom embed name, as displayed to Wix users. - name: enabled | type: boolean | description: Whether the custom embed is enabled on the site. Default: `true`. - name: loadOnce | type: boolean | description: Whether to load the custom embed once during initial site rendering, rather than on each page navigation. This setting affects performance and should be chosen based on the embed's functionality. Default: `true`. - name: domain | type: string | description: Site domain that's connected to the site, if relevant. - name: position | type: PositionOnPage | description: Position where the custom embed code is placed on the page. - enum: - UNKNOWN_POSITION: Illegal value, exception will be thrown if used - HEAD: HEAD position - BODY_START: BODY_START position - BODY_END: BODY_END position - name: embedData | type: CustomEmbed | description: Custom embed data. - name: category | type: Category | description: CustomEmbed's category - enum: - UNKNOWN_CATEGORY: Illegal type, exception will be thrown if used - ESSENTIAL: Essential category - FUNCTIONAL: Functional category - ANALYTICS: Analytics category - ADVERTISING: Advertising category - DATA_TO_THIRD_PARTY: Data to third party category - name: html | type: string | description: CustomEmbed's html Return type: PROMISE - name: _id | type: string | description: Custom embed GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the custom embed is updated. To prevent conflicting changes, the current revision must be passed when updating a custom embed. - name: name | type: string | description: Custom embed name, as displayed to Wix users. - name: enabled | type: boolean | description: Whether the custom embed is enabled on the site. Default: `true`. - name: loadOnce | type: boolean | description: Whether to load the custom embed once during initial site rendering, rather than on each page navigation. This setting affects performance and should be chosen based on the embed's functionality. Default: `true`. - name: domain | type: string | description: Site domain that's connected to the site, if relevant. - name: position | type: PositionOnPage | description: Position where the custom embed code is placed on the page. - enum: - UNKNOWN_POSITION: Illegal value, exception will be thrown if used - HEAD: HEAD position - BODY_START: BODY_START position - BODY_END: BODY_END position - name: embedData | type: CustomEmbed | description: Custom embed data. - name: category | type: Category | description: CustomEmbed's category - enum: - UNKNOWN_CATEGORY: Illegal type, exception will be thrown if used - ESSENTIAL: Essential category - FUNCTIONAL: Functional category - ANALYTICS: Analytics category - ADVERTISING: Advertising category - DATA_TO_THIRD_PARTY: Data to third party category - name: html | type: string | description: CustomEmbed's html - name: pageFilter | type: PageFilter | description: Page GUIDs where the custom embed should be loaded. By default, custom embeds are applied to all site pages. - name: pageIds | type: array | description: Pages where the site embed will be loaded. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: CUSTOM_EMBED_NOT_FOUND | Description: Couldn't find the custom embed. ``` ### Examples ### updateCustomEmbed ```javascript import { customEmbeds } from '@wix/embeds'; async function updateCustomEmbed(_id,customEmbed) { const response = await customEmbeds.updateCustomEmbed(_id,customEmbed); }; ``` ### updateCustomEmbed (with elevated permissions) ```javascript import { customEmbeds } from '@wix/embeds'; import { auth } from '@wix/essentials'; async function myUpdateCustomEmbedMethod(_id,customEmbed) { const elevatedUpdateCustomEmbed = auth.elevate(customEmbeds.updateCustomEmbed); const response = await elevatedUpdateCustomEmbed(_id,customEmbed); } ``` ### updateCustomEmbed (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 { customEmbeds } from '@wix/embeds'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { customEmbeds }, // Include the auth strategy and host as relevant }); async function updateCustomEmbed(_id,customEmbed) { const response = await myWixClient.customEmbeds.updateCustomEmbed(_id,customEmbed); }; ``` ---