Skip to main content

Session API

The Session API provides access to current POS session information and secure authentication tokens, allowing you to retrieve shop details, user information, location data, and generate tokens for secure backend communication. The API includes both static session data and dynamic token generation for authenticated API calls.

  • API authentication: Authenticate API calls to your app's backend using secure session tokens.
  • Shop customization: Customize extension behavior based on shop domain, location, or currency.
  • Location features: Implement location-specific features like tax calculations or inventory checks.
  • Activity tracking: Track user activity and staff interactions for analytics and audits.
Support
Targets (28)

The SessionApi object provides access to current session information and authentication. Access these properties through shopify.session to retrieve shop data and generate secure tokens. These properties enable secure API calls while maintaining user privacy and app permissions.

Anchor to currentSession
currentSession
required

Provides comprehensive information about the current POS session including shop details, user authentication, location data, staff member information, currency settings, and POS version. This data is static for the duration of the session and updates when users switch locations or staff members change.

Anchor to getSessionToken
getSessionToken
() => Promise<string>
required

Generates a fresh session token for secure communication with your app's backend service. Returns undefined when the authenticated user lacks proper app permissions. The token is a Shopify OpenID Connect ID Token that should be used in Authorization headers for backend API calls. This is based on the authenticated user, not the pinned staff member.


  • Handle authentication properly: Check for undefined session tokens and implement proper fallback behavior when authentication fails or permissions are insufficient.
  • Use appropriate identifiers: Distinguish between userId (authenticated account) and staffMemberId (pinned staff member) to implement correct permissions and personalization logic.
  • Implement location-aware features: Use locationId and currency information.
  • Secure backend communication: Use session tokens exclusively for backend API calls and never expose them in client-side logs or storage. Validate tokens on your backend before processing requests.

  • Session tokens are only available when the authenticated user has proper app permissions enabled—staff members who are pinned in but not authenticated can't generate tokens.
  • Session tokens should only be used for communication with your app's configured backend service and can't be used for direct Shopify API calls from the client side.

Was this page helpful?