# Reconcile and catch up

> List your codes by what happened to them, to check a month and to catch up after an outage.

A webhook is a hint, not the record. The record is the list of your codes: which were redeemed and
when, and which have ended. Read it to check a month's invoice, and to catch up after your receiver
was down. It needs the scope `access_codes:read`.

## List codes by what happened

```bash
curl "https://api.youth-platform.io/v1/access-codes?status=redeemed&redeemed_from=2026-12-01T00:00:00Z" \
  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN"
```

| Filter          | Keeps                                                                    |
| --------------- | ------------------------------------------------------------------------ |
| `batch_id`      | The codes of one batch                                                   |
| `status`        | The codes in one [status](/docs/access-codes#a-codes-life)               |
| `redeemed_from` | The codes redeemed at or after this time                                 |
| `redeemed_to`   | The codes redeemed before this time                                      |
| `ended_from`    | The codes whose access ended at or after this time, and has ended by now |
| `after`         | The next page: the `next` of the page before                             |
| `limit`         | How many codes a page holds: 1 to 1,000, 100 unless set                  |

Each item is a code as [Read the codes](/docs/access-codes/order#read-the-codes) shows it. Send
`Accept: text/csv` for a file your finance team can open: one CSV file of every matching code, not
paged, up to 50,000 codes. A list longer than that answers `422` `too_many_codes`: ask for a month
at a time, with `redeemed_from` and `redeemed_to`, or a batch at a time with `batch_id`.

Page through a list in one go, with `after`: `next` is not a feed of what is new, and a batch that
becomes `ready` later can sort before codes you have already read. Read a new batch's codes with
`batch_id`.

## Check a month

Compare the list with your own records:

1. List the codes redeemed up to the end of the month, with `redeemed_to`.
2. For each, compare `redeemed_at` with the activation you stored, and `access.ends_at` with the
   end you sent.
3. A code that is cancelled in your system, and `redeemed` in the list with no `access.ends_at`, is
   an end that never reached YOU(th): [send it again](/docs/access-codes/end-access).
4. A code that is `ended` in the list and active in your system is an `Access.ended` you missed:
   stop billing it.

## Catch up after an outage

When your receiver was down for longer than YOU(th) [retries](/docs/webhooks/retries), list the
codes redeemed since a little before the newest `AccessCode.redeemed` you have, an hour before for
example:

```bash
curl "https://api.youth-platform.io/v1/access-codes?redeemed_from=2026-12-12T08:30:00Z" \
  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN"
```

Skip the codes you already have, as you skip an `event_id` you have seen. `redeemed_at` is the time
the event carried in `occurred_at`.

Then list the accesses that ended meanwhile, which you would have heard of with `Access.ended`:

```bash
curl "https://api.youth-platform.io/v1/access-codes?status=ended&ended_from=2026-12-12T08:30:00Z" \
  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN"
```

Each has its end in `access.ends_at`.

## Make it routine

Run both lists on a schedule, once a day for example. Then an event lost on the way costs a
delay, and never a customer who has access and is not billed.

## Read one code

```bash
curl https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34 \
  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN"
```

This is the address an event's `resource_url` names.
