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

# createClientSession(params)

> Creates a client session without rendering a UI for advanced payment flows

Creates a client session without rendering a UI. This function is used in [advanced scenarios](/develop/advanced-usage#manual-session-creation) where you want to obtain a payment client token and order ID first, then possibly handle the UI or payment flow manually.

## Parameters

<ParamField body="priceId" type="string" required>
  The price identifier for the subscription/product.
</ParamField>

<ParamField body="externalId" type="string" required>
  The customer's external ID (your user ID).
</ParamField>

<ParamField body="email" type="string" required>
  Customer's email address.
</ParamField>

<ParamField body="orgId" type="string">
  Organization ID, if not configured globally. Not needed if you already called `configure()`.
</ParamField>

## Returns

A `Promise` resolving to an object containing at least `{ clientToken, orderId, type }`. The `clientToken` can be used with Primer's Headless Checkout, and `orderId` is the generated order identifier on Funnelfox's side.

## Example

```javascript theme={null}
import { createClientSession } from '@funnelfox/billing';

const session = await createClientSession({
  priceId: 'price_123',
  externalId: 'user_456',
  email: 'user@example.com',
  orgId: 'your-org-id', // Optional if configured
});

console.log(session.clientToken); // Use with Primer Headless Checkout
console.log(session.orderId);
```
