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

# Create a new design (V2)

> **Deprecated — use [POST /v3/designs](/api/create-design) instead.**

Creates a new design based on the provided prompt and optional images. This version supports custom design systems. v2 remains online for backwards compatibility with existing integrations and will be removed in a future release. The same API key works against both v2 and v3.




## OpenAPI

````yaml post /v2/pattern
openapi: 3.0.3
info:
  title: Magic Patterns API
  version: 1.0.4
  description: >-
    Provides an API for creating or modifying user interfaces using the Magic
    Patterns system.
servers:
  - url: https://api.magicpatterns.com/api
security:
  - ApiKeyAuth: []
paths:
  /v2/pattern:
    post:
      tags:
        - Patterns
      summary: Create a new design (V2)
      description: >
        **Deprecated — use [POST /v3/designs](/api/create-design) instead.**


        Creates a new design based on the provided prompt and optional images.
        This version supports custom design systems. v2 remains online for
        backwards compatibility with existing integrations and will be removed
        in a future release. The same API key works against both v2 and v3.
      operationId: createNewPatternV2
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - prompt
              properties:
                mode:
                  type: string
                  enum:
                    - fast
                    - best
                  description: >-
                    The mode to use for the new design, either 'fast' for
                    quicker generation or 'best' for higher quality. Defaults to
                    'fast'.
                  default: fast
                  example: fast
                prompt:
                  type: string
                  description: The prompt for the new design.
                  example: Create a login page
                designSystemId:
                  type: string
                  description: >-
                    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:
                  type: string
                  enum:
                    - auto
                    - claude_sonnet
                    - gemini
                  description: The model to use for generation. Defaults to 'auto'.
                  default: auto
                  example: auto
                images:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: >-
                    Optional images to inspire or guide the design creation.
                    Maximum file size is 5MB per image.
      responses:
        '200':
          description: Successfully created a new design.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: The unique ID of the created design.
                    example: abc123
                  sourceFiles:
                    type: array
                    description: The source files for the design.
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Unique identifier for the source file
                        name:
                          type: string
                          description: Name of the source file
                        code:
                          type: string
                          description: The actual source code content
                        type:
                          type: string
                          enum:
                            - javascript
                            - css
                            - asset
                          description: The type of source file
                  compiledFiles:
                    type: array
                    description: The compiled/processed files for the design.
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Unique identifier for the compiled file
                        fileName:
                          type: string
                          description: Name of the compiled file
                        hostedUrl:
                          type: string
                          description: URL where the compiled file is hosted
                        type:
                          type: string
                          enum:
                            - javascript
                            - css
                            - font
                          description: The type of compiled file
                  editorUrl:
                    type: string
                    description: URL to access the editor interface.
                    example: https://www.magicpatterns.com/c/abc123
                  previewUrl:
                    type: string
                    description: URL to preview the generated design.
                    example: https://abc123-preview.magicpatterns.app
                  chatMessages:
                    type: array
                    description: The conversation history for this design.
                    items:
                      type: object
                      properties:
                        role:
                          type: string
                          description: >-
                            The role of the message sender (e.g. user,
                            assistant).
                          example: assistant
                        content:
                          type: string
                          description: The content of the message.
                          example: I will create a login page with a centered layout.
        '400':
          description: Bad request due to invalid customId or other input values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized request due to missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Payment required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error during pattern creation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      deprecated: true
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: Details about the error encountered.
          example: Invalid API key.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-mp-api-key

````