Skip to main content
Migrate to Polaris

Version 2025-07 is the last API version to support React-based UI components. Later versions use web components, native UI elements with built-in accessibility, better performance, and consistent styling with Shopify's design system. Check out the migration guide to upgrade your extension.

Session Token API

The Session Token API lets you authenticate requests from your extension to your app's backend using a signed JSON Web Token (JWT). Use this API to get a token that your backend can verify using your app's shared secret, confirming the request came from a legitimate Shopify extension.

  • Authenticate backend requests: Pass a session token as a Bearer token in API calls to your app's backend so you can verify the request came from your extension.
  • Identify the customer: Read the optional sub claim in the token to get the customer's GID when they're signed in and your app has access to protected customer data.
  • Verify the shop: Use the dest claim to confirm which shop the request is associated with, ensuring your backend responds with the correct data.
Support
Targets (25)

The Session Token API object provides session token functionality for customer account extensions. Access the following properties on the API object to retrieve signed tokens for authenticating requests to your app's backend.

Anchor to sessionToken
sessionToken
required

Provides access to session tokens for verifying requests from your extension to your app's backend. Session tokens are signed JSON Web Tokens (JWTs) that contain information about the current session. For more details, see the Session Token API.


  • Request tokens close to usage: Call shopify.sessionToken.get() immediately before making a request rather than storing the token for later, since tokens expire after 5 minutes.
  • Verify tokens server-side: Always validate the token signature, expiration (exp), and audience (aud) on your backend using your app's shared secret.
  • Handle token errors gracefully: Wrap token retrieval and fetch calls in try-catch blocks so your extension can display a meaningful message if authentication fails.

  • Session tokens expire after 5 minutes. Your backend must handle expired tokens and your extension should request a new token for each request.
  • The sub claim is only present when the customer is signed in and your app has the read_customers scope. Don't rely on it being available in all contexts.
  • Session tokens are signed JWTs intended for your backend only. Don't expose sensitive claims to the customer or use them for client-side authorization decisions.

Was this page helpful?