Create Contact
Create a new Contact
curl --request POST \
--url https://airys.chat/api/v1/accounts/{account_id}/contacts \
--header 'Content-Type: application/json' \
--header 'api_access_token: <api-key>' \
--data '
{
"inbox_id": 1,
"name": "Alice",
"email": "alice@acme.inc",
"blocked": false,
"phone_number": "+123456789",
"avatar": "<string>",
"avatar_url": "https://example.com/avatar.png",
"identifier": "1234567890",
"additional_attributes": {
"type": "customer",
"age": 30
},
"custom_attributes": {}
}
'import requests
url = "https://airys.chat/api/v1/accounts/{account_id}/contacts"
payload = {
"inbox_id": 1,
"name": "Alice",
"email": "alice@acme.inc",
"blocked": False,
"phone_number": "+123456789",
"avatar": "<string>",
"avatar_url": "https://example.com/avatar.png",
"identifier": "1234567890",
"additional_attributes": {
"type": "customer",
"age": 30
},
"custom_attributes": {}
}
headers = {
"api_access_token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {api_access_token: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
inbox_id: 1,
name: 'Alice',
email: 'alice@acme.inc',
blocked: false,
phone_number: '+123456789',
avatar: '<string>',
avatar_url: 'https://example.com/avatar.png',
identifier: '1234567890',
additional_attributes: {type: 'customer', age: 30},
custom_attributes: {}
})
};
fetch('https://airys.chat/api/v1/accounts/{account_id}/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://airys.chat/api/v1/accounts/{account_id}/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([
'inbox_id' => 1,
'name' => 'Alice',
'email' => 'alice@acme.inc',
'blocked' => false,
'phone_number' => '+123456789',
'avatar' => '<string>',
'avatar_url' => 'https://example.com/avatar.png',
'identifier' => '1234567890',
'additional_attributes' => [
'type' => 'customer',
'age' => 30
],
'custom_attributes' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api_access_token: <api-key>"
],
]);
$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://airys.chat/api/v1/accounts/{account_id}/contacts"
payload := strings.NewReader("{\n \"inbox_id\": 1,\n \"name\": \"Alice\",\n \"email\": \"alice@acme.inc\",\n \"blocked\": false,\n \"phone_number\": \"+123456789\",\n \"avatar\": \"<string>\",\n \"avatar_url\": \"https://example.com/avatar.png\",\n \"identifier\": \"1234567890\",\n \"additional_attributes\": {\n \"type\": \"customer\",\n \"age\": 30\n },\n \"custom_attributes\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("api_access_token", "<api-key>")
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://airys.chat/api/v1/accounts/{account_id}/contacts")
.header("api_access_token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"inbox_id\": 1,\n \"name\": \"Alice\",\n \"email\": \"alice@acme.inc\",\n \"blocked\": false,\n \"phone_number\": \"+123456789\",\n \"avatar\": \"<string>\",\n \"avatar_url\": \"https://example.com/avatar.png\",\n \"identifier\": \"1234567890\",\n \"additional_attributes\": {\n \"type\": \"customer\",\n \"age\": 30\n },\n \"custom_attributes\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://airys.chat/api/v1/accounts/{account_id}/contacts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["api_access_token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"inbox_id\": 1,\n \"name\": \"Alice\",\n \"email\": \"alice@acme.inc\",\n \"blocked\": false,\n \"phone_number\": \"+123456789\",\n \"avatar\": \"<string>\",\n \"avatar_url\": \"https://example.com/avatar.png\",\n \"identifier\": \"1234567890\",\n \"additional_attributes\": {\n \"type\": \"customer\",\n \"age\": 30\n },\n \"custom_attributes\": {}\n}"
response = http.request(request)
puts response.read_body{
"payload": [
{
"additional_attributes": {},
"availability_status": "<string>",
"email": "<string>",
"id": 123,
"name": "<string>",
"phone_number": "<string>",
"blocked": true,
"identifier": "<string>",
"thumbnail": "<string>",
"custom_attributes": {
"attribute_key": "attribute_value",
"signed_up_at": "dd/mm/yyyy"
},
"last_activity_at": 123,
"created_at": 123,
"contact_inboxes": [
{
"source_id": "<string>",
"inbox": {
"id": 123,
"avatar_url": "<string>",
"channel_id": 123,
"name": "<string>",
"channel_type": "<string>",
"provider": "<string>"
}
}
]
}
],
"id": 123
}{
"description": "<string>",
"errors": [
{
"field": "<string>",
"message": "<string>",
"code": "<string>"
}
]
}Authorizations
This token can be obtained by visiting the profile page or via rails console. Provides access to endpoints based on the user permissions levels. This token can be saved by an external system when user is created via API, to perform activities on behalf of the user.
Path Parameters
The numeric ID of the account
Body
ID of the inbox to which the contact belongs
1
name of the contact
"Alice"
email of the contact
"alice@acme.inc"
whether the contact is blocked or not
false
phone number of the contact
"+123456789"
Send the form data with the avatar image binary or use the avatar_url
The url to a jpeg, png file for the contact avatar
"https://example.com/avatar.png"
A unique identifier for the contact in external system
"1234567890"
An object where you can store additional attributes for contact. example {"type":"customer", "age":30}
{ "type": "customer", "age": 30 }An object where you can store custom attributes for contact. example {"type":"customer", "age":30}, this should have a valid custom attribute definition.
{}curl --request POST \
--url https://airys.chat/api/v1/accounts/{account_id}/contacts \
--header 'Content-Type: application/json' \
--header 'api_access_token: <api-key>' \
--data '
{
"inbox_id": 1,
"name": "Alice",
"email": "alice@acme.inc",
"blocked": false,
"phone_number": "+123456789",
"avatar": "<string>",
"avatar_url": "https://example.com/avatar.png",
"identifier": "1234567890",
"additional_attributes": {
"type": "customer",
"age": 30
},
"custom_attributes": {}
}
'import requests
url = "https://airys.chat/api/v1/accounts/{account_id}/contacts"
payload = {
"inbox_id": 1,
"name": "Alice",
"email": "alice@acme.inc",
"blocked": False,
"phone_number": "+123456789",
"avatar": "<string>",
"avatar_url": "https://example.com/avatar.png",
"identifier": "1234567890",
"additional_attributes": {
"type": "customer",
"age": 30
},
"custom_attributes": {}
}
headers = {
"api_access_token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {api_access_token: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
inbox_id: 1,
name: 'Alice',
email: 'alice@acme.inc',
blocked: false,
phone_number: '+123456789',
avatar: '<string>',
avatar_url: 'https://example.com/avatar.png',
identifier: '1234567890',
additional_attributes: {type: 'customer', age: 30},
custom_attributes: {}
})
};
fetch('https://airys.chat/api/v1/accounts/{account_id}/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://airys.chat/api/v1/accounts/{account_id}/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([
'inbox_id' => 1,
'name' => 'Alice',
'email' => 'alice@acme.inc',
'blocked' => false,
'phone_number' => '+123456789',
'avatar' => '<string>',
'avatar_url' => 'https://example.com/avatar.png',
'identifier' => '1234567890',
'additional_attributes' => [
'type' => 'customer',
'age' => 30
],
'custom_attributes' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api_access_token: <api-key>"
],
]);
$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://airys.chat/api/v1/accounts/{account_id}/contacts"
payload := strings.NewReader("{\n \"inbox_id\": 1,\n \"name\": \"Alice\",\n \"email\": \"alice@acme.inc\",\n \"blocked\": false,\n \"phone_number\": \"+123456789\",\n \"avatar\": \"<string>\",\n \"avatar_url\": \"https://example.com/avatar.png\",\n \"identifier\": \"1234567890\",\n \"additional_attributes\": {\n \"type\": \"customer\",\n \"age\": 30\n },\n \"custom_attributes\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("api_access_token", "<api-key>")
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://airys.chat/api/v1/accounts/{account_id}/contacts")
.header("api_access_token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"inbox_id\": 1,\n \"name\": \"Alice\",\n \"email\": \"alice@acme.inc\",\n \"blocked\": false,\n \"phone_number\": \"+123456789\",\n \"avatar\": \"<string>\",\n \"avatar_url\": \"https://example.com/avatar.png\",\n \"identifier\": \"1234567890\",\n \"additional_attributes\": {\n \"type\": \"customer\",\n \"age\": 30\n },\n \"custom_attributes\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://airys.chat/api/v1/accounts/{account_id}/contacts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["api_access_token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"inbox_id\": 1,\n \"name\": \"Alice\",\n \"email\": \"alice@acme.inc\",\n \"blocked\": false,\n \"phone_number\": \"+123456789\",\n \"avatar\": \"<string>\",\n \"avatar_url\": \"https://example.com/avatar.png\",\n \"identifier\": \"1234567890\",\n \"additional_attributes\": {\n \"type\": \"customer\",\n \"age\": 30\n },\n \"custom_attributes\": {}\n}"
response = http.request(request)
puts response.read_body{
"payload": [
{
"additional_attributes": {},
"availability_status": "<string>",
"email": "<string>",
"id": 123,
"name": "<string>",
"phone_number": "<string>",
"blocked": true,
"identifier": "<string>",
"thumbnail": "<string>",
"custom_attributes": {
"attribute_key": "attribute_value",
"signed_up_at": "dd/mm/yyyy"
},
"last_activity_at": 123,
"created_at": 123,
"contact_inboxes": [
{
"source_id": "<string>",
"inbox": {
"id": 123,
"avatar_url": "<string>",
"channel_id": 123,
"name": "<string>",
"channel_type": "<string>",
"provider": "<string>"
}
}
]
}
],
"id": 123
}{
"description": "<string>",
"errors": [
{
"field": "<string>",
"message": "<string>",
"code": "<string>"
}
]
}