# Create payment.

> Creates a pending transaction and returns a hosted payment URL (`authorization_url`). Redirect the customer to this URL to complete the payment on Wajub's hosted page. Always verify the final status server-side via `GET /payments/{id}` or by listening to the `payment.succeeded` webhook, never rely solely on the redirect URL. Marketplaces can attribute this payment to a connected subaccount via the `X-Sync` header. With `deferred: true`, the payment is only prepared, for Wajub Components shown on a checkout before its order exists: no transaction, no `payment.created` webhook and no line in your payments until `POST /payments/{id}/activate`. The response has the same shape, with the `id` the payment keeps once activated. With a publishable key, `customer` and the addresses hold what the request sent, never the customer your account already has with that email or phone.

`POST https://api.wajub.com/payments`

## Headers

- `Idempotency-Key` (string): Your key for this request, 1 to 128 characters of letters, digits and `. _ : -`. The same request sent again with the same key returns the first answer instead of doing the work twice. See [Idempotency](https://docs.wajub.com/fr/api/idempotency).

## Body (application/json)

- `deferred` (boolean): Prepare the payment without creating it, for Components shown before your order exists. The customer then comes with `POST /payments/{id}/activate`.
- `amount` (number, required): Amount to collect in the major unit of the currency (e.g. 25000 = 25,000 XAF). Minimum: 0.01.
- `currency` (string, required): ISO 4217 currency code (XAF, XOF, NGN, GHS, KES…).
- `email` (string, nullable): The payer's email. One of `email`, `phone`, `customer_id` or `customer` is required, unless `deferred` is `true`.
- `customer_id` (string, nullable): One of your customers, by its `cus_` id. One of `email`, `phone`, `customer_id` or `customer` is required, unless `deferred` is `true`.
- `phone` (string, nullable): The payer's phone number, international format. One of `email`, `phone`, `customer_id` or `customer` is required, unless `deferred` is `true`.
- `name` (string, nullable): The payer's full name, shown on the payment page.
- `description` (string, nullable): A label shown to the customer on the payment page.
- `reference` (string, nullable): Your own reference for this payment, such as an order number (max 128 chars). Free and not unique: two payments may carry the same one. Find them with `GET /payments?reference=`; to make a retry safe, send an `Idempotency-Key` header.
- `callback` (string, nullable): Where the customer is sent back once the payment ends, whatever the outcome, with `status` in the query string (`succeeded`, `failed`, `cancelled`, `expired`). Must be HTTPS; in sandbox, `http://localhost` and `http://127.0.0.1` are accepted too. Any other address answers `422`.
- `expires` (object): When the payment ends on its own if nobody pays it.
  - `expires.in` (integer, nullable): Session expiry in minutes (5–43200). Defaults to 1440 (24h).
- `customer` (object, nullable): Customer information. Not required itself: at least one of `email`, `phone`, `customer_id` or `customer` is, unless `deferred` is true.
  - `customer.email` (string): Customer email address.
  - `customer.phone` (string): Customer phone number (international format).
  - `customer.name` (string): Customer full name displayed on the payment page.
- `theming` (object, nullable): Colours and logo of the payment page for this payment, over your account branding. Stored and returned; the page does not read it today.
- `address` (object, nullable): Accepted for older integrations and not used.
- `shipping` (object, nullable): Accepted for older integrations and not used.
- `items` (array of object, nullable): Lines shown on the payment page. Display only: they carry no price and never change `amount`.
  - `items[].name` (string, nullable): The line's label, up to 255 characters.
  - `items[].description` (string, nullable): Detail shown under the label, up to 1 000 characters.
  - `items[].quantity` (number, nullable): How many of this line, shown on the page.
- `telemetry` (object, nullable): Free-form data about the integration that created the payment, such as your SDK and app versions. Kept with the payment, not returned.
- `metadata` (object, nullable): Free-form key-value data attached to the transaction.
- `bearer` (string, nullable, one of `merchant`, `customer`): Who bears the platform fee: `merchant` (default) or `customer`.
- `accept` (object, nullable): What this payment may be paid with. Each list narrows the payment page and the charge; a channel outside them answers `422` `channel_not_accepted`.
  - `accept.countries` (array of string): Two-letter country codes: only the channels of these countries. Cards and crypto belong to no country and stay; name them under `types` or `channels` to exclude them.
  - `accept.channels` (array of string): Only these channels: slugs such as `cm.mtn`, `cm.mobile` for every mobile operator of Cameroon, or `mobile` for every mobile operator.
  - `accept.types` (array of string): Channel types accepted, such as `mobile_money` or `card`.
  - `accept.currencies` (string, nullable, one of `payment`, `any`): `payment`: only channels that settle in the payment's currency. `any` or absent: no currency filter.
- `shares` (array of object, nullable): Sync platforms: share this payment between your connected accounts. Each part names one of your accounts of this environment and an amount; what the parts leave of `amount` is your own share. Every account must be active and hold the `payments` permission, once per payment, 50 parts at most, every part in the payment's currency. Create the payment with your own key, without `X-Sync`, and not `deferred`. In live, a shared payment is collected on the Wajub rail only, and a Lite or Relay part needs Wajub's review of your platform for that mode.
  - `shares[].account` (string): One of your connected accounts, by its `acc_` id.
  - `shares[].amount` (number): The account's part, in the major unit of the payment's currency.
  - `shares[].currency` (string, nullable): The payment's currency, if sent: any other is refused.
  - `shares[].reference` (string, nullable): Your own reference for this part, up to 255 characters.
  - `shares[].hold` (object, nullable): Hold this part only, or with its own `max_days`: wins over the top-level `hold`.
    - `shares[].hold.until` (string, required, one of `released`): Only `released`.
    - `shares[].hold.max_days` (integer, nullable): As `hold.max_days`, for this part's account.
- `hold` (object, nullable): Sync: hold the seller's money until you release it (`POST /payments/{id}/release`), as a marketplace pays its seller once the buyer has the goods. On a payment made with `X-Sync` for a `lite` or `relay` account, or on a shared payment (`shares`), for every part. Never for a `direct` account. At the latest, the money is released on its own after `max_days`. A payment paid in instalments can be held: each instalment is held from its credit, and the whole sale from its last one.
  - `hold.until` (string, required, one of `released`): Only `released`.
  - `hold.max_days` (integer, nullable): The longest the sale is held, in days from the payment's success: 1 to the account's `hold_max_days` (30, 60 or 90), which is the default.

## Responses

- `201`: Payment initialized
- `401`: Unauthenticated
- `403`: Forbidden
- `409`: Shared payment: not on the Wajub rail
- `422`: Unprocessable Content
- `429`: Rate limited

## Example response (201)

```json
{
  "code": 201,
  "status": "Created",
  "message": "Payment initiated",
  "authorization_url": "https://pay.wajub.com/test_7Yh2Mp4kQ9xL4vR8tB3nW6yC1dF5sJ0aG…",
  "authorization_token": "test_7Yh2Mp4kQ9xL4vR8tB3nW6yC1dF5sJ0aG…",
  "transaction": {
    "id": "trx_test_CSUGajfv9xh0XQ5wu2lx",
    "reference": "order-4172",
    "amount": 25000,
    "currency": "XAF",
    "status": "pending",
    "description": "Order #4172",
    "sandbox": true,
    "created_at": "2026-01-15T10:30:00+00:00"
  }
}
```
