> This page is for Omni Channel.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.hams.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.hams.ai/_mcp/server.

# Reply in a conversation

POST https://omni-channel.hams.ai/api/v1/accounts/{account_id}/developer/conversations/{conversation_id}/messages
Content-Type: application/json

Adds a message or a private note to a conversation. This endpoint does not check the service window. For a reply to the customer, `POST /accounts/{account_id}/developer/messages` with `conversation_id` is better, because it checks the window first. The name of the key is the sender of the message. A request cannot set another sender.

Reference: https://docs.hams.ai/omni-channel/reference/conversations/create-conversation-message

## Authentication

- `api_access_token` header (required) — An API key that an administrator creates in **Settings** > **Developer**. The personal access token of a user does not work. A key reaches every inbox, conversation, and contact in the account that created it, and nothing in other accounts.

## Request

### Path parameters

- `account_id` (integer, required) — The id of your account. It is the number after `/accounts/` in the dashboard URL.
- `conversation_id` (integer, required) — The conversation number in the dashboard URL (`display_id`). It is not the internal `id` of the conversation.

### Body (application/json)

This endpoint expects an object.

- `content` (string, optional) — The text of the message.
- `private` (boolean, optional, default: false) — When `true`, the message is a private note. Agents see it, and the customer does not get it.
- `template_params` (TemplateParams, optional) — Sends an approved WhatsApp template instead of free text. A template is necessary to start a conversation on WhatsApp, or to send after the 24-hour service window closes. When this field is present, the API does not check the service window on any channel. Send it only on an inbox that has approved templates.

## Response

### 200

The message.

- `id` (integer, optional)
- `content` (string, optional, nullable)
- `inbox_id` (integer, optional)
- `conversation_id` (integer, optional) — The conversation number in the dashboard URL (`display_id`).
- `message_type` (integer, optional) — `0` for incoming, `1` for outgoing, `2` for activity, `3` for template.
- `content_type` (string, optional)
- `status` (string, optional)
- `content_attributes` (map from string to any, optional)
- `created_at` (integer, optional) — Unix timestamp, in seconds.
- `private` (boolean, optional)
- `source_id` (string, optional, nullable)
- `sender` (map from string to any, optional) — The sender. For a message that a key sends, `type` is `api_key` and `name` is the name of the key.

## Errors

### 401 Unauthorized Error

The token does not exist, is not an API key, or belongs to another account. The token can also be the token of a user who is not a member of the account, or the account can be suspended. The body has only the `error` field.

- `error` (string, required) — `Invalid Access Token`, `Key is not authorized to access this account`, `Access to this endpoint is not authorized for this token`, `You are not authorized to access this account`, or `Account is suspended`.

### 404 Not Found Error

The conversation or contact is not in this account. The body is `{"error": "Resource could not be found"}`.

- `error` (string, required)

### 422 Unprocessable Entity Error

The API cannot create the message. `error` gives the reason.

- `error` (string, required)

## Types

### TemplateParams

Sends an approved WhatsApp template instead of free text. A template is necessary to start a conversation on WhatsApp, or to send after the 24-hour service window closes. When this field is present, the API does not check the service window on any channel. Send it only on an inbox that has approved templates.

- `name` (string, required) — The name of the approved template.
- `language` (string, required) — The language code of the template, for example `en` or `en_US`. Send the code exactly as the template list in the dashboard shows it.
- `category` (string, optional) — The category of the template, for example `UTILITY` or `MARKETING`.
- `processed_params` (map from string to any, optional) — The values for the variables of the template. A WhatsApp Cloud positional template takes `{"body": {"1": "121212"}}`. A named template takes `{"body": {"order_id": "121212"}}`. `header`, `footer`, and `buttons` are also possible. A Twilio template takes a flat map, for example `{"1": "121212"}`.

## Examples

**Request**

```json
{
  "content": "The customer called about this too.",
  "private": true
}
```

**Response**

```json
{
  "id": 1,
  "content": "string",
  "inbox_id": 1,
  "conversation_id": 1,
  "message_type": 1,
  "content_type": "string",
  "status": "string",
  "content_attributes": {},
  "created_at": 1,
  "private": true,
  "source_id": "string",
  "sender": {}
}
```

**SDK Code**

```python Private note
import requests

url = "https://omni-channel.hams.ai/api/v1/accounts/1/developer/conversations/1/messages"

payload = {
    "content": "The customer called about this too.",
    "private": True
}
headers = {
    "api_access_token": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Private note
const url = 'https://omni-channel.hams.ai/api/v1/accounts/1/developer/conversations/1/messages';
const options = {
  method: 'POST',
  headers: {api_access_token: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"content":"The customer called about this too.","private":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Private note
package main

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

func main() {

	url := "https://omni-channel.hams.ai/api/v1/accounts/1/developer/conversations/1/messages"

	payload := strings.NewReader("{\n  \"content\": \"The customer called about this too.\",\n  \"private\": true\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("api_access_token", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Private note
require 'uri'
require 'net/http'

url = URI("https://omni-channel.hams.ai/api/v1/accounts/1/developer/conversations/1/messages")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api_access_token"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"content\": \"The customer called about this too.\",\n  \"private\": true\n}"

response = http.request(request)
puts response.read_body
```

```java Private note
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://omni-channel.hams.ai/api/v1/accounts/1/developer/conversations/1/messages")
  .header("api_access_token", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"content\": \"The customer called about this too.\",\n  \"private\": true\n}")
  .asString();
```

```php Private note
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://omni-channel.hams.ai/api/v1/accounts/1/developer/conversations/1/messages', [
  'body' => '{
  "content": "The customer called about this too.",
  "private": true
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'api_access_token' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Private note
using RestSharp;

var client = new RestClient("https://omni-channel.hams.ai/api/v1/accounts/1/developer/conversations/1/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("api_access_token", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"content\": \"The customer called about this too.\",\n  \"private\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Private note
import Foundation

let headers = [
  "api_access_token": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "content": "The customer called about this too.",
  "private": true
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://omni-channel.hams.ai/api/v1/accounts/1/developer/conversations/1/messages")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```