# Export a workspace's data

`POST /api/v1/workspaces/{workspaceId}/exports`

Asks for a copy of the workspace's data. The file is built in the background and listed in [List data exports](https://docs.monitorly.cloud/api/reference/operations/list-exports.md). Workspace owner or admin.

Sign-in: a dashboard session only. API tokens and OAuth sign-ins get `403 token.not_allowed`.

Section: Workspaces. Operation id in openapi.json: `export_workspace`.

## Parameters

| Name | In | Required | Type | Description |
|---|---|---|---|---|
| `workspaceId` | path | yes | string (uuid) | The workspace's id. |

## Responses

Errors are `application/problem+json` (`Problem`); branch on `type`.

### 202

The export, being built.

`application/json`: ExportView

| Field | Type | Required | Description |
|---|---|---|---|
| `createdAt` | string | yes |  |
| `expiresAt` | string | yes | When the file is deleted. |
| `finishedAt` | string \| null | no |  |
| `id` | string (uuid) | yes |  |
| `sizeBytes` | integer \| null | no |  |
| `state` | string | yes | `pending` (being built), `ready` (download it) or `failed` (ask again). |
| `workspaceId` | string (uuid) \| null | no | The workspace of a workspace export; `null` for the account's own. |
| `workspaceName` | string \| null | no |  |

### 400

Bad Request.

- `auth.credentials_conflict`: the request carries both a session cookie and a token

### 401

Unauthorized.

- `auth.unauthenticated`, `auth.session_expired`: no session, or it ended
- `token.invalid`: the token is malformed, unknown, revoked or expired, or its creator left the workspace

### 403

Forbidden.

- `auth.forbidden`: your role is too low for this
- `token.not_allowed`: this operation needs a signed-in session; tokens cannot call it
- `request.origin_mismatch`, `request.header_required`: a changing request with a session comes from another site or lacks `X-Monitorly-Request: 1`

### 404

Not Found.

- `request.not_found`: it does not exist, or you cannot see it

### 429

Too Many Requests.

- `session.rate_limited`: more than 5 changes a second from your sessions
- `export.rate_limited`: an export was asked for less than an hour ago, or one is still being built; wait `Retry-After` seconds

Schemas named above are listed with their fields in [the schema list](https://docs.monitorly.cloud/api/reference/schemas.md).
