TanqoryDocs

Storefront API

Read a store's catalog and build carts from your own site or app, with a storefront access token your app creates.

The Storefront API is the API for what buyers see: products, collections, pages, search, carts and checkout links. It answers on the store's own domain and takes a storefront access token, which your app creates with the Admin API. That token only reads what the store shows to every visitor and builds carts, so it is not a secret in the way your Admin API token is.

Before you start

You need an app installed on a store and its Admin API access token, as in Make your first API call, and the store's domain. Read the domain with the Admin API:

GraphQL
{ shop { primaryDomain { host } } }
JSON
{ "data": { "shop": { "primaryDomain": { "host": "docs-writer-store.mytanqory.com" } } } }

1. Create a storefront access token

Call storefrontAccessTokenCreate with your app's Admin API token. It needs no access scope of its own.

curl
curl -X POST "https://api.tanqory.com/admin/2026-10/stores/$STORE_ID/graphql" \
  -H "Authorization: Bearer $TANQORY_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"query": "mutation { storefrontAccessTokenCreate(input: { title: \"My storefront\" }) { storefrontAccessToken { accessToken accessScopes { handle } } userErrors { field message } } }"}'

The answer (the token shortened here):

JSON
{
  "data": {
    "storefrontAccessTokenCreate": {
      "storefrontAccessToken": {
        "accessToken": "e1c3…",
        "accessScopes": [
          { "handle": "unauthenticated_read_product_listings" },
          { "handle": "unauthenticated_write_checkouts" },
          { "handle": "unauthenticated_read_checkouts" },
          { "handle": "unauthenticated_read_selling_plans" }
        ]
      },
      "userErrors": []
    }
  }
}

2. Call the Storefront API

POST https://<store domain>/api/v1/stores/<store id>/2026-10/graphql, with the token in X-Tanqory-Storefront-Access-Token. On the store's own domain the short address https://<store domain>/api/2026-10/graphql.json (or /graphql) is the same API for that store, with no store id:

Shell
export TANQORY_STOREFRONT_TOKEN=<accessToken from step 1>
export STORE_HOST=<host from "Before you start">
curl -X POST "https://$STORE_HOST/api/v1/stores/$STORE_ID/2026-10/graphql" \
  -H "X-Tanqory-Storefront-Access-Token: $TANQORY_STOREFRONT_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"query": "{ shop { name } products(first: 2) { nodes { title handle variants(first: 1) { nodes { id price { amount currencyCode } } } } } }"}'

The answer:

JSON
{
  "data": {
    "shop": { "name": "Docs Writer Store" },
    "products": {
      "nodes": [
        { "title": "Linen Throw", "handle": "linen-throw", "variants": { "nodes": [{ "id": "gid://tanqory/ProductVariant/01a1dcb0-711d-72b3-b72f-032093b8ec7a", "price": { "amount": "2490.0", "currencyCode": "THB" } }] } },
        { "title": "Tall Stoneware Vase", "handle": "stoneware-vase", "variants": { "nodes": [{ "id": "gid://tanqory/ProductVariant/01a1dcb0-7616-7203-9e69-2c2c34fd9f67", "price": { "amount": "1290.0", "currencyCode": "THB" } }] } }
      ]
    }
  }
}

3. Create a cart

Pass a variant id from step 2 as merchandiseId:

GraphQL
mutation CreateCart($lines: [CartLineInput!]) {
  cartCreate(input: { lines: $lines }) {
    cart { id checkoutUrl totalQuantity cost { totalAmount { amount currencyCode } } }
    userErrors { field message }
  }
}
JSON
{ "lines": [{ "merchandiseId": "gid://tanqory/ProductVariant/01a1dcb0-711d-72b3-b72f-032093b8ec7a", "quantity": 1 }] }

The answer holds the cart and its checkoutUrl, on the store's own domain:

JSON
{
  "data": {
    "cartCreate": {
      "cart": {
        "id": "gid://tanqory/Cart/c1-5c39da09b860e971a6d65b8ddedb36cf?key=4a71176a3c676c9200d6a848e2609166",
        "checkoutUrl": "https://docs-writer-store.mytanqory.com/cart/c/c1-5c39da09b860e971a6d65b8ddedb36cf?key=4a71176a3c676c9200d6a848e2609166",
        "totalQuantity": 1,
        "cost": { "totalAmount": { "amount": "2490.0", "currencyCode": "THB" } }
      },
      "userErrors": []
    }
  }
}

Send the buyer to checkoutUrl to pay. Keep the cart id, with its key, to add lines later with cartLinesAdd.

Errors

A missing token, a token that is not valid, or one of another store answers HTTP 401, before GraphQL runs:

JSON
{"error":{"code":"invalid_access_token","message":"Send a valid access token in the X-Tanqory-Storefront-Access-Token header. The token sent is missing, not valid, or belongs to another store.","status":401}}

Everything else is a GraphQL answer, described in Errors.

Good to know

  • Password-protected stores. A store's password closes its online store pages, not its Storefront API. New stores, development stores among them, start password-protected, and the API answers there with a valid token.
  • Where to call it from. From your server, or from a browser on any domain: the API answers the browser's cross-origin preflight and lets any page read its answers (Access-Control-Allow-Origin: *, no cookies). A browser may send only the public X-Tanqory-Storefront-Access-Token, never the private token, which is for servers.
  • Versions. Name a version in the URL, as above. /api/v1/stores/<store id>/graphql without a version serves the newest one and moves on with each release; see Versioning.
  • What the token opens. The public scopes listed in step 1: published products and collections, carts and checkout links, and selling plans. Nothing about customers or orders, and nothing that changes the store.
  • The Storefront API reference lists every query, mutation and type.

Built from commit c0b3fb3fdef7 · API version 2026-10