Skip to content

JavaScript SDK

Last updated: 2026-06-01

The @dromlik/sdk package is the official JavaScript / TypeScript client. It runs in Node 18+ and modern browsers (browser usage requires a server-side proxy — never ship your API secret to a browser).

Install

npm install @dromlik/sdk

Initialise

import { Dromlik } from "@dromlik/sdk";

const client = new Dromlik({
  tenant: "acme",
  apiKey: process.env.DROMLIK_KEY!,
  apiSecret: process.env.DROMLIK_SECRET!,
});

List extensions

const { data } = await client.extensions.list({ page: 1, pageSize: 50 });
for (const ext of data) {
  console.log(ext.number, ext.name, ext.presence);
}

Originate a call

await client.calls.originate({
  from: "101",
  to: "+46812345678",
});

Subscribe to events

const events = client.events.subscribe([30011, 30015]); // call state, voicemail
events.on("event", (e) => {
  if (e.event === 30015) {
    console.log("Voicemail for", e.data.extension);
  }
});
events.on("error", console.error);

Verify a webhook

import { verifyWebhook } from "@dromlik/sdk";

app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
  if (!verifyWebhook(req.headers["x-dromlik-signature"], req.body, process.env.DROMLIK_WH_SECRET!)) {
    return res.status(401).send();
  }
  const event = JSON.parse(req.body.toString());
  // handle event
  res.send("ok");
});

Error handling

Every SDK call throws a DromlikError with errcode, message, and (when applicable) retryAfter. The client retries 429s and 5xxs automatically — you only need to handle errors that bubble up after retries are exhausted.