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.

Required scope: view-invoices

Parameters

ParameterTypeDescription
sort_fieldstring optionalField you want to sort by. Defaults to created_at.
sort_orderstring optionalSorting order, asc or desc. Defaults to desc.
pageinteger optionalPage number. Defaults to 1.
limitinteger optionalPage size. Defaults to 10, capped at 50.
qstring optionalFree-text search term.
filtersarray optionalAn array of filter criteria where each entry has the following keys (see below).

Filter Criteria

ParameterTypeDescription
filters[].fieldstringField you want to filter by.
filters[].valuestringThe value to compare by.
filters[].operatorstringComparison 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.