# Send a message with an attachment

> POST https://api.nabrah.ai/api/ext/omni_v2/conversation/conversation/{id}/messages_with_attachment

Group: Conversations. Page: https://www.nabrah.ai/en/docs/api-reference/conversations/send-a-message-with-an-attachment

Sends a message into the conversation with a file attachment. Unlike the plain `messages` endpoint, this variant uses `application/x-www-form-urlencoded` (form fields) rather than a JSON body, so the message text and message options are submitted as form parameters alongside the attachment reference. Returns the same created-message object shape as the JSON send endpoint, including the resulting `attachments` array. Use this when a reply needs to include an image, document, or other file.

## Form-encoded request

This endpoint does not accept JSON.

- **Content-Type**: Submit the body as `application/x-www-form-urlencoded`. The message fields (such as content and message type) are sent as form fields rather than a JSON object, together with the attachment payload.
- **When to use it**: Use this endpoint whenever the outgoing message carries a file. For text-only messages, internal notes, or templated content, use the JSON `POST.../{id}/messages` endpoint instead.

Because the content type is form-urlencoded, the Try-it panel does not show a JSON body variant for this operation.

## Instagram and TikTok reply windows

Outgoing messages on Instagram and TikTok conversations are only delivered inside the platform's reply window.

- **409 reply_window_closed**: Returned when the window has closed: 24 hours after the customer's last message on Instagram, 48 hours on TikTok. Private notes are not affected. On Instagram, team members replying from the platform can still reply for up to 7 days; API sends cannot.
- **Not delivered**: If the platform refuses a message after it was accepted, a private note starting with "Not delivered" is added to the conversation.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Path parameters

- `id` (integer, required): Integer id of the conversation to post the message into. From a list endpoint or `GET.../conversation/{id}`.

## Body (application/x-www-form-urlencoded)

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "content": "string",
  "content_attributes": {},
  "content_type": "string",
  "conversation_id": 0,
  "created_at": 0,
  "echo_id": "string",
  "id": 0,
  "inbox_id": 0,
  "message_type": 0,
  "private": false,
  "sender": {
    "id": 0,
    "name": "string",
    "available_name": "string",
    "avatar_url": "string",
    "type": "string"
  },
  "source_id": "string",
  "status": "string",
  "attachments": [
    {
      "id": 0,
      "account_id": 0,
      "message_id": 0,
      "thumb_url": "string",
      "data_url": "string",
      "file_size": 0,
      "file_type": "string",
      "extension": "string",
      "width": 0,
      "height": 0,
      "created_at": 0,
      "sender": {
        "id": 0,
        "name": "string",
        "available_name": "string",
        "avatar_url": "string",
        "type": "string",
        "availability_status": "string",
        "thumbnail": "string",
        "additional_attributes": {},
        "custom_attributes": {},
        "email": "string",
        "identifier": "string",
        "phone_number": "string",
        "blocked": false
      },
      "coordinates_lat": 0,
      "coordinates_lng": 0,
      "fallback_title": "string",
      "meta": {}
    }
  ]
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request POST \
  --url 'https://api.nabrah.ai/api/ext/omni_v2/conversation/conversation/<id>/messages_with_attachment' \
  --header 'X-API-Key: <your-api-key>'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/omni_v2/conversation/conversation/<id>/messages_with_attachment"
headers = {"X-API-Key": "<your-api-key>"}

response = requests.post(url, headers=headers)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const form = new FormData();

const response = await fetch("https://api.nabrah.ai/api/ext/omni_v2/conversation/conversation/<id>/messages_with_attachment", {
  method: "POST",
  headers: { "X-API-Key": "<your-api-key>" },
  body: form,
});

const data = await response.json();
console.log(data);
```

### Go

```go
// Send multipart/form-data with mime/multipart:
// POST https://api.nabrah.ai/api/ext/omni_v2/conversation/conversation/<id>/messages_with_attachment
```
