Skip to content

Create an Invoice

This endpoint creates an invoice ready to be paid.

Parameters

ParameterTypeDescription
referenceoptionalA reference to your invoice.
namerequiredThe name of the invoice (product or service) to pay.
amountrequiredThe amount to be paid is represented in a small integer format. For example, an amount of 10000 equals 100 DH.
currencyrequiredThe currency linked to your amount in capital letters.
descriptionrequiredA description that does not exceed 500 characters.
activeoptionalA boolean type that can activate or deactivate access to the invoice.

Returns

Returns an invoice object if the request was successful.

Request

Endpoint: https://api.youcanpay.com/invoices

Method: POST

bash
$ curl --location --request POST 'https://api.youcanpay.com/invoices' \
  --form 'name="samir"' \
  --form 'amount="10000"' \
  --form 'currency="MAD"' \
  --form 'description="Hello this is me saying hello"' \
  --form 'to="+212669336603"' \
  --form 'active="1"' \
  --form 'reference="tes ref"' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_TOKEN_eyJpc3...'

Response

json
{
  "data": {
    "object": "invoice",
    "id": "inv_22959e71-8b90-455d-9f4c-d32b5699950c",
    "reference": "0000000020",
    "name": "Invoice test",
    "description": "test test test test test",
    "active": false,
    "status": 0,
    "status_text": "pending",
    "created_at": 1706535358,
    "due_by": null,
    "deleted_at": null,
    "link": "https://youcanpay.com/i/6P1OEzW",
    "amount": {
      "amount": "1200",
      "currency": "MAD",
      "localized": "MAD 12.00"
    },
    "transactions": {
      "data": []
    }
  }
}