A Shopify Storefront API access token is one of two things. A public token travels in the X-Shopify-Storefront-Access-Token header and is meant to be visible to buyers. A private token travels in Shopify-Storefront-Private-Token and stays on a server. Some queries need neither, because the API also answers requests that carry no token at all.
Which one you want depends on where the request is made from. Where you get it depends on whether you run the store or build an app that other stores install. The API version throughout is 2026-10, the latest stable release in November 2026.
Do you need a token at all?
Often not, to begin with. The Storefront API reference lists what tokenless access covers: products and collections, selling plans, search, pages, blogs and articles, and the cart, both reading and writing.
curl -X POST https://your-store.myshopify.com/api/2026-10/graphql.json \
-H 'Content-Type: application/json' \
-d '{"query": "{ products(first: 3) { nodes { id title } } }"}'
Two limits come with it. The first is a query complexity limit of 1,000, and the reference says a query over it fails with the code MAX_COMPLEXITY_EXCEEDED. Each response reports what the query cost in extensions.cost.requestedQueryCost. When we asked Shopify’s public Hydrogen demo store for 250 products with up to 250 variant IDs each, without a token, the reported cost was 144, so a listing query of that size fits with room to spare.
The second limit is the data. The reference says product tags, metaobjects and metafields, menus and customers need a token. Inventory does too. Asking the same demo store for quantityAvailable without a token returned HTTP 200 with the rest of the data, null for that field and one error per product. Our post on reading stock levels through the Storefront API covers the scope behind it.
Do not count on an error to tell you a field needs a token. In the same test, tags came back as an empty array on all ten products with no error, and we could not tell whether those products have tags. menu(handle: "main-menu") returned a menu, although the reference lists menus as token-only. Check the fields you depend on against your own store.
The official @shopify/storefront-api-client (2.0.1 when this was written) will not start without a token. It throws Storefront API Client: a public or private access token must be provided, so tokenless requests mean plain fetch.
Public or private: which Shopify Storefront API access token?
Decide by where the code runs.
A public token is for a browser or a mobile app. The reference describes that as a place “where the token is visible to buyers”, so anyone reading it out of the bundle is expected. It also says public access capacity “scales with the number of buyers, based on their IP address”, which works because each buyer’s device makes its own requests.
A private token is for a server: a Next.js route handler, an Astro endpoint, a Worker. It is a secret, and the client library above throws if you pass it privateAccessToken where window exists.
With a private token, every buyer reaches Shopify from your server’s address. So on any request that results from buyer traffic, send the buyer’s address in a Shopify-Storefront-Buyer-IP header, spelled exactly like that, because the docs mark the name as case-sensitive. Without it, the reference says, Shopify “can’t differentiate requests from different buyers, which can result in throttled API requests, limited bot protection, and unauthenticated flows at checkout”. A request Shopify judges malicious gets a 430 Shopify Security Rejection. Requests with no buyer behind them, such as a static build generating product pages, do not need the header.
Where do you get a token?
The admin screen that older tutorials point at is closed. Shopify’s page on admin-created custom apps now says “You can no longer create new admin-created custom apps”. Existing ones keep working, and their Storefront API access token is still on the app’s page under Settings, Apps and sales channels, Develop apps.
For a store you run, install the Headless channel. Clicking Create storefront generates a public and a private token together. Permissions are ticked in the admin, not declared as scopes, and they are shared across every storefront in the channel. The private token can be rotated: generate a new one, deploy it, then delete the old one, which stays valid until you do.
For an app, tokens come from the GraphQL Admin API. storefrontAccessTokenCreate makes a public token, and delegateAccessTokenCreate makes one you can send as a private token.
mutation CreatePublicToken {
storefrontAccessTokenCreate(input: {title: "Marketing site"}) {
storefrontAccessToken {
id
accessToken
accessScopes {
handle
}
}
userErrors {
field
message
}
}
}
mutation CreatePrivateToken {
delegateAccessTokenCreate(
input: {
delegateAccessScope: [
"unauthenticated_read_product_listings"
"unauthenticated_read_product_inventory"
]
}
) {
delegateAccessToken {
accessToken
expiresIn
}
userErrors {
field
message
}
}
}
The public token takes on the app’s unauthenticated scopes, the unauthenticated_read_product_listings family, so read accessScopes on the result to see what it can do. The REST reference for the same resource says creation fails when the app has been granted none. The limit is 100 active storefront access tokens per shop.
The delegate token expires, where the StorefrontAccessToken object has no expiry field at all. Shopify’s delegate access guide says it inherits the remaining lifetime of the token that created it, and that refreshing the parent does not extend it. An app made in the Dev Dashboard and authenticated with the client credentials grant holds a 24-hour token, so a private Storefront token minted from it is dead within a day. Either mint a new one whenever the parent is renewed, or skip the delegate and send the app’s own access token in the private header. Shopify’s @shopify/shopify-api library (15.1.2) does the second, and the reference describes it as requesting unauthenticated scopes “on an existing access token”. Public apps are on a shorter clock still: our guide to expiring offline access tokens covers their one-hour tokens.
What does a rejected token look like?
It depends on which header carried it. The reference describes one case, a missing scope reported as ACCESS_DENIED inside an HTTP 200. These are the responses the Hydrogen demo store gave on 27 November 2026:
| Request | Status | extensions.code |
|---|---|---|
| Unknown value in the public header | 401 | UNAUTHORIZED |
| Unknown value in the private header | 403 | ACCESS_DENIED |
| Accepted request, field outside its access | 200 | ACCESS_DENIED |
The first two arrive with an empty message, so log the status and the code. The third is easy to miss, because the status is 200 and the other fields are present. Its message reads “Access denied for quantityAvailable field. Required access: unauthenticated_read_product_inventory access scope.”, and extensions.requiredAccess repeats the scope. A client that only checks response.ok renders the product with no stock figure and logs nothing.
The docs also list a 403 with the body "Unavailable Shop" for a store flagged as fraudulent, so read the body before blaming the token.
This helper sends the right header for each kind of access and turns all three failures into errors:
const API_VERSION = '2026-10';
export type StorefrontAuth =
| {kind: 'tokenless'}
| {kind: 'public'; token: string}
| {kind: 'private'; token: string; buyerIp?: string};
type GraphQLError = {
message: string;
extensions?: {code?: string; requiredAccess?: string};
};
export async function storefront<T>(
shop: string,
auth: StorefrontAuth,
query: string,
variables: Record<string, unknown> = {},
): Promise<T> {
const headers: Record<string, string> = {'Content-Type': 'application/json'};
if (auth.kind === 'public') {
headers['X-Shopify-Storefront-Access-Token'] = auth.token;
}
if (auth.kind === 'private') {
headers['Shopify-Storefront-Private-Token'] = auth.token;
if (auth.buyerIp) headers['Shopify-Storefront-Buyer-IP'] = auth.buyerIp;
}
const res = await fetch(`https://${shop}/api/${API_VERSION}/graphql.json`, {
method: 'POST',
headers,
body: JSON.stringify({query, variables}),
});
if (res.status === 401 || res.status === 403) {
throw new Error(
`HTTP ${res.status} on a ${auth.kind} request: ${await res.text()}`,
);
}
if (!res.ok) throw new Error(`Storefront API returned HTTP ${res.status}`);
const body = (await res.json()) as {data?: T; errors?: GraphQLError[]};
const errors = body.errors ?? [];
const denied = errors.filter((e) => e.extensions?.code === 'ACCESS_DENIED');
if (denied.length > 0) {
const missing = new Set(
denied.map((e) => e.extensions?.requiredAccess ?? e.message),
);
throw new Error(`Missing Storefront API access: ${[...missing].join(', ')}`);
}
if (errors.length > 0 || body.data === undefined) {
throw new Error(errors.map((e) => e.message).join('; ') || 'Empty response');
}
return body.data;
}
Throwing on any ACCESS_DENIED is deliberately strict. If a page can live without the field, drop it from the query.
Which token would we use?
For a server-rendered storefront on one store: the Headless channel’s private token, held in server-side environment variables, with the buyer’s IP forwarded on every request a buyer triggered.
Start tokenless for a prototype, or for a widget that only needs the data on the tokenless list, and move when a query needs tags, metafields or stock. Keep the public token for cases with no server in the path, such as a static site with client-side add to basket or a mobile app. We would not send a public token from a server. Its capacity is worked out from buyer IP addresses, and a server presents one address for everyone.
For an app, send the app’s own token as the private token, and treat any delegate token as a credential with an expiry date you have to manage. Once requests are authenticated, our walkthrough of the Storefront API cart picks up from there.
Whoooop builds Shopify stores and the custom storefronts and integrations around them. If a headless build is returning empty fields nobody can explain, our Shopify development team can trace which access it is missing.