# Create a checkout session

`POST https://morzepay.com/v1/checkout/sessions`

POST`/v1/checkout/sessions`

Creates a hosted payment page for an order. Send your customer to its `url`; the page asks for their number, sends the prompt, waits, lets them retry and gives them a receipt. When they’ve paid, we send them to your `success_url`.

With `reusable: true` it becomes a [payment page](https://morzepay.com/docs/payment-pages) that takes any number of payments until you expire it.

Permission`checkout:write`

### Headers

`Idempotency-Key`stringheader

8–80 letters, digits, `-` or `_`. Lets you retry safely: the same key and body return the first answer and never move money twice. See [Idempotency](https://morzepay.com/docs/api#idempotency).

### Body

JSON, with `Content-Type: application/json`.

`line_items`array

What they’re paying for, like invoice lines. Give these or `amount`.

Show child attributes

`description`stringrequired

What the line is for.

`quantity`integerrequired

How many.

`unit_amount`integerrequired

The price of one, in whole UGX.

`amount`integer

A single amount in UGX, instead of `line_items`. Needs `title`.

`title`string

What’s being paid for. Required with `amount`; defaults to the first line.

`description`string

Text under the title.

`success_url`string

Where to send the customer after paying. `{CHECKOUT_SESSION_ID}` is replaced with the session id.

`cancel_url`string

Shown as a back arrow on the page.

`reference`string

Your order id. Returned on the session and in webhooks.

`customer`object

Fills in the page for them.

Show child attributes

`name`string

`email`string

`phone`string

`require_email`boolean

Make the email field required, so they always get a receipt.

`require_name`boolean

Make the name field required.

`allow_custom_amount`boolean

Let the customer type the amount, for donations, fees and top-ups.

`min_amount`integer

The lowest amount they may type.

`reusable`booleandefault: false

`true`: a link that takes any number of payments until you expire it. `false`: one payment, then `complete`.

`expires_in_minutes`integerdefault: 1440

One-time sessions only. 30 to 10,080.

`wallet_id`string

Where payments land. Defaults to your main wallet.

`fee_bearer`string

`wallet` or `customer`.

`metadata`object

Up to 20 keys of your own, with simple values. Returned on the object and in webhooks.

### Returns

The checkout session, with its `url`.

### Errors

| Status | Code | When |
| 422 | VALIDATION_ERROR | For example, neither line_items nor amount, or a total outside UGX 500–5,000,000. |

The common codes, such as `UNAUTHENTICATED` and `RATE_LIMITED`, can come from any endpoint. See [Errors](https://morzepay.com/docs/api#errors).

Don’t ship an order just because the customer arrived at your `success_url`: anyone can open that address. Confirm with the `checkout.session.completed` webhook, or by [getting the session](https://morzepay.com/docs/api/get-checkout) and checking that its status is `complete`.



## Example request

```bash
curl -X POST "https://morzepay.com/v1/checkout/sessions" \
  -H "Authorization: Bearer $MORZEPAY_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-77812" \
  -d '{
  "title": "Order #77812",
  "line_items": [
    {
      "description": "Rolex combo",
      "quantity": 2,
      "unit_amount": 7000
    }
  ],
  "reference": "order-77812",
  "success_url": "https://yourshop.ug/thanks?session={CHECKOUT_SESSION_ID}",
  "cancel_url": "https://yourshop.ug/cart"
}'
```

## Example response (201)

```json
{
  "success": true,
  "data": {
    "id": "cs_J9WN4dg0YnY6VjMMwq0kL1",
    "object": "checkout.session",
    "livemode": true,
    "status": "open",
    "reusable": false,
    "url": "https://morzepay.com/c/83513594a9ee455aacf23ca24eeff21b",
    "title": "Order #77812",
    "description": null,
    "line_items": [
      {
        "description": "Rolex combo",
        "quantity": 2,
        "unit_amount": "7000.00",
        "amount": "14000.00"
      }
    ],
    "amount_total": "14000.00",
    "allow_custom_amount": false,
    "min_amount": null,
    "currency": "UGX",
    "fee_bearer": "wallet",
    "wallet_id": "wal_8fK2mQx7RtP4nVb9LcHs2w",
    "require_email": false,
    "require_name": false,
    "success_url": "https://yourshop.ug/thanks?session={CHECKOUT_SESSION_ID}",
    "cancel_url": "https://yourshop.ug/cart",
    "reference": "order-77812",
    "customer": {
      "name": null,
      "email": null,
      "phone": null
    },
    "metadata": null,
    "payments_count": 0,
    "amount_collected": "0.00",
    "transaction_id": null,
    "receipt_id": null,
    "receipt_url": null,
    "expires_at": "2026-10-29T09:00:23+03:00",
    "completed_at": null,
    "created_at": "2026-10-28T09:00:23+03:00"
  }
}
```
