Skip to main content

Sessions

Sessions allow distribution partners to establish consumer context for the ordering experience. Your platform provides user information to Gett, enabling a seamless experience with pre-filled details.

How It Works

  1. User authenticates on your platform (your own auth system)
  2. Your backend creates a Gett session with user information via the Gett API
  3. You initialize the Marketfront SDK with the session token
  4. User enjoys a seamless ordering experience with their information pre-filled

Session Creation

All integrations require backend session creation. This ensures that:

  1. Partner is authenticated — Your API key proves the request came from your platform
  2. Partner attribution is secure — Orders are correctly attributed to your platform
  3. Consumer context is established — The user's information flows securely to Gett

Request

EnvironmentEndpoint
Sandboxhttps://api-sandbox.gett-tech.com/v1/session/create
Productionhttps://api.gett-tech.com/v1/session/create
POST /v1/session/create
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Use your Sandbox API Key against the sandbox endpoint for development, and your Production API Key against the production endpoint for live orders.

Request Body

{
"partnerUserId": "your_user_id_12345",
"email": "user@example.com",
"givenName": "Jane",
"familyName": "Doe",
"phone": "+15551234567",
"expiresInSeconds": 3600,
"addresses": [
{
"formattedAddress": "123 Main St, Seattle, WA 98101, USA",
"googlePlaceId": "ChIJ...",
"latitude": 47.6062,
"longitude": -122.3321,
"unit": "4B",
"deliveryInstructions": "Leave at front desk"
}
],
"paymentMethods": [
{
"token": "pm_abc123",
"brand": "visa",
"last4": "4242",
"expMonth": 12,
"expYear": 2027
}
]
}

Response

{
"sessionToken": "gett_sess_abc123xyz",
"expiresAt": "2025-01-15T12:00:00Z"
}
FieldTypeDescription
sessionTokenstringToken that establishes consumer context for subsequent requests
expiresAtstringISO 8601 expiration timestamp

User Information

The user information is passed at the root level of the request.

Required Fields

FieldTypeDescription
partnerUserIdstringStable user identifier in your system. This links the Gett user to your user record.

Optional Fields

FieldTypeDescription
emailstringUser's email address
givenNamestringUser's first name
familyNamestringUser's last name
phonestringUser's phone number in E.164 format (e.g., +15551234567). Must be SMS-capable for order notifications.
expiresInSecondsintegerOptional session duration in seconds.

Addresses

Optionally provide the user's delivery addresses to pre-fill the checkout experience. The first address in the array is treated as the default.

{
"partnerUserId": "...",
"addresses": [
{
"formattedAddress": "123 Main St, Seattle, WA 98101, USA",
"googlePlaceId": "ChIJ...",
"latitude": 47.6062,
"longitude": -122.3321,
"unit": "4B",
"deliveryInstructions": "Leave at front desk"
}
]
}

Address Fields

FieldTypeRequiredDescription
formattedAddressstringNoFull human-readable address string
googlePlaceIdstringNoGoogle Maps Place ID (recommended for accuracy)
latitudenumberNoLocation latitude
longitudenumberNoLocation longitude
unitstringNoApartment, suite, unit, etc.
deliveryInstructionsstringNoNotes for the driver

Payment Methods

Optionally provide the user's saved payment methods to enable one-click checkout. Payment methods are displayed in the checkout UI and referenced by paymentToken when placing orders.

Card-on-File

Payment methods use Card-on-File interchange—see the Payments Guide for full details on how payment interchange works.

{
"partnerUserId": "...",
"addresses": [ ... ],
"paymentMethods": [
{
"token": "pm_abc123",
"brand": "visa",
"last4": "4242",
"expMonth": 12,
"expYear": 2027
}
]
}

Payment Method Fields

FieldTypeRequiredDescription
tokenstringYesYour reference to this payment token/id
brandstringYesCard brand: visa, mastercard, amex, discover
last4stringYesLast 4 digits of the card number
expMonthnumberYesCard expiration month (1-12)
expYearnumberYesCard expiration year (4-digit)
Metadata Only

Only pass display metadata—never raw card data. The token is your tokenized reference. See Payments for security details.


Using the Session Token

Initialize the Marketfront SDK with the session token returned from session creation. The session token encodes your partner identity, so no separate Partner ID is needed.

// Your backend creates the session with user data
const { sessionToken } = await yourBackend.createGettSession(user);

import { MarketfrontClient } from '@gett/marketfront';

const client = new MarketfrontClient({
sessionToken,
});

client.mount('#marketfront-container');

Session Lifecycle

Expiration

Sessions expire after the time specified in expiresAt. Before expiration, create a new session:

POST https://api.gett-tech.com/v1/session/create

The new session will inherit any in-progress cart from the previous session for the same partnerUserId.

Invalidation

To explicitly end a session (e.g., when your user logs out):

POST https://api.gett-tech.com/v1/session/invalidate
Authorization: Bearer gett_sess_abc123xyz

Security

API Key Protection

Your API key authenticates session creation requests. Never expose it in client-side code.

// Never do this in frontend code
const response = await fetch('https://api.gett-tech.com/v1/session/create', {
headers: { 'Authorization': `Bearer ${API_KEY}` } // Exposed!
});

// Always call from your backend
const response = await yourBackend.createGettSession(userId);

Session Token Handling

Session tokens are safe for client-side use but should still be handled carefully:

  • Tokens are scoped to a single session and user
  • Tokens cannot be used to create new sessions
  • Tokens expire automatically

Data Privacy

  • User data is processed according to Gett's privacy policy
  • You are responsible for obtaining appropriate consent from your users
  • Gett does not share user data with third parties

Error Handling

Session Creation Errors

Error CodeHTTP StatusDescriptionResolution
invalid_api_key401API key is invalid or revokedVerify your API key
missing_required_field400Required field is missingInclude all required user fields: partner_user_id, email, firstName, lastName
invalid_email400Email format is invalidProvide valid email
invalid_phone400Phone format is invalidUse E.164 format
invalid_address400Address could not be validatedVerify address fields
rate_limited429Too many requestsImplement backoff

Session Token Errors

Error CodeHTTP StatusDescriptionResolution
session_expired401Session token has expiredCreate a new session
session_invalid401Session token is malformed or revokedCreate a new session
session_not_found404Session does not existCreate a new session

Next Steps

  • Payments — Card-on-File setup and payment interchange
  • Events — Handle order lifecycle events
  • SDK Reference — Complete SDK API documentation