# Check pattern

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

Check a pattern file.

`POST /v1/patterns/check`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Check a pattern file. |
| Which tool does the same? | [`check_pattern`](https://docs.plotwork.dev/mcp/tools/check-pattern.md) |
| What does it take? | A JSON body of type [`CheckPatternInput`](https://docs.plotwork.dev/api/schemas.md#checkpatterninput). |
| What does it return? | Status 200 with a body of type [`CheckPatternResponse`](https://docs.plotwork.dev/api/schemas.md#checkpatternresponse). |
| What can go wrong? | `400` the body failed schema validation; `401` the api key is missing or not valid; `403` the account is on the free plan, which does not include the rest drawing and checking routes (plan.rest_not_included); `413` the body is larger than the size cap; `429` too many requests. Every failure uses the one error envelope. |

## What it does

Checks a pattern file as a save to an organisation checks it. A file that would not be saved is a normal 200 result with valid false and every problem with its field and a fix; a valid one comes back with each flavour filled with its slot defaults. Stores nothing; saving is POST /orgs/{org}/patterns.

## Request body

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

| Field | Type | Required | Description |
|---|---|---|---|
| `pattern` | `object` | yes | The pattern file. Every field is described at https://docs.plotwork.dev/schemas/plotwork.pattern.json; get_pattern with file true gives one to start from. |
| `pattern.$schema` | `string` | no |  |
| `pattern.name` | `string` | yes |  |
| `pattern.title` | `string` | yes |  |
| `pattern.summary` | `string` | yes |  |
| `pattern.whenToUse` | `string` | no |  |
| `pattern.tags` | `string[]` | no |  |
| `pattern.templates` | `object` | yes |  |
| `pattern.templates.neutral` | `string` | no |  |
| `pattern.templates.aws` | `string` | no |  |
| `pattern.templates.azure` | `string` | no |  |
| `pattern.templates.gcp` | `string` | no |  |
| `pattern.slots` | `object[]` | no |  |
| `pattern.slots[].id` | `string` | yes |  |
| `pattern.slots[].default` | `string` | yes |  |
| `pattern.slots[].meaning` | `string` | yes |  |
| `pattern.notes` | `object` | no |  |
| `pattern.notes.keep` | `string` | no |  |
| `pattern.notes.rename` | `string` | no |  |
| `pattern.notes.split` | `string` | no |  |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | Whether it would be saved, its problems, and the source of each flavour. | [`CheckPatternResponse`](https://docs.plotwork.dev/api/schemas.md#checkpatternresponse) |
| 400 | The body failed schema validation. | [`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 is on the Free plan, which does not include the REST drawing and checking routes (plan.rest_not_included). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 413 | The body is larger than the size cap. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 429 | Too many requests. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |

## Response body

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

| Field | Type | Required | Description |
|---|---|---|---|
| `valid` | `boolean` | yes | True when the file passes every check a save runs, so publish_pattern or the portal's import would take it. |
| `id` | `string \| null` | yes | The id it would have, org:<name>; null when the name is not valid. |
| `kind` | `string \| null` | yes | The kind of diagram every flavour draws; null when not valid. |
| `flavours` | `("neutral" \| "aws" \| "azure" \| "gcp")[]` | yes | The flavours the file gives. |
| `problems` | `object[]` | yes | Every problem at once, each with its field and a fix. Empty when valid. |
| `problems[].field` | `string` | yes | Where the problem is: name, title, templates.aws, slots.0.default, and so on; json for a file that is not JSON. |
| `problems[].message` | `string` | yes |  |
| `problems[].hint` | `string` | yes | How to fix it. |
| `sources` | `object` | yes | Each flavour filled with the slot defaults, keyed by flavour: send one to draw_diagram to see it and its warnings. Empty when not valid. |
| `next` | `string` | yes | The next step in one sentence. |

## 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 |
| [`check_pattern`](https://docs.plotwork.dev/mcp/tools/check-pattern.md) | The same operation as an MCP tool |
| [Tool reference](https://docs.plotwork.dev/mcp/tools.md) | The operations as callable tools |
