@allternit/platform is a typed client for the Platform API. It has no runtime dependencies and uses the global fetch, so it runs on Node 18+, Deno, Bun and in browsers (keep live keys on your server).
A project needs a card on file before it can do billable work; until then those calls throw PaymentRequiredError (402, code: "payment_method_required") with err.url, the console billing page. See Billing.

Create a client

Every API area is a property: client.accounts, client.agents (also model keys), client.conversations, client.numbers, client.messaging, client.webhooks, client.usage. Requests and responses are typed from the OpenAPI file.
For a route the SDK doesn’t wrap yet: client.http.request({ method: "GET", path: "/v1/…" }).

Request options

The last argument of every method is { idempotencyKey?, signal?, timeout?, headers?, query? }.

Idempotency

Every POST carries an Idempotency-Key header. The SDK makes a random one per call; pass your own to make a retry safe across process restarts:
See Idempotency and limits.

Errors

Non-2xx answers throw a subclass of APIError with status, type, code, message, param and requestId: Network failures throw APIConnectionError; a timeout throws APITimeoutError. Codes are listed in Errors.

Pagination

Streaming replies

stream.finalMessage() reads to the end and returns the stored reply. An error event throws a typed APIError (for example code: "turn_failed"). Pass { signal } to stop reading; the reply is still stored on the server.

Regenerating

The typed layer (src/generated/) is generated from cmd/allternit-cloud-api/openapi/platform-v1.yaml: