Skip to content
CapitalSourceThe CapitalOps platform
REST + SSEOpenAPI 3.1 · v1 · idempotent · stream-native

One core.
Every surface speaks REST.

The portal, the CLI, and the MCP server are all clients of the same api.capitalsource.ai/v1. Open a CSG-1003 with curl. Stream the intake turn. Read your usage in a one-liner. The OpenAPI file in the repo is the spec your client generates against.

curlSSE
# 1. Open a CSG-1003 session
POST /v1/applications
Authorization: Bearer csg_pat_live_…
Idempotency-Key: a4f9c2e1-…
→ 201 Created
{ "data": { "application_id": "cm7q4f9x0000…" }, "error": null }
# 2. Stream a conversational turn
POST /v1/applications/cm7q4f9x…/messages
Accept: text/event-stream
event: text-delta
data: { "type": "text-delta", "delta": "Got it. How much working" }
event: field-recorded
data: { "field": "legal_business_name" }

CapitalSource Agent Harness · Processor pilot

Integrate with an agent harness built for ongoing work.

The CapitalSource Agent Harness gives the Processor pilot a durable task record, scoped execution permissions, and explicit action approvals. Use REST or the TypeScript SDK to bring those controls into your own application.

Where it fits your stack

  • Read flow runs with agent status, evidence, action receipts, and actual or reserved model spending.
  • Submit a reviewer’s decision against the exact proposal hash; changed evidence invalidates approval.
  • Request reassessment or cancellation through authenticated, organization-scoped endpoints.

Pilot setup includes model routing and pricing, a Slack connection, and an enabled workspace. Start in shadow mode before approving delivery.

Surface guarantees

Five things every endpoint gives you.

The boring infrastructure brokers and funders shouldn't have to think about. We handle it once at the gateway so your client code stays simple.

PAT or OAuth2

Bearer PATs for the CLI and partner agents. OAuth2 client credentials for server-to-server. Both resolve to the same Principal, so authorization is evaluated identically either way.

Idempotency-Key honored

Token-spending POSTs accept an Idempotency-Key header. Replay the same key inside the 24h window and you get the cached response back instead of a second charge.

SSE streaming

Conversational intake turns stream over Server-Sent Events as a discriminated union. Each frame names its type on the event line, so a client can narrow without guessing.

OpenAPI 3.1

The surface is described by docs/openapi/v1.yaml, versioned in the repo. redocly lint is a CI gate, and the TypeScript SDK types are generated from that same file.

Tenant isolation

Every call carries an organization_id via the Principal. Wrong-org access is 404 by default, and a CI gate asserts isolation on every tenant-scoped endpoint.

Endpoint catalog

19 live endpoints. Plus what's next.

Five shipping groups and one roadmap group, badged so nothing is ambiguous. The application and capability endpoints are mirrored in the MCP server and the Recurser CLI, and all three forward to the same dispatch path. Byte-identical envelopes across the three surfaces are the design, not yet a live assertion — the parity suite under apps/core/test/parity/ has not been written.

Applications

8shipping

Create, advance, qualify, certify, package. The CSG-1003 lifecycle.

  • POST
    /v1/applications
    Open a CSG-1003 session. No request body.
  • GET
    /v1/applications
    Cursor-paginated list, org-scoped.
  • GET
    /v1/applications/:id
    Snapshot + filled fields.
  • POST
    /v1/applications/:id/messages
    Conversational turn (SSE).
  • POST
    /v1/applications/:id/qualify
    Run gating against current state.
  • POST
    /v1/applications/:id/certify
    Sign + persist the certified package.
  • GET
    /v1/applications/:id/package
    Package JSON with a signed PDF URL.
  • POST
    /v1/applications/validate
    Validate a payload without persisting.

Capabilities

1shipping

The REST mirror of the MCP tools/call surface. One registry, both surfaces.

  • POST
    /v1/capabilities/:slug/invoke
    Invoke a registered capability by slug.

Auth & OAuth

6shipping

Mint and rotate machine credentials. PATs and OAuth clients resolve to one Principal.

  • POST
    /v1/oauth/token
    Client-credentials grant.
  • GET
    /v1/oauth/clients
    List OAuth clients.
  • POST
    /v1/oauth/clients
    Mint an OAuth client.
  • POST
    /v1/oauth/clients/:id/rotate
    Rotate a client secret.
  • DELETE
    /v1/oauth/clients/:id
    Revoke a client.
  • POST
    /v1/auth/portal/exchange
    Exchange a portal session for a Principal.

Usage

1shipping

Where the spend came from, split by the surface that produced it.

  • GET
    /v1/usage/by-surface
    API / MCP / CLI / portal breakdown.

Health

3shipping

Liveness, readiness, and a smoke endpoint for orchestrators and uptime monitors.

  • GET
    /v1/health
    Process alive.
  • GET
    /v1/ready
    DB + Redis reachable. 503 when either is down.
  • GET
    /v1/ping
    Unauthenticated round-trip timestamp.

On the roadmap

5planned

Shapes we intend to ship, not counted above. None of these are routed today.

  • POST
    /v1/applications/:id/submit
    Dispatch a package to a funder panel.
  • POST
    /v1/agents/:agent/runs
    Kick off a run for a non-Intake agent.
  • POST
    /v1/webhooks/subscriptions
    Subscribe to deal events.
  • GET
    /v1/usage/daily
    Daily roll-ups for a date range.
  • GET
    /v1/funders
    Read the funder registry.
SSE streaming

Typed events, frame by frame.

Conversational intake turns stream over Server-Sent Events. Every frame names its type on the event line and repeats it inside the JSON payload, so a client narrows the union without guessing. Six variants, and that is the whole contract.

event: text-delta

Token chunks for live UI rendering.

event: field-recorded

A structured CSG-1003 field capture with its value.

event: file-mentioned

A supporting document the borrower named in passing.

event: needs-consultation

The gating engine could not route; a human takes over.

event: complete

The gating result that closes the turn.

event: error

A provider or validation failure, with a retryable flag.

TypeScript SDK

Skip the curl. Use the typed client.

@capitalsource/sdk has types generated from the same OpenAPI file, typed errors, and Idempotency-Key handling built in. It is the package the portal, the CLI, and the MCP server all consume.

Install

planned
$npm i @capitalsource/sdk

Not published yet — the package is private at 0.0.0 and is consumed inside the monorepo as workspace:*. Public release is on the roadmap.

Use

typescript
import { CapitalSourceClient } from "@capitalsource/sdk";

const cs = new CapitalSourceClient({
  baseUrl: process.env.CSG_CORE_URL!,
  token: process.env.CSG_API_TOKEN!,
});

const app = await cs.createApplication();

const turn = cs.streamApplicationMessages(app.application_id, {
  message: "Acme HVAC LLC, Texas, $150k WC",
});

for await (const ev of turn) {
  if (ev.type === "text-delta") process.stdout.write(ev.delta);
}
Get building

One token. One spec. Four surfaces.

Sign up, mint a PAT, and open your first CSG-1003 with POST /v1/applications. There is no sandbox tier and no separate trial surface — the same endpoints back the REST API, the MCP server, the CLI, and the portal.