Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

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 directly to manage subscriptions and deliveries.

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 does. erase(sequence, { paths }) and erasures(sequence) are erasure; 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 walks through the calls; Push 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 lists them.
    • events.tail(input, handlers) reads live events, and eventTypes reads, registers, checks, and deprecates event types.
  • To read several projects, createClient({ token: workspaceKey, project }) with a workspace key, 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 explains how it batches, retries, and reports each send.
  • In a browser, createInboxClient({ token }) with the signed-in principal’s user token or IdentityHound session token, or a function that supplies their credential. Inbox client 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 or Platform errors. 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.