# Read the access log

The access log records every door opening and refusal: who, which door, when and how (passkey, PIN, app, intercom…). Read it page by page, or export it as a file for your reporting tools.

**You need:** an API key from an account that may see the access log (Organisation, or an Operator with access logs allowed).

## Page through the log

```bash
curl "https://go.thebuilding.cloud/api/access-logs?per_page=100&from_date=2026-10-01&to_date=2026-11-01" \
  -H "Authorization: Bearer $TBC_KEY" \
  -H "Accept: application/json"
```

Useful filters:

| Parameter | What it does |
|---|---|
| `from_date`, `to_date` | Only events in this period. Send both. A plain date (`YYYY-MM-DD`) means the start of that day, so `to_date=2026-11-01` includes all of 31 October. |
| `search` | Free text, such as a person's name or a door. |
| `event_type` | Only one kind of event (the `event_type` value of the rows). |
| `access_status` | `rejected` for refused PIN attempts only. |
| `per_page`, `page` | Paging (see [Lists, paging and limits](https://go.thebuilding.cloud/developers/guides/lists-and-limits)). |

The newest events come first. To collect a whole month, start at page 1 and keep going until you reach the last page.

For one building only, use `GET /api/buildings/{id}/access-logs`.

## Export a file instead

For big ranges, ask for an export. It runs in the background, so it is faster and doesn't use up your request limit:

```bash
curl -X POST https://go.thebuilding.cloud/api/exports \
  -H "Authorization: Bearer $TBC_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"type": "access-logs", "export_params": {"from_date": "2026-10-01", "to_date": "2026-11-01"}}'
```

```json
{ "success": true, "message": "Export queued successfully", "data": { "export_id": 318, "total_records": 12840 } }
```

Check on it every few seconds until `status` is `completed` (or `failed`):

```bash
curl https://go.thebuilding.cloud/api/exports/318 \
  -H "Authorization: Bearer $TBC_KEY" \
  -H "Accept: application/json"
```

Then download the file. Access log exports are a `.zip` with one or more CSV files inside (big logs are split into parts):

```bash
curl -L -o access-log.zip https://go.thebuilding.cloud/api/exports/318/download \
  -H "Authorization: Bearer $TBC_KEY"
```

The export uses the same filters as the list. Other exports (`parking-logs`, `intercom-calls`, `invoices`, …) work the same way; some can also be `html` or `pdf` with `"export_format"`.
