> ## Documentation Index
> Fetch the complete documentation index at: https://firmly.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Session management endpoints for multi-domain cart tracking and postal code preferences

The Session API provides endpoints for managing shopping sessions across multiple merchant domains and storing postal code preferences for shipping calculations.

## Available Endpoints

### Active Cart Management

> [card] [Get Active Domains](https://firmly.mintlify.site/api-reference/session/get-active-domains.md)
>
> Retrieve a list of domains where the user has active carts

> [card] [Get Active Carts](https://firmly.mintlify.site/api-reference/session/get-active-carts.md)
>
> Retrieve all active shopping carts across multiple domains

### Postal Code Management

> [card] [Get Postal Code](https://firmly.mintlify.site/api-reference/session/get-postal-code.md)
>
> Retrieve the stored postal code preference

> [card] [Set Postal Code](https://firmly.mintlify.site/api-reference/session/set-postal-code.md)
>
> Update the postal code preference for shipping calculations

### Session Transfer

> [card] [Session Transfer](https://firmly.mintlify.site/api-reference/session/session-transfer.md)
>
> Transfer an external merchant session to Firmly's cart system

## Core Concepts

### Multi-Domain Cart Tracking

The session endpoints enable tracking of shopping carts across multiple merchant domains:

* **Active Domains**: Quickly check which merchants have active carts
* **Active Carts**: Retrieve full cart data for all active sessions
* **Exclude Filtering**: Filter out specific domains when retrieving active carts

### Postal Code Preference

A single postal code preference is stored per device session and used for:

* Shipping cost calculations
* Tax rate determination
* Delivery availability checks

> [!NOTE]
>
> The postal code is a global preference that applies to all merchant carts in the session. It can be null if not set.

### Session Transfer

The session transfer endpoint enables migrating existing merchant sessions to Firmly's cart system. This is useful for:

* Transitioning from native checkout to Firmly
* Preserving cart contents during platform migration
* Maintaining shopping continuity

> [!WARNING]
>
> Session transfer requires special integration setup with each merchant. Contact Firmly support for implementation details.

## Authentication

All session endpoints require device authentication using the `x-firmly-authorization` header. See the [Authentication Guide](https://firmly.mintlify.site/api-reference/authentication/browser-session.md) for details on obtaining access tokens.

## Use Cases

### Multi-Merchant Shopping

Track and manage carts across multiple stores:

```javascript theme={null}
// Get all active domains
const { domains } = await fetch('/api/v2/carts/active-domains', {
  headers: { 'x-firmly-authorization': token }
}).then(r => r.json());

// Get full cart data for active sessions
const { carts } = await fetch('/api/v2/carts/active', {
  headers: { 'x-firmly-authorization': token }
}).then(r => r.json());
```

### Shipping Calculations

Set postal code for accurate shipping quotes:

```javascript theme={null}
// Set postal code preference
await fetch('/api/v2/carts/postal-code', {
  method: 'POST',
  headers: { 
    'x-firmly-authorization': token,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ postal_code: '90210' })
});
```

### Cart Recovery

Transfer external sessions to Firmly:

```javascript theme={null}
// Transfer merchant session
const cart = await fetch('/api/v2/domains/staging.luma.gift/session/transfer', {
  method: 'POST',
  headers: { 
    'x-firmly-authorization': token,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    handle: 'merchant-session-id',
    cookies: ['session_cookie_value']
  })
}).then(r => r.json());
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.