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

# Update Email Blocks

> Replace an email body or mutate an existing block type.

# Update Email Blocks

You can replace an email body with raw HTML or structured blocks. You can also mutate an existing block between `text` and `html`.

## Request

<ParamField path="emailId" type="string" required>
  Email ID.
</ParamField>

<ParamField body="html" type="string">
  Raw HTML body. Replaces all blocks with a native HTML body.
</ParamField>

<ParamField body="blocks" type="array">
  Structured email blocks. Replaces all existing blocks. Put block styling under
  `styles`; top-level style keys like `backgroundColor`, `backgroundOpacity`,
  `borderColor`, `borderWidth`, and `borderRadius` are normalized into `styles`.
</ParamField>

<ParamField body="blockId" type="string">
  Existing block ID to mutate.
</ParamField>

<ParamField body="type" type="string">
  New block type. Type mutation supports `text` and `html`.
</ParamField>

<ParamField body="content" type="string">
  Optional replacement content for the mutated block.
</ParamField>

```bash theme={null}
curl -X PATCH "https://api.sequenzy.com/api/v1/emails/email_123/blocks" \
  -H "Authorization: Bearer API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"blockId":"legacy-block","type":"html"}'
```

## Responses

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "email": {
      "id": "email_123",
      "companyId": "company_123",
      "name": "Welcome",
      "subject": "Welcome",
      "previewText": null,
      "blocks": [{ "id": "legacy-block", "type": "html", "content": "<table>...</table>" }],
      "createdAt": "2026-04-19T12:00:00.000Z",
      "updatedAt": "2026-04-19T12:05:00.000Z"
    }
  }
  ```

  ```json 400 theme={null}
  {
    "success": false,
    "error": "Provide blockId to mutate a block or content to replace the body."
  }
  ```

  ```json 401 theme={null}
  {
    "success": false,
    "error": "Missing API key. Provide via x-api-key header or Authorization: Bearer <key>"
  }
  ```

  ```json 403 theme={null}
  { "success": false, "error": "No company selected" }
  ```

  ```json 404 theme={null}
  { "success": false, "error": "Block not found" }
  ```

  ```json 500 theme={null}
  { "success": false, "error": "Internal server error" }
  ```
</ResponseExample>
