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

# Update a message (API key)

> Replace the blocks of any message your bot sent. No time limit.

Rewrite a bot message after the `response_url` has expired. The update always **replaces the whole block list**: there is no merge and no partial patch, so send the full message again each time.

## Authorization

**Authorization** `string` *required*

`Bearer mac_live_…`

## Path parameters

**message\_id** `string` *required*

A message sent by the bot your key belongs to. Get it from the `message_id` in a send response, or from [Read history](https://docs.my-aichatbot.com/api-reference/get-messages.md).

## Body

`application/json`. Exactly **one** message, in any [Block Kit shape](https://docs.my-aichatbot.com/block-kit/overview.md#shortcuts) we accept.

**blocks** `array` *required*

The new block list, 1 to 25 blocks. Blocks you leave out are removed.

## Response

**ok** `boolean`

`true` on success.

**message\_id** `string`

The message you updated.

```bash curl theme={null}
curl -X PATCH "https://app.my-aichatbot.com/api/v1/messages/$MESSAGE_ID" \
  -H "Authorization: Bearer $MAC_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "blocks": [{ "type": "status", "state": "success", "label": "Done" }] }'
```

```javascript Node.js theme={null}
await fetch(`https://app.my-aichatbot.com/api/v1/messages/${messageId}`, {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${process.env.MAC_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    blocks: [{ type: 'status', state: 'success', label: 'Done' }]
  })
})
```

```python Python theme={null}
import os, requests

requests.patch(
    f"https://app.my-aichatbot.com/api/v1/messages/{message_id}",
    headers={"Authorization": f"Bearer {os.environ['MAC_KEY']}"},
    json={"blocks": [{"type": "status", "state": "success", "label": "Done"}]},
)
```

```json 200 OK theme={null}
{ "ok": true, "message_id": "0f8c…" }
```

```json 403 Not a bot message theme={null}
{
  "ok": false,
  "error": { "code": "not_bot_authored", "message": "Only bot messages are updatable." }
}
```

## Rules

| Rule | Detail |
| - | - |
| Bot messages only | Editing a visitor or operator message returns `403 not_bot_authored`. |
| 60 updates per message | Update number 61 returns `429 UPDATE_LIMIT_REACHED`. |
| Full replacement | Blocks you leave out are removed. Send everything again. |
| Checked every time | Each update runs the full Block Kit checks. |
| Frozen after takeover | `409 conversation_taken_over`. |

## Errors

| Status | Code | Meaning |
| - | - | - |
| `400` | `AMBIGUOUS_UPDATE_TARGET` | The body held more than one message. |
| `401` | `invalid_api_key` | Missing, broken, or revoked. |
| `403` | `not_bot_authored` | The target is not a bot message. |
| `404` | `message_not_found` | Unknown message, or it belongs to another bot. |
| `409` | `conversation_taken_over` | A person took over. |
| `422` | `BLOCK_VALIDATION_FAILED` | Bad Block Kit. The `issues` list shows each problem. |
| `429` | `rate_limited` | Over 120 writes per minute for this key. Wait for `retry_after` seconds. |
| `429` | `UPDATE_LIMIT_REACHED` | Past 60 updates on this message. |
| `500` | `PERSIST_FAILED` | We could not store the update. Safe to retry. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.