# Edit a conversation message (https://notert.io/docs/api/reference/edit-a-conversation-message)

`PATCH /api/v1/conversations/{id}/messages/{messageId}`

Replaces the text of a reply or internal note the token's holder sent, or takes its files off, or both, as the inbox's edit does. The customer reads an edited reply in the conversation, but an email already sent keeps what it said, and a note keeps mentioning a teammate whose @name it still writes. Only the holder's own messages can be changed. A file named that isn't on it is UNKNOWN_FILES, and nothing changes. Answers whether it changed and how many files it took off.

Access: A token with conversations:write.

## Path parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The conversation's id. At most 64 characters. |
| `messageId` | string | Yes | The reply or note, by its id. At most 64 characters. |

## Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `body` | string | No | Its new text, replacing it whole. Left out, its text stays. At most 5000 characters. |
| `removeAttachmentIds` | string[] | No | Files to take off it, pictures or documents, by the attachmentId the thread answers for each. A message left with no text and no file is NO_CONTENT. Default []. |

## Response 200

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | The conversation's id. |
| `messageId` | string | The message's id. |
| `edited` | boolean | Whether its text changed; false when it already said this. |
| `removedAttachments` | integer | How many files it took off. |

## Errors

| Status | Code | Message |
| --- | --- | --- |
| 400 | `BAD_REQUEST` | Input validation failed. |
| 400 | `NO_CONTENT` | A message needs some text unless it shares files. |
| 401 | `UNAUTHORIZED` | Send a valid API token as a Bearer token. |
| 403 | `HOLDER_NOT_ALLOWED` | The teammate who holds this API token's secret can't do this in the workspace now. A teammate who can should roll it in the workspace's settings. |
| 403 | `INSUFFICIENT_SCOPE` | This API token can't reply to or organize conversations. Create one that may in the workspace's settings. |
| 403 | `NETWORK_NOT_ALLOWED` | This API token works only from the networks it was made for. Call from one of them, or create a token for this one in the workspace's settings. |
| 403 | `NO_SEAT` | This workspace's plan has no seat for you. |
| 403 | `NOT_ALLOWED` | Only the teammate who sent a reply or note can change it, and the token's holder didn't send this one. |
| 403 | `WORKSPACE_SUSPENDED` | This workspace is suspended. |
| 404 | `NOT_FOUND` | Not Found. |
| 409 | `CHANGED_MEANWHILE` | Something changed meanwhile. Try again. |
| 409 | `UNKNOWN_FILES` | A file named to take off isn't on it, so nothing changed. If an earlier call took it off, that call's change stands; otherwise read it again for its files' ids. Its data holds `attachmentIds`. |
| 429 | `TOO_MANY_REQUESTS` | Too Many Requests. Its data holds `retryAfter`. |

## Example request

```sh
curl -X PATCH https://app.notert.io/api/v1/conversations/3b7e2a90-5c1d-4f8e-9a6b-1d2c3e4f5a60/messages/9c4d1e7a-2b3f-4a6c-8d5e-7f1a2b3c4d50 \
  -H "Authorization: Bearer $NOTERT_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "body": "You can export them from Billing, under Invoices and receipts.",
  "removeAttachmentIds": [
    "1f7c3a9e-5b2d-4e8a-9c6f-0d4b8e2a6c35"
  ]
}'
```

## Example response 200

```json
{
  "id": "3b7e2a90-5c1d-4f8e-9a6b-1d2c3e4f5a60",
  "messageId": "9c4d1e7a-2b3f-4a6c-8d5e-7f1a2b3c4d50",
  "edited": true,
  "removedAttachments": 1
}
```
