TypeScript SDK
@seny/sdk is a typed TypeScript client for the Seny REST API. It handles authentication, the workspace header, JSON encoding and error parsing, and gives you typed request and response objects for agents, conversations, campaigns, contacts and the rest of the resources listed below. It has no runtime dependencies and works anywhere fetch does — Node 18+, Bun, Deno, edge runtimes and serverless functions.
Install
npm install @seny/sdk
# or
pnpm add @seny/sdkQuickstart
Create an API key under Settings → API keys (see Authentication), keep it in an environment variable, and create a client:
import { createSenyClient } from "@seny/sdk";
const seny = createSenyClient({ apiKey: process.env.SENY_API_KEY! });
// Every agent in the workspace
const agents = await seny.agents.list({ limit: 20 });
console.log(agents.data.length, "of", agents.total);
// Full detail for one of them
const agent = await seny.agents.get(agents.data[0].id);
// The latest conversations, then one transcript with its tool calls
const recent = await seny.conversations.list({ widget_id: agent.id, limit: 5 });
const conv = await seny.conversations.get(recent.data[0].id);
console.log(conv.transcript, conv.tool_calls);The SDK calls the API from your server. Never ship an API key to a browser — to put Seny on a web page, use the embed script instead.
Client options
| Option | Default | What it does |
|---|---|---|
apiKey | — | Required. A seny_… API key or OAuth token, sent as Authorization: Bearer. |
baseUrl | https://app.seny.ai | Point the client at another Seny environment. |
workspace | the key's home workspace | Act in another workspace by id or name. See Workspaces. |
fetch | global fetch | Swap in your own implementation — for tests, retries or a proxy. |
Responses and pagination
Single-item calls (get, create, update) return the object itself. List calls return a page:
interface Page<T> {
data: T[];
total: number;
limit: number;
offset: number;
}Walk a long list with limit and offset:
let offset = 0;
for (;;) {
const page = await seny.contacts.list({ limit: 100, offset });
for (const contact of page.data) handle(contact);
offset += page.data.length;
if (!page.data.length || offset >= page.total) break;
}Every request and response type is exported, so you can type your own code against them: Agent, ConversationDetail, Campaign, Contact, TransferAttempt, Webhook and so on.
Errors
Any non-2xx response throws a SenyApiErrorcarrying the HTTP status, the API's error code, its message and, when there is one, a link to the relevant docs page:
import { SenyApiError } from "@seny/sdk";
try {
await seny.agents.get("does-not-exist");
} catch (err) {
if (err instanceof SenyApiError) {
console.error(err.status, err.code, err.message);
if (err.status === 403) console.error("missing permission — see", err.docs);
} else {
throw err; // network failure, not an API answer
}
}Status codes follow the conventions listed under API errors: 400 for a bad request, 401 for a missing or invalid key, 403 when the key lacks the permission, 404 when the resource doesn't exist in this workspace.
Workspaces
A key belongs to a user, not to one workspace, so it can act in any workspace that user belongs to — handy for agencies and dealer groups running several rooftops. workspaces.list()shows what the key can reach, with the user's role and permissions in each:
for (const ws of await seny.workspaces.list()) {
const rooftop = seny.forWorkspace(ws.id);
const { total } = await rooftop.conversations.list({ limit: 1 });
console.log(ws.name, ws.role, total, "conversations");
}forWorkspacereturns a new client and leaves the original unchanged, so a loop can't leave it pointed at the wrong workspace. You can also pass workspace once when you create the client. Either way it travels as the X-Seny-Workspaceheader, which keeps it out of URLs and request logs. Your permissions there are the user's live permissions in that workspace, intersected with the key's own.
Examples
Export yesterday's conversations
const page = await seny.conversations.list({ limit: 100 });
const since = Date.now() - 24 * 60 * 60 * 1000;
const yesterday = page.data.filter(c => Date.parse(c.started_at) >= since);
for (const c of yesterday) {
const detail = await seny.conversations.get(c.id);
await saveToWarehouse(detail);
}Enrol a lead in an outbound campaign
const contact = await seny.contacts.create({
first_name: "Jordan",
last_name: "Lee",
phone_e164: "+15555550123",
email_lower: "jordan@example.com",
});
// Enrol them in the campaign's first stage
const { data: stages } = await seny.campaigns.lists(campaignId);
await seny.campaigns.addContact(campaignId, {
contact_id: contact.id,
list_id: stages[0].id,
});This is live. An active campaign will call, text or email that person for real. Try it on a paused campaign first.
Find transfers that didn't connect
const failed = await seny.transferAttempts.list(agentId, {
outcome: ["no_answer", "busy", "failed"],
since: "2026-11-01",
});
for (const t of failed.data) {
console.log(t.requested_at, t.destination_label ?? t.destination, t.outcome, t.outcome_reason);
}What the SDK covers
The SDK wraps the resources below. Endpoints are relative to /api/v1/rest.
Workspaces
| SDK call | Endpoint |
|---|---|
seny.workspaces.list() | GET /workspaces |
Agents · API guide
| SDK call | Endpoint |
|---|---|
seny.agents.list({ status, limit, offset }) | GET /agents |
seny.agents.get(id) | GET /agents/:id |
seny.agents.create({ name, … }) | POST /agents |
seny.agents.update(id, patch) | PATCH /agents/:id |
seny.agents.delete(id) | DELETE /agents/:id |
Conversations · API guide
| SDK call | Endpoint |
|---|---|
seny.conversations.list({ widget_id, limit, offset }) | GET /conversations |
seny.conversations.get(id) | GET /conversations/:id |
seny.conversations.delete(id) | DELETE /conversations/:id |
Campaigns · API guide
| SDK call | Endpoint |
|---|---|
seny.campaigns.list({ status }) | GET /campaigns |
seny.campaigns.get(id) · create · update · delete | /campaigns/:id |
seny.campaigns.lists(id) · createList(id, input) | /campaigns/:id/lists |
seny.campaigns.contacts(id, { list_id, status }) · addContact(id, input) | /campaigns/:id/contacts |
seny.campaigns.approvals(id) · decideApproval(id, approvalId, decision) | /campaigns/:id/approvals |
seny.campaigns.calls(id) · getCall(id, callId) · hangupCall(id, callId) | /campaigns/:id/calls |
seny.campaignEvents.list(id, { contact_id, event_type, since, until }) | GET /campaigns/:id/events |
Contacts · API guide
| SDK call | Endpoint |
|---|---|
seny.contacts.list({ search }) · get · create · update · delete | /contacts |
Transfers · API guide
| SDK call | Endpoint |
|---|---|
seny.transferRules.list(agentId) · get · create · update · delete | /agents/:id/transfer-rules |
seny.transferAttempts.list(agentId, { outcome, since, simulated }) | GET /agents/:id/transfer-attempts |
Knowledge & sites · API guide
| SDK call | Endpoint |
|---|---|
seny.kbEntries.list({ widget_id }) · get · create · delete | /kb-entries |
seny.sites.list({ widget_id }) · get · recrawl · delete | /sites |
seny.sites.pages(siteId, { include_body }) | GET /sites/:id/pages |
Telephony & channels · API guide
| SDK call | Endpoint |
|---|---|
seny.phoneNumbers.list({ widget_id }) · get · update · release | /phone-numbers |
seny.voiceProfiles.list() · get · create · update · delete | /voice-profiles |
seny.emailInboxes.list({ widget_id }) · get · create · update · delete | /email-inboxes |
seny.sipTrunks.list() · get · create · update · delete | /sip-trunks |
Integrations & webhooks · API guide
| SDK call | Endpoint |
|---|---|
seny.integrations.list() · get · create · update · delete | /integrations |
seny.webhooks.list() · get · create · update · delete | /webhooks |
seny.webhooks.deliveries(webhookId, { success }) | GET /webhooks/:id/deliveries |
Reporting · API guide
| SDK call | Endpoint |
|---|---|
seny.analytics.get({ days, widget_id }) | GET /analytics |
seny.reports.list() · get · create · update · delete | /reports |
seny.reports.runs(reportId) | GET /reports/:id/runs |
seny.auditLog.list({ action, actor_user_id, since }) | GET /audit-log |
Endpoints the SDK doesn't wrap
The REST API is larger than the SDK: simulations, data tables, prompt modules, client workspaces, dashboard operations and more are API-only for now. Call them directly with the same key — every route is in the OpenAPI reference (https://app.seny.ai/api/v1/openapi.json), and CI fails if a route ships undocumented:
const res = await fetch("https://app.seny.ai/api/v1/rest/simulations", {
headers: { Authorization: `Bearer ${process.env.SENY_API_KEY}` },
});
const { data } = await res.json();If you're wiring Seny into an AI assistant rather than your own code, use the MCP server, which exposes every operation as a tool.