---
title: "Send Message"
url: "https://docs.yoagent.dev/reference/rest-api/operations/sendmessage"
---

# Send Message

POST

/v0/inboxes/{inbox_id}/messages/send

```sh
curl -s -X POST "https://api.yoagent.dev/v0/inboxes/inb_01je56wqswfmn9pgbc1wq8tjgq/messages/send" \
  -H "Authorization: Bearer $YOAGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Hello from a test.","to":["test@k7m2xq4p.yoagent.email"]}'
```

```js
const response = await fetch("https://api.yoagent.dev/v0/inboxes/inb_01je56wqswfmn9pgbc1wq8tjgq/messages/send", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.YOAGENT_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "text": "Hello from a test.",
    "to": [
      "test@k7m2xq4p.yoagent.email"
    ]
  }),
});
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/inboxes/inb_01je56wqswfmn9pgbc1wq8tjgq/messages/send",
    headers={"Authorization": f"Bearer {os.environ['YOAGENT_KEY']}"},
    json={
        "text": "Hello from a test.",
        "to": [
            "test@k7m2xq4p.yoagent.email",
        ],
    },
    timeout=60,
)
response.raise_for_status()
data = response.json()
```

- api.yoagent.dev/v0/inboxes/{inbox_id}/messages/send

Send a message from an inbox, in a new thread (`message_send` there); delivery goes on after the answer. A catch-all inbox cannot send.

## Authorizations

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

## Parameters

### Path Parameters

**inbox_id**

required

_Inbox Id_

Inbox id (inb\_…), address or \*@domain (the catch-all)

string

### Header Parameters

**Idempotency-Key**

_Idempotency-Key_

string

\>= 1 characters <= 255 characters

Send at most once: the same key with the same request answers the message sent before

## Request Body required

application/json

_MessageSend_

A new message from an inbox (a new thread).

object

**text**

_Text_

The plain-text body.

Any of:

**string**

string

<= 10485760 characters

**null**

null

**html**

_Html_

The HTML body.

Any of:

**string**

string

<= 10485760 characters

**null**

null

**labels**

_Labels_

Labels of the sent copy (system labels are refused).

Array\<string>

default: <= 20 items

**attachments**

_Attachments_

Files to attach.

Array\<object>

default: <= 50 items

_AttachmentIn_

A file to attach, its bytes in base64.

object

**filename**

_Filename_

The file’s name, as the recipient sees it.

Any of:

**string**

string

\>= 1 characters <= 998 characters

**null**

null

**content_type**

_Content Type_

Its media type.

string

default: application/octet-stream <= 255 characters /^\[a-z0-9!#$&^\_.+-]+/\[a-z0-9!#$&^\_.+-]+$/

**content_disposition**

_Content Disposition_

`attachment`: a file of the message; `inline`: shown in its HTML (`content_id`).

string

default: attachment

Allowed values: attachment inline

**content_id**

_Content Id_

For `inline`: the id the HTML names it by (`cid:<content_id>`).

Any of:

**string**

string

\>= 1 characters <= 998 characters

**null**

null

**content**

required

_Content_

The file’s bytes, in base64.

string format: base64

**to**

_To_

The recipients in `To`.

Array\<string>

default: <= 50 items

**cc**

_Cc_

The recipients in `Cc`.

Array\<string>

default: <= 50 items

**bcc**

_Bcc_

The recipients in `Bcc`: in no header.

Array\<string>

default: <= 50 items

**reply_to**

_Reply To_

Where replies go (`Reply-To`); omitted: to the inbox.

Array\<string>

default: <= 10 items

**subject**

_Subject_

The subject.

Any of:

**string**

string

\>= 1 characters <= 998 characters

**null**

null

## Responses

### 200

Successful Response

application/json

_MessageSent_

A sent message: its copy in the inbox and its thread. Delivery goes on after the answer (`message.sent`, `message.delivered` and the rest).

object

**message_id**

required

_Message Id_

string

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

**thread_id**

required

_Thread Id_

string

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

#### Example

```json
{
  "message_id": "msg_01je56wqswfmn9pgbc1wq8tjgq",
  "thread_id": "thr_01je56wqswfmn9pgbc1wq8tjgq"
}
```

### 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).
