# Manage customers

> Create a customer up front, update, list and block one, keep its tax ids, and follow its webhooks.

## Create a customer up front

Creating explicitly is worth it when you know the payer before they pay: a signup, an imported
customer base, a B2B account with a tax id and a billing address.

`POST /customers`

At least one of `email` or `phone` is required. Everything else is optional, and the fields below
are the ones worth knowing; the full list is in the [API reference](https://docs.wajub.com/api/customers/create).

- `email` (string): Required unless `phone` is given. Stored as sent, and found whatever its case: a second `POST /customers` with `Amina@Example.com` returns the customer stored as `amina@example.com`.
- `phone` (string): Required unless `email` is given. Stored in E.164: a number without its international prefix is read in `phone_country`, else your account's country.
- `name` (string): Display name, the only name field you can set.
- `type` (enum, default `individual`): `individual` or `business`. Sending `business_name` alone infers `business`.
- `business_name` (string): Required when `type` is `business`. Becomes the customer `name`.
- `currency` (string): Preferred currency, used as the checkout default when auto-convert is on.
- `preferred_language` (string): Locale for the hosted checkout, below the team and branding settings.
- `address` (object): Shipping address: `country`, `city`, `state`, `postal_code`, `address_line1`, `address_line2`.
- `billing` (object): Billing address, same shape as `address`.
- `customer_group` (string): Free-form segment you can filter the list on.
- `tags` (array): Strings, up to 50 characters each.
- `metadata` (object): Free-form key-value data of your own.

Send it from your server with the secret key.

**Create a customer**

```bash
curl https://api.wajub.com/customers \
  -H "Authorization: sk_test.xxxxxxxxxxxxxxxx…" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: cus-signup-9182" \
  -d '{
    "email": "amina@example.com",
    "phone": "+237670000000",
    "name": "Amina Diallo",
    "metadata": { "user_id": "u_9182" }
  }'
```

```javascript
const customer = await wajub.customers.create({
  email: 'amina@example.com',
  phone: '+237670000000',
  name: 'Amina Diallo',
  metadata: { user_id: 'u_9182' },
});

console.log(customer.id);
```

```python
customer = wajub.customers.create({
    "email": "amina@example.com",
    "phone": "+237670000000",
    "name": "Amina Diallo",
    "metadata": {"user_id": "u_9182"},
})

print(customer.id)
```

```php
$customer = $wajub->customers->create([
  'email' => 'amina@example.com',
  'phone' => '+237670000000',
  'name' => 'Amina Diallo',
  'metadata' => [
    'user_id' => 'u_9182',
  ],
]);

echo $customer->id;
```

```go
customer, err := client.Customers.Create(context.Background(), map[string]any{
	"email": "amina@example.com",
	"phone": "+237670000000",
	"name": "Amina Diallo",
	"metadata": map[string]any{"user_id": "u_9182"},
}, nil)
```

A new customer comes back as `201 Created`, with the `id` you will pass on payments from now on.

```json title="Response · 201 Created"
{
  "code": 201,
  "status": "Created",
  "message": "Customer created",
  "customer": {
    "id": "cus_test_sAaim5apjocIgtlhzJY3wQ8s",
    "type": "individual",
    "name": "Amina Diallo",
    "email": "amina@example.com",
    "phone": "+237670000000",
    "status": "active",
    "blocked": false,
    "tags": [],
    "metadata": { "user_id": "u_9182" },
    "sandbox": true,
    "created_at": "2026-09-11T10:24:00+00:00"
  }
}
```

> [!WARNING]
> **A duplicate answers 200, not 201**
>
> Create a customer whose email (whatever its case) or phone already exists and the API returns the
> existing record with `200 OK` and the message `Customer already exists for this merchant`. With a
> publishable key, that record holds only its `id` and the fields the request sent. Nothing is
> duplicated, and nothing is updated either. Branch on `code === 201` to tell a real
> creation from a match, and never treat the `200` as an error.

`Idempotency-Key` works here as it does on payments: the same key replays the original response for
24 hours instead of opening a second record. It is the safe way to retry a signup hook.

## Update a customer

A payment never corrects a customer, it only fills the fields still empty: see [A payment never
overwrites a customer](https://docs.wajub.com/payments/customers#a-payment-never-overwrites-a-customer). Corrections go
through `PUT /customers/{id}`.

`PUT /customers/{id}`

`PUT /customers/{id}` changes only the fields you send. The `name` changes only when you send it:
`first_name` and `last_name` are refused, and sending `business_name` on an individual leaves their
name alone (on a business, a new `business_name` becomes its name unless you send `name` too). An
`email` (whatever its case) or a `phone` already held by another customer of the account answers
`422` on that field, `A customer with this email already exists.` or
`A customer with this phone already exists.`

## Retrieve and list

Retrieving takes the customer `id` and returns the same object as the create call.

`GET /customers/{id}`

Listing returns your customers newest first, and accepts filters that map onto how you segment
them.

`GET /customers`

| Query parameter  | Accepts                                                               |
| ---------------- | --------------------------------------------------------------------- |
| `per_page`       | 1 to 100, defaults to 25                                              |
| `search`         | Free text over name, email, phone and id                              |
| `status`         | `active`, `inactive`, `blocked`                                       |
| `type`           | `individual`, `business`                                              |
| `country`        | Two-letter country code of the customer's shipping or billing address |
| `customer_group` | The group string you set on the customer                              |
| `cursor`         | An opaque cursor from a previous response                             |

Pagination has two modes and the default is the page-number one. Send no `cursor` and `meta` holds
`current_page`, `last_page`, `per_page` and `total`, plus the `next_cursor` and `has_more` that let
you go on with a cursor. Send that `next_cursor` as `cursor` and the endpoint switches to cursor
mode, where `meta` holds `per_page`, `next_cursor`, `prev_cursor` and `has_more` instead.
Cursor mode is what you want for a full export, since it stays correct while new customers are
being created. [Pagination](https://docs.wajub.com/api/pagination) covers both.

## On behalf of a subaccount

A marketplace creating a customer on behalf of one of its subaccounts adds the `X-Sync` header to
`POST /customers`, and the duplicate rule above applies: when the merchant already has a customer
with this email or phone, that customer is returned with `200`, and nothing is duplicated. The
platform's call only fills the fields the merchant left empty; it never changes one they set. The
customer returned, found or created, is open to the connection from then on: the platform can read
and list them and use them on its payments and invoices. It manages a customer it created; on one
the merchant already had, its updates only fill the fields the merchant left empty, and it cannot
block them. A payment created with `X-Sync` and
the email or phone of an existing customer is attached to that customer the same way. When the
merchant blocked that customer, the payment is refused from version `2026-11-02`, as for any
[blocked customer](#status-and-blocking), even if the connection has no access to them.

With `X-Sync`, a customer never shows the merchant's `notes`, `block_reason` or `metadata`, and
`notes` sent with `X-Sync` is ignored. `metadata` is the platform's own: it reads and writes it as
on any customer, each connection has its own, and the merchant's stays theirs. On a customer the
merchant already had, `POST /customers` and payments add the keys the platform has not set yet,
and `PUT /customers/{id}` replaces the platform's metadata. [Account
types](https://docs.wajub.com/sync/account-types#customers-are-shared-with-the-merchant) has the details.

## Status and blocking

A customer is `active`, `inactive` or `blocked`, and four endpoints move them between those states.

| Call                              | Effect                                                            |
| --------------------------------- | ----------------------------------------------------------------- |
| `POST /customers/{id}/block`      | Sets `blocked`, stores your `reason` and a `blocked_at` timestamp |
| `POST /customers/{id}/unblock`    | Returns the customer to `active`                                  |
| `POST /customers/{id}/deactivate` | Sets `inactive`                                                   |
| `POST /customers/{id}/activate`   | Sets `active`                                                     |

Blocking an already blocked customer answers `400`, as does unblocking one who is not blocked.

`inactive` is a label on the customer record, on every API version. What `blocked` does depends on
the version:

- **From `2026-11-02`**, a blocked customer cannot pay, in sandbox and live. A new payment for them,
  named by `customer_id` or found by their email or phone, answers `403` with
  `error_code: customer_blocked`, and nothing is created. A payment created on that version can no
  longer be charged or confirmed once its customer is blocked. Your payment links and invoices
  create their payments on the version your account is pinned to.
  [Blocked customers](https://docs.wajub.com/api/errors#blocked-customers)
- **Before `2026-11-02`**, `blocked` only marks the customer, for your team and your
  [routing rules](https://docs.wajub.com/orchestration/routing-rules): they can still pay.

Unblocking lets them pay again. [Versioning](https://docs.wajub.com/api/versioning) says how your version is chosen.

> [!NOTE]
> **To refuse a payer whatever the version**
>
> Add their email or phone to the Shield [blocklist](https://docs.wajub.com/risk/shield/rules), which is checked on every
> live transaction and rejects it outright.

## Tax ids

A business customer's tax registration numbers are kept in their own list, one entry per number: a
Cameroonian NIU, a Senegalese NINEA, an EU VAT number. The list is available in live only.

`POST /customers/{id}/tax_ids`

- `type` (string, required): The kind of number: `cm.niu`, `sn.ninea`, `ci.ifu`, `ke.pin`, `ng.tin`, `gh.tin`, `gh.vat`, `eu.vat`, `gb.vat` or `us.ein`. Another type is accepted too, and only its length is checked.
- `value` (string, required): The number itself, with or without the spaces and dashes its format writes.
- `country_code` (string, required): ISO 3166-1 alpha-2, such as `CM`.

Add the number from your server, with a live secret key:

**Add a tax id**

```bash
curl https://api.wajub.com/customers/cus_sAaim5apjocIgtlhzJY3wQ8s/tax_ids \
  -H "Authorization: $WAJUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "cm.niu",
    "value": "M123456789000L",
    "country_code": "CM"
  }'
```

```javascript
const taxId = await wajub.customers.createTaxId('cus_sAaim5apjocIgtlhzJY3wQ8s', {
  type: 'cm.niu',
  value: 'M123456789000L',
  country_code: 'CM',
});

console.log(taxId.verification_status);
```

```python
tax_id = wajub.customers.create_tax_id("cus_sAaim5apjocIgtlhzJY3wQ8s", {
    "type": "cm.niu",
    "value": "M123456789000L",
    "country_code": "CM",
})

print(tax_id["verification_status"])
```

```php
$taxId = $wajub->customers->createTaxId('cus_sAaim5apjocIgtlhzJY3wQ8s', [
  'type' => 'cm.niu',
  'value' => 'M123456789000L',
  'country_code' => 'CM',
]);

echo $taxId['verification_status'];
```

```go
taxID, err := client.Customers.CreateTaxID(context.Background(), "cus_sAaim5apjocIgtlhzJY3wQ8s", map[string]any{
	"type": "cm.niu",
	"value": "M123456789000L",
	"country_code": "CM",
}, nil)

if err != nil {
	log.Fatal(err)
}

log.Println(taxID["verification_status"])
```

The number comes back `pending` while Wajub checks it. `verification_status` then
becomes `verified` when the value matches the format of its type, `failed` when it does not, and
`unavailable` when the check could not run. The formats are the ones your own registration number is
checked against ([Tax configuration](https://docs.wajub.com/tax/configuration#customer-tax-ids) lists them): a Cameroonian
NIU is a letter, twelve digits and a letter. For an `eu.vat` number the check also confirms that
the number is registered.

Adding the same type and number again does not add a copy: the call answers `200` with the existing
entry, back to `pending` while it is checked again. That is how you retry an `unavailable` check.

`GET /customers/{id}/tax_ids` lists the numbers with their status, and
`DELETE /customers/{id}/tax_ids/{tax_id}` removes one.

## Webhooks

Three events follow a customer, and they carry the full customer object as their payload.

| Event              | Fires when                                                             |
| ------------------ | ---------------------------------------------------------------------- |
| `customer.created` | A customer is created, including one created implicitly by a payment   |
| `customer.updated` | Any field changes, including a status change or a merge from a payment |
| `customer.deleted` | The customer is deleted and anonymised                                 |

`customer.created` is noisier than it looks: it fires for every new payer your checkout sees, not
only for the ones you create yourself. Registration, verification and retries are covered in
[Webhooks](https://docs.wajub.com/developer-tools/webhooks).

- [Customers API reference](https://docs.wajub.com/api/customers): Every field on the resource, and its endpoints.
- [Shield Rules](https://docs.wajub.com/risk/shield/rules): The blocklist that actually refuses a payer, by email, phone, IP or BIN.
- [Webhooks](https://docs.wajub.com/developer-tools/webhooks): Register an endpoint and verify the signature on customer events.
- [Pagination](https://docs.wajub.com/api/pagination): Page numbers for a screen, cursors for an export.
