Skip to content

List All Invoices

Returns a paginated list of invoice objects related to the current authenticated account. The list is sorted, with the most recent invoices appearing first by default.

Parameters

ParameterTypeDescription
sort_fieldenum optionalField you want to sort by. Accepted values: amount, name, active, status, due_by, created_at
sort_orderstring optionalSorting order, can either be asc or desc
limitinteger optionalLimit query result (when working with pagination)
filtersarray optionalAn array of filter criteria where each entry has the following keys (see below)

Filter Criteria

Each entry in the filters array supports the following keys:

ParameterTypeDescription
filters[].fieldenumField you want to filter by. Accepted values: id, reference, name, amount, status, active, due_by, alias, created_at
filters[].valuestringThe value to compare by
filters[].operatorstringComparison operator (=: default, !=, >, <, =>, <=, is, is_not, in)

Returns

Returns a paginated collection of invoice objects. If no invoices are found, returns an empty collection.

Request

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

Method: GET

bash
$ curl --location -g --request GET 'https://api.youcanpay.com/invoices' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_TOKEN_eyJpc3...'

Request with Filters

bash
$ curl --location -g --request GET 'https://api.youcanpay.com/invoices?sort_field=amount&sort_order=asc&filters[0][field]=amount&filters[0][value]=100' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_TOKEN_eyJpc3...'

Response

json
{
  "data": [
    {
      "id": "inv_094648cb-58f9-7292-8fa5-29ae8189638c",
      "reference": "0000000001",
      "name": "invoice_test",
      "display_amount": "100 MAD",
      "status": 0,
      "is_active": true,
      "description": null,
      "due_by": null,
      "account_id": "8hqb691-c228-4941-bd56-8hkl427snxn",
      "alias": "https://youcanpay.com/i/IO09df4"
    },
    {...}
  ],
  "meta": {...}
}