# Add a ticket message with attachments

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

Group: Tickets. Page: https://www.nabrah.ai/en/docs/api-reference/tickets/add-a-ticket-message-with-attachments

Adds a new message to the ticket identified by path `id` with one or more file attachments (images, PDFs, etc.), and returns the created message object including its `attachments`. Send the request as `multipart/form-data`: put the note text in the `content` field and each file in an `attachments` field (repeat the field to send several files in one message). The message is posted into the ticket conversation as an outgoing reply on the underlying channel where applicable. For text-only messages without files, use POST /api/ext/omni_v2/ticket/{id}/messages instead.

## Multipart form fields

Send the request as multipart/form-data (not JSON).

- **content**: The text content of the message. May be empty when only attachments are sent.
- **attachments**: One or more files to attach. Repeat the `attachments` field once per file to upload several files in a single message.

## Allowed files & limits

Uploads are restricted for security.

- **Allowed types**: Images (png, jpg, jpeg, gif, webp), pdf, xlsx, csv. SVG and executable/script files are rejected.
- **Size & count**: Up to 10 files per message, 10 MB per file.

Disallowed type → 415; oversized file → 413; too many files → 400.

## Response

Returns the created message with its server-assigned `id`, `message_type`, `sender`, `created_at` (Unix epoch seconds), and an `attachments` array — each entry with `data_url`, `thumb_url`, `file_type`, `file_size`, and `extension`.

## Authorization

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

## Path parameters

- `id` (integer, required): Numeric identifier of the ticket to add a message to. From GET /api/ext/omni_v2/ticket or the create-ticket response.

## Body (multipart/form-data)

## 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",
    "type": "string",
    "email": "string",
    "phone_number": "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"
    }
  ]
}
```

### 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/ticket/<id>/messages_with_attachment' \
  --header 'X-API-Key: <your-api-key>'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/omni_v2/ticket/<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/ticket/<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/ticket/<id>/messages_with_attachment
```
