# File a hosted diagram in a folder

> Page: https://docs.plotwork.dev/api/patch-user-diagrams-id. Index of every page: https://docs.plotwork.dev/llms.txt

Moves the diagram into a folder (a path such as Payments/Checkout, up to five levels and forty characters a name) or to the top level with null.

`PATCH /user/diagrams/{id}`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | File a hosted diagram in a folder. |
| What does it take? | A JSON body of type [`MoveDiagramBody`](https://docs.plotwork.dev/api/schemas.md#movediagrambody). |
| What does it return? | Status 204 with no body. |
| What can go wrong? | `400` the folder path is not valid; details says why; `401` not signed in; `403` the request came from an origin that may not make changes; `404` no such diagram; `409` the diagram is locked (hosting.diagram_locked); details says when and that you can unlock it; `429` too many requests. Every failure uses the one error envelope. |

## What it does

Moves the diagram into a folder (a path such as Payments/Checkout, up to five levels and forty characters a name) or to the top level with null. An invalid path is a 400 with the reason, never rewritten. The link and the expiry do not change. A diagram that is not yours is a 404.

## Path parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | `string` | yes |  |

## Request body

The body has the type [`MoveDiagramBody`](https://docs.plotwork.dev/api/schemas.md#movediagrambody).

| Field | Type | Required | Description |
|---|---|---|---|
| `folder` | `string \| null` | yes | The folder to file the diagram in, or null for the top level. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 204 | Moved. | none |
| 400 | The folder path is not valid; details says why. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 401 | Not signed in. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 403 | The request came from an origin that may not make changes. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 404 | No such diagram. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 409 | The diagram is locked (hosting.diagram_locked); details says when and that you can unlock it. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 429 | Too many requests. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |

## See also

| Doc | Why |
|---|---|
| [API reference](https://docs.plotwork.dev/api/reference.md) | Every endpoint, and the error envelope |
| [Schemas](https://docs.plotwork.dev/api/schemas.md) | Every request and response type |
| [Tool reference](https://docs.plotwork.dev/mcp/tools.md) | The operations as callable tools |
