# Save a whiteboard tab to the organisation's library

> Page: https://docs.plotwork.dev/api/post-v1-boards-board-tabs-tab-save. Index of every page: https://docs.plotwork.dev/llms.txt

As a new diagram (to new), or as a new version of the library diagram the tab is linked to (to linked).

`POST /v1/boards/{board}/tabs/{tab}/save`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Save a whiteboard tab to the organisation's library. |
| What does it take? | A JSON body of type [`AgentSaveBoardTabBody`](https://docs.plotwork.dev/api/schemas.md#agentsaveboardtabbody). |
| What does it return? | Status 200 with a body of type [`AgentSaveBoardTabResult`](https://docs.plotwork.dev/api/schemas.md#agentsaveboardtabresult). |
| What can go wrong? | `400` the body is not valid; `401` the API key is missing or not valid; `403` the account's plan does not include the REST API (plan.rest_not_included), the key is a person's own or a person's own agent (boards.org_key_required), a trusted publisher (boards.publisher_not_allowed), an organisation key without the boards scope (key.scope_missing), boards are not on for the organisation (boards.not_enabled), or the caller may look but not change the board (boards.forbidden); `404` no such board or tab, or the board is not open to the caller: the cases look alike; `409` the tab changed since baseVersion and the edit no longer applies (diagram.version_conflict, with details.currentVersion and each operation's result), the board has as many tabs as it may (boards.tab_limit), or the organisation is on legal hold; `413` the source is longer than a tab may be (boards.source_too_long), or the board holds as much as it may (boards.storage_full); `422` the result has errors (diagram.invalid, the diagnostics in details), an edit did not apply to the current version (boards.operation_failed, details.results), or it holds something that looks like a secret and the organisation blocks them (boards.secret_blocked); `429` too many requests, or a daily limit is spent; `503` live whiteboards are not set up on this server. Every failure uses the one error envelope. |

## What it does

As a new diagram (to new), or as a new version of the library diagram the tab is linked to (to linked). Every library rule applies: folder rules, the label, secret scanning, the size, and approval, which holds the save (status held, W601). A linked save answers 409 diagram.version_conflict when the library diagram changed since libraryVersion. The REST twin of save_board_tab.

## Path parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `board` | `string` | yes | The board's id: 22 letters and digits. |
| `tab` | `string` | yes | The tab's id: 12 letters and digits. |

## Request body

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

| Field | Type | Required | Description |
|---|---|---|---|
| `to` | `"new" \| "linked"` | yes | new: a new library diagram. linked: a new version of the library diagram the tab is linked to. |
| `name` | `string` | no | at least 1 character; at most 200 characters. |
| `folder` | `string \| null` | no | at most 200 characters. |
| `libraryVersion` | `integer` | no | For linked: the library diagram's version the tab last saw. Left out, the tab's own link. minimum 0. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | Saved, held for approval, or unchanged. | [`AgentSaveBoardTabResult`](https://docs.plotwork.dev/api/schemas.md#agentsaveboardtabresult) |
| 400 | The body is not valid. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 401 | The API key is missing or not valid. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 403 | The account's plan does not include the REST API (plan.rest_not_included), the key is a person's own or a person's own agent (boards.org_key_required), a trusted publisher (boards.publisher_not_allowed), an organisation key without the boards scope (key.scope_missing), boards are not on for the organisation (boards.not_enabled), or the caller may look but not change the board (boards.forbidden). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 404 | No such board or tab, or the board is not open to the caller: the cases look alike. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 409 | The tab changed since baseVersion and the edit no longer applies (diagram.version_conflict, with details.currentVersion and each operation's result), the board has as many tabs as it may (boards.tab_limit), or the organisation is on legal hold. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 413 | The source is longer than a tab may be (boards.source_too_long), or the board holds as much as it may (boards.storage_full). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 422 | The result has errors (diagram.invalid, the diagnostics in details), an edit did not apply to the current version (boards.operation_failed, details.results), or it holds something that looks like a secret and the organisation blocks them (boards.secret_blocked). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 429 | Too many requests, or a daily limit is spent. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 503 | Live whiteboards are not set up on this server. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |

## Response body

A 200 answer has the type [`AgentSaveBoardTabResult`](https://docs.plotwork.dev/api/schemas.md#agentsaveboardtabresult).

| Field | Type | Required | Description |
|---|---|---|---|
| `diagram` | `object` | yes |  |
| `diagram.id` | `string` | yes |  |
| `diagram.name` | `string \| null` | yes |  |
| `diagram.version` | `integer` | yes |  |
| `status` | `"saved" \| "held" \| "unchanged"` | yes |  |
| `approval` | `object \| null` | yes |  |
| `approval.code` | `string` | yes |  |
| `approval.message` | `string` | yes |  |
| `tab` | `AgentBoardTab` | yes |  |
| `tab.id` | `string` | yes | at least 12 characters; at most 12 characters; pattern `^[0-9A-Za-z]+$`. |
| `tab.name` | `string` | yes |  |
| `tab.kind` | `string` | yes |  |
| `tab.position` | `number` | yes |  |
| `tab.version` | `integer` | yes | Send it as baseVersion with the next edit, and as sinceVersion to learn what changed after it. |
| `tab.updatedAt` | `integer` | yes |  |
| `tab.updatedBy` | `string` | yes |  |

## 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 |
