---
title: Platform API
description: 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.
url: https://agentlab.cresclab.com/docs/en/api
language: en
updated: 2026-12-05
---

# 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.

## 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.

> [!NOTE] 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`.

**TypeScript**

```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.

**Go**

```sh
go get github.com/chatbotgang/agentlab-go
```

The Go module `github.com/chatbotgang/agentlab-go` has the same shape: an installation token cache, `ForMember`, page iterators and `*Error` with `Recovery`.

## 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](https://agentlab.cresclab.com/docs/en/api/oauth.md).

## 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](https://agentlab.cresclab.com/docs/en/api/scopes.md).

## 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.

| `recovery`  | What gets the request working again                                                                |
| ----------- | -------------------------------------------------------------------------------------------------- |
| `authorize` | The person signs in to or authorizes your application again.                                       |
| `configure` | You or a workspace administrator change something, such as the scopes granted to the installation. |
| `retry`     | Try later with bounded backoff, after `Retry-After` when it is sent.                               |
| `none`      | The 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](https://agentlab.cresclab.com/docs/en/api/errors.md).

## 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:

| Event               | `data`                                                                       |
| ------------------- | ---------------------------------------------------------------------------- |
| `run`               | The whole run: first, whenever its status changes, and last when it settles. |
| `output_text.delta` | `{"delta": "…"}`, text the answer gained while `running`.                    |
| `error`             | An 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](https://agentlab.cresclab.com/docs/en/api/runs.md) and [RunEvents](https://agentlab.cresclab.com/docs/en/api/schemas.md#RunEvents).

## Reference

- [Runs](https://agentlab.cresclab.com/docs/en/api/runs.md): start, read, stream and cancel runs, and decide tool approvals.
- [Workspace](https://agentlab.cresclab.com/docs/en/api/workspace.md): the acting member, settings, teams, members and models.
- [Error codes](https://agentlab.cresclab.com/docs/en/api/errors.md): every code with its recovery and status.
- [Schemas](https://agentlab.cresclab.com/docs/en/api/schemas.md): every object, field by field.
