> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Magic Patterns API reference

> API reference for Magic Patterns: every `magicpatterns.api.*` operation with input and output types.

> [!NOTE]
>
> **New to Corsair?** See [API access](https://docs.corsair.dev/concepts/api.md), [authentication](https://docs.corsair.dev/concepts/auth.md), and [error handling](https://docs.corsair.dev/concepts/error-handling).

## Designs

### grep

`designs.grep`

Search the files of another Magic Patterns design

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.designs.grep({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	editorId: 'mH6sUubB354FxNKHTFCduC',
	query: 'OrderSummary',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `url` | `string` | No | A Magic Patterns design URL, or a Magic OS file URL (/os/\<osId>?file=\<fileId>). |
| `editorId` | `string` | No | A Magic Patterns design editor id. |
| `query` | `string` | Yes | Regex pattern to search for in file contents. |
| `filePattern` | `string` | No | Optional case-insensitive substring filter for file names. |
| `head_limit` | `number` | No | Optional maximum number of matches to return. |
| `offset` | `number` | No | Optional number of matches to skip. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### preview

`designs.preview`

Take a live screenshot or short GIF of a design as it is on the canvas

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.designs.preview({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	osFile: '54PVSAUzQjaTeeV1UuPZmv',
	viewport: 'mobile',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `osFile` | `string` | Yes | The id of the design, prototype, frame or slide deck to look at, as `list_files` lists it. |
| `frame` | `string` | No | For a prototype: the id of the frame to open it on, as `start.frame` names one. Omit to open it where it starts. |
| `args` | `object` | No | The props that frame is drawn with, as `start.args` gives them — or, previewing a frame itself, the frame's own props. |
| `viewport` | `desktop \| tablet \| mobile` | No | The window to draw it in: desktop 1280×900 (default), tablet 768×1024, mobile 390×844. |
| `fullPage` | `boolean` | No | Shoot the whole page at full size rather than one window of it: up to 18,750px tall at desktop width and 20,000px narrower, less at `density` 2, and the result says how much of a longer page was left out. A page too tall for one legible picture comes back in numbered segments, top to bottom, each attached, plus the whole page joined into one picture for your user. Without it, a page up to half again as tall as the window is zoomed out to fit it, down to 67%, and a longer one shows only its top. Default false. |
| `density` | `1 \| 2` | No | 2 for a 2x picture, drawn as a high-density screen draws it: the same layout, twice as many pixels each way, sharper for your user. You are attached a 1x copy, which shows you as much as you would see of the 2x one. Not with `record`. Default 1. |
| `element` | `object` | No | Show one element rather than the whole screen. Name it by source — `path` and `line` (or `text`) — or, failing that, by a CSS `selector`. |
| `interact` | `object` | No | Hover over or focus one element before the shot, to show what only appears then: a tooltip, a menu, a hover colour, a focus ring. Never edit the design to force such a state into view. Name it as `element` names one. With `element` too, the crop or outline is of that element in this state: to show a button's tooltip, hover over the button and crop to the element holding both. |
| `record` | `object` | No | Use it when what you made or changed is how something moves; for how it looks, take a picture. Record the design moving instead of taking a picture: a short animated GIF that loops, for your user to watch, of its entrance animation from when it has painted, or, with `interact`, of what the hover, focus or click does, or, with `steps`, of a short path through it. With `element` it is cropped to that element, and to everything it shows across the animation, such as a menu it opens. You get its URL, not the animation, and a picture of its last frame to check where it ends up: show your user the animation, by putting it in your reply as a markdown image, ![\<name>](https://mintlify.s3.us-west-1.amazonaws.com/corsair/plugins/magicpatterns/%3Curl%3E): it is an image, not a video, so a markdown image shows it playing. Not with `fullPage`. |
| `steps` | `object[]` | No | With `record`, instead of `interact`: up to 6 steps played in order on one page while it records, for a short path you are sure of — a few clicks and some typing to show a sign-up step, or moving from one screen of a prototype to the next. Each step waits for what it acts on to be on the page and still, up to 3 seconds. Not for finding out whether something works: a step that cannot be done ends the animation there, and the result says which and why. Open a prototype on the screen the path starts from with `frame`. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

> [accordion] args full type
>
> ```ts theme={null}
> {
> }
> ```

> [accordion] element full type
>
> ```ts theme={null}
> {
>   osFile?: string,
>   path?: string,
>   line?: number,
>   text?: string,
>   selector?: string,
>   instance?: number,
>   mode?: crop | highlight
> }
> ```

> [accordion] interact full type
>
> ```ts theme={null}
> {
>   action?: hover | focus | click,
>   osFile?: string,
>   path?: string,
>   line?: number,
>   text?: string,
>   selector?: string,
>   instance?: number
> }
> ```

> [accordion] record full type
>
> ```ts theme={null}
> {
>   durationMs?: number,
>   fps?: number
> }
> ```

> [accordion] steps full type
>
> ```ts theme={null}
> {
>   action: click | hover | focus | type | press | wait,
>   osFile?: string,
>   path?: string,
>   line?: number,
>   text?: string,
>   selector?: string,
>   instance?: number,
>   key?: string,
>   ms?: number
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### read

`designs.read`

Get the file list and entry preview of another Magic Patterns design

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.designs.read({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', url: 'https://magicpatterns.com/c/mH6sUubB354FxNKHTFCduC', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `url` | `string` | No | A Magic Patterns design URL, or a Magic OS file URL (/os/\<osId>?file=\<fileId>). |
| `editorId` | `string` | No | A Magic Patterns design editor id. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### readFiles

`designs.readFiles`

Read files from another Magic Patterns design

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.designs.readFiles({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	editorId: 'mH6sUubB354FxNKHTFCduC',
	files: [{ fileName: 'components/OrderSummary.tsx' }],
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `url` | `string` | No | A Magic Patterns design URL, or a Magic OS file URL (/os/\<osId>?file=\<fileId>). |
| `editorId` | `string` | No | A Magic Patterns design editor id. |
| `files` | `object[]` | Yes | — |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

> [accordion] files full type
>
> ```ts theme={null}
> {
>   fileName: string,
>   offset?: number,
>   limit?: number
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

## Feedback

### send

`feedback.send`

Send feedback to the Magic Patterns team

**Risk:** `destructive`

```ts theme={null}
await corsair.magicpatterns.api.feedback.send({ from: 'agent', feedback: 'It would help if mobile previews included the viewport dimensions in the response.' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `feedback` | `string` | Yes | The feedback, in plain language. For a problem: what you were trying to do, what you expected, what happened, and any workaround, with the ids or links involved. |
| `from` | `agent \| user` | Yes | "agent" for something you ran into yourself; "user" when relaying what your user said. |
| `category` | `bug \| confusing \| feature_request \| praise \| other` | No | What kind of feedback this is. |
| `toolName` | `string` | No | The Magic Patterns tool this is about, if any. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `ok` | `boolean \| null` | No | Whether the feedback was sent. |

***

## Files

### copy

`files.copy`

Copy files byte for byte inside a project

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.files.copy({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	osFile: '54PVSAUzQjaTeeV1UuPZmv',
	fromOsFile: '6EBZ8F3yjivUmmuKkHr2X1',
	files: [{ src: 'assets/store-logo.svg', dest: 'assets/store-logo.svg' }],
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `osFile` | `string` | No | The id of the OS file to copy into. Omit to copy into project files at the OS root. |
| `fromOsFile` | `string` | No | The id of the OS file to copy from. Omit to copy from `osFile` itself, e.g. from its `sources/` into one of its folders. |
| `files` | `object[]` | Yes | The copies, e.g. \[\{"src":"sources/github/acme-ui/src/Logo.svg","dest":"components/Header/Logo.svg"}]. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

> [accordion] files full type
>
> ```ts theme={null}
> {
>   src: string,
>   dest: string
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### delete

`files.delete`

Delete one file inside an OS file

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.magicpatterns.api.files.delete({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	osFile: '54PVSAUzQjaTeeV1UuPZmv',
	path: 'components/OrderSummaryDraft.tsx',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `osFile` | `string` | No | The id of the OS file that holds this file. Omit to delete a project file at the OS root. |
| `path` | `string` | Yes | Path within the OS file, or from the OS root when `osFile` is omitted. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### edit

`files.edit`

Replace exact text in a file in a project

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.files.edit({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	osFile: '54PVSAUzQjaTeeV1UuPZmv',
	path: 'components/OrderSummary.tsx',
	old_string: '<h2>Order summary</h2>',
	new_string: '<h2>Your order</h2>',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `osFile` | `string` | No | The id of the OS file that holds this file. Omit to edit a project file at the OS root, such as "package.json". |
| `path` | `string` | No | Path within the OS file. Omit for a markdown file. With no `osFile`, a path from the OS root. |
| `edits` | `object[]` | No | The replacements, applied in order, e.g. \[\{"old\_string":"\<h1>Old","new\_string":"\<h1>New"},\{"old\_string":"text-red-500","new\_string":"text-blue-500"}]. PREFERRED whenever you have more than one change to this file. Write each `old_string` as the file reads; edits must not overlap — an earlier `new_string` must not create or remove a later `old_string`. |
| `old_string` | `string` | No | The exact text to replace, for a single replacement only. For more than one, use `edits`. |
| `new_string` | `string` | No | The replacement text, used with `old_string`. |
| `replace_all` | `boolean` | No | With `old_string`: replace every occurrence instead of requiring a unique match. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

> [accordion] edits full type
>
> ```ts theme={null}
> {
>   old_string: string,
>   new_string: string,
>   replace_all?: boolean
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### glob

`files.glob`

Find files in an OS file by glob pattern

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.files.glob({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	pattern: 'components/**/*.tsx',
	osFile: '54PVSAUzQjaTeeV1UuPZmv',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `pattern` | `string` | Yes | Glob matched against each file path, e.g. "\*\*/*.stories.*". |
| `osFile` | `string` | Yes | The id of the OS file to look inside. |
| `path` | `string` | No | A directory inside `osFile` to search under, e.g. "sources". Paths come back relative to it. |
| `offset` | `number` | No | Skip this many matches, to page through a long result. Default: 0. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### grep

`files.grep`

Search file contents in a project with a regex

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.files.grep({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	pattern: 'OrderSummary',
	glob: '*.tsx',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `pattern` | `string` | Yes | A regular expression, in ripgrep syntax. |
| `osFile` | `string` | No | Restrict the search to one OS file. Omit to search the whole OS. |
| `path` | `string` | No | Narrow the search inside `osFile`: a directory searches everything under it, a file searches just that file. Requires `osFile`. |
| `upload` | `string` | No | A file the user attached in chat, by the `upload` path its message listed, e.g. "abc123/pricing.html". Read-only, and not part of the OS. Cannot be combined with `osFile` or `path`. |
| `glob` | `string` | No | Only search paths matching this glob, e.g. "\*.tsx". |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### list

`files.list`

List a project's OS files, or the files inside one OS file

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.files.list({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `osFile` | `string` | No | The id of an OS file to look inside. Omit to list the OS files themselves. |
| `path` | `string` | No | A directory inside `osFile` to list, e.g. "components". Requires `osFile`. Omit to list the whole OS file. |
| `depth` | `number` | No | Inside an OS file, how many levels deep to show (1 = direct children only); deeper files collapse into their directory. Default: every level. |
| `filter` | `string` | No | Case-insensitive regex. Inside an OS file it is applied to each file path relative to `path`, e.g. "\\\\.css\$"; at the OS level, to each OS file id and canvas name. |
| `offset` | `number` | No | Skip this many entries, to page through a long listing. Default: 0. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### read

`files.read`

Read a file in a project, with line numbers

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.files.read({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	osFile: '54PVSAUzQjaTeeV1UuPZmv',
	path: 'components/OrderSummary.tsx',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `osFile` | `string` | No | The id of the OS file that holds this file. Omit to read a project file at the OS root, such as "package.json". |
| `path` | `string` | No | Path within the OS file, e.g. "App.tsx". Omit for a markdown file, which is its one `index.md`, or for an image, which comes back as its pointer with the picture attached. With no `osFile`, a path from the OS root. |
| `upload` | `string` | No | A file the user attached in chat, by the `upload` path its message listed, e.g. "abc123/pricing.html". Read-only, and not part of the OS. Cannot be combined with `osFile` or `path`. |
| `offset` | `number` | No | First line to return, 1-based. Defaults to 1. |
| `limit` | `number` | No | Maximum lines to return. Defaults to 1500. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### runCommand

`files.runCommand`

Run a shell command in a project's workspace

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.magicpatterns.api.files.runCommand({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	command: 'npm run lint',
	purpose: 'Check for lint errors',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `command` | `string` | Yes | The command to run. |
| `purpose` | `string` | Yes | What this command does, in plain words anyone could follow: start with a bare verb, keep it under six words, and leave out commands, flags, file paths and code names, e.g. 'Check the page fits the screen'. The user sees it as the step's label both while it runs and after it finishes, so do not write 'Checks', 'Checking' or 'Checked'. |
| `osFile` | `string` | No | Run inside this OS file rather than at the OS root. Paths in the command are then relative to it. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### write

`files.write`

Create or overwrite a file in a project

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.files.write({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	osFile: '54PVSAUzQjaTeeV1UuPZmv',
	path: 'components/OrderSummary.tsx',
	content: 'export default function OrderSummary() {\n  return <h2>Order summary</h2>;\n}\n',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `osFile` | `string` | No | The id of the OS file to write into. Omit to write a project file at the OS root, such as "package.json". |
| `path` | `string` | No | Path within the OS file, e.g. "components/Card.tsx". Omit for a markdown file. With no `osFile`, a path from the OS root. |
| `content` | `string` | Yes | The full file contents. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

## Images

### generate

`images.generate`

Generate up to 5 images from a description and get CDN URLs

**Risk:** `destructive`

```ts theme={null}
await corsair.magicpatterns.api.images.generate({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	images: [{ name: 'Order confirmation', prompt: 'Softly lit clay illustration of a small parcel centered on a pale blue background.', aspectRatio: '3:2' }],
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `images` | `object[]` | Yes | Every image to generate, up to 5, produced concurrently. |
| `addToCanvas` | `boolean` | No | Also add each image to the canvas as its own image file. For images that are the deliverable. Leave it off for assets a design will reference by URL. |
| `parent` | `string` | No | Prototypes layout only: the id of the file to file each image under in the tree, as its own image file — a prototype, or any other top-level OS file. Implies `addToCanvas`. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   name: string,
>   prompt: string,
>   aspectRatio?: 1:1 | 1:4 | 4:1 | 1:8 | 8:1 | 2:3 | 3:2 | 3:4 | 4:3 | 4:5 | 5:4 | 9:16 | 16:9 | 21:9,
>   referenceImages?: string[]
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

## Legacy

### createArtifact

`legacy.createArtifact`

Create a working branch (artifact) of a legacy design

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.legacy.createArtifact({ artifactId: 'D4HeKJMZh7q3GdJech9UKK', name: 'Update checkout heading' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `artifactId` | `string` | Yes | The artifact ID to clone from (typically the active artifact from legacy\_get\_artifact or legacy\_get\_design\_status). |
| `name` | `string` | Yes | A short title for this version, phrased as the change you are about to make (e.g. "Swap hero CTA to solid variant"). Shown in the design timeline and the versions dropdown, so keep it to a few words. |
| `description` | `string` | No | Optional longer note on what you are about to change and why, shown above the version in chat. Prefer describing what actually shipped via legacy\_publish\_artifact instead — use this for a session that may not reach publish. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `artifactId` | `string \| null` | No | The new artifact ID. |
| `files` | `string[] \| null` | No | File names in the new artifact. |

***

### createDesign

`legacy.createDesign`

Create a legacy editor design, optionally generating it from a prompt

**Risk:** `destructive`

```ts theme={null}
await corsair.magicpatterns.api.legacy.createDesign({ name: 'Guest Checkout', prompt: 'Design a guest checkout with a shipping form and an order summary.' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | No | Optional name for the design. Defaults to "Untitled". |
| `prompt` | `string` | No | Optional natural language prompt for AI generation. If omitted, a blank design with scaffold files is created instantly. |
| `imageUrls` | `string[]` | No | Optional image URLs as visual references (only used with prompt). |
| `designSystemId` | `string` | No | Optional design system ID. Use legacy\_list\_design\_systems to discover IDs. |
| `designSystem` | `string` | No | Optional design system name (e.g. "Shadcn", "MUI"). Resolved case-insensitively. designSystemId takes precedence if both provided. |
| `templateId` | `string` | No | Optional editor ID of an existing design to use as a template. The design will be forked first, then any prompt is applied to the fork. Get the ID from the design URL (magicpatterns.com/c/\<id>) or via legacy\_get\_editor\_id\_from\_url. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `editorId` | `string \| null` | No | The editor ID — pass to legacy\_get\_design\_status, legacy\_send\_prompt, and other editor-scoped tools. |
| `editorUrl` | `string \| null` | No | URL of the design editor. |
| `previewUrl` | `string \| null` | No | URL of the live preview, if available. |
| `activeArtifactId` | `string \| null \| null` | No | The active artifact ID, or null if none yet. |
| `availableFiles` | `string[] \| null` | No | File names in the active artifact. |

***

### createDesignSystem

`legacy.createDesignSystem`

Create a legacy design system

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.legacy.createDesignSystem({ name: 'Storefront UI' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | The name of the new design system. |
| `logo` | `string` | No | Optional logo URL. Defaults to a placeholder. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `designSystemId` | `string \| null` | No | The new design system ID (ds-...). |
| `name` | `string \| null` | No | The design system name. |
| `editorUrl` | `string \| null` | No | URL of the design system editor. |

***

### createSlideDeck

`legacy.createSlideDeck`

Generate a legacy slide deck from a prompt

**Risk:** `destructive`

```ts theme={null}
await corsair.magicpatterns.api.legacy.createSlideDeck({ prompt: 'Create a five-slide deck explaining the checkout redesign and showing the new mobile flow.' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `prompt` | `string` | Yes | Natural language description of the slide deck to generate (e.g. "A 10-slide startup pitch deck for a fintech company"). |
| `name` | `string` | No | Optional name for the slide deck. Defaults to "Untitled". |
| `imageUrls` | `string[]` | No | Optional image URLs as visual references. |
| `designSystemId` | `string` | No | Optional design system ID. Use legacy\_list\_design\_systems to discover IDs. |
| `designSystem` | `string` | No | Optional design system name (e.g. "Shadcn", "MUI"). Resolved case-insensitively. designSystemId takes precedence if both provided. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `editorId` | `string \| null` | No | The editor ID — pass to legacy\_get\_design\_status, legacy\_send\_prompt, and other editor-scoped tools. |
| `editorUrl` | `string \| null` | No | URL of the deck editor. |
| `previewUrl` | `string \| null` | No | URL of the live preview, if available. |
| `activeArtifactId` | `string \| null \| null` | No | The active artifact ID, or null if none yet. |
| `availableFiles` | `string[] \| null` | No | File names in the active artifact. |

***

### getArtifact

`legacy.getArtifact`

Get a legacy design's active artifact and its files

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.getArtifact({ editorId: 'mH6sUubB354FxNKHTFCduC' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `editorId` | `string` | Yes | The editor ID of the design. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `artifactId` | `string \| null` | No | The active artifact ID. |
| `files` | `string[] \| null` | No | File names in the active artifact. |

***

### getDesignStatus

`legacy.getDesignStatus`

Get a legacy design's generation status and active artifact

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.getDesignStatus({ editorId: 'mH6sUubB354FxNKHTFCduC' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `editorId` | `string` | Yes | The editor ID from legacy\_create\_design or legacy\_get\_editor\_id\_from\_url. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `isGenerating` | `boolean \| null` | No | True if AI generation is still in progress — wait 60 seconds and poll again. |
| `activeArtifactId` | `string \| null \| null` | No | The current active artifact ID, or null if none. |
| `availableFiles` | `string[] \| null` | No | File names in the active artifact. |

***

### getDesignSystem

`legacy.getDesignSystem`

Get a legacy design system and its files

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.getDesignSystem({ designSystemId: 'ds-86b45d3c-1e79-48ac-b462-a81563f29c7d' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `designSystemId` | `string` | Yes | The design system ID (ds-...). Use legacy\_list\_design\_systems to discover available design systems. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `designSystemId` | `string \| null` | No | The design system ID (ds-...). |
| `name` | `string \| null` | No | The design system name. |
| `artifactId` | `string \| null` | No | The current active artifact. Pass as baseArtifactId to legacy\_write\_design\_system\_files to detect drift. |
| `files` | `string[] \| null` | No | The persisted file names. |
| `hasUnpublishedChanges` | `boolean \| null` | No | Whether the active artifact differs from the latest published version. |
| `guide` | `string \| null` | No | Pointer to the design\_system\_authoring\_guide prompt. |

***

### getEditorIdFromUrl

`legacy.getEditorIdFromUrl`

Resolve a legacy Magic Patterns URL to its editor id

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.getEditorIdFromUrl({ url: 'https://magicpatterns.com/c/mH6sUubB354FxNKHTFCduC' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | Yes | The Magic Patterns URL. Supported formats: - Design: "magicpatterns.com/c/\<id>" or "[https://www.magicpatterns.com/c/\&lt;id](https://www.magicpatterns.com/c/\&lt;id)>" - Published: "project-\<slug>.magicpatterns.app" - Canvas: "magicpatterns.com/s/\<canvasId>?nodeIds=\<nodeId>" |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `editorId` | `string \| null` | No | The resolved editor ID for use with editor-scoped tools. |

***

### getInspirationDocument

`legacy.getInspirationDocument`

Read an existing legacy inspiration document

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.getInspirationDocument({ inspirationId: 'eNvvKcruQxK69X62Kbhaza' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `inspirationId` | `string` | Yes | The Magic Patterns inspiration document id (the \<id> in magicpatterns.com/inspiration/\<id>). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| null` | No | The inspiration document id. |
| `title` | `string \| null` | No | Short label for what the concepts explore. |
| `userPrompt` | `string \| null` | No | The original request the concepts explore. |
| `status` | `string \| null` | No | 'generating' while concepts are still being produced, else 'ready'/'error'. |
| `baseline` | `object \| null` | No | The baseline the variants diverge from, if provided. |
| `viewport` | `object \| null` | No | The canvas the concepts were authored against (absent = 1280x800 desktop). |
| `variants` | `object[] \| null` | No | The concepts, in order (Concept A = variants\[0]). |

> [accordion] baseline full type
>
> ```ts theme={null}
> {
>   focus?: string | null,
>   sharedCopy?: string | null,
>   baselineStyle?: string | null,
>   html?: string | null
> } | null
> ```

> [accordion] viewport full type
>
> ```ts theme={null}
> {
>   width?: number | null,
>   height?: number | null
> } | null
> ```

> [accordion] variants full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   description?: string | null,
>   implementationPrompt?: string | null,
>   html?: string | null,
>   status?: string | null,
>   errorMessage?: string | null
> }[] | null
> ```

***

### listDesignSystems

`legacy.listDesignSystems`

List the design systems available to legacy editor designs

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.listDesignSystems({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `designSystems` | `object[] \| null` | No | The design systems available to the authenticated user. |

> [accordion] designSystems full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   isReserved?: boolean | null,
>   isActive?: boolean | null
> }[] | null
> ```

***

### listVersionHistory

`legacy.listVersionHistory`

List the version history of a legacy design

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.listVersionHistory({ editorId: 'mH6sUubB354FxNKHTFCduC' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `editorId` | `string` | Yes | The editor ID of the design. |
| `skip` | `number` | No | Number of recent versions to skip (for pagination). Defaults to 0 (most recent). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `versions` | `object[] \| null` | No | The most recent versions, newest first. |
| `hasMore` | `boolean \| null` | No | Whether older versions exist (paginate with skip). |

> [accordion] versions full type
>
> ```ts theme={null}
> {
>   artifactId?: string | null,
>   versionLabel?: string | null,
>   title?: string | null,
>   description?: string | null,
>   timeCreated?: number | null
> }[] | null
> ```

***

### publishArtifact

`legacy.publishArtifact`

Compile a legacy artifact and make it the design's active version

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.legacy.publishArtifact({ artifactId: 'Hha3QCTyP6Vf3qzkA9k4UF', editorId: 'mH6sUubB354FxNKHTFCduC', description: 'Updated the checkout heading to clarify that an account is optional.' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `artifactId` | `string` | Yes | The artifact ID to compile and publish. |
| `editorId` | `string` | Yes | The editor ID of the design this artifact belongs to. |
| `description` | `string` | No | A summary of what changed in this version, written like a commit message — a sentence or two, in the past tense, describing what actually shipped (e.g. "Swapped the hero CTA to the solid Button variant and dropped the legacy grid"). Always provide this: collaborators open the design without having seen your session, and this is the only prose explaining what you did. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `artifactId` | `string \| null` | No | The new published artifact ID. |
| `compiledFiles` | `string[] \| null` | No | The file names that were compiled. |

***

### publishDesignSystem

`legacy.publishDesignSystem`

Publish a legacy design system as a new immutable version

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.magicpatterns.api.legacy.publishDesignSystem({ designSystemId: 'ds-86b45d3c-1e79-48ac-b462-a81563f29c7d' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `designSystemId` | `string` | Yes | The design system ID (ds-...). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `version` | `object \| null` | No | The newly published version. |
| `isBackwardsCompatible` | `boolean \| null` | No | Whether the new version is backwards-compatible with the previously published version. |
| `reason` | `string \| null` | No | Explanation when the change is breaking. |

> [accordion] version full type
>
> ```ts theme={null}
> {
>   major?: number | null,
>   minor?: number | null
> } | null
> ```

***

### readArtifactFiles

`legacy.readArtifactFiles`

Read source files from a legacy design artifact

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.readArtifactFiles({
	artifactId: 'D4HeKJMZh7q3GdJech9UKK',
	fileNames: ['App.tsx'],
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `artifactId` | `string` | Yes | The artifact ID to read files from. |
| `fileNames` | `string[]` | Yes | Array of file names/paths to read. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `files` | `object[] \| null` | No | The requested files with their contents. |

> [accordion] files full type
>
> ```ts theme={null}
> {
>   name?: string | null,
>   content?: string | null
> }[] | null
> ```

***

### readDesignSystemFiles

`legacy.readDesignSystemFiles`

Read source files from a legacy design system

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.readDesignSystemFiles({
	designSystemId: 'ds-86b45d3c-1e79-48ac-b462-a81563f29c7d',
	fileNames: ['components/Button/index.tsx'],
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `designSystemId` | `string` | Yes | The design system ID (ds-...). |
| `fileNames` | `string[]` | Yes | Array of file names/paths to read (as listed by legacy\_get\_design\_system). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `files` | `object[] \| null` | No | The requested files with their contents. |

> [accordion] files full type
>
> ```ts theme={null}
> {
>   name?: string | null,
>   content?: string | null
> }[] | null
> ```

***

### readMessageHistory

`legacy.readMessageHistory`

Read recent chat messages of a legacy design

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.legacy.readMessageHistory({ editorId: 'mH6sUubB354FxNKHTFCduC' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `editorId` | `string` | Yes | The editor ID of the design. |
| `skip` | `number` | No | Number of recent items to skip (for pagination). Defaults to 0 (most recent). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `items` | `object[] \| null` | No | The recent chat items. |
| `hasMore` | `boolean \| null` | No | Whether older items exist (paginate with skip). |

> [accordion] items full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   role?: string | null,
>   app?: string | null,
>   content?: any[] | null,
>   timeCreated?: number | null
> }[] | null
> ```

***

### sendPrompt

`legacy.sendPrompt`

Send a prompt to the AI on a legacy design

**Risk:** `destructive`

```ts theme={null}
await corsair.magicpatterns.api.legacy.sendPrompt({ editorId: 'mH6sUubB354FxNKHTFCduC', prompt: 'Show the delivery estimate directly below the shipping options.' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `editorId` | `string` | Yes | The editor ID of the design to update. |
| `prompt` | `string` | Yes | A natural language description of what to create or change. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `requestId` | `string \| null` | No | The ID of the kicked-off generation request. |

***

### writeArtifactFiles

`legacy.writeArtifactFiles`

Write source files to a legacy design artifact

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.legacy.writeArtifactFiles({
	artifactId: 'Hha3QCTyP6Vf3qzkA9k4UF',
	files: [{ fileName: 'App.tsx', content: 'export default function App() {\n  return <main><h1>Guest checkout</h1></main>;\n}\n' }],
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `artifactId` | `string` | Yes | The artifact ID to write files to. |
| `files` | `object[]` | Yes | Array of files to write |

> [accordion] files full type
>
> ```ts theme={null}
> {
>   fileName: string,
>   content: string
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `files` | `string[] \| null` | No | All file names now in the artifact. |

***

### writeDesignSystemFiles

`legacy.writeDesignSystemFiles`

Write source files to a legacy design system

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.legacy.writeDesignSystemFiles({
	designSystemId: 'ds-86b45d3c-1e79-48ac-b462-a81563f29c7d',
	baseArtifactId: '5c8e2a71-3d94-4b6f-a0e2-9f17c4d8b350',
	files: [{ fileName: 'components/Button/index.tsx', content: 'export function Button({ label }: { label: string }) {\n  return <button type="button">{label}</button>;\n}\n' }, { fileName: 'components/Button/Button.previews.tsx', content: 'import { Button } from \'./index\';\n\nexport default {\n  componentName: \'Button\',\n  importPath: \'@/components/Button\',\n  previews: [{ name: \'Default\', render: () => <Button label="Save" /> }],\n};\n' }, { fileName: 'components/Button/Context.md', content: 'Primary action button. Use one per screen section.\n' }],
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `designSystemId` | `string` | Yes | The design system ID (ds-...). |
| `files` | `object[]` | Yes | Array of files to create or overwrite. |
| `baseArtifactId` | `string` | No | The artifactId from legacy\_get\_design\_system. If the active artifact has since changed, the write is rejected (409) so you can re-read. |

> [accordion] files full type
>
> ```ts theme={null}
> {
>   fileName: string,
>   content: string
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `artifactId` | `string \| null` | No | The new active artifact ID after the write. |
| `files` | `string[] \| null` | No | All file names now in the design system. |
| `validationErrors` | `string[] \| null` | No | Non-blocking validation errors — fix before legacy\_publish\_design\_system. |

***

## Magicos

### ask

`magicos.ask`

Send a prompt to MagicOS, the project's own design agent (spends credits)

**Risk:** `destructive`

```ts theme={null}
await corsair.magicpatterns.api.magicos.ask({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', message: 'Add an order confirmation screen to Mobile Checkout with a delivery estimate.', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `message` | `string` | Yes | What the user wants, in their words, as they would type it to MagicOS. Include what they said about it; add nothing they did not ask for. Name OS files by their canvas names. |
| `threadId` | `string` | No | The thread to continue, from an earlier ask\_magicos or list\_magicos\_threads. Leave it out to start a new thread. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### listThreads

`magicos.listThreads`

List MagicOS threads in a project and follow their progress

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.magicos.listThreads({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `limit` | `number` | No | How many threads to list, from 1 to 20. Defaults to 20. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

## Os Files

### create

`osFiles.create`

Add a prototype, frame, canvas, slide, document, image or note to a project canvas

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.osFiles.create({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	kind: 'prototype',
	name: 'Mobile Checkout',
	preset: 'mobile',
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `kind` | `canvas \| prototype \| frame \| slide \| slideDeck \| markdown \| json \| image \| text-annotation` | No | What to create. Required unless `copyFrom` is set, in which case the source kind is preserved. |
| `name` | `string` | Yes | A short human label for the canvas, e.g. "Checkout flow". Not a filename. |
| `parent` | `string` | No | The id of the file to make this under in the tree. Optional for anything but a "text-annotation" or a "slide", and any top-level OS file will do: filing is organisation, so it never changes how either builds, except that a prototype plays a frame filed under it, and a slide made under a slide deck is added to the end of `slides` in its `deck.json`, which is what the deck plays, in that order. A slide the deck plays requires the deck as `parent`; one made with no parent is refused. A variant of a slide is a slide too: copy it with `copyFrom` and the variations canvas as `parent`, and it stays a slide and is not added to `slides`. A copy of a slide with no parent is a frame. A deck holds slides only. The deck plays a slide only while that list names it. A canvas as `parent` places the new file on that canvas in the same step, as the next column of the last row it draws, which is what puts it under the canvas: a file is under the canvas that places it, and placed on one canvas only. To show a file on a second canvas, copy it with `copyFrom` and place the copy. Without one, it sits at the top of the tree, which is where work on something new belongs: a file the user mentioned only as context is not a parent, and neither is an option on a canvas for a new canvas or prototype. With `copyFrom`, omit it to file the copy where its source is. |
| `preset` | `web \| mobile` | No | Design or prototype only: the device it is built for. A prototype's frames draw at it. "web" (the default) is a 1280 × 900 desktop page; use "mobile", a 390 × 844 phone screen, when the user asked for a mobile or phone design or app. |
| `layout` | `app \| page` | No | Only with `copyFrom` naming a design, to change the layout the copy inherits. No new file takes one: never send it when creating a prototype, frame or anything else. "app" is one screen that fits the viewport, such as a dashboard or an app shell whose regions scroll inside it; its canvas node keeps its preset size. "page" is read top to bottom, such as a landing page or an article; its canvas node grows with the content while you write it, so size nothing with viewport units (`h-screen`, `min-h-screen`, `vh`). |
| `copyFrom` | `string` | No | The id of an existing OS file to copy exactly. Its kind, every file in its bundle, and its layout are preserved; `layout` overrides the last. |
| `frames` | `string[]` | No | Only when copying a prototype in an OS whose guide lays it out as pages: which of its frames come with the copy, by id. Each comes as a copy of its own, filed under the new prototype, and the copy imports it in place of the original, all in the same step. Omit to bring every frame it has; pass just the screens the copy is about to leave the rest out. |
| `after` | `string` | No | Only for a "canvas" in an OS whose guide lays it out as pages: the page the new one is listed right after among the pages, by its id or the id of a file on it. For a page of options on a prototype, pass that prototype, so the options follow the page the work is on; when a page of options on the same work already follows it, pass that page instead, so they stay in the order made. Omit for a page on something new, which goes last. |
| `canvasPlacement` | `object` | No | Only with a canvas as `parent`: where that canvas places the new file, in its own coordinates, as `place()` takes them. Read the canvas first and pass the spot you would otherwise move it to, such as the next column of its options at the gap they keep, so it appears there the moment it is made. Omit to have it placed as the next column of the last row. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

> [accordion] canvasPlacement full type
>
> ```ts theme={null}
> {
>   id?: string,
>   x: number,
>   y: number
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### delete

`osFiles.delete`

Remove a whole OS file and its placements from a project canvas

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.magicpatterns.api.osFiles.delete({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', osFile: '6EBZ8F3yjivUmmuKkHr2X1', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `osFile` | `string` | Yes | The id of the OS file to remove. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

## Projects

### check

`projects.check`

Type-check and build a project's designs and report what is broken

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.projects.check({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### create

`projects.create`

Create a new, empty MagicOS project

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.projects.create({ name: 'Checkout Redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | No | What to call it. Defaults to "Untitled". |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### done

`projects.done`

Mark the current request finished and get links and pictures of the changed designs

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.projects.done({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### guide

`projects.guide`

Read a project's workflow and conventions before creating or writing in it

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.projects.guide({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `topic` | `variants \| conventions \| addressing \| linking \| tools \| collaboration` | No | One part of the guide. Leave it out for the default. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### importClaudeDesign

`projects.importClaudeDesign`

Import a Claude Design HTML bundle from a public URL as a new prototype

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.projects.importClaudeDesign({ url: 'https://example.com/designs/checkout.html', title: 'Checkout Concept' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | Yes | Public HTTPS URL to the design file. Valid for \~1 hour. Fetch it server-side. |
| `title` | `string` | No | Suggested title for the imported design. |
| `download_token` | `string` | No | Access token for the design file, given separately from url. Pass it through unchanged; never extract one from url or alter url. |
| `claude_design_project_id` | `string` | No | Stable identifier of the design; identical on every re-send. Use it to update an existing import instead of creating a new one. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### list

`projects.list`

List the MagicOS projects you can reach, with their ids and your access

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.projects.list({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### setStatus

`projects.setStatus`

Show the people watching a project what the agent is working on

**Risk:** `write`

```ts theme={null}
await corsair.magicpatterns.api.projects.setStatus({
	osId: 'Z3ZDUguQKLKB1rTvrQsQry',
	summary: 'Simplifying the mobile checkout',
	newRequest: true,
	conversation: 'checkout-redesign',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `summary` | `string` | Yes | One short line, in plain language, about what you are doing right now — "rewriting the checkout flow", not "calling edit\_file". It is shown to a person, not parsed. |
| `osFiles` | `string[]` | No | The OS file ids this work is about, if you know them up front. Their frames are marked as being worked on. Optional: the files you actually touch are picked up on their own. |
| `newRequest` | `boolean` | No | True when you are starting on a new request from your user, rather than moving to the next step of the one you are on. Your work is shown on the project grouped by request, and this starts the next group, headed by this summary. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

## Threads

### read

`threads.read`

Read the messages and actions in one project thread

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.threads.read({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', threadId: 'yen3u5g8zy9ae4LLGJL764', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `threadId` | `string` | Yes | The thread to read, as search\_threads names it. |
| `before` | `string` | No | Read messages older than this one. Pass the "before" value the previous page ended with. |
| `limit` | `number` | No | How many messages to read. Defaults to 40, at most 100. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***

### search

`threads.search`

Search a project's past conversation threads

**Risk:** `read`

```ts theme={null}
await corsair.magicpatterns.api.threads.search({ osId: 'Z3ZDUguQKLKB1rTvrQsQry', query: 'delivery estimate', conversation: 'checkout-redesign' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `osId` | `string` | Yes | The id of the project to run against. |
| `query` | `string` | No | A few distinctive words to find. Omit to list the most recent threads. |
| `limit` | `number` | No | How many threads to return. Defaults to 5, at most 20. |
| `conversation` | `string` | No | A short name for this conversation, which you choose once and pass unchanged on every call in it: a chat id, or any two random words. Without it every conversation you run on this project counts as one writer, so another window's files are treated as yours. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `text` | `string \| null` | No | The tool's text reply. Picture and design links are in here. |
| `images` | `object[] \| null` | No | Pictures the tool attached, without their bytes; the text gives each one's URL. |

> [accordion] images full type
>
> ```ts theme={null}
> {
>   mimeType?: string | null,
>   byteLength?: number | null
> }[] | null
> ```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.