Skip to main content
POST
/
v2
/
pattern
Create a new design (V2)
curl --request POST \
  --url https://api.magicpatterns.com/api/v2/pattern \
  --header 'Content-Type: multipart/form-data' \
  --header 'x-mp-api-key: <api-key>' \
  --form 'prompt=Create a login page' \
  --form mode=fast \
  --form designSystemId=ds-9b80b54e-92b3-4b2f-8265-afe466ee8b75 \
  --form modelSelector=auto \
  --form 'images=<string>' \
  --form images.items='@example-file'
{
  "id": "abc123",
  "sourceFiles": [
    {
      "id": "<string>",
      "name": "<string>",
      "code": "<string>",
      "type": "javascript"
    }
  ],
  "compiledFiles": [
    {
      "id": "<string>",
      "fileName": "<string>",
      "hostedUrl": "<string>",
      "type": "javascript"
    }
  ],
  "editorUrl": "https://www.magicpatterns.com/c/abc123",
  "previewUrl": "https://abc123-preview.magicpatterns.app",
  "chatMessages": [
    {
      "role": "assistant",
      "content": "I will create a login page with a centered layout."
    }
  ]
}

Authorizations

x-mp-api-key
string
header
required

Body

multipart/form-data
prompt
string
required

The prompt for the new design.

Example:

"Create a login page"

mode
enum<string>
default:fast

The mode to use for the new design, either 'fast' for quicker generation or 'best' for higher quality. Defaults to 'fast'.

Available options:
fast,
best
Example:

"fast"

designSystemId
string

UUID of the design system to use. If nothing is provided, our base design system will be used. Otherwise you can use this to specify your own design system ID.

Example:

"ds-9b80b54e-92b3-4b2f-8265-afe466ee8b75"

modelSelector
enum<string>
default:auto

The model to use for generation. Defaults to 'auto'.

Available options:
auto,
claude_sonnet,
gemini
Example:

"auto"

images
file[]

Optional images to inspire or guide the design creation. Maximum file size is 5MB per image.

Response

Successfully created a new design.

id
string

The unique ID of the created design.

Example:

"abc123"

sourceFiles
object[]

The source files for the design.

compiledFiles
object[]

The compiled/processed files for the design.

editorUrl
string

URL to access the editor interface.

Example:

"https://www.magicpatterns.com/c/abc123"

previewUrl
string

URL to preview the generated design.

Example:

"https://abc123-preview.magicpatterns.app"

chatMessages
object[]

The conversation history for this design.