The REST Admin API is a legacy API as of October 1, 2024. All apps and integrations should be built with the GraphQL Admin API. For details and migration steps, visit our migration guide.

Requires script_tags access scope.

Theme app extensions

Your app might not pass App Store review if it uses script tags instead of theme app extensions. All new apps, and apps that integrate with Online Store 2.0 themes, should use theme app extensions, such as app blocks or app embed blocks. Script tags are an alternative you can use with only 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?

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:

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

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"
}

Was this section helpful?
Request body
scripttag
Script_tag resource
Was this section helpful?
post
/admin/api/2024-10/script_tags.json
Copy
curl -d '{"script_tag":{"event":"onload","src":"https://example.com/my_script.js"}}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2024-10/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": "2024-09-23T15:51:51-04:00",
    "updated_at": "2024-09-23T15:51:51-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?
Was this section helpful?
get
/admin/api/2024-10/script_tags.json
Copy
curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/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": "2024-09-23T15:51:31-04:00",
      "updated_at": "2024-09-23T15:51:31-04:00",
      "display_scope": "all",
      "cache": false
    },
    {
      "id": 596726825,
      "src": "https://js.example.org/foo.js",
      "event": "onload",
      "created_at": "2024-09-23T15:51:31-04:00",
      "updated_at": "2024-09-23T15:51:31-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?
Path parameters
scripttagid=596726825
string
required
Was this section helpful?
get
/admin/api/2024-10/script_tags/596726825.json
Copy
curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/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": "2024-09-23T15:51:31-04:00",
    "updated_at": "2024-09-23T15:51:31-04:00",
    "display_scope": "all",
    "cache": false
  }
}

Retrieves a count of all script tags

api_version
string
required

src
Count only script tags with a given URL.

Was this section helpful?
Was this section helpful?
get
/admin/api/2024-10/script_tags/count.json
Copy
curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/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?
Path parameters
scripttagid=596726825
string
required
Request body
scripttag
Script_tag resource
Was this section helpful?
put
/admin/api/2024-10/script_tags/596726825.json
Copy
curl -d '{"script_tag":{"id":596726825,"src":"https://somewhere-else.com/another.js"}}' \
-X PUT "https://your-development-store.myshopify.com/admin/api/2024-10/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": "2024-09-23T15:51:31-04:00",
    "updated_at": "2024-09-23T15:51:55-04:00",
    "display_scope": "all"
  }
}

Deletes a script tag

api_version
string
required

script_tag_id
string
required

Was this section helpful?
Path parameters
scripttagid=596726825
string
required
Was this section helpful?
del
/admin/api/2024-10/script_tags/596726825.json
Copy
curl -X DELETE "https://your-development-store.myshopify.com/admin/api/2024-10/script_tags/596726825.json" \
-H "X-Shopify-Access-Token: {access_token}"
{}Response
JSON
HTTP/1.1 200 OK
{}