/vtex-ai-skills:vtex-io-auth-tokens-and-contextfrom vtex-ai-skills
Guides selection of VTEX IO authentication tokens (`ctx.authToken`, `ctx.storeUserAuthToken`, `ctx.adminUserAuthToken`) for backend requests based on requester context.
Ships in vtex-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this skill when the main decision is which VTEX IO identity should authenticate a backend request to VTEX services.
ctx.authToken, ctx.storeUserAuthToken, and ctx.adminUserAuthTokenAUTH_TOKEN, STORE_TOKEN, or ADMIN_TOKENappKey and appToken usage inside a VTEX IO appDo not use this skill for:
manifest.jsonExternalClient, JanusClient, and other client abstractionsAUTH_TOKEN with ctx.authToken only for app-level operations that are not tied to a current shopper or Admin user.STORE_TOKEN with ctx.storeUserAuthToken whenever the action comes from storefront browsing or a shopper-triggered flow and the integration should respect shopper permissions.ADMIN_TOKEN with ctx.adminUserAuthToken whenever the action comes from an Admin interface and the integration should respect the logged-in Admin user's License Manager permissions.AUTH_TOKEN only when the operation is truly app-scoped and does not depend on a current shopper or Admin identity.authMethod, pass the token choice explicitly when the default app identity is not the right one for the request.IOContext at the client boundary instead of hardcoding credentials in handlers.ADMIN_TOKEN with ctx.adminUserAuthToken must remain server-side only and must never be exposed or proxied to browser clients.appKey and appToken inside a VTEX IO app unless there is a documented exception outside the normal VTEX IO auth-token model.Token selection at a glance:
| Token | Context field | Use when | Avoid when |
|---|---|---|---|
AUTH_TOKEN | ctx.authToken | app-level jobs, service-to-service work, or operations not linked to a current user | a shopper or Admin user is already driving the action |
STORE_TOKEN | ctx.storeUserAuthToken | storefront and shopper-triggered operations | backend jobs or Admin-only operations |
ADMIN_TOKEN | ctx.adminUserAuthToken | Admin requests that must respect the current user's LM role | storefront flows or background app tasks |
If a request is initiated by a current shopper or Admin user, the VTEX integration MUST use the corresponding user token instead of defaulting to the app token.
Why this matters
Using the app token for user-driven work widens permissions unnecessarily and disconnects the request from the real user context that should govern access.
Detection
If the code runs in a storefront or Admin request path and still uses ctx.authToken or implicit app-token behavior, STOP and verify whether ctx.storeUserAuthToken or ctx.adminUserAuthToken should be used instead.
Correct
export class OmsClient extends JanusClient {
constructor(ctx: IOContext, options?: InstanceOptions) {
super(ctx, {
...options,
headers: {
...options?.headers,
VtexIdclientAutCookie: ctx.storeUserAuthToken,
},
})
}
}
Wrong
export class OmsClient extends JanusClient {
constructor(ctx: IOContext, options?: InstanceOptions) {
super(ctx, {
...options,
headers: {
...options?.headers,
VtexIdclientAutCookie: ctx.authToken,
},
})
}
}
Use ctx.authToken only when the request is genuinely app-scoped and no current shopper or Admin identity should govern the action.
Why this matters
The app token carries the permissions declared in the app manifest. Using it for user-triggered actions can bypass the narrower shopper or Admin permission model that the platform expects.
Detection
If a request originates from an Admin page, storefront interaction, or another user-facing workflow, STOP before using ctx.authToken and confirm that the action is truly app-level rather than user-scoped.
Correct
export class RatesAndBenefitsClient extends JanusClient {
constructor(ctx: IOContext, options?: InstanceOptions) {
super(ctx, {
...options,
headers: {
...options?.headers,
VtexIdclientAutCookie: ctx.authToken,
},
})
}
}
Wrong
export class AdminOrdersClient extends JanusClient {
constructor(ctx: IOContext, options?: InstanceOptions) {
super(ctx, {
...options,
headers: {
...options?.headers,
VtexIdclientAutCookie: ctx.authToken,
},
})
}
}
This is wrong when the client is used from an Admin flow that should respect the logged-in user's role.
A VTEX IO app MUST use tokens from IOContext or authMethod instead of embedding appKey, appToken, or static VTEX credentials in source code or routine runtime configuration.
Why this matters
Hardcoded VTEX credentials are harder to rotate, easier to leak, and bypass the request-context model that VTEX IO clients already support.
Detection
If you see X-VTEX-API-AppKey, X-VTEX-API-AppToken, raw VTEX API credentials, or environment variables carrying permanent VTEX credentials inside a normal IO app integration, STOP and replace them with the correct auth-token flow unless there is a documented exception.
Correct
await ctx.clients.catalog.getSkuById(id, {
authMethod: 'ADMIN_TOKEN',
})
Wrong
await fetch(`https://${ctx.vtex.account}.myvtex.com/api/catalog/pvt/stockkeepingunit/${id}`, {
headers: {
'X-VTEX-API-AppKey': process.env.VTEX_APP_KEY!,
'X-VTEX-API-AppToken': process.env.VTEX_APP_TOKEN!,
},
})
Start from the requester context, choose the token identity that matches that requester, and keep the token propagation inside the client layer.
Minimal selection guide:
storefront request -> STORE_TOKEN / ctx.storeUserAuthToken
admin request -> ADMIN_TOKEN / ctx.adminUserAuthToken
background app work -> AUTH_TOKEN / ctx.authToken
Pass the token explicitly when the client supports authMethod:
await ctx.clients.orders.listOrders({
authMethod: 'ADMIN_TOKEN',
})
await ctx.clients.orders.listOrders({
authMethod: 'STORE_TOKEN',
})
Or inject the matching token in a custom VTEX client:
import type { IOContext, InstanceOptions } from '@vtex/api'
import { JanusClient } from '@vtex/api'
export class OmsClient extends JanusClient {
constructor(ctx: IOContext, options?: InstanceOptions) {
super(ctx, {
...options,
headers: {
...options?.headers,
VtexIdclientAutCookie: ctx.adminUserAuthToken,
},
})
}
}
Keep the decision close to the request boundary, then let downstream handlers and services depend on the correctly configured client rather than choosing tokens ad hoc in many places.
ctx.authToken, even when a shopper or Admin user initiated the action.ctx.authToken in Admin pages and accidentally bypassing the current Admin user's License Manager role context.ctx.authToken in storefront flows that should be limited by shopper permissions.appKey and appToken in an IO app instead of using auth tokens from IOContext.ctx.authToken, ctx.storeUserAuthToken, or ctx.adminUserAuthToken in plain text, or forwarding raw tokens to downstream services that do not need them.ctx.storeUserAuthToken and ctx.adminUserAuthToken preferred when a user is actually driving the action?ctx.authToken used only for app-level operations that are not tied to a current user?authMethod usage rather than scattered across handlers?vtex-io-auth-and-policies - Use when the main choice is which permissions and policies the chosen identity should carryAUTH_TOKEN, STORE_TOKEN, and ADMIN_TOKENWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
46 skills in this plugin
/architecture-well-architected-commerceApply when scoping, reviewing, or documenting cross-cutting VTEX commerce architecture across storefront, IO, headless, marketplace, payments, or any other VTEX module. Grounds work in the Well-Architected Commerce framework—Technical Foundation (reliability, trust, integrity; security, infrastructure, compliance), Future-proof (innovation, simplicity, efficiency; scalable and adaptable solutions), and Operational Excellence (accuracy, accountability, data-driven improvement; process and customer experience). Routes implementation detail to product tracks (IO caching and paths, Master Data strategy, marketplace integrations). Use for solution design, architecture reviews, and RFP-level technical structure./faststore-storefrontCore coding rules and workflow for developing VTEX FastStore storefronts. Use when starting any FastStore development task, writing TypeScript/React components, creating section overrides, extending the BFF, or styling. Covers all primary conventions, safety rules, and the development workflow used across every FastStore project./headless-bff-architectureApply when designing or modifying a BFF (Backend-for-Frontend) layer, middleware, or API proxy for a headless VTEX storefront. Covers BFF middleware architecture, public vs private API classification, VtexIdclientAutCookie management, API key protection, and secure request proxying. Use for any headless commerce project that must never expose VTEX_APP_KEY or call private VTEX APIs from the browser./headless-caching-strategyApply when implementing caching logic, CDN configuration, or performance optimization for a headless VTEX storefront. Covers which VTEX APIs can be cached (Intelligent Search, Catalog) versus which must never be cached (Checkout, Profile, OMS), stale-while-revalidate patterns, cache invalidation, and BFF-level caching. Use for any headless project that needs TTL rules and caching strategy guidance./headless-checkout-proxyApply when implementing cart, checkout, or order placement logic proxied through a BFF for headless VTEX storefronts. Covers OrderForm lifecycle, cart creation, item management, profile/shipping/payment attachments, orderFormId management, and secure checkout flows. Use for any headless frontend that needs to proxy VTEX Checkout API calls through a server-side layer with proper session cookie handling./headless-intelligent-searchApply when implementing search functionality, faceted navigation, or autocomplete in a headless VTEX storefront. Covers product_search, autocomplete_suggestions, facets, banners, correction_search, and top_searches endpoints, plus analytics event collection. Use for any custom frontend that integrates VTEX Intelligent Search API for product discovery and search result rendering.npx claudepluginhub vtex/skills --plugin vtex-ai-skillsOther plugins' skills for the same job