SDKs
Both SDKs are generated from the OpenAPI document: one method per operation, grouped by resource, with the client plumbing (bearer key, JSON, problem details as errors, Idempotency-Key, rate limit headers, cursor pagination) and webhook signature verification.
TypeScript (@postbuddy/sdk)
npm install @postbuddy/sdkimport { PostBuddyClient, PostBuddyError } from '@postbuddy/sdk';
const client = new PostBuddyClient({ apiKey: process.env.POSTBUDDY_API_KEY! });
const page = await client.templates.list({ query: { limit: 20 } });Node 18+ and browsers (bring the key only to trusted code). The client talks to https://api.postbuddy.nl unless you pass baseUrl. client.call(...) returns status, request id and rate limit information next to the data; client.paginate(client.templates.list, { query: { limit: 100 } }) iterates every row of a cursor-paged list. Every request times out after 30 seconds (timeoutMs on the client or per call) with a PostBuddyError whose code is request_timeout; pass signal to cancel a request, which then rejects with the standard AbortError.
Python (postbuddy)
pip install postbuddyfrom postbuddy import Client
client = Client(api_key)
page = client.templates.list(query={"limit": 20})Python 3.9+, no dependencies. The client talks to https://api.postbuddy.nl unless you pass base_url. client.call(...) returns a CallResult; client.paginate(client.templates.list, query={"limit": 100}) iterates every row of a cursor-paged list. Requests time out after 30 seconds (timeout on the client or per call, in seconds) with PostBuddyTimeoutError, a PostBuddyError with code request_timeout that is also a TimeoutError.
Batches, files and retries
Both clients retry a 429 (rate_limited or ingestions_busy) after its Retry-After, at most 120 seconds a wait, three times by default (maxRetries in TypeScript, max_retries in Python, 0 to switch it off); a 429 was not carried out, so the retry is safe for every operation.
For many cards at once (see batches and files):
| TypeScript | Python | Does |
|---|---|---|
createItemBatch(postflowId, items, opts) | create_item_batch(postflow_id, items) | Sends a batch of up to 5,000 items with a fresh Idempotency-Key unless you give one |
uploadItemFile(postflowId, data, { format }) | upload_item_file(postflow_id, data, format="ndjson") | Announces, uploads and starts an NDJSON or CSV file, then waits until it is done |
waitForIngestion(id, opts) | wait_for_ingestion(id) | Polls the ingestion until it is done or failed |
ingestionRows(id, { outcome }) | ingestion_rows(id, outcome=None) | Iterates every row with its outcome |
itemFileTemplate(postflowId) | item_file_template(postflow_id) | The CSV template of a Postflow as text |
downloadIngestionErrors(id) | download_ingestion_errors(id) | The error file as text (needs personal_data.read) |
Approving a Postbatch answers 202 while a job releases its items; the helpers follow it:
| TypeScript | Python | Does |
|---|---|---|
approvePostbatch(id, body, opts) | approve_postbatch(id, body) | Approves and waits until the approval ends: APPROVED, or approval.state refused or failed (wait: false answers at once) |
waitForApproval(id, opts) | wait_for_approval(id) | Polls the Postbatch until its approval is no longer working |
Other languages
Generate a client from the OpenAPI document with the generator of your choice; the document carries the error codes, the list parameters and the rate limit classes. Apex examples and a Postman collection follow with the Salesforce release.