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
| Parameter | Type | Description |
|---|---|---|
sort_field | enum optional | Field you want to sort by. Accepted values: amount, name, active, status, due_by, created_at |
sort_order | string optional | Sorting order, can either be asc or desc |
limit | integer optional | Limit query result (when working with pagination) |
filters | array optional | An 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:
| Parameter | Type | Description |
|---|---|---|
filters[].field | enum | Field you want to filter by. Accepted values: id, reference, name, amount, status, active, due_by, alias, created_at |
filters[].value | string | The value to compare by |
filters[].operator | string | Comparison 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": {...}
}