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 and run an agent. Set your key and org id as environment variables.
import { EClipsClient } from '@eclips/sdk';
const client = new EClipsClient({
apiKey: process.env.ECLIPS_API_KEY!,
organizationId: process.env.ECLIPS_ORG_ID!,
});
// Fire and poll — blocks until the agent finishes
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" }Verifying webhooks
Every webhook POST is signed with HMAC-SHA256. Verify it before trusting the payload.
import { EClipsClient } from '@eclips/sdk';
// In your webhook route, verify the signature before trusting the body
const ok = EClipsClient.verifyWebhook(
rawBody,
request.headers['x-eclips-signature'],
process.env.WEBHOOK_SECRET!,
);
if (!ok) return new Response('Unauthorized', { status: 401 });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, triage item, or webhook not found
}
}Method reference
client.run()AgentsTrigger an agent run, returns run_id immediately
client.runAndWait()AgentsTrigger + poll until a terminal state
client.getRun()AgentsFetch status and result for any run
client.listRuns()AgentsPaginated run history for your org
client.listTriage()TriagePending human-in-the-loop items
client.approveTriage()TriageApprove and continue the blocked run
client.rejectTriage()TriageReject and cancel the blocked run
client.createWebhook()WebhooksRegister a webhook endpoint
client.listWebhooks()WebhooksList all registered webhooks
client.deleteWebhook()WebhooksRemove a webhook
client.createBatch()BatchSubmit many tasks in a single job
client.getBatch()BatchPoll a batch job status
client.listBatches()BatchHistory of batch jobs
client.cancelBatch()BatchCancel rows not yet started
client.triggerWorkflow()WorkflowsRun a multi-step workflow
client.listWorkflows()WorkflowsFetch all saved workflows