跳转到内容
EN

Renew an access token

Code Mode: praxis.customer.accessTokens.renew

HTTP: POST /customer/v1/access_tokens/renew

Replace a live access token with a fresh one so a signed-in end user stays signed in without signing in again. It is PRE-AUTH: the credential is the token the caller already carries as Authorization: Bearer <access_token>, verified by this door, and the token names the sign-in it renews. Call it before the token’s expires_at; the sign-in and its resource scopes stay the same, so what the end user may reach does not change. A missing, unverifiable or foreign token answers 401 ACCESS_TOKEN_EXPIRED, and a sign-in that is over answers 401 SIGN_IN_EXPIRED or SIGN_IN_REVOKED, in which case the end user signs in again through praxis.customer.accessTokens.create. A blocked end user answers 403 CUSTOMER_BLOCKED. When the sign-in itself has ended, the renewal does not extend it. This door has its own per-IP anonymous budget: over it answers 429 RATE_LIMITED with Retry-After.

签名

praxis.customer.accessTokens.renew(args?:Record<string,never>):Promise<{/** Object type, always customer_access_token. */ type?:"customer_access_token";/** The bearer token to send as `Authorization: Bearer <access_token>`; it lasts at most two hours and never outlives the sign-in. */ access_token?:string;/** RFC 3339 time this token stops working; renew before it with access_tokens/renew. */ expires_at?:string;/** RFC 3339 time the sign-in itself ends; a renewal never extends it. */ session_expires_at?:string;/** Id of the sign-in (csi_…) this token was issued from, which the renewal and the sign-out act on. */ sign_in_id?:string;/** Present on an anonymous answer only. */ continuation_token?:string;/** The end user the token belongs to. */ customer?:{/** End-user id (the merchant's own value, or anon_… for a visitor). */ id:string;/** Kind of end user: identified for one that signed in through a grant code, anonymous for a visitor admitted with a publishable key. */ type:"identified"|"anonymous"}}>;

响应

状态码内容类型说明
201application/jsonA fresh access token for the same sign-in, with its new expiry.
400application/jsonINVALID_PARAMS: the request is not shaped the way this face accepts — an unknown or misspelled field, a repeated query parameter, a resource scope not in the form <type>:<id>:<action>, an expand value that is not products, sign_ins or usage, or a confirm that does not repeat the path customer id. The error names the field at fault and what it accepts; correct that field and send the request again.
401application/jsonThe credential is missing, malformed or expired. Merchant routes answer UNAUTHENTICATED when the API key or session names no organization; the pre-auth doors answer GRANT_CODE_INVALID when a grant code is unknown, already used, expired or foreign, and ACCESS_TOKEN_EXPIRED when the end-user token cannot be verified (a sign-in that is over answers SIGN_IN_EXPIRED or SIGN_IN_REVOKED). Send a valid API key, request a fresh grant code, or sign the end user in again.
403application/jsonThe credential is valid but the call is refused: ORIGIN_NOT_ALLOWED when the request Origin does not satisfy the sign-in or grant binding, CUSTOMER_BLOCKED when the directory has blocked that end user, RESOURCE_NOT_GRANTED when the resource asked for is outside what the sign-in carries. Fix the cause the message names — send the bound origin, unblock the end user, or grant the resource in the next grant code — then retry.
429application/jsonRATE_LIMITED: the caller IP has spent this door per-minute anonymous budget. Wait the seconds in the Retry-After response header and send the request again; do not retry immediately.
502application/jsonUPSTREAM_UNAVAILABLE: the token issuer or another dependency refused the call, so nothing was issued or changed. Retry later, and if it persists report the time and the request path.
503application/jsonUPSTREAM_UNAVAILABLE: this face is not usable in this environment — the CUSTOMER service binding is unwired, or the anonymous rate limiter is unavailable or misconfigured so the door fails closed. Use an environment where the face is wired, or retry when the dependency is back.