Create a theme preview token
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/themes/example/preview-token';const options = { method: 'POST', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"draft":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The theme ID.
The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The theme editor’s token: it also opens a draft of unsaved values.
Example generated
{ "draft": true}Responses
Section titled “Responses”object
When the token stops working, as an ISO 8601 timestamp.
The theme’s own preview address, which shows a catalog release without a token, or null for a build or a link.
ID of the draft the token opens. Only when the request asked for a draft.
A signed token that opens a preview of the theme on the storefront. It works for 24 hours.
Example generated
{ "expires_at": "2026-04-15T12:00:00Z", "url": "example", "draft_id": "example", "token": "example"}The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
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.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The resource does not exist in this store.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}