Crescendo Lab Docs
English
Sign up

Platform API

The Agent Lab Platform API v1 for your own server: sign in as an installation, act for a member, scopes, idempotency, errors, pagination and runs.

Last updated

What it is#

The Platform API is the versioned API your own server uses to work in an Agent Lab workspace: read it as one of its members, run an agent configuration you pass with each run, and answer a channel's entry points. It is the same contract the platform's own clients use.

  • Base URL: https://api.agentlab.cresclab.com. The major version is in the path (/v1).
  • Server to server only. Calls carry a client secret or a person's token, so they never come from a browser.
  • The contract is one OpenAPI 3.1 document, served at GET /v1/openapi.json. The reference pages here are generated from it.

Pre-release

v1 is 1.0.0-alpha. Within v1 only additive changes ship: new operations, new optional request fields, new response fields, new error codes and enum values. Ignore fields you don't know and tolerate enum values you don't know.

SDKs#

Both are generated from the same contract and add sign-in, acting for a member, pagination, errors with recovery, idempotency keys and run streams. They publish their first versions during the v1 pre-release; until then, generate a client from GET /v1/openapi.json.

sh
npm install @crescendolab/agentlab-sdk

@crescendolab/agentlab-sdk runs on Node.js 22 or later and on serverless and edge runtimes, and refuses to start in a browser.

Sign in as an installation#

A workspace administrator installs your application in their workspace. Your server then asks for a one-hour installation token with its client credentials and uses it as Authorization: Bearer <token>:

http
POST /v1/oauth/token
Authorization: Basic <client_id:client_secret>
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&installation_id=<installation id>

There is no refresh token: ask again when the hour is up. The SDKs cache the token and ask for a new one five minutes before it expires.

Most workspace operations act for a member: send the member's account id in Agentlab-On-Behalf-Of. The member must be a current member of the workspace who signed in to your application there; the answer is what that member may see and do in the console. In the TypeScript SDK:

ts
import { AgentLab } from "@crescendolab/agentlab-sdk";

const installation = new AgentLab().installation({ clientId, clientSecret, installationId });
const member = installation.forMember(accountId);

A person who signs in to your application gets their own access token (authorization_code with PKCE); call with it as agentlab.person({ accessToken }). See OAuth.

Scopes and consent#

Every operation declares the scopes a token must carry in x-agentlab-scopes, all of them. An installation's scopes are what a workspace administrator approved at install time; scopes your application asks for later wait for approval (pendingScopes on GET /v1/installation) and reach the next token, not the current one. A scope never grants more than the member it acts for has.

Some scopes are restricted, such as conversations:read and members:read: no installation holds them until the platform has reviewed the application. A missing scope is refused with SCOPE_NOT_GRANTED, recovery: configure. Every scope and its operations: Scopes.

Idempotency#

An operation that creates something takes Idempotency-Key (at most 255 characters): starting a run, deciding a tool call, creating a deployment. The same key and body within 24 hours answer the first answer again without acting again; the same key with a different body is 409. Without a key, a retried run is a second run, charged again. The SDKs send a fresh key when you pass none; pass your own (an order id, say) to make your retries safe.

Errors and recovery#

Workspace operations answer every refusal as {"error": {"code", "message", "recovery", "requestId"}}. Read recovery to decide what to do; code says which case it was, and message is for your logs only.

recoveryWhat gets the request working again
authorizeThe person signs in to or authorizes your application again.
configureYou or a workspace administrator change something, such as the scopes granted to the installation.
retryTry later with bounded backoff, after Retry-After when it is sent.
noneThe request itself is wrong. Don't retry it.

Quote requestId when you ask for support. The OAuth endpoints answer OAuth's own error shape. Every code: Error codes.

Pagination#

A list takes cursor and limit (1 to 100, 50 by default) and answers items and nextCursor, which is absent or null on the last page. Pass nextCursor back as cursor for the next page; the SDKs' paginate does it for you.

Runs and their events#

POST /v1/workspaces/{workspaceId}/runs runs an agent configuration you pass (agent) on the member's input, with the same loop, budgets and conversation store as every other answer. It answers 202 with the run queued; follow it with GET …/runs/{runId} until it is completed, failed or refused.

Send Accept: text/event-stream to get the run as server-sent events instead:

Eventdata
runThe whole run: first, whenever its status changes, and last when it settles.
output_text.delta{"delta": "…"}, text the answer gained while running.
errorAn error body; the run could not be read and the stream ends.

A stream ends when the run settles or after ten minutes; read or stream the run again with GET …/runs/{runId}. A run that waits for a person to approve a tool call is requires_action, with the calls in requiredAction.toolApprovals; decide each with POST …/runs/{runId}/tool-approvals/{toolCallId}. Details: Runs and RunEvents.

Reference#