Create Customer Session - Polar
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
POST
https://api.polar.shhttps://sandbox-api.polar.sh
/ v1 / customer-sessions /
Try it
Python
from polar.v2026_04 import Polar
polar = Polar("polar_oat_xxx")
response = polar.customer_sessions.create(
return_url='https://example.com/account',
customer_id='00000000-0000-4000-8000-000000000000',
)
print(response)
JavaScript
import { createPolar } from "@polar-sh/sdk/2026-04";
const polar = createPolar({
accessToken: "polar_oat_xxx",
});
const response = await polar.customerSessions.create(
{
"return_url": "https://example.com/account",
"customer_id": "00000000-0000-4000-8000-000000000000"
},
);
console.log(response);
Curl
curl --request POST \
--url https://api.polar.sh/v1/customer-sessions/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"member_id": "<string>",
"external_member_id": "<string>",
"return_url": "https://example.com/account"
}
'
Fetch API
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_id: '<string>',
member_id: '<string>',
external_member_id: '<string>',
return_url: 'https://example.com/account'
})
};
fetch('https://api.polar.sh/v1/customer-sessions/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.polar.sh/v1/customer-sessions/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => '<string>',
'member_id' => '<string>',
'external_member_id' => '<string>',
'return_url' => 'https://example.com/account'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Example Response
201
{
"created_at": "2026-01-01T00:00:00.000000Z",
"modified_at": "2026-01-01T00:00:00.000000Z",
"id": "<string>",
"token": "<string>",
"expires_at": "2026-01-01T00:00:00.000000Z",
"return_url": "<string>",
"customer_portal_url": "<string>",
"customer_id": "<string>",
"customer": {
"id": "992fae2a-2a17-4b7a-8d9e-e287cf90131b",
"created_at": "2026-01-01T00:00:00.000000Z",
"modified_at": "2026-01-01T00:00:00.000000Z",
"metadata": {},
"email": "customer@example.com",
"email_verified": true,
"type": "individual",
"name": "John Doe",
"billing_name": "John Doe",
"billing_address": {
"country": "US",
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>"
},
"tax_id": {
"[0]": "<string>"
},
"organization_id": "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
"deleted_at": "2026-01-01T00:00:00.000000Z",
"first_user_event_at": "2026-01-01T00:00:00.000000Z",
"avatar_url": "https://www.gravatar.com/avatar/xxx?d=404",
"external_id": "usr_1337",
"locale": "<string>",
"default_payment_method_id": "<string>"
}
}
Error Response
{
"error": "AmbiguousExternalCustomerID",
"detail": "<string>"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}
Authorizations
Authorization
string
header
required
You can generate a Personal Access Token from your settings.
Request Body
- customer_id: string
, required - member_id: string
| null - external_member_id: string | null
- return_url: string
| null, required length: 1 - 2083
Response Fields
- created_at: string
, required - modified_at: string
| null, required - id: string
, required - token: string, required
- expires_at: string
, required - return_url: string | null, required
- customer_portal_url: string, required
- customer_id: string
, required - customer: CustomerIndividual or CustomerTeam, required.