---
title: "ResourceShark API: Events"
description: "Read events, with the ResourceShark API."
url: "https://agentpost.tools/docs/resourceshark/reference/events"
kind: reference
---

# Events

Read the project’s change feed in order from a cursor.

Paths are relative to `https://api.agentpost.tools/v1/resources`. [Who may call](/docs/resourceshark/reference.md#who-may-call) explains each credential.

## Read events

`GET /events`

Lists the project’s retained changes in order after a cursor and gives the next cursor. Send after=latest to start from now. A cursor behind the oldest change kept is refused with cursor\_expired, whose details give the oldest and latest seq. [Change feed retention](/docs/resourceshark/concepts/change-feed.md#retention) explains which changes the feed keeps. For your server’s secret key: a credential confined to one holder, such as a user token, is refused.

-   **Who may call:** Your server, with your project’s secret key.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.events.read(query)`
-   **Pages:** `limit`, 1 to 500, default 100. A feed: every answer has `next`, to send as `after`. [Lists](/docs/platform/api-basics.md#lists) has the rule.

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `after` | `integer` or `string` or `string` | No | The `seq` to read after, or `latest` to start from now: no events, and `next` set to the newest `seq`. Start at 0, then pass each page’s `next`. Any integer or string, or `"latest"`. |
| `limit` | `integer` | No | The most events to answer with, from 1 to 500; 1–500; default `100`. |
| `types` | `string` | No | Full event types to keep, separated by commas. Without it, every type. |

### Response

`200 OK`, with [`EventsPage`](/docs/resourceshark/reference/events.md#the-eventspage-object).

### Errors

-   [`invalid_request`](/docs/resourceshark/errors.md#invalid_request) (400)
-   [`cursor_expired`](/docs/resourceshark/errors.md#cursor_expired) (410)

Any operation can also answer with the codes [Conventions](/docs/resourceshark/reference.md#conventions) lists.

```bash tab="curl"
curl 'https://api.agentpost.tools/v1/resources/events?after=36&limit=20&types=tools.agentpost.resources.hold.placed' \
  -H "Authorization: Bearer sk_test_…"
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/resourceshark-sdk';

const client = createClient({ token: 'sk_test_…' });
const { events, next } = await client.events.read({
  after: 36,
  limit: 20,
  types: 'tools.agentpost.resources.hold.placed',
});
```

```json title="Response"
{
  "events": [
    {
      "id": "01M83PPH00000000000000000E",
      "seq": 37,
      "specversion": "1.0",
      "type": "tools.agentpost.resources.hold.placed",
      "source": "/resourceshark",
      "subject": "hld_01M83PPH000000000000000002",
      "time": "2026-11-23T11:00:00.000Z",
      "datacontenttype": "application/json",
      "data": {
        "context": {
          "actor": {
            "id": "key:juniper-backend"
          }
        },
        "holdId": "hld_01M83PPH000000000000000002",
        "reason": "hold",
        "evidence": {
          "kind": "booking_request",
          "ref": "court_request_217"
        },
        "movementIds": ["mov_01M83PPH00000000000000000F"],
        "holderRef": "principal:external:u_maya",
        "label": "court-booking",
        "reference": {
          "kind": "booking_request",
          "ref": "court_request_217"
        },
        "expiresAt": "2026-11-23T11:15:00.000Z",
        "lines": [
          {
            "claimId": "clm_01M83PPH000000000000000004",
            "resourceId": "res_01M83PPH000000000000000004",
            "scope": {
              "instanceId": "ins_01M83PPH000000000000000001"
            },
            "quantity": 1,
            "span": {
              "start": "2026-11-23T17:00:00.000Z",
              "end": "2026-11-23T18:00:00.000Z"
            },
            "status": "held"
          }
        ],
        "status": "open",
        "sourceKey": "court:217:hold",
        "actor": {
          "id": "key:juniper-backend"
        },
        "createdAt": "2026-11-23T11:00:00.000Z",
        "updatedAt": "2026-11-23T11:00:00.000Z"
      }
    }
  ],
  "next": 37
}
```

## The EventsPage object

One page of the feed. `after=latest` answers no events and the newest `seq` as `next`; a cursor behind the oldest event kept is `cursor_expired`.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `events` | [`ChangeEvent`](/docs/resourceshark/reference/events.md#the-changeevent-object) array | Always |  |
| `next` | `number` | Always | Pass as `after` to continue. Always present. A full page gives its last event’s `seq`. A shorter page has caught up, so it gives the newest `seq` read, past any events a `types` filter skipped. |

```json title="The EventsPage object"
{
  "events": [
    {
      "id": "01M83PPH00000000000000000E",
      "seq": 37,
      "specversion": "1.0",
      "type": "tools.agentpost.resources.hold.placed",
      "source": "/resourceshark",
      "subject": "hld_01M83PPH000000000000000002",
      "time": "2026-11-23T11:00:00.000Z",
      "datacontenttype": "application/json",
      "data": {
        "context": {
          "actor": {
            "id": "key:juniper-backend"
          }
        },
        "holdId": "hld_01M83PPH000000000000000002",
        "reason": "hold",
        "evidence": {
          "kind": "booking_request",
          "ref": "court_request_217"
        },
        "movementIds": ["mov_01M83PPH00000000000000000F"],
        "holderRef": "principal:external:u_maya",
        "label": "court-booking",
        "reference": {
          "kind": "booking_request",
          "ref": "court_request_217"
        },
        "expiresAt": "2026-11-23T11:15:00.000Z",
        "lines": [
          {
            "claimId": "clm_01M83PPH000000000000000004",
            "resourceId": "res_01M83PPH000000000000000004",
            "scope": {
              "instanceId": "ins_01M83PPH000000000000000001"
            },
            "quantity": 1,
            "span": {
              "start": "2026-11-23T17:00:00.000Z",
              "end": "2026-11-23T18:00:00.000Z"
            },
            "status": "held"
          }
        ],
        "status": "open",
        "sourceKey": "court:217:hold",
        "actor": {
          "id": "key:juniper-backend"
        },
        "createdAt": "2026-11-23T11:00:00.000Z",
        "updatedAt": "2026-11-23T11:00:00.000Z"
      }
    }
  ],
  "next": 37
}
```

## The ChangeEvent object

One change-feed record: CloudEvents 1.0, structured JSON. Written out in full, the kit’s `ChangeEventBase` with this service’s source, so the SDK’s generated types need nothing from the kit.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `id` | `string` | Always | A plain ULID, unique to the event. |
| `seq` | `number` | Always | The event’s place in the project’s feed, from 1. Pass it as `after` to read the events after it. |
| `specversion` | `"1.0"` | Always |  |
| `type` | `string` | Always |  |
| `source` | `"/resourceshark"` | Always | `EVENT_SOURCE`, written out so the SDK’s generated types need no value. |
| `subject` | `string` | When set | The record the event is about. |
| `time` | `string` | Always | An ISO 8601 date and time. |
| `datacontenttype` | `"application/json"` | Always |  |
| `data` | `object` | Always |  |
| `data.context` | [`ActingContext`](/docs/resourceshark/reference/events.md#the-actingcontext-object) | Always | Who made the change, and for whom. |

```json title="The ChangeEvent object"
{
  "id": "01M83PPH00000000000000000E",
  "seq": 37,
  "specversion": "1.0",
  "type": "tools.agentpost.resources.hold.placed",
  "source": "/resourceshark",
  "subject": "hld_01M83PPH000000000000000002",
  "time": "2026-11-23T11:00:00.000Z",
  "datacontenttype": "application/json",
  "data": {
    "context": {
      "actor": {
        "id": "key:juniper-backend"
      }
    },
    "holdId": "hld_01M83PPH000000000000000002",
    "reason": "hold",
    "evidence": {
      "kind": "booking_request",
      "ref": "court_request_217"
    },
    "movementIds": ["mov_01M83PPH00000000000000000F"],
    "holderRef": "principal:external:u_maya",
    "label": "court-booking",
    "reference": {
      "kind": "booking_request",
      "ref": "court_request_217"
    },
    "expiresAt": "2026-11-23T11:15:00.000Z",
    "lines": [
      {
        "claimId": "clm_01M83PPH000000000000000004",
        "resourceId": "res_01M83PPH000000000000000004",
        "scope": {
          "instanceId": "ins_01M83PPH000000000000000001"
        },
        "quantity": 1,
        "span": {
          "start": "2026-11-23T17:00:00.000Z",
          "end": "2026-11-23T18:00:00.000Z"
        },
        "status": "held"
      }
    ],
    "status": "open",
    "sourceKey": "court:217:hold",
    "actor": {
      "id": "key:juniper-backend"
    },
    "createdAt": "2026-11-23T11:00:00.000Z",
    "updatedAt": "2026-11-23T11:00:00.000Z"
  }
}
```

## The ActingContext object

Who made a change and for whom, as a change-feed event carries it: the actor, and the delegator when the actor acted under a delegation. ResourceShark’s own changes, such as a sweep’s, name the `service` principal `resourceshark`.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `actor` | [`PrincipalRef`](/docs/resourceshark/reference/supply.md#the-principalref-object) | Always | The principal that made the request with its own credential. Your project’s secret key is `key:` and the key’s name, with no `kind`. |
| `onBehalfOf` | [`PrincipalRef`](/docs/resourceshark/reference/supply.md#the-principalref-object) | When set | The delegator, when the actor acted under a delegation. |

```json title="The ActingContext object"
{
  "actor": {
    "id": "key:juniper-backend"
  }
}
```
