Create a contact
curl --request POST \
--url https://api.chatling.ai/v3/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "3132353852",
"first_name": "Ada",
"last_name": "Lovelace",
"email": "[email protected]",
"company": "Analytical Engines"
}
'import requests
url = "https://api.chatling.ai/v3/contacts"
payload = {
"agent_id": "3132353852",
"first_name": "Ada",
"last_name": "Lovelace",
"email": "[email protected]",
"company": "Analytical Engines"
}
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({
agent_id: '3132353852',
first_name: 'Ada',
last_name: 'Lovelace',
email: '[email protected]',
company: 'Analytical Engines'
})
};
fetch('https://api.chatling.ai/v3/contacts', 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/contacts",
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([
'agent_id' => '3132353852',
'first_name' => 'Ada',
'last_name' => 'Lovelace',
'email' => '[email protected]',
'company' => 'Analytical Engines'
]),
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/contacts"
payload := strings.NewReader("{\n \"agent_id\": \"3132353852\",\n \"first_name\": \"Ada\",\n \"last_name\": \"Lovelace\",\n \"email\": \"[email protected]\",\n \"company\": \"Analytical Engines\"\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/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"3132353852\",\n \"first_name\": \"Ada\",\n \"last_name\": \"Lovelace\",\n \"email\": \"[email protected]\",\n \"company\": \"Analytical Engines\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatling.ai/v3/contacts")
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 \"agent_id\": \"3132353852\",\n \"first_name\": \"Ada\",\n \"last_name\": \"Lovelace\",\n \"email\": \"[email protected]\",\n \"company\": \"Analytical Engines\"\n}"
response = http.request(request)
puts response.read_body{
"object": "contact",
"id": "0f8fad5b-d9cb-469f-a165-70867728950e",
"agent": {
"id": "3132353852",
"type": "ai_agent",
"name": "Support agent"
},
"channel": "web",
"first_name": "<string>",
"last_name": "<string>",
"email": "<string>",
"phone": "<string>",
"job_title": "<string>",
"company": "<string>",
"website": "<string>",
"industry": "<string>",
"address": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"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": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "not_found_error",
"code": "resource_not_found",
"message": "No agent with this ID exists, or this API key can't access it.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "invalid_request_error",
"code": "contact_already_exists",
"message": "Another contact of this agent already has this email: 0f8fad5b-d9cb-469f-a165-70867728950e.",
"param": "email",
"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>"
}
]
}
}Contacts
Create a contact
Creates a contact for an agent, and runs the agent’s workflows that start when a contact is created. Each email can belong to only one of the agent’s contacts.
POST
/
contacts
Create a contact
curl --request POST \
--url https://api.chatling.ai/v3/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "3132353852",
"first_name": "Ada",
"last_name": "Lovelace",
"email": "[email protected]",
"company": "Analytical Engines"
}
'import requests
url = "https://api.chatling.ai/v3/contacts"
payload = {
"agent_id": "3132353852",
"first_name": "Ada",
"last_name": "Lovelace",
"email": "[email protected]",
"company": "Analytical Engines"
}
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({
agent_id: '3132353852',
first_name: 'Ada',
last_name: 'Lovelace',
email: '[email protected]',
company: 'Analytical Engines'
})
};
fetch('https://api.chatling.ai/v3/contacts', 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/contacts",
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([
'agent_id' => '3132353852',
'first_name' => 'Ada',
'last_name' => 'Lovelace',
'email' => '[email protected]',
'company' => 'Analytical Engines'
]),
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/contacts"
payload := strings.NewReader("{\n \"agent_id\": \"3132353852\",\n \"first_name\": \"Ada\",\n \"last_name\": \"Lovelace\",\n \"email\": \"[email protected]\",\n \"company\": \"Analytical Engines\"\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/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"3132353852\",\n \"first_name\": \"Ada\",\n \"last_name\": \"Lovelace\",\n \"email\": \"[email protected]\",\n \"company\": \"Analytical Engines\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatling.ai/v3/contacts")
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 \"agent_id\": \"3132353852\",\n \"first_name\": \"Ada\",\n \"last_name\": \"Lovelace\",\n \"email\": \"[email protected]\",\n \"company\": \"Analytical Engines\"\n}"
response = http.request(request)
puts response.read_body{
"object": "contact",
"id": "0f8fad5b-d9cb-469f-a165-70867728950e",
"agent": {
"id": "3132353852",
"type": "ai_agent",
"name": "Support agent"
},
"channel": "web",
"first_name": "<string>",
"last_name": "<string>",
"email": "<string>",
"phone": "<string>",
"job_title": "<string>",
"company": "<string>",
"website": "<string>",
"industry": "<string>",
"address": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"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": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "not_found_error",
"code": "resource_not_found",
"message": "No agent with this ID exists, or this API key can't access it.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "invalid_request_error",
"code": "contact_already_exists",
"message": "Another contact of this agent already has this email: 0f8fad5b-d9cb-469f-a165-70867728950e.",
"param": "email",
"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>"
}
]
}
}Headers
Body
application/json
At least one parameter needs a value. Values are trimmed, and an empty string or null leaves a field empty. Values over the length limits are rejected, not truncated.
Response
The new contact.