@plainrouter/sdk is the generated TypeScript client for the signed Plainrouter OpenAPI contract. It exposes typed request and response models, API methods, and Zod schemas for the Conversion API, including cursor-based event listing.
The current npm release is 0.10.1 and targets signed API contract 0.5.0. The source is in plainrouter/sdk. Review release notes before upgrading while the SDK remains in the 0.x series.
Version
0.10.1 includes the required event consent fields and verifySignalIngestion.What changes when upgrading?
In0.10.1, inventory 404 error unions include ApiRouteNotFound as well as account errors. Inspect the error code and body before branching. The patch also fixes the default Launcher import route; it does not enable legacy Launcher or widen credentials.
When upgrading from releases before 0.10.0, use DeploymentPlanRead and zDeploymentPlanRead instead of the removed DeploymentPlan names. Exhaustive status handling must include delivery held and destination needs_attention. Hand-built Destination objects need attention_reason, held_count and notices with the declared types.
The client defaults to Accept: application/json and rejects redirects with ApiRedirectError, which retains the response status and headers. Exported Zod request parsers reject extra keys on closed objects; request functions still leave server validation responsible for submitted fields. Follow response cursors with unchanged filters rather than assuming one page is complete.
Review the published release notes and the shared upgrade checks.
Requirements
- Node.js
22.22.2or newer. - A Signals workspace secret.
- Server-side code. Do not use the secret in a browser bundle.
Install
Configure the client
Configure the shared client once when your server starts:signalTrackerSecret property keeps its compatibility name in 0.10.1. The client does not read credentials from the environment automatically.
Configure another API origin
The default API base URL ishttps://plainrouter.com/api/v1. Override it only for a Plainrouter-provided region or a controlled test environment:
fetch implementation through the same configuration object.
Available methods
The package also exports the generated TypeScript models and Zod schemas. Use the schemas when you need runtime validation at an application boundary.
Verify Signal ingestion
duplicate: true. The event confirms ledger receipt but is not real arrival evidence and does not complete onboarding.
Send a purchase and inspect its delivery
Follow the Node.js and TypeScript purchase recipe for a completecreateEvent request, recorded consent checks, stable retry IDs, and a typed getEvent delivery check. It sends through Plainrouter; it is not a direct Meta Graph API tutorial.
By default, operations return data, error, and response; an HTTP failure must be checked before using data. A transport failure may have no response; check it before reading the status. Code using throwOnError: true must also catch thrown failures. Stop on 401, inspect field errors on 422, and retry an uncertain purchase timeout only with its original persisted ID and payload. Avoid logging entire request or error objects. See the API error table.