Skip to content
DocsClient code

Client code

There is no Postbroad package to install. The API is plain HTTPS and JSON, described by one OpenAPI 3.1 document, and any OpenAPI tool gives you a typed client:

Text
https://postbroad.com/docs/openapi.json

The API reference is generated from the same document, so the two never disagree. Point any OpenAPI tool at it to get typed requests in your language.

#TypeScript

Generate types with openapi-typescript and call the API with its small openapi-fetch client:

Shell
npm install openapi-fetch
npm install --save-dev openapi-typescript
npm exec -- openapi-typescript https://postbroad.com/docs/openapi.json -o src/postbroad.d.ts
TypeScript
import createClient from "openapi-fetch";
import type { paths } from "./postbroad";

const postbroad = createClient<paths>({
  baseUrl: "https://app.postbroad.com",
  headers: { Authorization: `Bearer ${process.env.POSTBROAD_TOKEN}` },
});

const { data, error } = await postbroad.GET("/v1/brands");
if (error) throw new Error(`${error.code}: ${error.detail}`);
console.log(data);

Paths, parameters, bodies and answers are checked by the compiler. Regenerate the types from time to time to pick up new endpoints and fields; within one API version changes are additive only.

#Other languages

Any generator that reads OpenAPI 3.1 works, for example OpenAPI Generator for Python, Go, Java, Ruby or C#.

#Two things every client must do

  • Send Authorization: Bearer <key> on every call (Authentication).
  • Send a fresh Idempotency-Key on every write, and reuse the same one when you retry that write.

#Retries

Retry only when the problem body says retryable: true, and wait for the Retry-After header when it is there. The error catalogue lists which codes are retryable, and rate limits explains the request allowance per key.

Last generated 8 Nov 2026, from the contracts the API runs on.