Skip to main content

Session API
APIs

The Session API contains the information about the current user session, and allows to fetch a fresh session token for communication with your apps backend service.

required

Access information on the current POS session.

() => Promise<string>
required

Get a fresh session token for communication with your app's backend service. When the authenticated user (the user that logged into Shopify POS with their email address) doesn't have the correct app permissions enabled for your app, null will be returned. This is irrelevant of which POS Staff member is pinned in, as those are not authenticated users. For more information, see our app permissions documentation. Calls to Shopify APIs must be made by your app’s backend service.

Was this section helpful?

Examples of using the Session API

Was this section helpful?

Retrieve the current session data

import React, {useState} from 'react';
import {
reactExtension,
useApi,
Screen,
Text,
} from '@shopify/ui-extensions-react/point-of-sale';

const SmartGridModal = () => {
const {currentSession, getSessionToken} =
useApi<'pos.home.modal.render'>().session;

const {shopId, userId, locationId, staffMemberId} = currentSession;
const [sessionToken, setSessionToken] = useState<string>();

getSessionToken().then((newToken) => {
setSessionToken(newToken);
});

return (
<Screen name="ScreenOne" title="Screen One Title">
<Text>
shopId: {shopId}, userId: {userId}, locationId: {locationId}, staffId:
{staffMemberId}
</Text>
<Text>sessionToken: {sessionToken}</Text>
</Screen>
);
};

export default reactExtension('pos.home.modal.render', () => (
<SmartGridModal />
));