Create an Invoice
This endpoint creates an invoice ready to be paid.
Required scope: create-invoice
Parameters
| Parameter | Type | Description |
|---|---|---|
reference | optional | A reference to your invoice. |
name | required | The name of the invoice (product or service) to pay. |
amount | required | The amount to be paid, in minor units. |
currency | required | The currency linked to your amount, in capital letters. |
description | required | A description of the invoice. |
due_by | optional | The date the invoice is due. |
active | optional | Whether the invoice is active. Defaults to false. |
Returns
Returns an invoice object if the request was successful.
Request
Endpoint: https://youcanpay.com/api/v2/invoices
Method: POST
bash
$ curl --location --request POST 'https://youcanpay.com/api/v2/invoices' \
--form 'name="Invoice test"' \
--form 'amount="1200"' \
--form 'currency="MAD"' \
--form 'description="Hello this is me saying hello"' \
--form 'active="1"' \
--form 'reference="test ref"' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN_eyJpc3...'Response
json
{
"object": "v2.invoice",
"id": "inv_22959e71-8b90-455d-9f4c-d32b5699950c",
"reference": "0000000020",
"name": "Invoice test",
"description": "test test test test test",
"active": false,
"status": "pending",
"amount": {
"amount": "12.00",
"currency": "MAD",
"localized": "MAD 12.00"
},
"link": "https://youcanpay.com/i/6P1OEzW",
"due_by": null,
"created_at": "2024-01-29 12:15:58",
"deleted_at": null
}Errors
| Error | Description |
|---|---|
| Unsupported currency | The currency you provided isn't supported for your account. |
| Invalid amount | The amount is below the minimum or above the maximum allowed transaction amount. |