Skip to Content
Hookboard

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.json

It 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.ts

Use 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 propertyAccepts
TextA string, a number, or { "$bind": … } / { "$expr": … }
Number, true/falseThe value, any string (for a {{ }} template), or $bind / $expr
Fixed choices such as variant, and iconsOnly 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

NameWhat it is
CardInputThe body of POST /cards
CardPatchThe body of PATCH /cards/{id}
CardA card as returned by the API
ElementAny element; a union of one schema per component, such as ButtonElement
Action, Effect, EffectsActions and effects
WebhookRequest, WebhookReplyWhat Hookboard sends to a webhook action's URL, and what it reads back
ErrorThe body of every failed request

On this page