Capx
Products / TypeScript SDK
Private betaThe Capx TypeScript SDK is available to private beta participants. Join the waitlist for access.

Typed SDK. Ship faster.

Full type safety for every API endpoint. Autocomplete in your IDE. Async iterators for streaming. Typed errors with recovery hints. Built for modern TypeScript.

@capx/sdkapp.ts
import { Capx } from '@capx/sdk';

// ── Initialize ────────────────────────────────────────
const capx = new Capx({
  apiKey: process.env.CAPX_API_KEY,
});

// ── Companies ─────────────────────────────────────────
const company = await capx.companies.create({
  name: 'acme-marketing',
  template: 'saas-agency',
  governance: {
    approval_required: true,
    spend_cap: 500,
  },
});

// ── Agents ────────────────────────────────────────────
const agents = await capx.agents.list(company.id);
// agents: Agent[] - typed with role, adapter, model, budget, status

await capx.agents.wake(company.id, 'strategist');
// Trigger immediate heartbeat for the strategist agent

// ── Playbooks ─────────────────────────────────────────
const run = await capx.playbooks.run(company.id, 'content-pipeline', {
  inputs: { topic: 'AI agents', tone: 'professional' },
});
// run: PlaybookRun - id, status, steps[], cost, duration

// ── Activity Stream ───────────────────────────────────
for await (const event of capx.activity.stream(company.id)) {
  console.log(`[${event.agent}] ${event.action}: ${event.status}`);
  // TypeScript knows event.agent, event.action, event.status
  // at compile time
}

// ── Approvals ─────────────────────────────────────────
await capx.approvals.approve(company.id, taskId, {
  feedback: 'Ship it.',
});

Four modules

Companies, agents, playbooks, and activity. Every method returns typed responses. Every parameter has IntelliSense.

capx.companiesCreate, list, update, pause, resume, destroy
const company = await capx.companies.create({
  name: 'acme',
  template: 'saas-agency',
});
capx.agentsList, wake, pause, stream logs
const agents = await capx.agents.list(id);
await capx.agents.wake(id, 'writer');
// agents: Agent[] with full types
capx.playbooksRun, list, history with auto-pagination
const run = await capx.playbooks.run(
  id, 'seo-audit', { inputs: { url } }
);
capx.activityQuery events, real-time SSE stream
for await (const e of capx.activity.stream(id)) {
  // e: ActivityEvent - fully typed
}

Typed error handling

Every error is a typed class with structured metadata. Catch specific errors and handle them programmatically. Each error includes a recovery suggestion.

Error classes + try/catcherror-handling.ts
import {
  CapxAuthError,
  CapxRateLimitError,
  CapxGovernanceError,
  CapxInsufficientCreditsError,
  CapxNotFoundError,
  CapxValidationError,
} from '@capx/sdk';

try {
  await capx.playbooks.run(companyId, 'content-pipeline', {
    inputs: { topic: 'AI agents' },
  });
} catch (err) {
  if (err instanceof CapxRateLimitError) {
    // err.retryAfter: number (seconds)
    await sleep(err.retryAfter * 1000);
    // retry...
  }
  if (err instanceof CapxGovernanceError) {
    // err.policy: string - which governance rule blocked
    // err.suggestion: string - how to resolve
    console.log(`Blocked by: ${err.policy}`);
  }
  if (err instanceof CapxInsufficientCreditsError) {
    // err.creditsRequired: number
    // err.creditsAvailable: number
    console.log(`Need ${err.creditsRequired} credits`);
  }
  if (err instanceof CapxValidationError) {
    // err.fields: { field: string; message: string }[]
    err.fields.forEach(f => console.log(`${f.field}: ${f.message}`));
  }
}
PRIVATE BETAAccess-gated

The TypeScript SDK is available to private beta participants. Request access to integrate.

On the roadmap

+capx.webhooks -- register, list, and verify webhook endpoints
+capx.templates -- browse and fork company templates programmatically
+capx.governance -- read and update governance policies via SDK
+capx.costs -- query cost breakdown with typed period filters
+Middleware helpers for Express, Next.js, and Hono
+React hooks: useCompany, useAgents, useActivity

Request access to the private beta.

Request private beta access.

Type-safe, async-first, built for modern TypeScript. The SDK is available to private beta participants. Request access to start integrating.