Persist an agent conversation turn
curl --request POST \
--url https://api.orbit.devotel.io/api/v1/agents/{id}/conversations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"conversation_id": "conv_9f3c1a2b",
"messages": [
{
"role": "user",
"content": "Where is my order?"
},
{
"role": "assistant",
"content": "Your order shipped this morning and arrives tomorrow."
}
],
"tokens_used": 412,
"channel": "whatsapp"
}
'import requests
url = "https://api.orbit.devotel.io/api/v1/agents/{id}/conversations"
payload = {
"conversation_id": "conv_9f3c1a2b",
"messages": [
{
"role": "user",
"content": "Where is my order?"
},
{
"role": "assistant",
"content": "Your order shipped this morning and arrives tomorrow."
}
],
"tokens_used": 412,
"channel": "whatsapp"
}
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({
conversation_id: 'conv_9f3c1a2b',
messages: [
{role: 'user', content: 'Where is my order?'},
{
role: 'assistant',
content: 'Your order shipped this morning and arrives tomorrow.'
}
],
tokens_used: 412,
channel: 'whatsapp'
})
};
fetch('https://api.orbit.devotel.io/api/v1/agents/{id}/conversations', 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.orbit.devotel.io/api/v1/agents/{id}/conversations",
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([
'conversation_id' => 'conv_9f3c1a2b',
'messages' => [
[
'role' => 'user',
'content' => 'Where is my order?'
],
[
'role' => 'assistant',
'content' => 'Your order shipped this morning and arrives tomorrow.'
]
],
'tokens_used' => 412,
'channel' => 'whatsapp'
]),
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.orbit.devotel.io/api/v1/agents/{id}/conversations"
payload := strings.NewReader("{\n \"conversation_id\": \"conv_9f3c1a2b\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Where is my order?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Your order shipped this morning and arrives tomorrow.\"\n }\n ],\n \"tokens_used\": 412,\n \"channel\": \"whatsapp\"\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.orbit.devotel.io/api/v1/agents/{id}/conversations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"conversation_id\": \"conv_9f3c1a2b\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Where is my order?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Your order shipped this morning and arrives tomorrow.\"\n }\n ],\n \"tokens_used\": 412,\n \"channel\": \"whatsapp\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orbit.devotel.io/api/v1/agents/{id}/conversations")
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 \"conversation_id\": \"conv_9f3c1a2b\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Where is my order?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Your order shipped this morning and arrives tomorrow.\"\n }\n ],\n \"tokens_used\": 412,\n \"channel\": \"whatsapp\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"persisted": true,
"conversation_id": "<string>"
},
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"docs_url": "<string>"
}
}Agents
Persist an agent conversation turn
Service-to-service callback used by the agent runtime to persist a completed chat conversation and its latest turn — messages, tokens used, and optional per-turn debug data — to the tenant’s conversation history. When the turn tripped an escalation trigger, pass escalated: true with a reason to fire the configured human-handoff action. Authenticated with an internal service token, not a public API key.
POST
/
api
/
v1
/
agents
/
{id}
/
conversations
Persist an agent conversation turn
curl --request POST \
--url https://api.orbit.devotel.io/api/v1/agents/{id}/conversations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"conversation_id": "conv_9f3c1a2b",
"messages": [
{
"role": "user",
"content": "Where is my order?"
},
{
"role": "assistant",
"content": "Your order shipped this morning and arrives tomorrow."
}
],
"tokens_used": 412,
"channel": "whatsapp"
}
'import requests
url = "https://api.orbit.devotel.io/api/v1/agents/{id}/conversations"
payload = {
"conversation_id": "conv_9f3c1a2b",
"messages": [
{
"role": "user",
"content": "Where is my order?"
},
{
"role": "assistant",
"content": "Your order shipped this morning and arrives tomorrow."
}
],
"tokens_used": 412,
"channel": "whatsapp"
}
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({
conversation_id: 'conv_9f3c1a2b',
messages: [
{role: 'user', content: 'Where is my order?'},
{
role: 'assistant',
content: 'Your order shipped this morning and arrives tomorrow.'
}
],
tokens_used: 412,
channel: 'whatsapp'
})
};
fetch('https://api.orbit.devotel.io/api/v1/agents/{id}/conversations', 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.orbit.devotel.io/api/v1/agents/{id}/conversations",
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([
'conversation_id' => 'conv_9f3c1a2b',
'messages' => [
[
'role' => 'user',
'content' => 'Where is my order?'
],
[
'role' => 'assistant',
'content' => 'Your order shipped this morning and arrives tomorrow.'
]
],
'tokens_used' => 412,
'channel' => 'whatsapp'
]),
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.orbit.devotel.io/api/v1/agents/{id}/conversations"
payload := strings.NewReader("{\n \"conversation_id\": \"conv_9f3c1a2b\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Where is my order?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Your order shipped this morning and arrives tomorrow.\"\n }\n ],\n \"tokens_used\": 412,\n \"channel\": \"whatsapp\"\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.orbit.devotel.io/api/v1/agents/{id}/conversations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"conversation_id\": \"conv_9f3c1a2b\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Where is my order?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Your order shipped this morning and arrives tomorrow.\"\n }\n ],\n \"tokens_used\": 412,\n \"channel\": \"whatsapp\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orbit.devotel.io/api/v1/agents/{id}/conversations")
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 \"conversation_id\": \"conv_9f3c1a2b\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Where is my order?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Your order shipped this morning and arrives tomorrow.\"\n }\n ],\n \"tokens_used\": 412,\n \"channel\": \"whatsapp\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"persisted": true,
"conversation_id": "<string>"
},
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"docs_url": "<string>"
}
}Authorizations
BearerApiKey
Dashboard JWT token from Clerk
Path Parameters
Identifier of the agent that handled the conversation.
Body
application/json
Stable identifier for the conversation being persisted.
Ordered message log for the conversation.
Show child attributes
Show child attributes
Required range:
x >= 0Channel the conversation ran on (defaults to "api").
Set true when the turn tripped an escalation trigger.
⌘I