---
title: Account API 参考
description: Platform API v1 的 Account：每个操作的路径、参数、请求与回应字段、scope、幂等与错误，直接取自 API 合约。
url: https://agentlab.cresclab.com/docs/zh-cn/api/account
language: zh-Hans
updated: 2026-12-05
---

# Account API 参考

Platform API v1 的 Account：每个操作的路径、参数、请求与回应字段、scope、幂等与错误，直接取自 API 合约。

> [!NOTE]
> 由 API 合约（Agent Lab Platform API 1.0.0-alpha.1）产生。说明文本是合约的英文原文。

The signed-in person, across workspaces. The workspace operations here are account-level
(`x-agentlab-principal: account`): they happen before any installation exists, so they are
called with the person's own sign-in token for the application, carrying the account-level
scopes `workspaces:read` or `workspaces:create` that the person approved when they signed in.
The application declares those scopes as it declares any other, and `workspaces:create` needs
Agent Lab's review first. These scopes reach these operations and nothing inside a workspace,
where only an installation's token is accepted; an installation's token is refused here.

## The signed-in person's profile

`GET /v1/account/profile`

Reachable by an operators' own application from its registered page origin with the
person's access token (`Origin` names that page), or by the console with its session cookie.
A bearer token sent without that origin is read as a console request and needs the cookie.

| Scope | 身分 | 验证方式 | Idempotency-Key |
| --- | --- | --- | --- |
| 无 | — | `personToken`, `consoleSession` | — |

### 回应

| 状态码 | 内容 | 说明 |
| --- | --- | --- |
| `200` | `application/json`: `object` | The profile. |
| `401` | `application/json`: [LegacyErrorString](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#LegacyErrorString) | `authenticationRequired`. |
| `403` | `application/json`: [LegacyErrorString](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#LegacyErrorString) | `originNotAllowed`: the origin is neither the console's nor the application's. |
| `503` | `application/json`: [LegacyErrorString](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#LegacyErrorString) 或 [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | `authenticationUnavailable`, or the API contract could not be read (`Error`). |

#### `200` `application/json`

| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `profile` | `object` | 是 | — |
| `profile.accountId` | `string` | 是 | The opaque account key, never the email. |
| `profile.email` | `string` | 是 | — |
| `profile.loginMethods` | `string`[] | 是 | — |
| `status` | `string` | 是 | 可用值: `ready`. |

## The person's workspaces

`GET /v1/workspaces`

The workspaces the signed-in person can open, with their role in each, and whether they may
create another. With `state=deletion_scheduled`, the workspaces they own that are scheduled
for deletion instead: recoverable in the console until `deletionEffectiveAt`. Reading changes
nothing: an invitation waiting for the person is claimed when they next open the console.

| Scope | 身分 | 验证方式 | Idempotency-Key |
| --- | --- | --- | --- |
| `workspaces:read` | `account` | `personToken` | — |

### 参数

| 名称 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `state` | query | `string` | 否 | `deletion_scheduled` lists the recoverable workspaces instead. 可用值: `deletion_scheduled`. |
| `cursor` | query | `string` | 否 | The `nextCursor` of the previous page. Opaque. |
| `limit` | query | `integer` | 否 | Items per page. 默认值: `50`. |

### 回应

| 状态码 | 内容 | 说明 |
| --- | --- | --- |
| `200` | `application/json`: [AccountWorkspaceList](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#AccountWorkspaceList) | One page of workspaces. |
| `400` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | The request itself is wrong, such as a `cursor` this list did not answer (`recovery: none`). |
| `401` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | No token, or a token the platform does not honor. |
| `403` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | `SCOPE_NOT_GRANTED`: the sign-in does not carry the scope, or the application no longer declares it or Agent Lab no longer approves it (`recovery: authorize`: sign the person in again asking for it); `PERSON_TOKEN_REQUIRED`: an installation's token (`recovery: none`); `SERVER_TO_SERVER_ONLY`: sent from a browser (`recovery: none`). |
| `429` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | Rate limited (`recovery: retry`). |
| `503` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | Try again later (`recovery: retry`). |

## Create a workspace

`POST /v1/workspaces`

A workspace the signed-in person owns, under the same limit and slug rules as creating one in
the console. The application is not installed in it: to act there, it asks to be installed,
and the person approves that on the install consent screen. A retry with the same slug after
the first succeeded answers `WORKSPACE_SLUG_UNAVAILABLE`, so read the list before trying again.

| Scope | 身分 | 验证方式 | Idempotency-Key |
| --- | --- | --- | --- |
| `workspaces:create` | `account` | `personToken` | — |

### 请求内容

`application/json`: [AccountWorkspaceCreate](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#AccountWorkspaceCreate)

| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `name` | `string` | 是 | — |
| `slug` | `string` | 是 | — |

### 回应

| 状态码 | 内容 | 说明 |
| --- | --- | --- |
| `201` | `application/json`: [AccountWorkspace](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#AccountWorkspace) | The workspace. |
| `400` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | The request itself is wrong, such as a `cursor` this list did not answer (`recovery: none`). |
| `401` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | No token, or a token the platform does not honor. |
| `403` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | `WORKSPACE_CREATION_LIMIT_REACHED`: the person may not create another workspace (`recovery: none`); or as for every account-level operation (`AccountForbidden`). |
| `409` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | `WORKSPACE_SLUG_UNAVAILABLE`: the slug is taken or reserved (`recovery: none`). |
| `413` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | The body is larger than the operation accepts (`PAYLOAD_TOO_LARGE`, `recovery: none`). |
| `429` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | Rate limited (`recovery: retry`). |
| `503` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | Try again later (`recovery: retry`). |

## Whether the person can open a workspace

`GET /v1/workspaces/{workspaceId}/admission`

Why a workspace the person expected is not in their list: `reachable` (it is open to them),
`realm_not_admitted` (they are a member, but signed in through an entrance the workspace does
not admit; `signInRealms` names the ones it does), or `no_membership`, which is also the
answer for a workspace that does not exist.

| Scope | 身分 | 验证方式 | Idempotency-Key |
| --- | --- | --- | --- |
| `workspaces:read` | `account` | `personToken` | — |

### 参数

| 名称 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `workspaceId` | path | `string` | 是 | The workspace, by id. |

### 回应

| 状态码 | 内容 | 说明 |
| --- | --- | --- |
| `200` | `application/json`: [WorkspaceAdmission](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#WorkspaceAdmission) | The answer. |
| `401` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | No token, or a token the platform does not honor. |
| `403` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | `SCOPE_NOT_GRANTED`: the sign-in does not carry the scope, or the application no longer declares it or Agent Lab no longer approves it (`recovery: authorize`: sign the person in again asking for it); `PERSON_TOKEN_REQUIRED`: an installation's token (`recovery: none`); `SERVER_TO_SERVER_ONLY`: sent from a browser (`recovery: none`). |
| `429` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | Rate limited (`recovery: retry`). |
| `503` | `application/json`: [Error](https://agentlab.cresclab.com/docs/zh-cn/api/schemas.md#Error) | Try again later (`recovery: retry`). |
