> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# Create Invoice

> Create a one-time payment request for a specific customer.

### Authentication

Requires `X-API-KEY` header.

You can also pass an optional `Idempotency-Key` header to safely retry requests without creating duplicate records. See the [Idempotency guide](/api-reference/idempotency.md) for details.

### Body Parameters

**title** `string` *required*

The invoice title shown to the customer.

**amount** `integer`

The invoiced amount, as a whole number in cents (smallest currency unit). For example, `120000` is \$1,200.00. Do not send decimals. Required unless you send `line_items`; if you send both, the total of the line items is used and `amount` is ignored.

**line\_items** `object[]`

Priced lines for the invoice. The invoice amount is the total of the lines (`quantity` times `unit_price_cents`, summed). **An invoice can have at most 50 line items**; a request with more is rejected (see the `400` example below).

**properties**

**title** `string` *required*

What the line is for. Up to 255 characters.

**unit\_price\_cents** `integer` *required*

The price of one unit, as a whole number in cents. At least `1`.

**quantity** `string` (default: 1)

How many units, with up to two decimal places, for example `"2"` or `"1.5"`. At least `0.01`.

**description** `string`

Optional note for the line. Up to 1000 characters.

**unit** `string`

Optional unit label, for example `hours`. Up to 40 characters.

**customer\_name** `string` *required*

The customer's full name.

**customer\_email** `email` *required*

The customer's email address.

**currency** `string` (default: USD)

Must be `USD`. Only USD payments are supported.

**description** `string`

Optional description or notes for the invoice.

**reference\_id** `string`

Your own id for this invoice, for example a booking or order id. Up to 255 characters; surrounding whitespace is trimmed. Blank or `null` means none, and invoices without one are not limited. It must be unique among your invoices: if you already used it on another invoice, the request fails with `409` and `duplicate_reference_id`. It comes back on the invoice, on the payment in [`/v1/transactions/`](/api-reference/transactions/list) and in the [`invoice.paid` webhook](/api-reference/webhooks/overview). See [Matching a payment to your own record](#matching-a-payment-to-your-own-record).

**customer\_phone** `string`

The customer's phone number.

**redirect\_url** `string`

URL to redirect the customer after successful payment.

**expires\_at** `datetime`

Optional expiry deadline (ISO 8601), for example `2027-12-31T23:59:59Z`. Must be in the future, or the invoice is created already expired: a date in the past is accepted, not rejected, and the invoice cannot be paid. The invoice counts as expired once the calendar day of `expires_at` has ended in India Standard Time (UTC+05:30), not at the exact moment.

**payment\_method\_configuration** `object`

Limit which payment methods the checkout offers. Send either `enabled` (only these methods) or `disabled` (the usual methods minus these), one at a time. Omit it, or send `null`, to offer the usual methods. See [Payment Methods](/api-reference/payment-methods.md).

**properties**

**enabled** `string[]`

Payment method identifiers to offer, for example `["card", "klarna"]`.

**disabled** `string[]`

Payment method identifiers to hide, for example `["crypto"]`. Disabling `card` also hides Apple Pay and Google Pay.

> [!NOTE]
>
> A `reference_id` can be used on one invoice only. If you create an invoice with one you already used, the API returns `409` with the code `duplicate_reference_id`, and `details.invoice_id` is the `id` of the existing invoice (see the `409` example below). There are no exceptions: a paid, expired or voided invoice keeps its reference, so a new invoice for the same booking needs a different `reference_id`.
>
> An `Idempotency-Key` still works. With the key, a retried create returns the original invoice. Without it, a retry of a create that has a `reference_id` gets the `409`. An invoice without a `reference_id` is not limited, so only an `Idempotency-Key` stops a duplicate there. Send one. See the [Idempotency guide](/api-reference/idempotency.md).

### Matching a payment to your own record

* Create one invoice per booking or order, and pass your own id as `reference_id`.
* Store the `id` of the invoice that comes back, next to your record.
* When the `invoice.paid` webhook arrives, find your record by its `reference_id`, or by `invoice_id`, which is the `id` you stored.
* If a create returns `duplicate_reference_id`, an invoice for that record already exists. Fetch it with `GET /v1/invoices/{id}/`, using `details.invoice_id`, and reuse its `checkout_url` if it is not paid or expired.

### Response

Returns the created invoice with a `checkout_url` to send to the customer.

**id** `uuid`

The unique identifier for the invoice.

**invoice\_number** `string`

Auto-generated invoice number.

**reference\_id** `string | null`

Your own id for this invoice, as you sent it when you created the invoice. `null` if none was set.

**amount** `integer`

The invoiced amount in cents (smallest currency unit).

**checkout\_url** `string`

The payment URL to send to the customer.

**is\_paid** `boolean`

`false` - invoices are unpaid on creation.

**is\_expired** `boolean`

`false` unless the calendar day of `expires_at` has already passed. It is `true` straight away if you sent a past `expires_at`.

**expires\_at** `datetime`

The expiry deadline, if provided.

**payment\_method\_configuration** `object | null`

The saved payment method setting, for example `{"enabled": ["card"]}`. `null` means the usual methods. See [Payment Methods](/api-reference/payment-methods.md).

**created\_at** `datetime`

Timestamp when the invoice was created.

```bash cURL
curl -X POST https://api.playto.so/v1/invoices/ \
  -H "X-API-KEY: sk_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Website Redesign - Phase 1",
    "description": "Wireframes and initial mockups.",
    "reference_id": "booking_88213",
    "amount": 120000,
    "currency": "USD",
    "customer_name": "Jane Smith",
    "customer_email": "jane@acme.com",
    "customer_phone": "+1 555 000 1234",
    "redirect_url": "https://yoursite.com/thank-you",
    "expires_at": "2027-12-31T23:59:59Z",
    "payment_method_configuration": { "disabled": ["crypto"] }
  }'
```

```json 201
{
  "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
  "invoice_number": "INV-20240501-C3D4E5",
  "reference_id": "booking_88213",
  "title": "Website Redesign - Phase 1",
  "description": "Wireframes and initial mockups.",
  "amount": 120000,
  "currency": "USD",
  "customer_name": "Jane Smith",
  "customer_email": "jane@acme.com",
  "customer_phone": "+1 555 000 1234",
  "checkout_url": "https://app.playto.so/pay/checkout?paymentLinkId=c3d4e5f6-a7b8-9012-cdef-123456789012",
  "redirect_url": "https://yoursite.com/thank-you",
  "is_paid": false,
  "is_expired": false,
  "paid_at": null,
  "expires_at": "2027-12-31T23:59:59Z",
  "payment_method_configuration": {"disabled": ["crypto"]},
  "created_at": "2024-05-01T10:00:00Z"
}
```

```json 400 (validation error)
{
  "error": {
    "type": "invalid_request_error",
    "code": "validation_error",
    "message": "One or more fields are invalid.",
    "details": {
      "customer_name": ["This field is required."],
      "customer_email": ["Enter a valid email address."]
    }
  }
}
```

```json 400 (more than 50 line items)
{
  "error": {
    "type": "invalid_request_error",
    "code": "validation_error",
    "message": "One or more fields are invalid.",
    "details": {
      "line_items": ["At most 50 line items."]
    }
  }
}
```

```json 409 (reference_id already used)
{
  "error": {
    "type": "conflict_error",
    "code": "duplicate_reference_id",
    "message": "An invoice with this reference_id already exists.",
    "details": {
      "invoice_id": "c3d4e5f6-a7b8-9012-cdef-123456789012"
    }
  }
}
```
