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.eventspublishes one event or a batch, validates one, queries the history and pages through it withiterate, both withsort: 'receivedAt'for receipt-time order, and gets one by sequence or bysourceandid.importEvents({ batchId, origin, events })imports another system’s history and returns a result per entry, as Import event history does.erase(sequence, { paths })anderasures(sequence)are erasure; pass{ idempotencyKey }to retry an erasure safely.pushAddressesregisters a phone withregister(recipientId, { provider: 'expo', token })after the principal signs in, marks it seen withseen(id, notificationId)when the app opens, and removes it withdelete(id), ordeleteByToken({ provider, token }), when they sign out. Send a push to a phone walks through the calls; Push explains the rules.ingestFailures.listlists recorded ingestion failures.config.getreads settings andconfig.putreplaces them. Send all required settings on an update. Update the config lists them.events.tail(input, handlers)reads live events, andeventTypesreads, 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 sendsprojectasx-agentpost-projecton every request, so create one client per project. A workspace key only reads:events.query,iterate,get,lookup, andtail, andeventTypes.listandgetwork. Every other call throwsEventwolfApiErrorwith the codeforbidden. - 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 throwsWebhookVerificationErrorwith acodesuch assignature_mismatchortimestamp_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.