Fivexer

TypeScript

The TypeScript SDK (@fivexer/sdk) is the reference implementation for the /v1 API. It has zero runtime dependencies and runs anywhere with fetch.

Install

bash
npm install @fivexer/sdk

Quickstart

typescript
import { Fivexer } from '@fivexer/sdk';

const client = new Fivexer({
    baseUrl: 'https://api.fivexer.com',
    apiKey: 'sk_test_...',
});

await client.workers.upsert({ id: 'agent_1', tags: ['english', 'billing'] });
const task = await client.tasks.create({ tags: ['english', 'billing'], priority: 90 });
console.log(task.id, task.status);

Errors and quotas

typescript
import { FivexerApiError } from '@fivexer/sdk';

try {
    await client.tasks.create({ tags: ['english'] });
} catch (e) {
    if (e instanceof FivexerApiError) {
        console.log(e.status, e.code);
        console.log(e.quota?.taskRateRemaining);
    }
}

Worker portal

typescript
import { FivexerWorker } from '@fivexer/sdk';

const worker = new FivexerWorker({ baseUrl: 'https://api.fivexer.com' });
await worker.auth.login({ workspaceId: 'ws_1', workerId: 'agent_1', pin: '4821' });
await worker.tasks.accept(taskId);

Webhooks

Webhook verification is Node-only and lives at the @fivexer/sdk/webhook subpath so browser bundles don't pull node:crypto:

typescript
import { verifyWebhookSignature, SIGNATURE_HEADER } from '@fivexer/sdk/webhook';

const ok = verifyWebhookSignature(secret, header, await request.text());

Was this page helpful?