> ## 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.

# Update a component

> Update a component's name and/or LMX body. Body changes cascade to every email using the component.

When the `lmx` body changes, the update cascades to every email using this component, and `affectedEmailCount` reports how many were affected. A change that would introduce a dynamic variable an email using the component cannot use is rejected.


## OpenAPI

````yaml /openapi.json post /v1/components/{componentId}
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.0
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: Components
    description: View email components
  - name: Configuration
    description: View configuration settings
  - name: Contacts
    description: Manage contacts in your audience
  - name: Contact properties
    description: Manage contact properties
  - 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
paths:
  /v1/components/{componentId}:
    parameters:
      - name: componentId
        in: path
        required: true
        description: The ID of the component.
        schema:
          type: string
    post:
      tags:
        - Components
      summary: Update a component
      description: >-
        Update a component's name and/or body. When the `lmx` body changes, the
        update cascades to every email using this component, and
        `affectedEmailCount` reports how many were affected. A change that would
        introduce a dynamic variable an email using the component cannot use is
        rejected.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateComponentBody'
      responses:
        '200':
          description: Successful.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateComponentResponse'
        '400':
          description: Invalid `componentId` or request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentFailureResponse'
        '401':
          description: Invalid API key or content API not enabled for this team.
        '404':
          description: Component not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentFailureResponse'
        '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, or a body change that would break emails using the
            component.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentValidationFailureResponse'
      security:
        - apiKey: []
components:
  schemas:
    UpdateComponentBody:
      type: object
      description: At least one of `name` or `lmx` must be provided.
      properties:
        name:
          type: string
        lmx:
          type: string
          description: The component body as an LMX string.
    UpdateComponentResponse:
      allOf:
        - $ref: '#/components/schemas/ComponentResponse'
        - type: object
          properties:
            affectedEmailCount:
              type: number
              description: >-
                The number of emails using this component that were updated by
                the body change. `0` when only the name changed.
          required:
            - affectedEmailCount
    ComponentFailureResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
    ComponentValidationFailureResponse:
      type: object
      properties:
        message:
          type: string
        invalidTags:
          type: array
          description: >-
            The dynamic variables that the change would push into an email that
            cannot use them. Present only when the update was rejected for that
            reason.
          items:
            type: string
      required:
        - message
    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
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

## Related topics

- [API Introduction](/docs/api-reference/intro.md)
- [Components](/docs/creating-emails/components.md)
- [Uploading a custom email](/docs/creating-emails/uploading-custom-email.md)
- [Get a component](/docs/api-reference/get-component.md)
