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

# Create Invoice

> Endpoint used to create an invoice

> [!NOTE]
>
> The setting to charge admin fee and channel fee to the customer does not
> apply to the Invoice feature.

```bash Request Example theme={null}
curl --request POST 'https://api.mayar.id/hl/v2/invoices/create' \
--header 'Authorization: Bearer Paste-Your-API-Key-Here' \
--header 'Content-Type: application/json' \
--data-raw '{
        "name": "Budi Santoso",
        "email": "budi.santoso@example.com",
        "mobile": "081234567890",
        "description": "Pelunasan pesanan",
        "expiredAt": "2026-07-19T16:43:23.000Z",
        "items": [
            {
                "quantity": 3,
                "rate": 11000,
                "description": "Paket layanan A"
            }
        ],
        "extraData": {
            "noCustomer": "827hiueqy271hj",
            "idProd": "contoh aja"
        }
    }'
```

```json Response Example 200 theme={null}
{
    "statusCode": 200,
    "messages": "success",
    "data": {
        "id": "6f8c19ff-5b97-4792-aa89-d2a12797b356",
        "transactionId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "link": "https://testingmayar.myr.id/invoices/ycfyxbj2h3",
        "expiredAt": 1784479403000,
        "extraData": {
            "noCustomer": "827hiueqy271hj",
            "idProd": "contoh aja"
        }
    }
}
```

Endpoint:

```Production Production theme={null}
https://api.mayar.id/hl/v2/invoices/create
```

```Sandbox Sandbox theme={null}
https://api.mayar.io/hl/v2/invoices/create
```

## Authorization

**Authorization** `string` *required*

Example:

`Authorization | Bearer Paste-Your-API-Key-Here`

## Request Body

**name** `string` *required*

Full name of the customer.

**email** `string` *required*

Email address of the customer.

**mobile** `string` *required*

Mobile phone number of the customer.

**items** `array` *required*

List of invoice items.

**items\[].quantity** `number` *required*

Quantity of the item.

**items\[].rate** `number` *required*

Price per item. Negative values are accepted and can be used as a discount line
(e.g. `{ "description": "Diskon", "quantity": 1, "rate": -10000 }`). The
invoice total must remain greater than zero.

**items\[].description** `string` *required*

Description of the item.

**description** `string`

Description or notes related to the invoice.

**expiredAt** `string`

Invoice expiration time in ISO 8601 format (UTC).

**tax** `integer`

Tax amount applied to the invoice.

**paymentMethod** `string`

Restrict the invoice to a specific payment method (lowercase). Accepts one of
the following values:

* `qris`
* `va/bni`
* `va/bri`
* `va/mandiri`
* `va/cimb`
* `va/permata`
* `va/bjb`
* `va/bsi`
* `ewallet/dana`
* `ewallet/gopay`
* `ewallet/linkaja`
* `ewallet/shopeepay`
* `ewallet/jenius`
* `outlet/alfamart`

The selected channel must be enabled in your payment channel configuration;
otherwise the request returns a `400` with
`"Payment method \"...\" is not available or disabled"`.

> [!NOTE]
>
> `paymentMethod` determines the payment code returned by the API (for example a
> VA number or a QRIS payload) for that specific method. The Mayar checkout page
> link (`link`) still follows the payment methods configured in your Mayar
> settings.

**cashtag** `string`

Cashtag associated with the invoice. Only required when using
`ewallet/jeniuspay` as the `paymentMethod`.

**extraData** `object`

Additional custom data attached to the invoice.

## Response

Successful Response

### Main Structure (Root)

**statusCode** `integer`

Status code form API.

**messages** `string`

Status message that describes the status code.

**data** `object`

The created invoice data.

### data Structure (Object)

**data.id** `string`

Unique identifier of the invoice record.

**data.transactionId** `string`

Unique identifier of the associated transaction.

**data.link** `string`

Invoice URL that can be accessed by the customer.

**data.expiredAt** `number`

Timestamp (in milliseconds) indicating when the invoice will expire.

**data.extraData** `object`

Additional custom data attached to the invoice (echoed from the request).

### Errors

**400 Bad Request** `object`

Returned when the request body fails validation:
`{ "statusCode": 400, "messages": "Validation Error" }` or
`{ "statusCode": 400, "messages": "extraData Validation Error" }`.

**400 Invoice total must be greater than zero** `object`

Returned when the sum of `rate × quantity` (plus tax) is not positive, e.g. a
discount line larger than the subtotal:
`{ "statusCode": 400, "messages": "Invoice total must be greater than zero" }`.

**404 Not Found** `object`

Returned when the customer could not be found or created:
`{ "statusCode": 404, "messages": "Customer not found and failed to create new customer" }`.

**409 Conflict** `object`

Returned when an invoice with the same identifier already exists:
`{ "statusCode": 409, "messages": "already exist" }`.

**429 Too Many Requests** `object`

Returned when a duplicate create request is detected:
`{ "statusCode": 429, "messages": "Duplicate request detected. Please wait 1 minute before trying again." }`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.