The ScriptTag resource represents remote javascript which is loaded into the pages of a shop's storefront and in the final "Thank You" page of checkout. This makes it easy to add functionality to those pages without touching any theme templates. A script tag has two main attributes:

  • src: The URL of the remote script.
  • event: The DOM event which triggers the loading of the script. Currently, "onload" is the only supported event.

When an app is uninstalled from a shop, all of the script tags which it created are automatically removed along with it.

Reminder A ScriptTag will only appear in checkout if the src starts with 'https://' in order not to break the SSL lock.

Authenticated access scopes: web.read_script_tags, com.write_script_tags

ScriptTag properties

created_at

"created_at": "2021-05-13T07:29:20.1Z"

The date and time (ISO 8601 format) when the ScriptTag was created.

event

"event": "onload"

DOM event which triggers the loading of the script. Valid values are: "onload".

id

"id": 1206854680

The unique numeric identifier for the ScriptTag.

src

"src": "http://yourapp.com/foo.js"

Specifies the location of the ScriptTag.

updated_at

"updated_at": "2021-05-13T07:29:20.808Z"

The date and time (ISO 8601 format) when the ScriptTag was last updated.

display_scope

"display_scope": "all"

Specifies where the file should be included. Valid values are: "all".

Endpoints

GET https://apis.haravan.com/web/script_tags.json

Receive a list of all ScriptTags.

limit

Limit of the result.(default: 50) (maximum: 50)

page

Page to show the result.(default: 1)

since_id

Restrict results to after the specified ID

created_at_min

Show script_tags created after date (format: 2008-12-31 03:00).

created_at_max

Show script_tags created before date (format: 2008-12-31 03:00).

created_at_min

Show script_tags created after date (format: 2008-12-31 03:00).

updated_at_min

Show script_tags created after date (format: 2008-12-31 03:00).

updated_at_max

Show script_tags updated after date (format: 2008-12-31 03:00).

fields

Comma-separated list of fields to include in the response.

src

Show script tags with a given URL.

Retrieves a list of enabling discount codes by page number. By default, the number of resources on the page is 50.

GET https://apis.haravan.com/com/discounts.json?page=2

View response

HTTP/1.1 200 OK
{
    "script_tags": [
        {
            "created_at": "2022-02-09T03:13:35.224Z",
            "event": "onload",
            "id": 1000132951,
            "src": "https:your-app.com/foo.js",
            "updated_at": "2022-02-09T03:13:35.224Z",
            "display_scope": "all"
        }
    ]
}
				

Get script tags with a particular URL.

GET https://apis.haravan.com/web/script_tags.json?src=http://your-app.com/foo.js

View response

HTTP/1.1 200 OK
{
    "script_tags": [
        {
            "created_at": "2022-02-09T03:48:55.204Z",
            "event": "onload",
            "id": 1000132953,
            "src": "http://your-app.com/foo.js",
            "updated_at": "2022-02-09T03:48:55.204Z",
            "display_scope": "all"
        }
    ]
}	
GET https://apis.haravan.com/web/script_tags/count.json

Receive a count of all ScriptTags.

Receive a count of all ScriptTags.

GET https://apis.haravan.com/web/script_tags/count.json

View response

HTTP/1.1 200 OK
{
    "count": 1
}

Get a single script tag by its ID.

GET https://apis.haravan.com/web/script_tags/1000132953.json

View response

HTTP/1.1 200 OK
{
    "script_tag": {
        "created_at": "2022-02-09T03:48:55.204Z",
        "event": "onload",
        "id": 1000132953,
        "src": "http://your-app.com/foo.js",
        "updated_at": "2022-02-09T03:48:55.204Z",
        "display_scope": "all"
    }
}

Create a new ScriptTag.

POST https://apis.haravan.com/web/script_tags.json

{
  "script_tag": {
    "event": "onload",
    "src": "http://your-app.com/foo.js"
  }
}

View response

HTTP/1.1 200 OK
{
    "script_tag": {
        "created_at": "2022-02-09T03:48:55.204Z",
        "event": "onload",
        "id": 1000132953,
        "src": "http://your-app.com/foo.js",
        "updated_at": "2022-02-09T03:48:55.204Z",
        "display_scope": "all"
    }
}

Update a script tags's URL.

PUT https://apis.haravan.com/web/script_tags/1000132953.json

{
  "script_tag": {
    "id": 1000132953,
    "src": "http://your-app.com/another.js"
  }
}

View response

HTTP/1.1 200 OK
{
    "script_tag": {
        "created_at": "2022-02-09T03:48:55.204Z",
        "event": "onload",
        "id": 1000132953,
        "src": "http://your-app.com/another.js",
        "updated_at": "2022-02-09T03:59:46.094Z",
        "display_scope": "all"
    }
}
DELETE https://apis.haravan.com/web/script_tags/{id}.json

Remove an existing script tag from a shop.


Remove an existing script tag from a shop.

DELETE https://apis.haravan.com/web/script_tags/1000132953.json

{}

View response

HTTP/1.1 200 OK
[]