# Events

Every event on your account, whether or not an endpoint subscribes, and forwarding to your machine.

Related guide: [Logs and events](https://provenanceauth.com/docs/integrate/logs-and-events.md)

## Endpoints

- `POST /v1/devtools/listen_sessions`: [Start a listen session](#post-v1-devtools-listen-sessions)
- `GET /v1/events/{id}`: [Retrieve an event](#get-v1-events-id)
- `GET /v1/events`: [List events](#get-v1-events)
- `GET /v1/devtools/listen_sessions/{id}/stream`: [Stream a listen session](#get-v1-devtools-listen-sessions-id-stream)

## The event object

### Attributes

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | no | Unique identifier for the object. Stable across deliveries and replays. |
| `object` | enum | no | The type of object. One of `event`. |
| `type` | string | no | The event type, such as `mandate.approval.approved`. |
| `created_at` | timestamp | no | When it happened. |
| `environment` | enum | no | The environment it happened in. One of `sandbox`, `live`. |
| `account_id` | string | no | Your account's ID. |
| `api_version` | string | no | On a delivery: the API version it was rendered at, the endpoint's `api_version`. |
| `data` | object | no | The event's object; see each event type. |
| `object_ids` | array of strings | no | The IDs the event is about (its data's `id` and `*_id` fields). |

### Example

```json
{
  "id": "evt_01M7VYJNP621NB5SY85XD481NG",
  "object": "event",
  "type": "mandate.intent.revoked",
  "created_at": "2026-11-20T07:43:46.886Z",
  "environment": "sandbox",
  "account_id": "acct_000000000000000000000000000000a2",
  "data": {
    "revocation_id": "rev_01M7VYJNP6AFSN8093BPQ8CGHS",
    "scope": "token",
    "value": "96ca2ebb-e18e-4142-bb07-2f73ecc874e9",
    "reason": "cancelled by the requester"
  },
  "object_ids": [
    "rev_01M7VYJNP6AFSN8093BPQ8CGHS"
  ]
}
```

## Start a listen session

`POST /v1/devtools/listen_sessions`

Starts forwarding your sandbox events to your machine, as `provenance listen` does. Returns the stream to read and the signing secret to sign forwarded events with. Sandbox keys only, and only an All products key; a key limited to some products gets 403 `insufficient_scope`.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |
| `events` | body | array of strings | no | Only these event types; `*` or nothing for all. |

### Returns

The session. The same signing secret comes back every time for your account, so a local handler is set up once.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`sandbox_only`](https://provenanceauth.com/docs/platform/errors.md#sandbox_only)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5
curl -X POST "$PROVENANCE_API/v1/devtools/listen_sessions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "events": ["mandate.approval.approved", "mandate.approval.declined"] }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/devtools/listen_sessions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "events": ["mandate.approval.approved", "mandate.approval.declined"] }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/devtools/listen_sessions", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}, json={
    "events": [
        "mandate.approval.approved",
        "mandate.approval.declined"
    ]
}).json()
```

### Response 201

```json
{
  "id": "lsn_01M7VYJTGPT49BN44TVT9RAKK4",
  "object": "listen_session",
  "environment": "sandbox",
  "events": [
    "mandate.approval.approved",
    "mandate.approval.declined"
  ],
  "stream_path": "/v1/devtools/listen_sessions/lsn_01M7VYJTGPT49BN44TVT9RAKK4/stream?events=mandate.approval.approved%2Cmandate.intent.declined",
  "secret": "whsec_bI4QonWpZAj2hpM1qyrVakd1EIjIYtxl0fdpO7",
  "signature_header": "Provenance-Signature"
}
```

## Retrieve an event

`GET /v1/events/{id}`

One event, with the deliveries made of it to your webhook endpoints.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The object's ID. |

### Returns

The event and its deliveries.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5
curl -s -X POST "$PROVENANCE_API/v1/mandate/intents" \
  -H "Authorization: Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" \
  -H "Content-Type: application/json" \
  -d '{
    "action_description": "Pay invoice INV-2041",
    "agent_session_id": "sess_reference_events",
    "device_id": "dev_00000000000000000000000000000001"
  }' > step.json
export INTENT_TOKEN=$(jq -r '.intent_token' step.json)
curl -s -X POST "$PROVENANCE_API/v1/mandate/revocations" \
  -H "Authorization: Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" \
  -H "Content-Type: application/json" \
  -d "{
    \"intent_token\": \"$INTENT_TOKEN\",
    \"reason\": \"cancelled by the requester\"
  }" > /dev/null
curl -s "$PROVENANCE_API/v1/events?limit=1" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > step.json
export EVENT_ID=$(jq -r '.data[0].id' step.json)
curl "$PROVENANCE_API/v1/events/$EVENT_ID" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/intents`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "action_description": "Pay invoice INV-2041",
    "agent_session_id": "sess_reference_events",
    "device_id": "dev_00000000000000000000000000000001"
  }),
})).json();
const intentToken = step1.intent_token;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/revocations`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "intent_token": intentToken,
    "reason": "cancelled by the requester"
  }),
})).json();
const step3 = await (await fetch(`${process.env.PROVENANCE_API}/v1/events?limit=1`, {
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" },
})).json();
const eventId = step3.data[0].id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/events/${eventId}`, {
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/mandate/intents", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "action_description": "Pay invoice INV-2041",
    "agent_session_id": "sess_reference_events",
    "device_id": "dev_00000000000000000000000000000001"
}).json()
intent_token = step1["intent_token"]
step2 = httpx.post(f"{api}/v1/mandate/revocations", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "intent_token": intent_token,
    "reason": "cancelled by the requester"
}).json()
step3 = httpx.get(f"{api}/v1/events?limit=1", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}).json()
event_id = step3["data"][0]["id"]
data = httpx.get(f"{api}/v1/events/{event_id}", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}).json()
```

### Response 200

```json
{
  "id": "evt_01M7VYJR3RFA7D8DB5GK5Z3945",
  "object": "event",
  "type": "mandate.intent.revoked",
  "created_at": "2026-11-20T07:43:49.368Z",
  "environment": "sandbox",
  "account_id": "acct_000000000000000000000000000000a2",
  "data": {
    "revocation_id": "rev_01M7VYJR3RJP09ZG8PH958CE55",
    "scope": "token",
    "value": "d2386db2-c570-4b4e-acb1-51b510205ed8",
    "reason": "cancelled by the requester"
  },
  "object_ids": [
    "rev_01M7VYJR3RJP09ZG8PH958CE55"
  ],
  "deliveries": []
}
```

## List events

`GET /v1/events`

Lists your account's events, newest first, whether or not a webhook endpoint subscribes to them. Kept 7, 30 or 90 days by plan. With an API key, only an All products key reads them; a key limited to some products gets 403 `insufficient_scope`.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `limit` | query | integer | no | Page size, 1–100 (default 20). Outside the range → 400 parameter_invalid. |
| `cursor` | query | string | no | Opaque; pass a response's `next_cursor` back to get the next page. |
| `type` | query | string | no | Only these event types, comma-separated. |
| `created_gte` | query | timestamp | no | Only events at or after this time. |
| `created_lte` | query | timestamp | no | Only events at or before this time. |
| `object_id` | query | string | no | Only events about this object. |

### Returns

A page of events, newest first.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5
curl -s -X POST "$PROVENANCE_API/v1/mandate/intents" \
  -H "Authorization: Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" \
  -H "Content-Type: application/json" \
  -d '{
    "action_description": "Pay invoice INV-2041",
    "agent_session_id": "sess_reference_events",
    "device_id": "dev_00000000000000000000000000000001"
  }' > step.json
export INTENT_TOKEN=$(jq -r '.intent_token' step.json)
curl -s -X POST "$PROVENANCE_API/v1/mandate/revocations" \
  -H "Authorization: Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" \
  -H "Content-Type: application/json" \
  -d "{
    \"intent_token\": \"$INTENT_TOKEN\",
    \"reason\": \"cancelled by the requester\"
  }" > /dev/null
curl "$PROVENANCE_API/v1/events?limit=2&type=mandate.intent.revoked" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/intents`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "action_description": "Pay invoice INV-2041",
    "agent_session_id": "sess_reference_events",
    "device_id": "dev_00000000000000000000000000000001"
  }),
})).json();
const intentToken = step1.intent_token;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/revocations`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "intent_token": intentToken,
    "reason": "cancelled by the requester"
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/events?limit=2&type=mandate.intent.revoked`, {
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/mandate/intents", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "action_description": "Pay invoice INV-2041",
    "agent_session_id": "sess_reference_events",
    "device_id": "dev_00000000000000000000000000000001"
}).json()
intent_token = step1["intent_token"]
step2 = httpx.post(f"{api}/v1/mandate/revocations", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "intent_token": intent_token,
    "reason": "cancelled by the requester"
}).json()
data = httpx.get(f"{api}/v1/events?limit=2&type=mandate.intent.revoked", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}).json()
```

### Response 200

```json
{
  "object": "list",
  "data": [
    {
      "id": "evt_01M7VYJNP621NB5SY85XD481NG",
      "object": "event",
      "type": "mandate.intent.revoked",
      "created_at": "2026-11-20T07:43:46.886Z",
      "environment": "sandbox",
      "account_id": "acct_000000000000000000000000000000a2",
      "data": {
        "revocation_id": "rev_01M7VYJNP6AFSN8093BPQ8CGHS",
        "scope": "token",
        "value": "96ca2ebb-e18e-4142-bb07-2f73ecc874e9",
        "reason": "cancelled by the requester"
      },
      "object_ids": [
        "rev_01M7VYJNP6AFSN8093BPQ8CGHS"
      ]
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## Stream a listen session

`GET /v1/devtools/listen_sessions/{id}/stream`

Server-Sent Events of your sandbox events as they happen: `event: event` with the full event as `data`. Read it with the key that started the session. A stream ends after an hour; reconnect.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The listen session's ID. |
| `events` | query | string | no | Only these event types, comma-separated. |

### Returns

An event stream (`text/event-stream`).

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`sandbox_only`](https://provenanceauth.com/docs/platform/errors.md#sandbox_only)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5
curl "$PROVENANCE_API/v1/devtools/listen_sessions/$LISTEN_SESSION_ID/stream" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/devtools/listen_sessions/${listenSessionId}/stream`, {
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/devtools/listen_sessions/{listen_session_id}/stream", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}).json()
```
