# List the payments

`GET /api/v1/billing/payments`

Retrieve every payment this account made, newest first, each with the invoice Stripe issued for it.

One row per invoice, whether it was the one time purchase or a renewal. They are kept here rather than read from Stripe on every call, so this never waits on Stripe and never stops working when Stripe does.

An account we opened access on has no payment at all, and so answers an empty list.

This endpoint also answers QUERY, with the same parameters sent in the request body. [How QUERY works](https://my.monicahq.com/docs/api/query-method).

## Query parameters

- `per_page` (integer, optional, defaults to 25): How many payments one page holds. Brought into the allowed range rather than refused.

## Returns

A page of payment objects, an empty list rather than an error when there are none.

- `data` (array): The payments on this page. An empty list rather than an error when there are none.
- `data[]` (object): One payment.
- `data[].type` (string): Always payment. It names the kind of record, so a caller holding several kinds can tell them apart without looking at where they came from.
- `data[].id` (string): The id of this record, as a string even when it reads as a number. It is what every endpoint naming this record takes.
- `data[].attributes` (object): Everything the record holds.
- `data[].attributes.provider_id` (string): The id of the invoice at Stripe, which is also this record's id. It is what makes a confirmation Stripe sends twice recognisable as one payment.
- `data[].attributes.offer` (string): Which plan was paid for: monthly, yearly or lifetime. It is kept as it stood on the day, so retagging a price at Stripe never rewrites the history, and it is null when the catalogue no longer knows the price that was charged.
- `data[].attributes.status` (string): The state of the invoice, as Stripe names it.
- `data[].attributes.total` (integer): What was paid, in the smallest unit of the currency, tax included.
- `data[].attributes.tax` (integer): The tax share of that total, worked out by Stripe from where the buyer was, and already part of it rather than added to it.
- `data[].attributes.currency` (string): The currency of both amounts, three letters as Stripe writes them.
- `data[].attributes.invoice_number` (string): The number Stripe gave the invoice, null when it gave none.
- `data[].attributes.invoice_url` (string): The page at Stripe where the invoice is read. Null when Stripe issued none.
- `data[].attributes.invoice_pdf_url` (string): The same invoice as a file. Null when Stripe issued none.
- `data[].attributes.billed_at` (timestamp): When Stripe finalised the invoice, as a count of seconds since 1970. It is what the list is ordered by.
- `data[].links` (object): Where to find this record.
- `data[].links.self` (string): The absolute address this record is read from.
- `meta` (object): Where you are in the collection.
- `meta.page` (integer): The page this is, counting from 1.
- `meta.per_page` (integer): How many one page holds, which is the size that was asked for once it has been brought into the allowed range.
- `meta.total` (integer): How many payments there are in all, not how many are on this page.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://my.monicahq.com/api/v1/billing/payments \
  -H "Authorization: Bearer $MONICA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
      "per_page": "50"
  }'
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/billing/payments', {
  headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    per_page: '50',
  }),
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->get('https://my.monicahq.com/api/v1/billing/payments', [
    'per_page' => '50',
]);
```

## Response

`200`

```json
{
    "data": [
        {
            "type": "payment",
            "id": "in_1QdundieAwards",
            "attributes": {
                "provider_id": "in_1QdundieAwards",
                "offer": "lifetime",
                "status": "paid",
                "total": 19900,
                "tax": 3317,
                "currency": "eur",
                "invoice_number": "DM-0042",
                "invoice_url": "https://invoice.stripe.com/i/test_a1dundermifflin",
                "invoice_pdf_url": "https://pay.stripe.com/invoice/test_a1dundermifflin/pdf",
                "billed_at": 1757073600
            },
            "links": {
                "self": "https://my.monicahq.com/api/v1/billing/payments/in_1QdundieAwards"
            }
        }
    ],
    "meta": {
        "page": 1,
        "per_page": 25,
        "total": 1
    }
}
```
