# List workspaces

> The workspaces the API key can act in, with the caller's role in each. A workspace API key lists its own workspace.

Source: https://docs.stacksync.com/api-reference/workspaces/list_workspaces

`GET https://api.stacksync.com/v1/workspaces`

- Operation: `list_workspaces`
- Resource: Workspaces
- Access: read-only

## Authentication

- `Authorization: Bearer <key>`: A workspace API key (workspace_…, created by a workspace owner under Workspace settings > Stacksync API) acts with editor rights on that workspace only; a user API key (user_…, created under Profile > Stacksync API) acts as that user in every workspace they belong to. POST, PUT and PATCH requests must send Content-Type: application/json. Every authentication failure answers 403.

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | integer, 1 to 200, default 50 | No | Maximum number of items returned, at most 200 |
| `offset` | integer, at least 0, default 0 | No | Number of items skipped before the first one returned |

## Returns

### 200 OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | array of object (Workspace) | Yes |  |
| `data[].workspace_id` | integer | Yes |  |
| `data[].workspace_name` | string | Yes |  |
| `data[].role` | string (viewer \| editor \| owner) \| null | Yes | The caller's role in the workspace: viewer, editor or owner (a workspace API key acts as an editor) |
| `data[].default_region` | string (besg \| usnv) \| null | Yes | The region the web app opens on and new resources go to by default |
| `has_more` | boolean | Yes | Whether more items follow this page: request the next one with offset + limit |
| `limit` | integer | Yes |  |
| `offset` | integer | Yes |  |

## Example request

```bash
curl -X GET "https://api.stacksync.com/v1/workspaces" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY"
```

## Example response (200)

```json
{
  "data": [
    {
      "workspace_id": 0,
      "workspace_name": "<workspace_name>",
      "role": "viewer",
      "default_region": "besg"
    }
  ],
  "has_more": false,
  "limit": 0,
  "offset": 0
}
```

## Errors

| Status | Meaning | Body |
| --- | --- | --- |
| 400 | Bad Request | `{ "error": string, "msg": string, "field": string \| null }` |
| 403 | Forbidden | `{ "error": string, "msg": string, "field": string \| null }` |

## Related

- [API Reference overview](https://docs.stacksync.com/api-reference): base URLs, regions, pagination, idempotency and errors
- [Authentication](https://docs.stacksync.com/api-reference/authentication): API keys and the 403 answers
- OpenAPI document: https://docs.stacksync.com/openapi.json
- [List the members of a workspace](https://docs.stacksync.com/api-reference/workspaces/list_workspace_members)
- [Get a workspace](https://docs.stacksync.com/api-reference/workspaces/get_workspace)