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.
Required scope: view-invoices
Parameters
| Parameter | Type | Description |
|---|---|---|
sort_field | string optional | Field you want to sort by. Defaults to created_at. |
sort_order | string optional | Sorting order, asc or desc. Defaults to desc. |
page | integer optional | Page number. Defaults to 1. |
limit | integer optional | Page size. Defaults to 10, capped at 50. |
q | string optional | Free-text search term. |
filters | array optional | An array of filter criteria where each entry has the following keys (see below). |
Filter Criteria
| Parameter | Type | Description |
|---|---|---|
filters[].field | string | Field you want to filter by. |
filters[].value | string | The value to compare by. |
filters[].operator | string | Comparison operator. Accepted values: = (default), is, is_not, !=, <, <=, >, >=, in, like, not like. |
Returns
Returns a paginated collection of invoice objects. If no invoices are found, returns an empty collection.
Request
Endpoint: https://youcanpay.com/api/v2/invoices
Method: GET
bash
$ curl --location -g --request GET 'https://youcanpay.com/api/v2/invoices' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN_eyJpc3...'Request with Filters
bash
$ curl --location -g --request GET 'https://youcanpay.com/api/v2/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
{
"object": "v2.invoice",
"data": [
{
"object": "v2.invoice",
"id": "inv_094648cb-58f9-7292-8fa5-29ae8189638c",
"reference": "0000000001",
"name": "invoice_test",
"description": null,
"active": true,
"status": "pending",
"amount": {
"amount": "100.00",
"currency": "MAD",
"localized": "MAD 100.00"
},
"link": "https://youcanpay.com/i/IO09df4",
"due_by": null,
"created_at": "2024-01-29 10:22:38",
"deleted_at": null
}
],
"pagination": {
"current_page": 1,
"per_page": 10,
"total": 6,
"last_page": 1
}
}See the Invoice object for a description of each field.