# Inspect requests and events

See every API request your account made with its redacted request and response bodies, the most frequent errors, and every event, in the console or through the API.

Use request logs and events to see what your integration sent, what the API answered and what happened on your account. Every request made with your API keys or in the console is logged, and every event is stored whether or not a webhook endpoint subscribes to it. Both are free on every plan.

**Before you begin:** export the sandbox account's All products key (request logs and events take an All products key or the console, never a key restricted to some products), then make a request to have something to look at.

**curl**

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5
curl -s $PROVENANCE_API/v1/webhook_endpoints \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const api = process.env.PROVENANCE_API;
const headers = { Authorization: `Bearer ${process.env.PROVENANCE_KEY}` };
await fetch(`${api}/v1/webhook_endpoints`, { headers });
```

**Python**

```python
import os, httpx

api = os.environ["PROVENANCE_API"]
headers = {"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}
httpx.get(f"{api}/v1/webhook_endpoints", headers=headers)
```

```json
{ "object": "list", "has_more": false }
```

## 1. List your requests

[`GET /v1/request_logs`](https://provenanceauth.com/docs/api/request-logs.md#get-v1-request-logs) lists requests newest first. Each item is metadata: the method, route, status, latency, the key that made it, the `Idempotency-Key` and the IDs it touched.

**curl**

```bash
curl -s "$PROVENANCE_API/v1/request_logs?limit=1&route=/v1/webhook_endpoints&method=GET" \
  -H "Authorization: Bearer $PROVENANCE_KEY" | tee logs.json
export REQUEST_LOG_ID=$(jq -r '.data[0].id' logs.json)
```

**Node**

```ts
const logs = await (await fetch(`${api}/v1/request_logs?limit=1&route=/v1/webhook_endpoints&method=GET`, { headers })).json();
const requestLogId = logs.data[0].id;
```

**Python**

```python
logs = httpx.get(f"{api}/v1/request_logs", params={"limit": 1, "route": "/v1/webhook_endpoints", "method": "GET"}, headers=headers).json()
request_log_id = logs["data"][0]["id"]
```

```json
{
  "object": "list",
  "data": [
    {
      "id": "rlog_01M6V8P4WQ4Y7V92HPEPNYQW4R",
      "object": "request_log",
      "request_id": "req_01M6V8P4WMPDW3HRZEEGSDJ4VQ",
      "method": "GET",
      "route": "/v1/webhook_endpoints",
      "path": "/v1/webhook_endpoints",
      "status_code": 200,
      "source": "api_key",
      "error_code": null,
      "truncated": false
    }
  ]
}
```

Filter with these query parameters, together or alone:

| Parameter | Matches |
| --- | --- |
| `created_gte`, `created_lte` | A time range |
| `status_class`, `status_code` | `4xx`, or one status such as `404` |
| `method`, `route` | `POST`, or a route template such as `/v1/webhook_endpoints/:id` |
| `api_key_id` | Requests made with one key |
| `idempotency_key` | Every attempt that sent one `Idempotency-Key` |
| `request_id` | The request behind an error's `request_id` |
| `object_id` | Requests that touched an object, such as an endpoint or an approval |

## 2. Open one request

[`GET /v1/request_logs/{id}`](https://provenanceauth.com/docs/api/request-logs.md#get-v1-request-logs-id) returns the request with its bodies. Pass a request log ID, or the `request_id` from an error body.

**curl**

```bash
curl -s $PROVENANCE_API/v1/request_logs/$REQUEST_LOG_ID \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const log = await (await fetch(`${api}/v1/request_logs/${requestLogId}`, { headers })).json();
```

**Python**

```python
log = httpx.get(f"{api}/v1/request_logs/{request_log_id}", headers=headers).json()
```

```json
{
  "id": "rlog_01M6V8P4WQ4Y7V92HPEPNYQW4R",
  "object": "request_log",
  "method": "GET",
  "status_code": 200,
  "body_status": "available",
  "request": { "headers": { "authorization": "[redacted]" }, "query": {}, "body": null },
  "response": { "body": { "object": "list", "data": [], "has_more": false, "next_cursor": null } }
}
```

Bodies are redacted before they're stored, so the log can't leak what it was given:

| What | How it's stored |
| --- | --- |
| Secrets shown once (API keys, webhook and OAuth client secrets, authenticator seeds, recovery codes), intent and mandate tokens, link tokens | `[redacted]` |
| `Authorization`, `Cookie` and `X-CSRF-Token` headers | `[redacted]` |
| Phone numbers | The last 2 digits |
| Email addresses | The first letter and the domain |
| IP addresses | Removed |
| Passkey attestations and assertions, base64 images | Their type and size |
| Bodies over 16 KB (request) or 32 KB (response) | Cut, with `truncated: true` |
| Link tokens and codes in a path | `[redacted]` in `path` |

Pages anyone with the link can open, such as a capture link or an approval link, aren't logged, even when you open them signed in to the console. With an API key, only an All products key reads the log and events; a key limited to some products gets `insufficient_scope`.

`body_status` says when bodies aren't shown:

| `body_status` | Meaning |
| --- | --- |
| `available` | Both bodies are shown. |
| `not_recorded` | Live mode on a deployment without a body encryption key: metadata only. |
| `unreadable` | The bodies were sealed under an earlier encryption key (a changed key, or a sandbox restart). |
| `hidden` | Your console role sees metadata only (analysts). |

## 3. Find the errors that matter

[`GET /v1/request_logs/errors_summary`](https://provenanceauth.com/docs/api/request-logs.md#get-v1-request-logs-errors-summary) returns the most frequent 4xx and 5xx error codes in the last hour, day or week, with up to three example requests each.

**curl**

```bash
curl -s "$PROVENANCE_API/v1/request_logs/errors_summary?window=24h" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const summary = await (await fetch(`${api}/v1/request_logs/errors_summary?window=24h`, { headers })).json();
```

**Python**

```python
summary = httpx.get(f"{api}/v1/request_logs/errors_summary", params={"window": "24h"}, headers=headers).json()
```

```json
{ "object": "errors_summary", "window": "24h" }
```

## 4. List events

[`GET /v1/events`](https://provenanceauth.com/docs/api/events.md#get-v1-events) lists every event on your account, newest first, in the same envelope your webhook endpoints receive. It takes the same time range and `object_id` filters as request logs, plus `type` (comma-separated). [`GET /v1/events/{id}`](https://provenanceauth.com/docs/api/events.md#get-v1-events-id) adds the deliveries made of it to your endpoints.

**curl**

```bash
curl -s "$PROVENANCE_API/v1/events?limit=3" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const events = await (await fetch(`${api}/v1/events?limit=3`, { headers })).json();
```

**Python**

```python
events = httpx.get(f"{api}/v1/events", params={"limit": 3}, headers=headers).json()
```

```json
{ "object": "list" }
```

## 5. Use them in the console

In the console, **Developers → Logs** lists requests with the same filters, the errors summary at the top and a drawer with both bodies. **Developers → Events** lists events. Turn on **Live** on either page to watch new requests and events as they happen. An object's page (an approval, a grant, an endpoint) has a **Timeline** tab with the requests and events that touched it, in order.

## How long they're kept

| Plan | Request logs and events | Webhook deliveries and attempts |
| --- | --- | --- |
| Free | 7 days | 30 days |
| Pro | 30 days | 30 days |
| Growth | 90 days | 30 days |
| Enterprise | 90 days, or longer by arrangement (up to a year) | 30 days |

An account export includes every request log with its bodies and every event; deleting the account removes them.

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `404` [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing) | The ID belongs to another account or environment, or it's past your plan's window | Check the key's environment; open logs within the window. |
| `400` [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid) | A filter's value is malformed, such as `status_class=9xx` | Use the values in the table above. |
| `body_status` is `hidden` | Your console role is analyst | Ask an owner or developer to open it. |

## See also

- [Test webhooks](https://provenanceauth.com/docs/integrate/test-webhooks.md): attempts, resend, replay and forwarding events to your machine
- [Webhooks](https://provenanceauth.com/docs/integrate/webhooks.md)
- [Errors](https://provenanceauth.com/docs/platform/errors.md)
