Create or reuse a customer
POST
/api/customers
const url = 'https://example.com/api/customers';const options = { method: 'POST', headers: { cookie: 'better-auth.session_token=<better-auth.session_token>', 'Content-Type': 'application/json' }, body: '{"name":"example","source":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/customers \ --header 'Content-Type: application/json' \ --cookie better-auth.session_token=<better-auth.session_token> \ --data '{ "name": "example", "source": "example" }'Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”Customer display name.
Media type application/json
object
name
required
string
source
string
Example generated
{ "name": "example", "source": "example"}Responses
Section titled “ Responses ”The created or existing customer.
Media type application/json
object
customer
required
A customer available for offer assignment.
object
id
required
string
name
required
string
source
required
string
Example generated
{ "customer": { "id": "example", "name": "example", "source": "example" }}The request body could not be parsed or validated.
Media type application/json
Standard API error payload.
object
error
required
object
code
required
string
message
required
string
issues
Array<string>
Example generated
{ "error": { "code": "example", "message": "example", "issues": [ "example" ] }}No valid Better Auth session was present.
Media type application/json
Returned when no valid Better Auth session is present.
object
error
required
string
Example generated
{ "error": "example"}