Custom Code

Manage custom scripts and code for your Webflow site using the Scripts tools. Register scripts, apply them to sites or pages, and manage script configurations.

Currently, only site-level custom code is supported, and only JavaScript scripts can be applied. Page-level scripts aren’t yet supported.


List registered scripts

List all registered scripts for a site. To apply a script to a site or page, first register it via the Register Script endpoints, then apply it using the relevant Site or Page endpoints.

Tool: site_registered_scripts_list

site_id
stringRequired

Unique identifier for the site

Returns

Response
1{
2 "registeredScripts": [
3 {
4 "id": "alert",
5 "canCopy": false,
6 "displayName": "Alert",
7 "hostedLocation": "https://cdn.webflow.io/.../alert-0.0.1.js",
8 "integrityHash": {},
9 "createdOn": "2022-10-26T00:28:54.191Z",
10 "version": "0.0.1"
11 },
12 {
13 "id": "alert",
14 "canCopy": false,
15 "displayName": "Alert",
16 "hostedLocation": "https://cdn.webflow.io/.../alert-0.0.2.js",
17 "integrityHash": {},
18 "createdOn": "2022-10-26T00:28:54.191Z",
19 "version": "0.0.2"
20 },
21 {
22 "id": "cms_slider",
23 "canCopy": true,
24 "displayName": "CMS Slider",
25 "hostedLocation": "https://cdn.jsdelivr.net/.../cms_slider.js",
26 "integrityHash": "sha384-J+YlJ8v0gpaRoKH7SbFbEmxOZlAxLiwNjfSsBhDooGa5roXlPPpXbEevck4J7YZ+",
27 "createdOn": "2022-10-26T00:28:54.191Z",
28 "version": "1.0.0"
29 }
30 ],
31 "pagination": {
32 "limit": 100,
33 "offset": 0,
34 "total": 3
35 }
36}

List applied scripts

Get all scripts applied to a site by the App. To apply a script to a site or page, first register it via the Register Script endpoints, then apply it using the relevant Site or Page endpoints.

Tool: site_applied_scripts_list

site_id
stringRequired

Unique identifier for the site

Returns

Response
1{
2 "scripts": [
3 {
4 "id": "cms_slider",
5 "location": "header",
6 "version": "1.0.0",
7 "attributes": {
8 "my-attribute": "some-value"
9 }
10 },
11 {
12 "id": "alert",
13 "location": "header",
14 "version": "0.0.1",
15 "attributes": {}
16 }
17 ],
18 "lastUpdated": "2022-10-26T00:28:54.191Z",
19 "createdOn": "2022-10-26T00:28:54.191Z"
20}

Add inline site script

Register an inline script for a site and apply it to a site. Inline scripts are limited to 2000 characters.

Tool: add_inline_site_script

site_id
stringRequired

Unique identifier for the site

request
objectRequired

Script registration request

sourceCode
stringRequired

JavaScript code (max 2000 characters)

version
stringRequired

Script version identifier

displayName
stringRequired

Name for the script

canCopy
booleanDefaults to true

Whether the script can be copied

location
enumRequired

Where to apply the script (header or footer)

attributes
object

Optional script attributes

Returns

Response
1{
2 "id": "alert",
3 "canCopy": false,
4 "displayName": "Alert",
5 "hostedLocation": "https://uploads-ssl.webflow.com/6258612d1ee792848f805dcf%2F64b6c769ff52ba6c3d904a91%2F660d6e15b3d1696f2d2b1447%2Falert-0.0.1.js",
6 "integrityHash": {},
7 "createdOn": "2022-10-26T00:28:54.191Z",
8 "version": "0.0.1"
9}

Delete all site scripts

Delete all custom code scripts from a site.

Tool: delete_all_site_scripts

site_id
stringRequired

Unique identifier for the site

Returns

Response
1{}

Example workflow

  1. List registered scripts to see what’s available
  2. List applied scripts to see what’s currently active
  3. Add inline scripts as needed for site functionality
  4. Remove scripts when no longer needed

Best practices

  • Keep inline scripts under 2000 characters
  • Use descriptive display names for easier management
  • Place critical scripts in the header, non-critical in the footer
  • Test scripts in a staging environment before applying to production