# Add a ticket message

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

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

Adds a new message to the ticket identified by path `id` and returns the created message object (id, content, sender, type, timestamps). Provide the text in the `message` field. The message is posted into the ticket conversation as a reply on the underlying channel where applicable.

## Request

- **message**: The text content of the message to add to the ticket. Fields: `message`.

## Response

Returns the created message with its server-assigned `id`, `message_type`, `sender`, and `created_at` (Unix epoch seconds).

## 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 (application/json)

### Example: Add message

Post a reply/message into the ticket conversation.

```json
{
  "message": "Thanks for reaching out! We've issued your refund and you should see it within 3-5 business days."
}
```

## 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"
}
```

### 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' \
  --header 'X-API-Key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "message": "Thanks for reaching out! We'\''ve issued your refund and you should see it within 3-5 business days."
}'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/omni_v2/ticket/<id>/messages"
headers = {
    "X-API-Key": "<your-api-key>",
}
payload = {
    "message": "Thanks for reaching out! We've issued your refund and you should see it within 3-5 business days."
}

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

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/omni_v2/ticket/<id>/messages", {
  method: "POST",
  headers: {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "message": "Thanks for reaching out! We've issued your refund and you should see it within 3-5 business days."
  }),
});

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

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "message": "Thanks for reaching out! We've issued your refund and you should see it within 3-5 business days."
}`)

	req, _ := http.NewRequest("POST", "https://api.nabrah.ai/api/ext/omni_v2/ticket/<id>/messages", payload)
	req.Header.Set("X-API-Key", "<your-api-key>")
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
