# List Workspaces

`GET /api/v1/workspaces`

## Description
List workspaces the API key holder has access to. Supports pagination and scope filtering (active/archived/all). Returns each workspace with the caller's roleKey and roleKeys.

## Parameters

- **scope** (query) — `string`: Filter by archived state.

- **limit** (query) — `integer`: Page size. Capped at 250.

- **offset** (query) — `integer`: Number of records to skip. Deprecated: use cursor. When both are sent, cursor wins.

- **cursor** (query) — `string`: Pagination cursor returned in a previous response's nextCursor field.

## Responses

### 200 — List of workspaces the caller has access to.

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean"
    },
    "data": {
      "type": "object",
      "properties": {
        "workspaces": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "A workspace groups workflows, tables, knowledge bases, files, and credentials under a single billing + permission boundary.",
            "properties": {
              "id": {
                "type": "string",
                "description": "Unique workspace identifier.",
                "example": "wsp_abc123"
              },
              "name": {
                "type": "string",
                "description": "Workspace display name.",
                "example": "Engineering"
              },
              "slug": {
                "type": "string",
                "description": "Immutable URL slug assigned at creation. Crockford base32, unique within the parent organization.",
                "example": "engin3r2"
              },
              "color": {
                "type": "string",
                "description": "Hex color shown in the workspace switcher.",
                "pattern": "^#[0-9a-fA-F]{6}$",
                "example": "#3972F6"
              },
              "ownerId": {
                "type": "string",
                "description": "User ID of the workspace owner."
              },
              "organizationId": {
                "type": "string",
                "description": "Parent organization ID."
              },
              "billedAccountUserId": {
                "type": "string",
                "description": "User ID whose subscription is billed for this workspace's usage. Defaults to ownerId."
              },
              "allowPersonalApiKeys": {
                "type": "boolean",
                "description": "Whether members can create personal API keys for this workspace.",
                "default": true
              },
              "roleKey": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The caller's most significant role key on this workspace. Seeded keys are workspace:admin, workspace:write, and workspace:read. Custom role keys can also appear.",
                "example": "workspace:admin"
              },
              "roleKeys": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Every role key the caller holds on this workspace, including organization-wide roles.",
                "example": [
                  "workspace:admin"
                ]
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "archivedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "Set when the workspace is archived; null otherwise."
              }
            }
          }
        },
        "totalCount": {
          "type": "integer",
          "description": "Total workspaces matching the filter, ignoring limit/offset."
        },
        "limit": {
          "type": "integer"
        },
        "offset": {
          "type": "integer"
        }
      }
    },
    "nextCursor": {
      "type": "string",
      "nullable": true,
      "description": "Cursor for fetching the next page. null when there are no more results."
    }
  }
}
```

### 400 — Invalid request parameters. Check the details array for specific validation errors.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message describing the validation failure."
    },
    "details": {
      "type": "array",
      "description": "List of specific validation errors with field-level details.",
      "items": {
        "type": "object"
      }
    }
  }
}
```

### 401 — Invalid or missing API key. Ensure the X-API-Key header is set with a valid key.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```
