TypeScript SDK
A fully typed, zero-dependency client for the eClips REST API. Works in Node.js 18+ and any modern runtime with fetch.
Install
npm install @eclips/sdkQuickstart
Create a client with your API key and run an agent. The org is derived from the key.
import { EClipsClient } from '@eclips/sdk';
// The organization is derived from your API key — no org id needed.
const client = new EClipsClient({ apiKey: process.env.ECLIPS_API_KEY! });
// Fire and poll — resolves once the run reaches a terminal state
const result = await client.runAndWait(
'procurement_specialist',
'Get 3 vendor quotes for 500 laptops — Dell, HP, Lenovo',
);
console.log(result.status); // "completed"
console.log(result.result); // { vendors: [...], recommended: "Dell" }Batch runs
Run the same agent over many rows in a single call and poll for progress.
// Run the same agent over many rows in one call
const batch = await client.createBatch('ap_specialist', [
{ invoice_id: 'INV-1001' },
{ invoice_id: 'INV-1002' },
{ invoice_id: 'INV-1003' },
]);
// Poll for progress
const status = await client.getBatch(batch.id);
console.log(status.completed, '/', status.total);Webhooks
Register a webhook with createWebhook(url, events); eClips POSTs a signed payload on each event. The signing secret is returned once at creation — verify the HMAC-SHA256 signature before trusting the body.
import { EClipsClient } from '@eclips/sdk';
import crypto from 'crypto';
const client = new EClipsClient({ apiKey: process.env.ECLIPS_API_KEY! });
// 1. Register a webhook. The signing secret is returned ONCE — store it.
const { secret } = await client.createWebhook(
'https://your-app.com/webhooks/eclips',
['run.completed', 'run.failed', 'run.triage_required'],
);
// 2. In your webhook route, verify the HMAC-SHA256 signature before trusting
// the body. It arrives in X-eClips-Signature as sha256=<hex>.
function verify(rawBody: string, signature: string, secret: string) {
const expected = crypto
.createHmac('sha256', secret)
.update(rawBody)
.digest('hex');
return `sha256=${expected}` === signature;
}Typed errors
Each failure is a catchable error class so you can branch on exactly what happened.
import {
EClipsClient,
AuthenticationError,
RateLimitError,
TimeoutError,
NotFoundError,
} from '@eclips/sdk';
try {
const result = await client.runAndWait('ap_specialist', task);
} catch (err) {
if (err instanceof AuthenticationError) {
// Invalid or missing API key
} else if (err instanceof RateLimitError) {
await sleep(err.retryAfter ?? 60); // seconds
} else if (err instanceof TimeoutError) {
// err.runId is still valid — poll client.getRun(err.runId)
} else if (err instanceof NotFoundError) {
// Run or triage item not found
}
}Method reference
client.run()RunsStart a run; returns { run_id, status, agent_type }
client.runAndWait()RunsStart a run + poll until terminal
client.waitForRun()RunsPoll an existing run until terminal
client.getRun()RunsFetch a single run by id
client.listRuns()RunsList runs ({ data, total, limit, offset })
client.listTriage()TriagePending human-in-the-loop items
client.approveTriage()TriageApprove and continue the blocked run
client.rejectTriage()TriageReject an item with an optional reason
client.createWebhook()WebhooksRegister a URL + events; returns the secret once
client.listWebhooks()WebhooksList registered webhook endpoints
client.deleteWebhook()WebhooksDelete a webhook by id
client.listWorkflows()WorkflowsList workflows for your org
client.getWorkflow()WorkflowsFetch a single workflow by id
client.createWorkflow()WorkflowsCreate a workflow ({ name, steps, edges })
client.triggerWorkflow()WorkflowsRun a workflow with optional input
client.listWorkflowRuns()WorkflowsList runs for a workflow
client.createBatch()BatchRun an agent over many rows at once
client.getBatch()BatchFetch a batch with progress counts
client.listBatches()BatchList batches for your org
client.cancelBatch()BatchCancel an in-flight batch