# Save a diagram as one of the organisation's patterns

> Page: https://docs.plotwork.dev/api/post-orgs-org-patterns. Index of every page: https://docs.plotwork.dev/llms.txt

Saves source as a pattern in the built-in format, checked as the built-in ones are, with every problem answered at once.

`POST /orgs/{org}/patterns`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Save a diagram as one of the organisation's patterns. |
| What does it take? | A JSON body of type [`CreateOrganisationPatternBody`](https://docs.plotwork.dev/api/schemas.md#createorganisationpatternbody). |
| What does it return? | Status 201 with a body of type [`OrganisationPattern`](https://docs.plotwork.dev/api/schemas.md#organisationpattern). |
| What can go wrong? | `400` the body is not valid; `401` not signed in; `403` the role may not (orgs.forbidden), the plan does not include the policies (plan.governance_not_included), the organisation has 50 patterns (orgs.pattern_limit_reached), or the request came from an origin that may not make changes; `404` no such organisation, or the caller is not a member of it; `409` the organisation has a pattern of that name (orgs.pattern_exists); `422` the pattern has problems (orgs.pattern_invalid, every problem in details); `429` too many requests; `503` organisations are not set up on this server. Every failure uses the one error envelope. |

## What it does

Saves source as a pattern in the built-in format, checked as the built-in ones are, with every problem answered at once. Its id is org:<name>, and find_pattern offers it first to the organisation's agents. The owner and admins, on Enterprise.

## Path parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `org` | `string` | yes | The organisation's id or its slug. |

## Request body

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

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | yes | The name after `org:`: lowercase letters, digits and single hyphens, such as `payments-service`. Never changes. at least 1 character; at most 50 characters. |
| `title` | `string` | yes | at most 80 characters. |
| `summary` | `string` | yes | One sentence: what the diagram shows. at most 300 characters. |
| `whenToUse` | `string` | no | Two or three sentences: when to start from it, and when not to. at most 600 characters. |
| `tags` | `string[]` | no | Words a search should match, such as `payments`. |
| `templates` | `object` | yes | The Plotwork source of each flavour (neutral, aws, azure, gcp), at least one, with `{{slot}}` markers inside quoted labels. |
| `templates.neutral` | `string` | no | at most 10000 characters. |
| `templates.aws` | `string` | no | at most 10000 characters. |
| `templates.azure` | `string` | no | at most 10000 characters. |
| `templates.gcp` | `string` | no | at most 10000 characters. |
| `slots` | `object[]` | no |  |
| `slots[].id` | `string` | yes | Lowercase words joined with hyphens; written `{{id}}` inside a quoted label of the source. at least 1 character; at most 40 characters. |
| `slots[].default` | `string` | yes | The text the slot has when nothing replaces it. No quotes or line breaks. at most 60 characters. |
| `slots[].meaning` | `string` | yes | One line on what belongs in the slot, so an agent fills it with the right thing. at most 200 characters. |
| `notes` | `object` | no | What to keep, what to rename, and when to split. Left out, each has a plain default. |
| `notes.keep` | `string` | no | at most 400 characters. |
| `notes.rename` | `string` | no | at most 400 characters. |
| `notes.split` | `string` | no | at most 400 characters. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 201 | The pattern as saved. | [`OrganisationPattern`](https://docs.plotwork.dev/api/schemas.md#organisationpattern) |
| 400 | The body is not valid. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 401 | Not signed in. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 403 | The role may not (orgs.forbidden), the plan does not include the policies (plan.governance_not_included), the organisation has 50 patterns (orgs.pattern_limit_reached), or the request came from an origin that may not make changes. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 404 | No such organisation, or the caller is not a member of it. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 409 | The organisation has a pattern of that name (orgs.pattern_exists). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 422 | The pattern has problems (orgs.pattern_invalid, every problem in details). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 429 | Too many requests. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 503 | Organisations are not set up on this server. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |

## Response body

A 201 answer has the type [`OrganisationPattern`](https://docs.plotwork.dev/api/schemas.md#organisationpattern).

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | `string` | yes | What the tools take: `org:<name>`. |
| `name` | `string` | yes | The name after `org:`. |
| `title` | `string` | yes |  |
| `summary` | `string` | yes |  |
| `whenToUse` | `string` | yes |  |
| `kind` | `string` | yes | The kind of diagram, such as `flow`. |
| `tags` | `string[]` | yes |  |
| `flavours` | `("neutral" \| "aws" \| "azure" \| "gcp")[]` | yes |  |
| `slotCount` | `integer` | yes | minimum 0. |
| `createdAt` | `integer` | yes |  |
| `updatedAt` | `integer` | yes |  |
| `updatedBy` | `string \| null` | yes | The account that last saved it, or null once that account is gone. |
| `templates` | `object` | yes | The Plotwork source of each flavour (neutral, aws, azure, gcp), at least one, with `{{slot}}` markers inside quoted labels. |
| `templates.neutral` | `string` | no | at most 10000 characters. |
| `templates.aws` | `string` | no | at most 10000 characters. |
| `templates.azure` | `string` | no | at most 10000 characters. |
| `templates.gcp` | `string` | no | at most 10000 characters. |
| `slots` | `object[]` | yes |  |
| `slots[].id` | `string` | yes | Lowercase words joined with hyphens; written `{{id}}` inside a quoted label of the source. at least 1 character; at most 40 characters. |
| `slots[].default` | `string` | yes | The text the slot has when nothing replaces it. No quotes or line breaks. at most 60 characters. |
| `slots[].meaning` | `string` | yes | One line on what belongs in the slot, so an agent fills it with the right thing. at most 200 characters. |
| `notes` | `object` | yes |  |
| `notes.keep` | `string` | yes | What to leave exactly as it is. |
| `notes.rename` | `string` | yes | What to rename or replace, and how. |
| `notes.split` | `string` | yes | When the diagram has grown too big, and where to cut it. |

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