# Audit endpoints

Every path starts at your [API URL](https://docs.qualithm.com/api.md#find-your-api-url). Every response is JSON, and an error has the [error body](https://docs.qualithm.com/api.md#errors).

## List the team's activity, newest first

`GET /v1/teams/{teamId}/audit-events`

Newest first, by `occurredAt` then `id`.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `audit.read` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `limit` | query | integer | No | Items per page, 1 to 100. Default 50. |
| `cursor` | query | string | No | A previous page's `nextCursor`, to read the page after it |

**Response:** `200` with [AuditEventPage](#auditeventpage) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/teams/<team-id>/audit-events" \
  -H "Authorization: Bearer <your-api-token>"
```

## Types

### AuditEventPage

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `items` | array of [AuditEvent](#auditevent) | Yes |  |
| `nextCursor` | string or null | Yes | Pass as `cursor` to read the next page; `null` on the last page |

### AuditEvent

One immutable audit-trail record.

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `id` | string | Yes | An audit event ID: `aud_…`; also accepts the legacy `evt_…` |
| `teamId` | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `actorKind` | one of `"member"`, `"device"`, `"system"` | Yes |  |
| `actorId` | string or null | Yes | The member or device that acted; null for the system |
| `action` | string | Yes | Dot-namespaced action, e.g. `device.claim` |
| `targetKind` | string | Yes | What the action acted on, e.g. `device` |
| `targetId` | string | Yes | An ID of any kind: `<kind>_[<zone>_]<ULID>` |
| `metadata` | any | Yes | Non-sensitive context for the action |
| `occurredAt` | string (date-time) | Yes | UTC time, RFC 3339 |
