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

# Send Message

> Send a text message to a lead

## Endpoint

<Card>
  <strong>POST</strong> `/backend/messages/send`
</Card>

## Body Parameters

<ParamField body="lead_id" type="string" required>
  Recipient lead ID
</ParamField>

<ParamField body="content" type="string" required>
  Message content
</ParamField>

<ParamField body="type" type="string" default="text">
  Message type: `text`
</ParamField>

## Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.leavo.ai/backend/messages/send" \
    -H "Authorization: Bearer your_api_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "lead_id": "lead-uuid",
      "content": "Hello! How can I help you today?",
      "type": "text"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.leavo.ai/backend/messages/send', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      lead_id: 'lead-uuid',
      content: 'Hello! How can I help you today?',
      type: 'text'
    })
  });
  ```

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

  response = requests.post(
      'https://api.leavo.ai/backend/messages/send',
      headers={
          'Authorization': 'Bearer your_api_key_here',
          'Content-Type': 'application/json'
      },
      json={
          'lead_id': 'lead-uuid',
          'content': 'Hello! How can I help you today?',
          'type': 'text'
      }
  )
  ```
</CodeGroup>

## Response

```json theme={null}
{
  "success": true,
  "data": {
    "id": "message-uuid",
    "lead_id": "lead-uuid",
    "content": "Hello! How can I help you today?",
    "type": "text",
    "role": "assistant",
    "status": "pending",
    "timestamp": "2024-01-15T10:30:00Z"
  }
}
```

## Possible Errors

| Code            | Description                           |
| --------------- | ------------------------------------- |
| `NOT_FOUND`     | Lead not found                        |
| `INVALID_PHONE` | Lead has no valid phone               |
| `CHANNEL_ERROR` | Error connecting to messaging channel |
