Skip to main content

The REST Admin API is a legacy API as of October 1, 2024. Starting April 1, 2025, all new public apps must be built exclusively with the GraphQL Admin API. For details and migration steps, visit our migration guide.

ScriptTag

Requires script_tags access scope.
Theme app extensions

If your app integrates with a Shopify theme and you plan to submit it to the Shopify App Store, you must use theme app extensions instead of Script tags. Script tags can only be used with vintage themes. Learn more.

The ScriptTag resource represents remote JavaScript code that is loaded into the pages of a shop's storefront or the order status page of checkout. This lets you add functionality to those pages without using theme templates.

Script tags are scoped to the app that created them. When an app is uninstalled from a shop, all of the script tags that it created are automatically removed along with it.

Was this section helpful?

Anchor to

The ScriptTag resource

Anchor to

Properties


created_at
read-only

The date and time (ISO 8601) when the script tag was created.


event
deprecated

The DOM event that triggers the loading of the script. Valid values: onload.


id
read-only
->
id

The ID for the script tag.


src
->
src

The URL of the remote script.


display_scope

The page or pages on the online store where the script should be included. Valid values:

Show display_scope properties
  • online_store: Include the script only on the web storefront.
  • order_status: Include the script only on the order status page.
  • all: Include the script on both the web storefront and the order status page.

cache

Whether the Shopify CDN can cache and serve the script tag. Valid values:

Show cache properties
  • true: The script will be cached and served by the CDN. The cache expires 15 minutes after the script tag is successfully returned.
  • false: The script will be served as is.
Default value: false.

updated_at
read-only

The date and time (ISO 8601) when the script tag was last updated.


Was this section helpful?
{}

The ScriptTag resource

{
"created_at": "2012-08-24T14:01:47-04:00",
"event": "onload",
"id": 596726825,
"src": "https://js.example.org/foo.js",
"display_scope": "online_store",
"cache": true,
"updated_at": "2012-08-24T14:01:47-04:00"
}

Anchor to POST request, Creates a new script tag
post
Creates a new script tag

Creates a new script tag

Anchor to Parameters of Creates a new script tagParameters


api_version
string
required

Was this section helpful?

Anchor to post-script-tags-examplesExamples

Create a new script tag

Request body
script_tag
Script_tag resource
Show script_tag properties
script_tag.event:"onload"
deprecated

The DOM event that triggers the loading of the script. Valid values: onload.

script_tag.src:"https://example.com/my_script.js"
->
src

The URL of the remote script.

Creating a script tag without a src and event will return an error

Was this section helpful?
post

/admin/api/2025-07/script_tags.json

curl -d '{"script_tag":{"event":"onload","src":"https://example.com/my_script.js"}}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2025-07/script_tags.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"

{}

Response

JSON
HTTP/1.1 201 Created
{
"script_tag": {
"id": 870402687,
"src": "https://example.com/my_script.js",
"event": "onload",
"created_at": "2025-07-01T14:45:09-04:00",
"updated_at": "2025-07-01T14:45:09-04:00",
"display_scope": "all",
"cache": false
}
}

Retrieves a list of all script tags. Note: This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to Make paginated requests to the REST Admin API.


api_version
string
required

created_at_max

Show script tags created before this date. (format: 2014-04-25T16:15:47-04:00)


created_at_min

Show script tags created after this date. (format: 2014-04-25T16:15:47-04:00)


fields

A comma-separated list of fields to include in the response.


limit
≤ 250
default 50

The number of results to return.


since_id

Restrict results to after the specified ID.


src

Show script tags with this URL.


updated_at_max

Show script tags last updated before this date. (format: 2014-04-25T16:15:47-04:00)


updated_at_min

Show script tags last updated after this date. (format: 2014-04-25T16:15:47-04:00)


Was this section helpful?

Retrieve a list of all script tags

Retrieve a list of all script tags after the specified ID

Query parameters
since_id=421379493

Restrict results to after the specified ID.

Retrieve a list of all script tags with a particular URL

Query parameters
src=https://js.example.org/foo.js

Show script tags with this URL.

Was this section helpful?
get

/admin/api/2025-07/script_tags.json

curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-07/script_tags.json" \
-H "X-Shopify-Access-Token: {access_token}"

{}

Response

JSON
HTTP/1.1 200 OK
{
"script_tags": [
{
"id": 421379493,
"src": "https://js.example.org/bar.js",
"event": "onload",
"created_at": "2025-07-01T14:37:24-04:00",
"updated_at": "2025-07-01T14:37:24-04:00",
"display_scope": "all",
"cache": false
},
{
"id": 596726825,
"src": "https://js.example.org/foo.js",
"event": "onload",
"created_at": "2025-07-01T14:37:24-04:00",
"updated_at": "2025-07-01T14:37:24-04:00",
"display_scope": "all",
"cache": false
}
]
}

Retrieves a single script tag


api_version
string
required

script_tag_id
string
required

fields

A comma-separated list of fields to include in the response.


Was this section helpful?

Retrieve a single script tag by its ID

Path parameters
script_tag_id=596726825
string
required
Was this section helpful?
get

/admin/api/2025-07/script_tags/596726825.json

curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-07/script_tags/596726825.json" \
-H "X-Shopify-Access-Token: {access_token}"

{}

Response

JSON
HTTP/1.1 200 OK
{
"script_tag": {
"id": 596726825,
"src": "https://js.example.org/foo.js",
"event": "onload",
"created_at": "2025-07-01T14:37:24-04:00",
"updated_at": "2025-07-01T14:37:24-04:00",
"display_scope": "all",
"cache": false
}
}

Anchor to GET request, Retrieves a count of all script tags
get
Retrieves a count of all script tags
deprecated

Retrieves a count of all script tags


api_version
string
required

src

Count only script tags with a given URL.


Was this section helpful?

Retrieve a count of all script tags for your shop

Was this section helpful?
get

/admin/api/2025-07/script_tags/count.json

curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-07/script_tags/count.json" \
-H "X-Shopify-Access-Token: {access_token}"

{}

Response

JSON
HTTP/1.1 200 OK
{
"count": 2
}

Updates a script tag


api_version
string
required

script_tag_id
string
required

Was this section helpful?

Update a script tag's URL

Path parameters
script_tag_id=596726825
string
required
Request body
script_tag
Script_tag resource
Show script_tag properties
script_tag.id:596726825
read-only

The ID for the script tag.

script_tag.src:"https://somewhere-else.com/another.js"
->
src

The URL of the remote script.

Was this section helpful?
put

/admin/api/2025-07/script_tags/596726825.json

curl -d '{"script_tag":{"id":596726825,"src":"https://somewhere-else.com/another.js"}}' \
-X PUT "https://your-development-store.myshopify.com/admin/api/2025-07/script_tags/596726825.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"

{}

Response

JSON
HTTP/1.1 200 OK
{
"script_tag": {
"src": "https://somewhere-else.com/another.js",
"cache": false,
"id": 596726825,
"event": "onload",
"created_at": "2025-07-01T14:37:24-04:00",
"updated_at": "2025-07-01T14:45:12-04:00",
"display_scope": "all"
}
}

Deletes a script tag


api_version
string
required

script_tag_id
string
required

Was this section helpful?

Delete an existing script tag

Path parameters
script_tag_id=596726825
string
required
Was this section helpful?
del

/admin/api/2025-07/script_tags/596726825.json

curl -X DELETE "https://your-development-store.myshopify.com/admin/api/2025-07/script_tags/596726825.json" \
-H "X-Shopify-Access-Token: {access_token}"

{}

Response

JSON
HTTP/1.1 200 OK
{}