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

# Send Message

> Send an SMS, email, or WhatsApp message to a lead from one of your agents

Send a message to a lead on behalf of an agent, just as you would from the app. Provide the message content or omit `body` to have the agent generate it based on the lead's context and outstanding requests.

Messages are sent immediately and appear on the lead's timeline. They bypass approval requirements and working-hour restrictions, but respect channel opt-outs.

## Authentication

Requires the `x-api-key` header with a valid workspace API key.

## Path Parameters

**leadId** `string` *required*

The unique identifier of the lead

## Request Body

**agentId** `string` *required*

The agent sending the message. The message is sent from this agent's email
address or phone number.

**channel** `enum` *required*

`SMS`, `EMAIL`, or `WHATSAPP`

**body** `string`

The message text. For `SMS` and `EMAIL`, leave it out to have the agent write
the message based on what it still needs from the lead. This requires the
agent to be collecting a checklist from the lead. For `WHATSAPP`, send either
`body` or `templateId`.

**subject** `string`

`EMAIL` only. Required when you send `body` for a new thread. When the agent
writes the message, it writes the subject too unless you send one. Not
accepted with `inReplyToMessageId` or `replyToLatestThread`, since a reply
keeps its thread's subject.

**inReplyToMessageId** `string`

`EMAIL` only. The ID of an email in this lead's conversation with the agent,
sent or received. The message is sent as a reply on that email's thread.

**replyToLatestThread** `boolean`

`EMAIL` only. Set to `true` to reply on the most recent email thread between
the agent and the lead, without needing a message ID. Returns a `404` if there
is no email thread yet. Can't be combined with `inReplyToMessageId`. Without
either field, the email starts a new thread.

**templateId** `string`

`WHATSAPP` only. The Twilio content template SID (`HX...`) of an approved
template. Its variables are filled in from the lead and agent.

**templateParams** `object`

`WHATSAPP` only, with `templateId`. Values for template variables that can't
be filled in from the lead or agent, keyed by variable name (e.g.
`{ "LEAD_NAME": "Jordan" }` for a lead with no first name). The variables are
`AGENT_NAME`, `COMPANY_NAME`, `LEAD_NAME`, and `PORTAL_LINK`.

## Response

**success** `boolean`

Whether the message was sent

**message** `object`

**properties**

**id** `string`

ID of the message

**channel** `enum`

Channel the message was sent on

**lifecycle** `enum`

Status of the message (e.g. `SENT`)

**body** `string`

The message that was sent. For email this includes the agent's signature

**subject** `string | null`

The email subject, or `null` for other channels

```bash SMS theme={null}
curl --request POST \
  --url https://api-v2.getomni.ai/api/v1/leads/a9d0a790-201b-47e9-84ed-cc7eed1270c5/messages \
  --header 'x-api-key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "agentId": "3f1c2b7e-8d4a-4c6f-9e2b-1a5d7c9e0f12",
    "channel": "SMS",
    "body": "Hi Jordan, just following up on your application."
  }'
```

```bash Email theme={null}
curl --request POST \
  --url https://api-v2.getomni.ai/api/v1/leads/a9d0a790-201b-47e9-84ed-cc7eed1270c5/messages \
  --header 'x-api-key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "agentId": "3f1c2b7e-8d4a-4c6f-9e2b-1a5d7c9e0f12",
    "channel": "EMAIL",
    "subject": "Your application",
    "body": "Hi Jordan,\n\nJust following up on your application."
  }'
```

```bash AI-written SMS theme={null}
curl --request POST \
  --url https://api-v2.getomni.ai/api/v1/leads/a9d0a790-201b-47e9-84ed-cc7eed1270c5/messages \
  --header 'x-api-key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "agentId": "3f1c2b7e-8d4a-4c6f-9e2b-1a5d7c9e0f12",
    "channel": "SMS"
  }'
```

```bash WhatsApp template theme={null}
curl --request POST \
  --url https://api-v2.getomni.ai/api/v1/leads/a9d0a790-201b-47e9-84ed-cc7eed1270c5/messages \
  --header 'x-api-key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "agentId": "3f1c2b7e-8d4a-4c6f-9e2b-1a5d7c9e0f12",
    "channel": "WHATSAPP",
    "templateId": "HXb5b62575e6e4ff6129ad7c8efe1f983e"
  }'
```

```javascript Node.js theme={null}
const options = {
  method: "POST",
  headers: {
    "x-api-key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    agentId: "3f1c2b7e-8d4a-4c6f-9e2b-1a5d7c9e0f12",
    channel: "SMS",
    body: "Hi Jordan, just following up on your application.",
  }),
};

fetch(
  "https://api-v2.getomni.ai/api/v1/leads/a9d0a790-201b-47e9-84ed-cc7eed1270c5/messages",
  options,
)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));
```

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

url = "https://api-v2.getomni.ai/api/v1/leads/a9d0a790-201b-47e9-84ed-cc7eed1270c5/messages"
headers = {
    "x-api-key": "<your-api-key>",
    "Content-Type": "application/json",
}
payload = {
    "agentId": "3f1c2b7e-8d4a-4c6f-9e2b-1a5d7c9e0f12",
    "channel": "SMS",
    "body": "Hi Jordan, just following up on your application.",
}

response = requests.request("POST", url, json=payload, headers=headers)
print(response.json())
```

```json 200 theme={null}
{
  "success": true,
  "message": {
    "id": "7c2e9f41-5b8d-4a3e-b6f0-2d1c8e7a9b54",
    "channel": "SMS",
    "lifecycle": "SENT",
    "body": "Hi Jordan, just following up on your application.",
    "subject": null
  }
}
```

```json 400 theme={null}
{
  "success": false,
  "error": "channel is required"
}
```


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