Authentication & Headers
Publishable API keys, dual-actor JWTs, passwordless Email OTP, secret keys, locale headers, and CSRF preflight rules
Authentication & Request Headers
xclade uses a dual-actor authentication model (customer and user) combined with Publishable API Keys for sales-channel scoping.
HTTP Headers Reference
| Header | Accepted Alias | Purpose |
|---|---|---|
X-Xclade-Publishable-Key | X-Publishable-Api-Key | Scopes catalog queries, stock availability, and new carts to the Sales Channels linked to your pk_... key. |
Authorization | — | Bearer <jwt> (customer or admin JWT) or Bearer sk_... (merchant secret API key). |
X-Xclade-Locale | X-Locale | BCP-47 locale tag (e.g. en-US, fr-FR, de-DE) for localized catalog responses and cache isolation. |
X-Xclade-Request | X-GraphQL-Request, Apollo-Require-Preflight | CSRF preflight marker required for non-browser GET /graphql queries in production (also satisfied when X-Xclade-Publishable-Key is present). |
X-Store-Domain | Host | Storefront origin domain used for tenant scope resolution when no publishable key is supplied. |
Dual-Actor Authentication
xclade distinguishes two principal actor types via the ActorType enum:
customer— Storefront shoppers and B2B company employees (default forlogin,requestEmailOtp,verifyEmailOtp, and password resets).user— Store administrators (used for admin access on/graphqland/admin/graphql).
1. Email & Password Login
mutation LoginCustomer($email: String!, $password: String!) {
login(email: $email, password: $password, actor_type: customer) {
token
expires_at
status
customer {
id
email
first_name
last_name
}
}
}Pass the returned JWT on subsequent requests:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...2. Passwordless 6-Digit Email OTP
Dispatch a single-use 6-digit verification code and exchange it for a signed JWT bearer token:
mutation RequestOtp($email: String!) {
requestEmailOtp(email: $email, actor_type: customer) {
success
message
}
}mutation VerifyOtp($email: String!, $code: String!) {
verifyEmailOtp(email: $email, code: $code, actor_type: customer) {
token
expires_at
customer {
id
email
}
}
}3. Inspecting Active Auth State
Call authStatus (never cached) to verify the current token or session cookie:
query CheckAuth {
authStatus {
authenticated
actor_type
customer {
id
email
}
user {
id
email
}
}
}4. Password Reset
mutation RequestReset($email: String!) {
requestPasswordReset(email: $email, actor_type: customer) {
success
message
}
}
mutation CompleteReset($token: String!, $password: String!, $email: String) {
resetPassword(token: $token, password: $password, email: $email, actor_type: customer) {
success
message
}
}Merchant Secret API Keys (sk_...)
For trusted server-to-server integrations, ERP bridges, or scripts, generate a secret API key in your store's Admin Console and send it as a bearer token:
Authorization: Bearer sk_live_...Never expose sk_... secret keys in browser bundles or client-side code. Use pk_... Publishable API Keys for public storefronts and customer JWTs for authenticated shopper sessions.
Cache Isolation for Authenticated Requests
Whenever a request carries a valid customer or user identity—or calls a private resolver (RequireAuth, RequireCustomer, RequireAdmin)—the Go middleware automatically bypasses XcladeResponseCache and sets:
Cache-Control: private, no-store