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 |
team_uuid | String | UUID of the team that you want to assign to a contact |
channel_uuid | String | The message will be sent from this channel (when omitted, it will use the default main channel) |
bot_status | String | The status of the bot for this contact. The status of the bot. Accepts either bot_start or bot_end . |
When passing bot_status
make sure that the bot is enabled in your account. Visit bots in your Callbell account to create and enable one.
If you have a bot enabled, the default status is bot_start
meaning that the bot will reply whenever the contact writes. If this is not the intended behavior, you can set the status to bot_end
to stop the bot from replying to the contact. This can be useful when you want to take over the conversation manually or when you want to stop the bot from replying to the contact for any other reason.
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
and team_uuid
: either needs to exists in your account.
Example Request
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
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)
using System.Net.Http;
using System.Net.Http.Headers;
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://api.callbell.eu/v1/contacts");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"source\": \"whatsapp\",\n \"identifier\": \"123456789\",\n \"name\": \"John Doe\"\n }");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
class Main {
public static void main(String[] args) throws IOException {
URL url = new URL("https://api.callbell.eu/v1/contacts");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("POST");
httpConn.setRequestProperty("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
httpConn.setRequestProperty("Content-Type", "application/json");
httpConn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
writer.write("{\n \"source\": \"whatsapp\",\n \"identifier\": \"123456789\",\n \"name\": \"John Doe\"\n }");
writer.flush();
writer.close();
httpConn.getOutputStream().close();
InputStream responseStream = httpConn.getResponseCode() / 100 == 2
? httpConn.getInputStream()
: httpConn.getErrorStream();
Scanner s = new Scanner(responseStream).useDelimiter("\\A");
String response = s.hasNext() ? s.next() : "";
System.out.println(response);
}
}
extern crate reqwest;
use reqwest::header;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut headers = header::HeaderMap::new();
headers.insert("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM".parse().unwrap());
headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::blocking::Client::builder()
.redirect(reqwest::redirect::Policy::none())
.build()
.unwrap();
let res = client.post("https://api.callbell.eu/v1/contacts")
.headers(headers)
.body(r#"
{
"source": "whatsapp",
"identifier": "123456789",
"name": "John Doe"
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Response
Parameter | Type | Description |
---|---|---|
contact | Contact | The contact which was created. |
Example Response
{
"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",
"conversationHref": "https://dash.callbell.eu/chat/f3670b13446b412796238b1cd78899f9",
"tags": [],
"assignedUser": null,
"customFields": {}
}
]
}