Skip to content

Create a theme preview token

POST
/stores/{storeRef}/themes/{id}/preview-token
curl --request POST \
--url https://apibase.ecomweb.app/api/v1/stores/example/themes/example/preview-token \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '{ "draft": true }'

Returns a signed token that opens a preview of this theme on the storefront for 24 hours, and the theme’s own preview address when it uses a catalog release. Send draft: true to also get a draft_id: the token then opens the unsaved values written with the preview draft route. Needs the read:settings scope.

Required scopes: read:settings

id
required
string

The theme ID.

storeRef
required
string

The store’s ref, as returned by GET /stores.

Media typeapplication/json
object
draft

The theme editor’s token: it also opens a draft of unsaved values.

boolean

Example generated

{
"draft": true
}
Media typeapplication/json
object
expires_at
required

When the token stops working, as an ISO 8601 timestamp.

string format: date-time
url
required

The theme’s own preview address, which shows a catalog release without a token, or null for a build or a link.

string
nullable
draft_id

ID of the draft the token opens. Only when the request asked for a draft.

string
token
required

A signed token that opens a preview of the theme on the storefront. It works for 24 hours.

string

Example generated

{
"expires_at": "2026-04-15T12:00:00Z",
"url": "example",
"draft_id": "example",
"token": "example"
}

The request is malformed or failed validation.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key is missing, invalid, revoked or expired.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The resource does not exist in this store.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}