---
title: "Create a customer"
method: POST
path: "/v1/customers"
tags: ["Customers"]
---

# Create a customer

`POST /v1/customers`

## Request

- Base URL: `https://api.affiliaterail.com`
- URL: `https://api.affiliaterail.com/v1/customers`
- Auth: HTTP bearer

Through a click (`click_id`, the referral's identity carries over and the partner is whoever owns it) or directly to a partner (`partner_id`, recorded as `tracked_by: api`). Set `external_customer_id` so charges you send later match.

**Scope:** `commissions:write` (or `write`)

## Request body

- CustomerCreate
  - `program_id` string, required: Prefixed id (`prg_…`)
  - `partner_id` string: Attribute directly to a partner
  - `click_id` string: Or attribute through the click the visitor arrived on (one of partner_id or click_id is required)
  - `email` string, email
  - `name` string
  - `identifier` string: Your own id for this customer
  - `external_customer_id` string: The processor's customer id, used to match incoming charges
  - `status` 'lead' | 'trial' | 'active' | 'cancelled' | 'suspended'
  - `metadata` object, nullable: Your own key/value data, stored as given

## Response `201`

The new customer

- Customer
  - `id` string, required: Prefixed id (`cus_…`)
  - `object` 'customer', required
  - `program_id` string, required: Prefixed id (`prg_…`)
  - `partner_id` string, required: Prefixed id (`part_…`)
  - `referral_id` string, nullable, required: Prefixed id (`ref_…`)
  - `link_id` string, nullable, required: Prefixed id (`lnk_…`)
  - `coupon_id` string, nullable, required: Prefixed id (`cpn_…`)
  - `processor` 'stripe' | 'paddle' | 'chargebee' | 'manual' | 'api' | 'null', nullable, required
  - `external_customer_id` string, nullable, required
  - `external_subscription_id` string, nullable, required
  - `email` string, nullable, required
  - `name` string, nullable, required
  - `identifier` string, nullable, required
  - `status` 'lead' | 'trial' | 'active' | 'cancelled' | 'refunded' | 'suspended', required
  - `tracked_by` 'link' | 'coupon' | 'manual' | 'api', required
  - `lead_at` string, date-time, nullable, required: ISO-8601, UTC
  - `converted_at` string, date-time, nullable, required: ISO-8601, UTC
  - `metadata` object, nullable, required: Your own key/value data, stored as given
  - `created_at` string, date-time, required: ISO-8601, UTC
  - `updated_at` string, date-time, required: ISO-8601, UTC

## Other responses

- `400`: Invalid request
- `401`: Missing or unknown API key
- `403`: Key lacks the required scope
- `404`: No such object in your organization
- `422`: The request was understood and refused
- `429`: Rate limited: see Retry-After

---

[API](https://skmtc.dev/affiliaterail/apis/affiliaterail-api.md) · [All operations](https://skmtc.dev/affiliaterail/apis/affiliaterail-api/llms.txt) · [OpenAPI document](https://skmtc.dev/affiliaterail/apis/affiliaterail-api/revisions/ea41f345c092?raw)
