@tolt/api wraps every v2 endpoint in a typed method. Run it on your server: it needs your secret API key.
Returned
response200
successtrue
data[part_8fKq…, …]
has_moretrue
next_cursor
Thrown on 4xx, 5xx
ToltApiErrorNotFoundError
statusCode404
body.code
body.doc_url…/errors#not_found
Install
Initialize
{ id: "part_..." }). Single-item calls return the API envelope { success, message, data }. list calls return a page you can iterate.
Common calls
List partners
for await walks every page. The SDK passes each next_cursor back as starting_after for you.
page.data holds one page’s rows, and page.response the envelope with has_more. Iteration only moves forward: with ending_before, read page.data and don’t iterate.
Create a customer
Bind a signup to a partner.customer_id is your id for the customer, ideally the one your billing system uses (a Stripe customer id, say), since billing integrations match payments on it. Send it or email. A partner_id (or link_id) is required; add the click_id tolt.js captured to keep the click’s link.
Record a payment
Amounts are integers in minor units (4900 = $49.00). Responses return money fields as strings ("4900") because they are stored as 64-bit integers. customer_id here is the Tolt cus_ id.
Refund it
Mint an embed token
For the partner dashboard embed. Pass apartner_id, or partner: { email, program_id }.
Errors
Non-2xx responses throw. Known statuses get their own class under theToltApi namespace; everything else is a ToltApiError. ToltApiTimeoutError extends ToltApiError, so check it first.
err.body is the error object (ToltApi.ErrorResponse): { success, message, code, doc_url, errors? }. err.requestId is the Request-Id to quote to support.
Retries and timeouts
Requests that fail with 408, 429 or 5xx are retried with exponential backoff, honoringRetry-After. Set defaults on the client, or override per call with a second argument.
Per-request options:
maxRetries, timeoutInSeconds, abortSignal, headers, queryParams.
Response headers
Call.withRawResponse() to read headers such as X-RateLimit-Remaining or Request-Id.
Resources
Each method maps to one endpoint in the API reference.

