POST /contacts
Creates a new contact.
Required Parameters
Parameter | Type | Description |
---|---|---|
identifier | String | The identifier of the contact (e.g. phone number in WhatsApp) |
source | Source | The source of the contact (e.g. whatsapp ) |
name | String | The name of the contact |
Optional Parameters
Parameter | Type | Description |
---|---|---|
tags | String[] | A list of comma-separated values (e.g ['Call back', 'Interested'] ) |
custom_fields | String{} | An object with the custom fields (e.g. {'Billing Address': 'Main Street 1'} ) |
assigned_user | String | Email of the user that you want to assign to a contact |
caution
When passing custom_fields
or tags
make sure that they exist in your account. See tags and custom_fields in your settings.
Same applies for assigned_user
, must be a valid email of a user in your account.
Example Request
- cURL
- Node
- Ruby
- Go
- PHP
- Python
curl -X POST "https://api.callbell.eu/v1/contacts" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"source": "whatsapp",
"identifier": "123456789",
"name": "John Doe"
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/contacts',
// '{\n "source": "whatsapp",\n "identifier": "123456789",\n "name": "John Doe"\n }',
{
'source': 'whatsapp',
'identifier': '123456789',
'name': 'John Doe'
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/contacts')
req = Net::HTTP::Post.new(uri)
req.content_type = 'application/json'
req['Authorization'] = 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM'
# The object won't be serialized exactly like this
# req.body = "{\n \"source\": \"whatsapp\",\n \"identifier\": \"123456789\",\n \"name\": \"John Doe\"\n }"
req.body = {
'source' => 'whatsapp',
'identifier' => '123456789',
'name' => 'John Doe'
}.to_json
req_options = {
use_ssl: uri.scheme == 'https'
}
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(req)
end
package main
import (
"fmt"
"io"
"log"
"net/http"
"strings"
)
func main() {
client := &http.Client{}
var data = strings.NewReader(`{
"source": "whatsapp",
"identifier": "123456789",
"name": "John Doe"
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/contacts", data)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM")
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.callbell.eu/v1/contacts');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n \"source\": \"whatsapp\",\n \"identifier\": \"123456789\",\n \"name\": \"John Doe\"\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'source': 'whatsapp',
'identifier': '123456789',
'name': 'John Doe',
}
response = requests.post('https://api.callbell.eu/v1/contacts', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "source": "whatsapp",\n "identifier": "123456789",\n "name": "John Doe"\n }'
#response = requests.post('https://api.callbell.eu/v1/contacts', headers=headers, data=data)
Response
Parameter | Type | Description |
---|---|---|
contact | Contact | The contact which was created. |
Example Response
response.json
{
"contact": [
{
"uuid": "414a6d692bd645ed803f2e7ce360d4c8",
"name": "John Doe",
"phoneNumber": "123456789",
"avatarUrl": null,
"createdAt": "2020-11-13T21:08:53Z",
"source": "whatsapp",
"href": "https://dash.callbell.eu/contacts/414a6d692bd645ed803f2e7ce360d4c8",
"tags": [],
"assignedUser": null,
"customFields": {}
}
]
}