---
title: "Update Messages"
url: "https://docs.yoagent.dev/reference/rest-api/operations/updatemessages"
---

# Update Messages

POST

/v0/messages/update

```sh
curl -s -X POST "https://api.yoagent.dev/v0/messages/update" \
  -H "Authorization: Bearer $YOAGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"add_labels":["unread"],"message_ids":["msg_01je56wqswfmn9pgbc1wq8tjgq"]}'
```

```js
const response = await fetch("https://api.yoagent.dev/v0/messages/update", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.YOAGENT_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "add_labels": [
      "unread"
    ],
    "message_ids": [
      "msg_01je56wqswfmn9pgbc1wq8tjgq"
    ]
  }),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
```

```python
import os

import requests

response = requests.post(
    "https://api.yoagent.dev/v0/messages/update",
    headers={"Authorization": f"Bearer {os.environ['YOAGENT_KEY']}"},
    json={
        "add_labels": [
            "unread",
        ],
        "message_ids": [
            "msg_01je56wqswfmn9pgbc1wq8tjgq",
        ],
    },
    timeout=60,
)
response.raise_for_status()
data = response.json()
```

- api.yoagent.dev/v0/messages/update

Add or remove labels of messages (up to 200; read is removing `unread`): all of them or none — one the caller does not see is 404, one it may not change 403. The changed messages as list rows.

## Authorizations

- **[ApiKey](https://docs.yoagent.dev/reference/rest-api#apikey)**

## Request Body required

application/json

_MessagesUpdate_

Add or remove labels of messages (read is removing `unread`): all of them or none.

object

**add_labels**

_Add Labels_

Labels to add: `unread` or the project’s own.

Array\<string>

default: <= 20 items

**remove_labels**

_Remove Labels_

Labels to remove: `unread` (marks it read) or the project’s own.

Array\<string>

default: <= 20 items

**message_ids**

required

_Message Ids_

The messages to change.

Array\<string>

\>= 1 items <= 200 items

## Responses

### 200

Successful Response

application/json

_MessageBatch_

The messages a batch changed, as list rows (their labels and `version` after it).

object

**messages**

required

_Messages_

Array\<object>

_MessageItem_

A message in a list: no bodies.

object

**version**

required

_Version_

Goes up by one on every change: of two copies, the one with the higher version is the newer.

integer

**message_id**

required

_Message Id_

string

/^msg\_\[0-7]\[0-9a-hjkmnp-tv-z]{25}$/

**project_id**

required

_Project Id_

string

/^prj\_\[0-7]\[0-9a-hjkmnp-tv-z]{25}$/

**inbox_id**

required

_Inbox Id_

string

/^inb\_\[0-7]\[0-9a-hjkmnp-tv-z]{25}$/

**thread_id**

required

_Thread Id_

string

/^thr\_\[0-7]\[0-9a-hjkmnp-tv-z]{25}$/

**envelope_to**

required

_Envelope To_

The address the message came to; null for a message the inbox sent (`sent`).

Any of:

**string**

string

**null**

null

**envelope_from**

required

_Envelope From_

string

**plus_tag**

required

_Plus Tag_

Any of:

**string**

string

**null**

null

**from**

required

_From_

Array\<object>

_Party_

A name and address from a header.

object

**name**

required

_Name_

string

**address**

required

_Address_

string

**to**

required

_To_

Array\<object>

_Party_

A name and address from a header.

object

**name**

required

_Name_

string

**address**

required

_Address_

string

**subject**

required

_Subject_

Any of:

**string**

string

**null**

null

**preview**

required

_Preview_

Any of:

**string**

string

**null**

null

**labels**

required

_Labels_

Array\<string>

**size**

required

_Size_

integer

**received_at**

required

_Received At_

string format: date-time

#### Example

```json
{
  "messages": [
    {
      "version": 1,
      "message_id": "msg_01je56wqswfmn9pgbc1wq8tjgq",
      "project_id": "prj_01je56wqswfmn9pgbc1wq8tjgq",
      "inbox_id": "inb_01je56wqswfmn9pgbc1wq8tjgq",
      "thread_id": "thr_01je56wqswfmn9pgbc1wq8tjgq",
      "envelope_to": "test@k7m2xq4p.yoagent.email",
      "envelope_from": "bounce@example.com",
      "plus_tag": null,
      "from": [
        {
          "name": "Example App",
          "address": "noreply@example.com"
        }
      ],
      "to": [
        {
          "name": "",
          "address": "test@k7m2xq4p.yoagent.email"
        }
      ],
      "subject": "Your sign-in code",
      "preview": "Your sign-in code is 482913.",
      "labels": [
        "received",
        "unread"
      ],
      "size": 66000,
      "received_at": "2026-12-01T12:00:00Z"
    }
  ]
}
```

### default

An error (400, 401, 403, 404, 405, 409, 413, 429, 500, 503), in the one shape every call answers: [Errors](https://docs.yoagent.dev/reference/conventions#errors).
