---
title: "Update a block"
method: PUT
path: "/blocks/{id}"
tags: ["Blocks"]
---

# Update a block

`PUT /blocks/{id}`

## Request

- Base URL: `https://api5.optimove.net/content/v1`
- URL: `https://api5.optimove.net/content/v1/blocks/{id}`
- Auth: API key in header `X-API-KEY`

Replaces a block. Send every field: optional fields that are left out are reset to their defaults.
Only the tenant that created a block can update it.

## Request body

- BlockRequest
  - `tagName` string, required: Tag name that templates use to reference the block. Must be unique.
  - `name` string, required: Display name of the block. Must be unique among the tenant's blocks.
  - `folderId` string, uuid, nullable: Folder to put the block in. Leave it out for the root folder. Must be an existing folder.
  - `description` string, nullable: Free-text description of the block.
  - `html` string, required: HTML content of the block. Can contain Liquid personalization tags.
  - `plaintext` string, required: Plain-text version of the content. Stored exactly as sent. The API doesn't generate it from the HTML, `autoGeneratePlainText` takes effect only in UI.
  - `editorData` string, nullable: Editor state as a serialized string. Required when `isSavedRow` is `true`.
  - `editorType` 'html' | 'visual', required: Editor the content is built with: - `html`: HTML code editor - `visual`: drag-and-drop editor
  - `autoGeneratePlainText` boolean: UI only. Whether the Optimove UI generates the plain text from the HTML when the block is edited there. **The API never generates plain text.** It stores `plaintext` exactly as sent, whatever this value is.
  - `isSavedRow` boolean: Whether the block is available as a saved row in the visual editor. Allowed only when `editorType` is `visual` and `editorData` is set.
  - `code` TemplateCode: Custom code of the block.
    - `header` string, nullable: Reusable Liquid assignments that the block's content can use. Shown as the Workbench in the Optimove UI.

## Response `200`

The updated block.

- BlockResponse
  - `id` string, uuid, required
  - `tagName` string, required
  - `name` string, required
  - `folderId` string, uuid, nullable
  - `description` string, nullable
  - `html` string, required
  - `plaintext` string, required
  - `editorData` string, nullable
  - `editorType` 'html' | 'visual', required: Editor the content is built with: - `html`: HTML code editor - `visual`: drag-and-drop editor
  - `autoGeneratePlainText` boolean, required: UI only. Whether the Optimove UI generates the plain text from the HTML when the block is edited there. The API never generates plain text: `plaintext` is returned exactly as it was stored.
  - `isSavedRow` boolean, required
  - `code` TemplateCode: Custom code of the block.
    - `header` string, nullable: Reusable Liquid assignments that the block's content can use. Shown as the Workbench in the Optimove UI.
  - `createdAt` string, date-time, required
  - `createdBy` string, required: Name of the API key or user that created the block.
  - `updatedAt` string, date-time, required
  - `updatedBy` string, required: Name of the API key or user that last updated the block.

## Other responses

- `400`: The request is malformed or fails validation.
- `401`: The `X-API-KEY` header is missing or the API key is not valid.
- `403`: The API key doesn't have the admin role, or the tenant isn't allowed to change this item.
- `404`: The block doesn't exist.
- `409`: Another block already has the same name or tag name.
- `422`: The content can't be saved (see the create operation), or templates use the block. In the second case, `data` lists those templates.
- `429`: The tenant's rate limit is reached. Retry after the time in `x-ratelimit-reset`.
- `500`: Unexpected server error.

---

[API](https://skmtc.dev/optimove/apis/content-api.md) - [All operations](https://skmtc.dev/optimove/apis/content-api/llms.txt) - [OpenAPI document](https://skmtc.dev/optimove/apis/content-api/revisions/2f4f55f36f0e?raw)
