Skip to content

TypeScript SDK

The DICE SDK is a typed client for the public API, generated from the OpenAPI document. It has no dependencies and runs on Node 20 or newer.

JS
import { DiceClient } from '@dice/sdk';

const dice = new DiceClient({ apiKey: process.env.DICE_API_KEY });
const { intake_id } = await dice.leads.create({ first_name: 'Ada', email: '[email protected]', message: 'Furnace repair' });
const lead = await dice.leads.waitForLead(intake_id);

for await (const l of dice.paginate((p) => dice.leads.list({ ...p, status: 'QUALIFIED' }))) console.log(l.id, l.score);

What it does for you

  • Sends the key as Authorization: Bearer …, and Dice-Business for agency keys (dice.forBusiness(id)).
  • Adds an Idempotency-Key to every POST. Pass your own with { idempotencyKey } to retry safely across processes.
  • Retries 429 answers after Retry-After and network errors on requests that are safe to repeat.
  • Throws DiceApiError with status, code, message and requestId.
  • dice.paginate(…) walks every page of a list.
  • verifyWebhook({ secret, payload, signature }) checks a delivery and returns the event, or throws WebhookSignatureError.

Other languages

Generate a client from the OpenAPI document at /api/openapi.json with any OpenAPI generator, or call the API directly: it is plain JSON over HTTPS.