Create an AI agent
curl --request POST \
--url https://api.chatling.ai/v3/agents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Support agent",
"business_name": "Acme",
"timezone": "America/Toronto",
"ai": {
"instructions": "Answer questions about orders and shipping. Keep replies short.",
"knowledge_base_only": true
}
}
'import requests
url = "https://api.chatling.ai/v3/agents"
payload = {
"name": "Support agent",
"business_name": "Acme",
"timezone": "America/Toronto",
"ai": {
"instructions": "Answer questions about orders and shipping. Keep replies short.",
"knowledge_base_only": True
}
}
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({
name: 'Support agent',
business_name: 'Acme',
timezone: 'America/Toronto',
ai: {
instructions: 'Answer questions about orders and shipping. Keep replies short.',
knowledge_base_only: true
}
})
};
fetch('https://api.chatling.ai/v3/agents', 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.chatling.ai/v3/agents",
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([
'name' => 'Support agent',
'business_name' => 'Acme',
'timezone' => 'America/Toronto',
'ai' => [
'instructions' => 'Answer questions about orders and shipping. Keep replies short.',
'knowledge_base_only' => true
]
]),
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.chatling.ai/v3/agents"
payload := strings.NewReader("{\n \"name\": \"Support agent\",\n \"business_name\": \"Acme\",\n \"timezone\": \"America/Toronto\",\n \"ai\": {\n \"instructions\": \"Answer questions about orders and shipping. Keep replies short.\",\n \"knowledge_base_only\": true\n }\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.chatling.ai/v3/agents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Support agent\",\n \"business_name\": \"Acme\",\n \"timezone\": \"America/Toronto\",\n \"ai\": {\n \"instructions\": \"Answer questions about orders and shipping. Keep replies short.\",\n \"knowledge_base_only\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatling.ai/v3/agents")
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 \"name\": \"Support agent\",\n \"business_name\": \"Acme\",\n \"timezone\": \"America/Toronto\",\n \"ai\": {\n \"instructions\": \"Answer questions about orders and shipping. Keep replies short.\",\n \"knowledge_base_only\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"object": "agent",
"id": "3132353852",
"type": "ai_agent",
"name": "Support agent",
"status": "active",
"business_name": "Acme",
"timezone": "America/Toronto",
"created_at": "2023-11-07T05:31:56Z",
"ai": {
"model": "gpt-6-luna",
"instructions": "<string>",
"internal_language": "en",
"temperature": 123,
"knowledge_base_only": true,
"attachments": {
"enabled": true,
"allow_images": true,
"max_per_message": 2
}
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The API key is invalid or has been revoked.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "permission_error",
"code": "agent_limit_reached",
"message": "Your plan's limit on agents and chatbots has been reached.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}Agents
Create an AI agent
Available for AI agents only.
For chatbots, use Create a chatbot.
The agent counts toward the plan’s limit on AI agents and chatbots. Keys limited to selected agents can’t use this endpoint.
POST
/
agents
Create an AI agent
curl --request POST \
--url https://api.chatling.ai/v3/agents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Support agent",
"business_name": "Acme",
"timezone": "America/Toronto",
"ai": {
"instructions": "Answer questions about orders and shipping. Keep replies short.",
"knowledge_base_only": true
}
}
'import requests
url = "https://api.chatling.ai/v3/agents"
payload = {
"name": "Support agent",
"business_name": "Acme",
"timezone": "America/Toronto",
"ai": {
"instructions": "Answer questions about orders and shipping. Keep replies short.",
"knowledge_base_only": True
}
}
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({
name: 'Support agent',
business_name: 'Acme',
timezone: 'America/Toronto',
ai: {
instructions: 'Answer questions about orders and shipping. Keep replies short.',
knowledge_base_only: true
}
})
};
fetch('https://api.chatling.ai/v3/agents', 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.chatling.ai/v3/agents",
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([
'name' => 'Support agent',
'business_name' => 'Acme',
'timezone' => 'America/Toronto',
'ai' => [
'instructions' => 'Answer questions about orders and shipping. Keep replies short.',
'knowledge_base_only' => true
]
]),
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.chatling.ai/v3/agents"
payload := strings.NewReader("{\n \"name\": \"Support agent\",\n \"business_name\": \"Acme\",\n \"timezone\": \"America/Toronto\",\n \"ai\": {\n \"instructions\": \"Answer questions about orders and shipping. Keep replies short.\",\n \"knowledge_base_only\": true\n }\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.chatling.ai/v3/agents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Support agent\",\n \"business_name\": \"Acme\",\n \"timezone\": \"America/Toronto\",\n \"ai\": {\n \"instructions\": \"Answer questions about orders and shipping. Keep replies short.\",\n \"knowledge_base_only\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatling.ai/v3/agents")
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 \"name\": \"Support agent\",\n \"business_name\": \"Acme\",\n \"timezone\": \"America/Toronto\",\n \"ai\": {\n \"instructions\": \"Answer questions about orders and shipping. Keep replies short.\",\n \"knowledge_base_only\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"object": "agent",
"id": "3132353852",
"type": "ai_agent",
"name": "Support agent",
"status": "active",
"business_name": "Acme",
"timezone": "America/Toronto",
"created_at": "2023-11-07T05:31:56Z",
"ai": {
"model": "gpt-6-luna",
"instructions": "<string>",
"internal_language": "en",
"temperature": 123,
"knowledge_base_only": true,
"attachments": {
"enabled": true,
"allow_images": true,
"max_per_message": 2
}
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The API key is invalid or has been revoked.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "permission_error",
"code": "agent_limit_reached",
"message": "Your plan's limit on agents and chatbots has been reached.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}Headers
Body
application/json
Unknown parameters, including inside ai, return 422.
Response
The new agent.