Skip to main content
POST
Create a script
Creates a script owned by your installation. The store is bound to your app token server-side, so never send a shop id.

The integration field

integration is optional for app tokens. An app script belongs to the installation, not to a merchant catalog integration, so you can leave the field out:
If you send integration, it must name your own app. Any of these values is accepted and not stored, because the installation already records the owner:
  • your app id, from GET /app/context at data.app.id. It is also the id in the developer console URL, /apps/developer/<id>.
  • your client id, app_<hex>
  • your installation id, from GET /app/context at data.app.installationId
Any other value returns 400 with Unknown script integration. A merchant session gets the same message when the id is not a catalog script integration.

Before you create

Call GET /scripts, or GET /scripts/integration/<your app id>, before creating anything. An app sees only its own scripts, so this read back tells you whether a previous install already created one and avoids duplicates on reinstall. Both return data as an array.

Prefer an app embed when you can

If the script only needs to load on every page, declare an app embed instead of writing through this API. See Storefront extensions: the platform injects the script at install and you make no runtime call. Use the scripts API when the code must be created, changed or switched per store at runtime.

Uninstall

Uninstalling switches your running scripts off and remembers which ones were on. If the merchant reinstalls and grants WRITE_SCRIPTS again, those scripts come back on. Check GET /scripts after an install before creating a new one.

Authorizations

Authorization
string
header
required

Installed-app access token (prefix app_), issued by the OAuth install flow. The store is bound to the token server-side — never send a shop id.

Body

application/json
integration
string

Optional for app tokens. Your own app id (from GET /app/context, data.app.id), your client id or your installation id. The value is accepted and not stored, because an app script belongs to the installation. A merchant session must send a catalog script integration instead.

code
string

The script/tracking code to inject into the storefront.

enabled
boolean

Whether the script is active.

Response

The created script.

Standard Salesive response envelope. The operation-specific payload is carried in data.

status
integer
required

HTTP status code, echoed in the body.

success
boolean
required

Whether the request succeeded.

message
string
required

Human-readable result message.

data
object

A storefront script/tracking snippet. An app only ever sees the scripts its own installation created.