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

<Info>
  At least one of `name` or `lmx` must be provided.
</Info>

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.

## Request

### Path parameters

<ParamField path="componentId" type="string" required>
  The ID of the component.
</ParamField>

### Body

<ParamField body="name" type="string">
  The component name.
</ParamField>

<ParamField body="lmx" type="string">
  The component body as an [LMX](/creating-emails/lmx) string.
</ParamField>

## Response

### Success

<ResponseField name="id" type="string" required>
  The component ID.
</ResponseField>

<ResponseField name="name" type="string" required>
  The component name.
</ResponseField>

<ResponseField name="lmx" type="string" required>
  The component body serialized as LMX.
</ResponseField>

<ResponseField name="affectedEmailCount" type="number" required>
  The number of emails using this component that were updated by the body
  change. `0` when only the name changed.
</ResponseField>

### Error

If the request body is invalid, a `400 Bad Request` is returned.

A `404 Not Found` is returned if the component does not exist.

If the API key is invalid (or content API is not enabled for your team), a
`401 Unauthorized` is returned.

A `413 Payload Too Large` is returned when the LMX body exceeds the size limit.

A `422 Unprocessable Entity` is returned when the LMX is invalid, or when a body
change would break emails using the component. When the update is rejected
because a change would push unsupported dynamic variables into an email, the
response may include an `invalidTags` array listing those variables.

<ResponseField name="message" type="string" required>
  An error message describing what went wrong.
</ResponseField>

<ResponseField name="invalidTags" type="string[]">
  Dynamic variables that the change would push into an email that cannot use
  them. Present only when the update was rejected for that reason.
</ResponseField>

<ResponseExample>
  ```json Response theme={"dark"}
  {
    "id": "cmn5ziajr01oztzlifwarda8m",
    "name": "Hero header",
    "lmx": "<Section><H2>Welcome back</H2></Section>",
    "affectedEmailCount": 4
  }
  ```

  ```json Error response theme={"dark"}
  {
    "message": "This change would introduce unsupported variables in one or more emails.",
    "invalidTags": ["eventName"]
  }
  ```
</ResponseExample>
