Typed clients
Generate a client from the OpenAPI document so your cards are checked as you write them.
The whole API is described as OpenAPI 3.1 at:
https://app.hookboard.dev/api/v1/openapi.jsonIt covers every endpoint and, under components.schemas, every component, action and effect. A client generated from it knows that a button's variant has five possible values, that a webhook action needs a url, and which icon names exist.
TypeScript
Generate types:
npx openapi-typescript https://app.hookboard.dev/api/v1/openapi.json -o hookboard.d.tsUse them with any fetch wrapper that reads OpenAPI types, such as openapi-fetch:
import createClient from "openapi-fetch";
import type { paths } from "./hookboard";
const hookboard = createClient<paths>({
baseUrl: "https://app.hookboard.dev",
headers: { Authorization: `Bearer ${process.env.HOOKBOARD_KEY}` },
});
await hookboard.POST("/api/v1/cards", {
body: {
id: "hello",
ui: { type: "text", value: "Typed all the way down." },
},
});Now a misspelled component, an unknown property or icon, or a webhook without a url fails at compile time instead of at 2 a.m.
Other languages
Any OpenAPI 3.1 generator works. The document uses oneOf with a type discriminator for elements, actions and effects, which most generators turn into tagged unions.
What the types allow
| Kind of property | Accepts |
|---|---|
| Text | A string, a number, or { "$bind": … } / { "$expr": … } |
| Number, true/false | The value, any string (for a {{ }} template), or $bind / $expr |
Fixed choices such as variant, and icons | Only the listed values, or $bind / $expr |
The server also accepts a {{ }} template for a fixed choice. The types don't, so they can catch typos. Write { "$expr": "…" } when you need to compute one.
Useful schema names
| Name | What it is |
|---|---|
CardInput | The body of POST /cards |
CardPatch | The body of PATCH /cards/{id} |
Card | A card as returned by the API |
Element | Any element; a union of one schema per component, such as ButtonElement |
Action, Effect, Effects | Actions and effects |
WebhookRequest, WebhookReply | What Hookboard sends to a webhook action's URL, and what it reads back |
Error | The body of every failed request |