Session TokenAPI
The API for interacting with session tokens.
Anchor to standardapiStandardApi
The base API object provided to purchase
extension targets.
The session token providing a set of claims as a signed JSON Web Token (JWT).
The token has a TTL of 5 minutes.
If the previous token expires, this value will reflect a new session token with a new signature and expiry.
Refer to session token examples for more information.
Anchor to useSessionTokenuse Session Token()
Returns a the session token API object.
SessionToken
Requests a session token that hasn't expired. You should call this method every time you need to make a request to your backend in order to get a valid token. This method will return cached tokens when possible, so you don’t need to worry about storing these tokens yourself.
Using a session token with fetch()
Anchor to examplesExamples
Anchor to example-session-token-claimsSession token claims
The contents of the token are signed using your shared app secret. The optional sub
claim contains the customer's gid
if they are logged in and your app has permission to read customer accounts. For example, a loyalty app that needs to check a customer's point balance can use the sub
claim to verify the customer's account.
Your app server can only trust the claims within the session token. It cannot use the token to trust the entire HTTP request. See security considerations for details.