Create Chat Message
curl --request POST \
--url https://api.talqing.com/v1/chats/{chat_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"client_message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"files": [
{
"data_url": "<string>",
"filename": "<string>"
}
],
"message": "",
"stream": false
}
'import requests
url = "https://api.talqing.com/v1/chats/{chat_id}/messages"
payload = {
"client_message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"files": [
{
"data_url": "<string>",
"filename": "<string>"
}
],
"message": "",
"stream": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
client_message_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
files: [{data_url: '<string>', filename: '<string>'}],
message: '',
stream: false
})
};
fetch('https://api.talqing.com/v1/chats/{chat_id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.talqing.com/v1/chats/{chat_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'client_message_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'files' => [
[
'data_url' => '<string>',
'filename' => '<string>'
]
],
'message' => '',
'stream' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.talqing.com/v1/chats/{chat_id}/messages"
payload := strings.NewReader("{\n \"client_message_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"files\": [\n {\n \"data_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"message\": \"\",\n \"stream\": false\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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.talqing.com/v1/chats/{chat_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"client_message_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"files\": [\n {\n \"data_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"message\": \"\",\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.talqing.com/v1/chats/{chat_id}/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 \"client_message_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"files\": [\n {\n \"data_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"message\": \"\",\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body{
"chat_status": "open",
"error": "<string>",
"input": {
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_version": 123,
"attachments": [
{
"bytes": 123,
"height": 123,
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"mime_type": "<string>",
"url": "<string>",
"url_expires_at": "2023-11-07T05:31:56Z",
"width": 123,
"filename": "<string>",
"kind": "image"
}
],
"attachments_not_kept": [
{
"reason": "<string>"
}
],
"author": {
"id": "<string>",
"name": "<string>"
},
"channel": "phone_call",
"client_message_id": "<string>",
"content": {
"button": {
"text": "<string>",
"payload": "<string>"
},
"kind": "button",
"replied_to": "<string>"
},
"conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"delivery_error": {
"code": "<string>",
"message": "<string>"
},
"delivery_status": "not_applicable",
"direction": "inbound",
"elapsed": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"idempotency_key": "<string>",
"latency": {
"kind": "response",
"stages": [
{
"kind": "stt",
"label": "<string>",
"ms": 123
}
],
"total_ms": 123
},
"metadata": {},
"metrics": {
"e2e_latency": 123,
"end_of_turn_delay": 123,
"llm_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"llm_node_ttft": 123,
"llm_tokens_per_second": 123,
"on_user_turn_completed_delay": 123,
"started_speaking_at": 123,
"stopped_speaking_at": 123,
"stt_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"transcription_delay": 123,
"tts_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"tts_node_ttfb": 123
},
"origin": "speech",
"post_type": "template",
"provider_message_id": "<string>",
"raw_payload": {},
"role": "developer",
"scope": "conversation",
"session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"text": "<string>",
"trigger_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"turn_error": "<string>",
"turn_status": "running",
"type": "message",
"updated_at": "2023-11-07T05:31:56Z",
"visibility": "customer_visible"
},
"items": [
{
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_version": 123,
"attachments": [
{
"bytes": 123,
"height": 123,
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"mime_type": "<string>",
"url": "<string>",
"url_expires_at": "2023-11-07T05:31:56Z",
"width": 123,
"filename": "<string>",
"kind": "image"
}
],
"attachments_not_kept": [
{
"reason": "<string>"
}
],
"author": {
"id": "<string>",
"name": "<string>"
},
"channel": "phone_call",
"client_message_id": "<string>",
"content": {
"button": {
"text": "<string>",
"payload": "<string>"
},
"kind": "button",
"replied_to": "<string>"
},
"conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"delivery_error": {
"code": "<string>",
"message": "<string>"
},
"delivery_status": "not_applicable",
"direction": "inbound",
"elapsed": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"idempotency_key": "<string>",
"latency": {
"kind": "response",
"stages": [
{
"kind": "stt",
"label": "<string>",
"ms": 123
}
],
"total_ms": 123
},
"metadata": {},
"metrics": {
"e2e_latency": 123,
"end_of_turn_delay": 123,
"llm_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"llm_node_ttft": 123,
"llm_tokens_per_second": 123,
"on_user_turn_completed_delay": 123,
"started_speaking_at": 123,
"stopped_speaking_at": 123,
"stt_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"transcription_delay": 123,
"tts_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"tts_node_ttfb": 123
},
"origin": "speech",
"post_type": "template",
"provider_message_id": "<string>",
"raw_payload": {},
"role": "developer",
"scope": "conversation",
"session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"text": "<string>",
"trigger_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"turn_error": "<string>",
"turn_status": "running",
"type": "message",
"updated_at": "2023-11-07T05:31:56Z",
"visibility": "customer_visible"
}
],
"status": "running",
"superseded_by_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}chats
Create Chat Message
Send a message and get the agent’s reply back on this request.
A newer message supersedes one still being answered: the older request
returns status: canceled with superseded_by_item_id.
POST
/
v1
/
chats
/
{chat_id}
/
messages
Create Chat Message
curl --request POST \
--url https://api.talqing.com/v1/chats/{chat_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"client_message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"files": [
{
"data_url": "<string>",
"filename": "<string>"
}
],
"message": "",
"stream": false
}
'import requests
url = "https://api.talqing.com/v1/chats/{chat_id}/messages"
payload = {
"client_message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"files": [
{
"data_url": "<string>",
"filename": "<string>"
}
],
"message": "",
"stream": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
client_message_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
files: [{data_url: '<string>', filename: '<string>'}],
message: '',
stream: false
})
};
fetch('https://api.talqing.com/v1/chats/{chat_id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.talqing.com/v1/chats/{chat_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'client_message_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'files' => [
[
'data_url' => '<string>',
'filename' => '<string>'
]
],
'message' => '',
'stream' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.talqing.com/v1/chats/{chat_id}/messages"
payload := strings.NewReader("{\n \"client_message_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"files\": [\n {\n \"data_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"message\": \"\",\n \"stream\": false\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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.talqing.com/v1/chats/{chat_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"client_message_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"files\": [\n {\n \"data_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"message\": \"\",\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.talqing.com/v1/chats/{chat_id}/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 \"client_message_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"files\": [\n {\n \"data_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"message\": \"\",\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body{
"chat_status": "open",
"error": "<string>",
"input": {
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_version": 123,
"attachments": [
{
"bytes": 123,
"height": 123,
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"mime_type": "<string>",
"url": "<string>",
"url_expires_at": "2023-11-07T05:31:56Z",
"width": 123,
"filename": "<string>",
"kind": "image"
}
],
"attachments_not_kept": [
{
"reason": "<string>"
}
],
"author": {
"id": "<string>",
"name": "<string>"
},
"channel": "phone_call",
"client_message_id": "<string>",
"content": {
"button": {
"text": "<string>",
"payload": "<string>"
},
"kind": "button",
"replied_to": "<string>"
},
"conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"delivery_error": {
"code": "<string>",
"message": "<string>"
},
"delivery_status": "not_applicable",
"direction": "inbound",
"elapsed": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"idempotency_key": "<string>",
"latency": {
"kind": "response",
"stages": [
{
"kind": "stt",
"label": "<string>",
"ms": 123
}
],
"total_ms": 123
},
"metadata": {},
"metrics": {
"e2e_latency": 123,
"end_of_turn_delay": 123,
"llm_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"llm_node_ttft": 123,
"llm_tokens_per_second": 123,
"on_user_turn_completed_delay": 123,
"started_speaking_at": 123,
"stopped_speaking_at": 123,
"stt_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"transcription_delay": 123,
"tts_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"tts_node_ttfb": 123
},
"origin": "speech",
"post_type": "template",
"provider_message_id": "<string>",
"raw_payload": {},
"role": "developer",
"scope": "conversation",
"session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"text": "<string>",
"trigger_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"turn_error": "<string>",
"turn_status": "running",
"type": "message",
"updated_at": "2023-11-07T05:31:56Z",
"visibility": "customer_visible"
},
"items": [
{
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_version": 123,
"attachments": [
{
"bytes": 123,
"height": 123,
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"mime_type": "<string>",
"url": "<string>",
"url_expires_at": "2023-11-07T05:31:56Z",
"width": 123,
"filename": "<string>",
"kind": "image"
}
],
"attachments_not_kept": [
{
"reason": "<string>"
}
],
"author": {
"id": "<string>",
"name": "<string>"
},
"channel": "phone_call",
"client_message_id": "<string>",
"content": {
"button": {
"text": "<string>",
"payload": "<string>"
},
"kind": "button",
"replied_to": "<string>"
},
"conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"delivery_error": {
"code": "<string>",
"message": "<string>"
},
"delivery_status": "not_applicable",
"direction": "inbound",
"elapsed": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"idempotency_key": "<string>",
"latency": {
"kind": "response",
"stages": [
{
"kind": "stt",
"label": "<string>",
"ms": 123
}
],
"total_ms": 123
},
"metadata": {},
"metrics": {
"e2e_latency": 123,
"end_of_turn_delay": 123,
"llm_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"llm_node_ttft": 123,
"llm_tokens_per_second": 123,
"on_user_turn_completed_delay": 123,
"started_speaking_at": 123,
"stopped_speaking_at": 123,
"stt_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"transcription_delay": 123,
"tts_metadata": {
"model_name": "<string>",
"model_provider": "<string>"
},
"tts_node_ttfb": 123
},
"origin": "speech",
"post_type": "template",
"provider_message_id": "<string>",
"raw_payload": {},
"role": "developer",
"scope": "conversation",
"session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"text": "<string>",
"trigger_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"turn_error": "<string>",
"turn_status": "running",
"type": "message",
"updated_at": "2023-11-07T05:31:56Z",
"visibility": "customer_visible"
}
],
"status": "running",
"superseded_by_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}{
"detail": {
"errors": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
}Authorizations
BearerAuthSessionCookie
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
application/json
One message: what was typed, what was attached, or both.
Response
The turn. With stream: true, a text/event-stream of assistant.* and item.created frames ending in one turn.result.
What one message led to: the agent's reply, and where the chat stands.
Available options:
open, ended Show child attributes
Show child attributes
Show child attributes
Show child attributes
Available options:
running, done, error, canceled