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

# Send an application message or receive a channel event

POST https://app.logicdialog.ai/channels/messages
Content-Type: application/json

For application messaging use channel=api in the query and a ChannelApiToken from a deployed Channels API client. The body channel is a customer channel allowed for that client, such as email. Supply a unique id per message; retry the identical payload with the same id. A reused id with changed input or pending previous delivery returns 409. Omit conversationId to start a new conversation; include the returned ID to continue, keeping the same customerId and channel. Replies are asynchronous and arrive at the configured signed webhook. The JSON example documents API messaging; other transports use adapter-specific payloads.

Reference: https://api.logicdialog.ai/api-reference/messaging-and-history/post-channels-messages

## Authentication

- `Authorization` header (bearer token, required) — Token for one deployed API client, configured in Project → Channels.
- `Authorization` header (bearer token, required) — Short-lived widget session capability
- `X-Twilio-Signature` header (required) — API Key authentication via header

## Request

### Query parameters

- `channel` (string, required, default: api) — Ingress transport. Use api for application integrations. Other public transports are widget and twilio; their payloads and credentials differ.
- `workspaceId` (string, required) — Workspace identifier; required for API clients.
- `environment` (enum, required, default: live) — API messaging currently supports Live.
  - Allowed values: `live`
- `integrationId` (string, required) — Enabled API client identifier from Channels.

### Body (application/json)

This endpoint expects a Messaging and history_post_channels_messages_Request.

- `id` (string, required)
- `text` (string, required)
- `customerId` (string, required)
- `channel` (string, required)
- `conversationId` (string, optional)
- `subject` (string, optional)

## Response

### 200

Twilio SMS durably queued; empty TwiML acknowledgement.

### 202

Accepted; returns the LogicDialog conversationId

- `accepted` (true, required)
- `conversationId` (string, required)

## Errors

### 400 Bad Request Error

Invalid channel payload.

- `any`

### 401 Unauthorized Error

Invalid API client credentials

- `any`

### 403 Forbidden Error

Channel not enabled for this client

- `any`

### 409 Conflict Error

Pending message or reused message ID with different content

- `any`

### 415 Unsupported Media Type Error

Unsupported content type.

- `any`

### 422 Unprocessable Entity Error

Unsupported message content, including MMS attachments.

- `any`

### 429 Too Many Requests Error

Rate or pending message limit exceeded.

- `any`

## Examples

**Request**

```json
{
  "id": "message-001",
  "text": "What are your opening hours?",
  "customerId": "customer-42",
  "channel": "email"
}
```

**Response**

```json
{
  "accepted": true,
  "conversationId": "conv_example"
}
```

**SDK Code**

```python Messaging and history_post_channels_messages_example (application/json)
import requests

url = "https://app.logicdialog.ai/channels/messages"

payload = {
    "id": "message-001",
    "text": "What are your opening hours?",
    "customerId": "customer-42",
    "channel": "email"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Messaging and history_post_channels_messages_example (application/json)
const url = 'https://app.logicdialog.ai/channels/messages';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"id":"message-001","text":"What are your opening hours?","customerId":"customer-42","channel":"email"}'
};

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

```go Messaging and history_post_channels_messages_example (application/json)
package main

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

func main() {

	url := "https://app.logicdialog.ai/channels/messages"

	payload := strings.NewReader("{\n  \"id\": \"message-001\",\n  \"text\": \"What are your opening hours?\",\n  \"customerId\": \"customer-42\",\n  \"channel\": \"email\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Messaging and history_post_channels_messages_example (application/json)
require 'uri'
require 'net/http'

url = URI("https://app.logicdialog.ai/channels/messages")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"id\": \"message-001\",\n  \"text\": \"What are your opening hours?\",\n  \"customerId\": \"customer-42\",\n  \"channel\": \"email\"\n}"

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

```java Messaging and history_post_channels_messages_example (application/json)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.logicdialog.ai/channels/messages")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"id\": \"message-001\",\n  \"text\": \"What are your opening hours?\",\n  \"customerId\": \"customer-42\",\n  \"channel\": \"email\"\n}")
  .asString();
```

```php Messaging and history_post_channels_messages_example (application/json)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.logicdialog.ai/channels/messages', [
  'body' => '{
  "id": "message-001",
  "text": "What are your opening hours?",
  "customerId": "customer-42",
  "channel": "email"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Messaging and history_post_channels_messages_example (application/json)
using RestSharp;

var client = new RestClient("https://app.logicdialog.ai/channels/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"id\": \"message-001\",\n  \"text\": \"What are your opening hours?\",\n  \"customerId\": \"customer-42\",\n  \"channel\": \"email\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Messaging and history_post_channels_messages_example (application/json)
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "id": "message-001",
  "text": "What are your opening hours?",
  "customerId": "customer-42",
  "channel": "email"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.logicdialog.ai/channels/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()
```