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

# Create a component

> Create a new email component from an LMX body.



## OpenAPI

````yaml https://app.loops.so/openapi.json post /v1/components
openapi: 3.1.0
info:
  title: Loops OpenAPI Spec
  description: This is the OpenAPI Spec for the [Loops API](https://loops.so/docs/api).
  version: 1.21.3
servers:
  - url: https://app.loops.so/api
security: []
tags:
  - name: API key
  - name: Audience segments
    description: View audience segments
  - name: Campaigns
    description: Create and manage email campaigns
  - name: Campaign groups
    description: Organize campaigns into groups
  - name: Configuration
    description: View configuration settings
  - name: Contacts
    description: Manage contacts in your audience
  - name: Contact properties
    description: Manage contact properties
  - name: Components
    description: View email components
  - name: Email messages
    description: Manage email message content for campaigns
  - name: Events
    description: Trigger workflows with events
  - name: Event patterns
    description: View workflow event patterns
  - name: Mailing lists
    description: View mailing lists
  - name: Themes
    description: View email themes
  - name: Transactional emails
    description: Create, manage, and send transactional emails
  - name: Transactional groups
    description: Organize transactional emails into groups
  - name: Uploads
    description: Upload image assets
  - name: Workflows
    description: View and mutate workflow graphs
  - name: Workflow nodes
    description: View and mutate workflow nodes
  - name: Webhooks
    description: >-
      Events Loops sends to your configured webhook endpoint when certain events
      happen in your account. Configure an endpoint in Settings → Webhooks. Each
      account supports one webhook endpoint. Events are signed with
      `webhook-id`, `webhook-timestamp`, and `webhook-signature` headers and
      delivered at a maximum rate of 10 per second. See
      https://loops.so/docs/webhooks for setup, verification, and payload
      details.
paths:
  /v1/components:
    post:
      tags:
        - Components
      summary: Create a component
      description: Create a new email component from an LMX body.
      operationId: createComponent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateComponentBody'
      responses:
        '201':
          description: Component created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentResponse'
        '400':
          description: Invalid request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentFailureResponse'
        '401':
          description: Invalid API key or content API not enabled for this team.
        '405':
          description: Wrong HTTP request method.
        '413':
          description: LMX body exceeds the size limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentFailureResponse'
        '422':
          description: Invalid LMX.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentFailureResponse'
      security:
        - apiKey: []
components:
  schemas:
    CreateComponentBody:
      type: object
      properties:
        name:
          type: string
          description: The component name.
        lmx:
          type: string
          description: The component body as an LMX string.
      required:
        - name
        - lmx
      examples:
        - name: Header
          lmx: <Paragraph>Welcome to Acme</Paragraph>
    ComponentResponse:
      type: object
      properties:
        id:
          type: string
          description: The ID of the component.
        name:
          type: string
          description: The name of the component.
        lmx:
          type: string
          description: The component body serialized as LMX.
      required:
        - id
        - name
        - lmx
      examples:
        - id: clp2o4i6u8y0t5r3e1w7q9s1
          name: Header
          lmx: <Paragraph>Welcome to Acme</Paragraph>
    ComponentFailureResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      examples:
        - message: Component not found.
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

## Related topics

- [Components](/docs/creating-emails/components.md)
- [API Introduction](/docs/api-reference/intro.md)
- [Get a component](/docs/api-reference/get-component.md)
- [Update a component](/docs/api-reference/update-component.md)
