---
title: "EventWolf SDK"
description: "Learn what the EventWolf SDK holds, which client to create for publishing from your server, reading a principal's inbox in a browser, and verifying webhooks, and what each does on failure."
url: "https://agentpost.tools/docs/eventwolf/sdk"
kind: sdk
---

# EventWolf SDK

`@agentpost-tools/eventwolf-sdk` is the TypeScript library for EventWolf’s HTTP API. It runs in Node 24 and modern browsers using Fetch and Web Crypto. It covers publishing, importing, reading history and the live tail, the type registry, erasing personal fields, the config, push addresses, a principal’s inbox, and checking webhook signatures. Call the [HTTP API](/docs/eventwolf/reference.md) directly to manage subscriptions and deliveries.

```sh
npm i @agentpost-tools/eventwolf-sdk
```

## Entry points

| Import | What it has |
| --- | --- |
| `@agentpost-tools/eventwolf-sdk` | `createClient`, `createPublisher`, `createInboxClient`, `verifyWebhook`, `EventwolfApiError`, `HOSTED_BASE_URL`, `ulid`, and the contract’s types |
| `@agentpost-tools/eventwolf-sdk/webhooks` | `verifyWebhook`, `WebhookVerificationError`, `signWebhook`, and webhook types |

## Create a client

Create the client that fits the job. `createClient` and `createInboxClient` take `baseUrl`, which defaults to `HOSTED_BASE_URL`, `https://api.agentpost.tools/v1/events`.

-   **On your server,** `createClient({ token: key })` with your project’s secret key, `key`. A rejected publish is a result, `{ result: 'rejected', code, issues }`, not an error.
    -   `events` publishes one event or a batch, validates one, queries the history and pages through it with `iterate`, both with `sort: 'receivedAt'` for receipt-time order, and gets one by sequence or by `source` and `id`. `importEvents({ batchId, origin, events })` imports another system’s history and returns a result per entry, as [Import event history](/docs/eventwolf/guides/import-history.md) does. `erase(sequence, { paths })` and `erasures(sequence)` are [erasure](/docs/eventwolf/concepts/erasure.md); pass `{ idempotencyKey }` to retry an erasure safely.
    -   `pushAddresses` registers a phone with `register(recipientId, { provider: 'expo', token })` after the principal signs in, marks it seen with `seen(id, notificationId)` when the app opens, and removes it with `delete(id)`, or `deleteByToken({ provider, token })`, when they sign out. [Send a push to a phone](/docs/eventwolf/guides/push.md) walks through the calls; [Push](/docs/eventwolf/concepts/push.md) explains the rules.
    -   `ingestFailures.list` lists recorded ingestion failures. `config.get` reads settings and `config.put` replaces them. Send all required settings on an update. [Update the config](/docs/eventwolf/reference/config.md#update-the-config) lists them.
    -   `events.tail(input, handlers)` reads [live events](/docs/eventwolf/sdk/tail.md), and `eventTypes` reads, registers, checks, and deprecates [event types](/docs/eventwolf/sdk/event-types.md).
-   **To read several projects,** `createClient({ token: workspaceKey, project })` with a [workspace key](/docs/platform/concepts/workspace-keys.md), `workspaceKey`, and the ID of the project to read, `project`. The client sends `project` as `x-agentpost-project` on every request, so create one client per project. A workspace key only reads: `events.query`, `iterate`, `get`, `lookup`, and `tail`, and `eventTypes.list` and `get` work. Every other call throws `EventwolfApiError` with the code `forbidden`.
-   **To publish without waiting,** `createPublisher({ client, source })` over that client. [Publisher](/docs/eventwolf/sdk/publisher.md) explains how it batches, retries, and reports each send.
-   **In a browser,** `createInboxClient({ token })` with the signed-in principal’s [user token](/docs/platform/concepts/user-tokens.md) or IdentityHound session token, or a function that supplies their credential. [Inbox client](/docs/eventwolf/sdk/inbox.md) explains its calls and how its stream reconnects.
-   **In a webhook receiver,** `await verifyWebhook({ secret, headers, body })` with the endpoint’s secret and the raw body. It returns the event and the delivery’s ID, or throws `WebhookVerificationError` with a `code` such as `signature_mismatch` or `timestamp_out_of_tolerance`. During a rotation, pass both secrets.

## Errors

A method throws `EventwolfApiError` when the API answers with an error, except a publish rejection, which it returns as a result. The error carries the HTTP `status` and the body’s `code`, optional `details`, and optional `docs` link to [EventWolf’s errors](/docs/eventwolf/errors.md) or [Platform errors](/docs/errors.md). Checking `error.code` narrows `error.details` to that code’s type, such as `{ issues }` for `invalid_filter` or `config_invalid`. `retryable` is `true` for HTTP 429 and 500 or above. Network and abort failures come from Fetch. JSON requests are aborted after `timeoutMs`, 10 seconds by default. Live streams have no request timeout and report failures through `onError(error, { stopped })`. When a message callback throws, the stream reports the error and reconnects from its previous cursor.
