--- title: Session API description: 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. api_version: 2025-01 api_name: pos-ui-extensions source_url: html: https://shopify.dev/docs/api/pos-ui-extensions/2025-01/apis/session-api md: https://shopify.dev/docs/api/pos-ui-extensions/2025-01/apis/session-api.md --- # Session APIAPIs 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. ## SessionApi * currentSession Session required Access information on the current POS session. * getSessionToken () => Promise\ required Get a fresh session token for communication with your app's backend service. Calls to Shopify APIs must be made by your app’s backend service. ### Session * currency The currency code associated with the location currently in on POS. ```ts CurrencyCode ``` * locationId The location ID associated with the POS' current location. ```ts number ``` * shopDomain The shop domain associated with the shop currently logged into POS. ```ts string ``` * shopId The shop ID associated with the shop currently logged into POS. ```ts number ``` * staffMemberId The staff ID who is currently pinned into the POS. Note that this staff member ID may be different to the User ID, as the staff member who enters their PIN may be different to the User who logged onto POS. ```ts number ``` * userId The user ID associated with the Shopify account currently authenticated on POS. ```ts number ``` ```ts export interface Session { /** * The shop ID associated with the shop currently logged into POS. */ shopId: number; /** * The user ID associated with the Shopify account currently authenticated on POS. */ userId: number; /** * The shop domain associated with the shop currently logged into POS. */ shopDomain: string; /** * The location ID associated with the POS' current location. */ locationId: number; /** * The staff ID who is currently pinned into the POS. * Note that this staff member ID may be different to the User ID, as the staff member who enters their PIN may be different to the User who logged onto POS. */ staffMemberId?: number; /** * The currency code associated with the location currently in on POS. */ currency: CurrencyCode; } ``` ### CurrencyCode ```ts 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BOV' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHE' | 'CHF' | 'CHW' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'COU' | 'CRC' | 'CUC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HRK' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MXV' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLL' | 'SOS' | 'SRD' | 'SSP' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'USN' | 'UYI' | 'UYU' | 'UYW' | 'UZS' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XAG' | 'XAU' | 'XBA' | 'XBB' | 'XBC' | 'XBD' | 'XCD' | 'XDR' | 'XOF' | 'XPD' | 'XPF' | 'XPT' | 'XSU' | 'XTS' | 'XUA' | 'XXX' | 'YER' | 'ZAR' | 'ZMW' | 'ZWL' ``` ## Examples Examples of using the Session API Retrieve the current session data ### Examples * #### Retrieve the current session data ##### React ```tsx 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(); getSessionToken().then((newToken) => { setSessionToken(newToken); }); return ( shopId: {shopId}, userId: {userId}, locationId: {locationId}, staffId: {staffMemberId} sessionToken: {sessionToken} ); }; export default reactExtension('pos.home.modal.render', () => ( )); ``` ##### TS ```ts import { Screen, Stack, Text, extension, } from '@shopify/ui-extensions/point-of-sale'; export default extension('pos.home.modal.render', (root, api) => { const {session} = api; const {currentSession, getSessionToken} = session; const {shopId, userId, locationId, staffMemberId} = currentSession; const screen = root.createComponent(Screen, { name: 'ScreenOne', title: 'Screen One Title', }); const currentSessionText = root.createComponent( Text, {}, `shopId: ${shopId}, userId: ${userId}, locationId: ${locationId}, staffId: ${staffMemberId}`, ); const sessionTokenText = root.createComponent( Text, {}, 'sessionToken: undefined', ); getSessionToken().then((newToken) => { sessionTokenText.children.forEach((child) => { sessionTokenText.removeChild(child); }); sessionTokenText.appendChild(`sessionToken: ${newToken}`); }); screen.appendChild(currentSessionText); screen.appendChild(sessionTokenText); root.appendChild(screen); }); ```