Skip to main content
The TypeScript SDK wraps the REST API with typed methods, automatic retries on 429 and 5xx responses, automatic idempotency keys for print jobs, pagination iterators and webhook verification.
createAndWait creates the job and polls until it reaches done, error, cancelled or expired. It returns the final job, so check job.state and job.stateMessage rather than expecting an exception for a failed print.

Configuration

The SDK retries 429 responses, waiting for Retry-After when it is present, and retries 5xx responses and network errors with exponential backoff. printJobs.create and createAndWait send an Idempotency-Key automatically and reuse it on every retry, so a retry cannot print twice. Pass { idempotencyKey } as the second argument to use your own key. Other POST requests are not retried on 5xx errors.

Errors

Any non-2xx response that survives the retries throws a PrintEasyError with status, code and requestId. createAndWait throws a PrintEasyTimeoutError when the job is still not in a final state after timeoutMs (default 60 seconds); its job property holds the last known job, which may still print.
See Errors for the codes the API returns.

Pagination

list(params) returns one page, { data, hasMore, nextCursor }. iterate(params) is an async generator that follows nextCursor for you and yields every item:
computers, printers, printJobs and webhooks have list, iterate and get. events (and webhook deliveries) have list and iterate only, with no get. Pass after and dir: "asc" to events.list to poll for new events.

Webhooks

pe.webhooks.verify(body, headers, secret) checks the signature of a request and throws WebhookVerificationError if it is invalid or older than 5 minutes. Pass the raw body string, not parsed JSON.
The same object manages endpoints: pe.webhooks.create, update, delete, deliveries(id) and replay(deliveryId). create returns the signing secret once. See Webhooks for a full receiver.

Raw generated client

The convenience methods sit on top of a client generated from the OpenAPI spec. It has one function per operation, named by its operationId, and a type for every schema:
Use it for an endpoint the wrapper has no helper for. The generated functions do not add retries or idempotency keys.