Skip to content

Create an Invoice

This endpoint creates an invoice ready to be paid.

Required scope: create-invoice

Parameters

ParameterTypeDescription
referenceoptionalA reference to your invoice.
namerequiredThe name of the invoice (product or service) to pay.
amountrequiredThe amount to be paid, in minor units.
currencyrequiredThe currency linked to your amount, in capital letters.
descriptionrequiredA description of the invoice.
due_byoptionalThe date the invoice is due.
activeoptionalWhether 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

ErrorDescription
Unsupported currencyThe currency you provided isn't supported for your account.
Invalid amountThe amount is below the minimum or above the maximum allowed transaction amount.