Skip to content

Node.js SDK

@linnia/sdk wraps the REST API with a typed method for every command, long-polling, retries and webhook verification. It has no dependencies and runs on Node 18+, Bun, Deno and edge runtimes.

Terminal window
npm install @linnia/sdk
import { Linnia } from "@linnia/sdk";
const linnia = new Linnia({ apiKey: process.env.LINNIA_API_KEY });
const [account] = await linnia.accounts.list();
// Reads finish in seconds: read() waits and returns the result.
const { items } = await linnia.read(account.id, "company_employees", {
company: "https://www.linkedin.com/company/northwind",
title: "sales",
});
// Writes are queued and paced inside the account's working hours and limits.
const job = await linnia.commands.connect(account.id, {
person: items[0].publicIdentifier,
note: "Hi Jana, enjoyed your post on RevOps hiring.",
});
console.log(job.status); // "queued", "scheduled" or "awaiting_approval"

linnia.commands has one method per command in the API reference, named in camelCase: searchPeople, companyEmployees, searchPosts, searchJobs, listConnections, getProfile, sendMessage, connect and the rest. Inputs are typed from the OpenAPI spec, so your editor knows every filter.

Each method returns the job. Pass options as the third argument:

Option What it does
wait Seconds to wait for the job to finish (up to 600).
idempotencyKey The same key returns the same job, so retries are safe.

linnia.read(account, command, input) is the shortcut for reads: it waits and returns job.result, or throws the job’s error.

Failures throw LinniaError with type (stable, for code), message (for people), status and often next (what to do instead). See Errors for the types. 429 and 5xx responses are retried with backoff (maxRetries, default 2).

Writes can take hours because Linnia paces them like a person, so react to webhooks instead of polling.

const { webhook, secret } = await linnia.webhooks.create({
url: "https://example.com/linnia",
events: ["message.received", "invitation.accepted", "job.completed"],
});
// In your handler, with the raw request body:
const valid = await linnia.webhooks.verify({
secret,
body: rawBody,
signature: req.headers["linnia-signature"],
timestamp: req.headers["linnia-signature-timestamp"],
});

linnia.accounts, linnia.jobs, linnia.workflows, linnia.approvals, linnia.automations, linnia.people (timeline and notes) and linnia.webhooks cover the rest of the API. linnia.request(method, path, options) reaches any endpoint directly.