POST /messages/send
After 24h without a reply from the customer, it is not possible to send regular messages, you'll need to use a Template message, see examples below.
Required Parameters
Parameter | Type | Description |
---|---|---|
to | String | Phone number or platform identifier |
from | String | Channel identifier (e.g. whatsapp ) |
type | MessageType | Type of message to be sent |
content | MessageContent | Content of the message |
channel_uuid | String | The message will be sent from this channel |
Optional Parameters
Parameter | Type | Description |
---|---|---|
template_uuid | String | Unique identifier of the template message |
optin_contact | Boolean | Confirmation that the contact has opted-in for receiving messages |
template_values | Array | Values for multi-variable template message |
assigned_user | String | Message will be assigned to this collaborator's email |
team_uuid | String | Message will be assigned to this team |
fields | String | Comma-separated fields to be returned in the message. Supported values: contact,conversation |
bot_status | String | The status of the bot for this contact. Accepts either bot_start or bot_end . |
metadata | Object | Metadata to be attached to the message. |
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.
Example Request
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"channel_uuid": "35f6f8cc-b550-4278-a2ea-099f3a4e0730",
"content": {
"text": "Hello!"
}
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "channel_uuid": "35f6f8cc-b550-4278-a2ea-099f3a4e0730",\n "content": {\n "text": "Hello!"\n }\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'channel_uuid': '35f6f8cc-b550-4278-a2ea-099f3a4e0730',
'content': {
'text': 'Hello!'
}
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"channel_uuid\": \"35f6f8cc-b550-4278-a2ea-099f3a4e0730\",\n \"content\": {\n \"text\": \"Hello!\"\n }\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'text',
'channel_uuid' => '35f6f8cc-b550-4278-a2ea-099f3a4e0730',
'content' => {
'text' => 'Hello!'
}
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"channel_uuid": "35f6f8cc-b550-4278-a2ea-099f3a4e0730",
"content": {
"text": "Hello!"
}
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"channel_uuid\": \"35f6f8cc-b550-4278-a2ea-099f3a4e0730\",\n \"content\": {\n \"text\": \"Hello!\"\n }\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'channel_uuid': '35f6f8cc-b550-4278-a2ea-099f3a4e0730',
'content': {
'text': 'Hello!',
},
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "channel_uuid": "35f6f8cc-b550-4278-a2ea-099f3a4e0730",\n "content": {\n "text": "Hello!"\n }\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"channel_uuid\": \"35f6f8cc-b550-4278-a2ea-099f3a4e0730\",\n \"content\": {\n \"text\": \"Hello!\"\n }\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"channel_uuid\": \"35f6f8cc-b550-4278-a2ea-099f3a4e0730\",\n \"content\": {\n \"text\": \"Hello!\"\n }\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"channel_uuid": "35f6f8cc-b550-4278-a2ea-099f3a4e0730",
"content": {
"text": "Hello!"
}
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Response
Parameter | Type | Description |
---|---|---|
message | MessageSendRequest | The message send request. The system will initially enqueue the message. |
Example Response
{
"message": {
"uuid": "adf3d1216d4c4dcd908199d6700f2381",
"status": "enqueued"
}
}
Example Response (with fields=contact
)
{
"message": {
"uuid": "adf3d1216d4c4dcd908199d6700f2381",
"status": "enqueued",
"contact": {
"uuid": "c7b3d1216d4c4dcd908199d6700f2381",
"name": "John Doe",
"phone": "+1234567890",
"email": "john@doe.com"
}
}
}
Example Response (with fields=conversation
)
{
"message": {
"uuid": "adf3d1216d4c4dcd908199d6700f2381",
"status": "enqueued",
"conversation": {
"source": "whatsapp",
"href": "https://dash.callbell.eu/chat/f3670b13446b412796238b1cd78899f9",
"createdAt": "2024-09-23T20:09:10Z"
}
}
}
Example Response (with fields=conversation,contact
)
{
"message": {
"uuid": "adf3d1216d4c4dcd908199d6700f2381",
"status": "enqueued",
"conversation": {
"source": "whatsapp",
"href": "https://dash.callbell.eu/chat/f3670b13446b412796238b1cd78899f9",
"createdAt": "2024-09-23T20:09:10Z"
},
"contact": {
"uuid": "c7b3d1216d4c4dcd908199d6700f2381",
"name": "John Doe",
"phone": "+1234567890",
"email": "john@doe.com"
}
}
}
Send Message with Automatic User Assignment
It is possible to send a message via API request with an assigned user by sending their email in the assigned_user
parameter.
The user has to be part of your team, otherwise the assignment will not work.
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "Hello! This message has an assigned user!"
},
"assigned_user": "john.doe@email.com"
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "content": {\n "text": "Hello! This message has an assigned user!"\n },\n "assigned_user": "john.doe@email.com"\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'content': {
'text': 'Hello! This message has an assigned user!'
},
'assigned_user': 'john.doe@email.com'
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Hello! This message has an assigned user!\"\n },\n \"assigned_user\": \"john.doe@email.com\"\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'text',
'content' => {
'text' => 'Hello! This message has an assigned user!'
},
'assigned_user' => 'john.doe@email.com'
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "Hello! This message has an assigned user!"
},
"assigned_user": "john.doe@email.com"
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Hello! This message has an assigned user!\"\n },\n \"assigned_user\": \"john.doe@email.com\"\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'content': {
'text': 'Hello! This message has an assigned user!',
},
'assigned_user': 'john.doe@email.com',
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "content": {\n "text": "Hello! This message has an assigned user!"\n },\n "assigned_user": "john.doe@email.com"\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Hello! This message has an assigned user!\"\n },\n \"assigned_user\": \"john.doe@email.com\"\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Hello! This message has an assigned user!\"\n },\n \"assigned_user\": \"john.doe@email.com\"\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "Hello! This message has an assigned user!"
},
"assigned_user": "john.doe@email.com"
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Send Message with Metadata
You can send a message with custom metadata by passing an object in the metadata
parameter. This is useful for storing additional information about the message, especially when combined with the webhooks feature. This metadata will be returned in the webhook events.
Don’t store any sensitive information (bank account numbers, card details, and so on) as metadata or in the description parameter. Use it only for non-sensitive information like internal ids, references or similar.
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "Hello! This message has an assigned user!"
},
"metadata": {
"customer_id": "123456",
"sent_from": "backend_api"
}
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "content": {\n "text": "Hello! This message has an assigned user!"\n },\n "metadata": {\n "customer_id": "123456",\n "sent_from": "backend_api"\n }\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'content': {
'text': 'Hello! This message has an assigned user!'
},
'metadata': {
'customer_id': '123456',
'sent_from': 'backend_api'
}
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Hello! This message has an assigned user!\"\n },\n \"metadata\": {\n \"customer_id\": \"123456\",\n \"sent_from\": \"backend_api\"\n }\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'text',
'content' => {
'text' => 'Hello! This message has an assigned user!'
},
'metadata' => {
'customer_id' => '123456',
'sent_from' => 'backend_api'
}
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "Hello! This message has an assigned user!"
},
"metadata": {
"customer_id": "123456",
"sent_from": "backend_api"
}
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Hello! This message has an assigned user!\"\n },\n \"metadata\": {\n \"customer_id\": \"123456\",\n \"sent_from\": \"backend_api\"\n }\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'content': {
'text': 'Hello! This message has an assigned user!',
},
'metadata': {
'customer_id': '123456',
'sent_from': 'backend_api',
},
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "content": {\n "text": "Hello! This message has an assigned user!"\n },\n "metadata": {\n "customer_id": "123456",\n "sent_from": "backend_api"\n }\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Hello! This message has an assigned user!\"\n },\n \"metadata\": {\n \"customer_id\": \"123456\",\n \"sent_from\": \"backend_api\"\n }\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Hello! This message has an assigned user!\"\n },\n \"metadata\": {\n \"customer_id\": \"123456\",\n \"sent_from\": \"backend_api\"\n }\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "Hello! This message has an assigned user!"
},
"metadata": {
"customer_id": "123456",
"sent_from": "backend_api"
}
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Metadata Limitations
The metadata object can contain up to 10 key-value pairs. The key must be a string with a maximum length of 50 characters, and the value must be a string with a maximum length of 500 characters.
Send Message with Media Attachments
You can use the API to send media messages containing images, documents, audio and video messages.
Is it also possible to add a caption when sending image
attachments (see the example request below).
Send Image Attachment Example
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"url": "https://example.com/my_image.jpeg"
}
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "image",\n "content": {\n "url": "https://example.com/my_image.jpeg"\n }\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'image',
'content': {
'url': 'https://example.com/my_image.jpeg'
}
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"url\": \"https://example.com/my_image.jpeg\"\n }\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'image',
'content' => {
'url' => 'https://example.com/my_image.jpeg'
}
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"url": "https://example.com/my_image.jpeg"
}
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"url\": \"https://example.com/my_image.jpeg\"\n }\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'image',
'content': {
'url': 'https://example.com/my_image.jpeg',
},
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "image",\n "content": {\n "url": "https://example.com/my_image.jpeg"\n }\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"url\": \"https://example.com/my_image.jpeg\"\n }\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"url\": \"https://example.com/my_image.jpeg\"\n }\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"url": "https://example.com/my_image.jpeg"
}
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Send Image Attachment & Caption Example
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"url": "https://example.com/my_image.jpeg",
"text: "This is my caption"
}
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
'{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "image",\n "content": {\n "url": "https://example.com/my_image.jpeg",\n "text: "This is my caption"\n }\n }',
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
uri = URI('https://api.callbell.eu/v1/messages/send')
req = Net::HTTP::Post.new(uri)
req.content_type = 'application/json'
req['Authorization'] = 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM'
req.body = "{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"url\": \"https://example.com/my_image.jpeg\",\n \"text: \"This is my caption\"\n }\n }"
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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"url": "https://example.com/my_image.jpeg",
"text: "This is my caption"
}
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"url\": \"https://example.com/my_image.jpeg\",\n \"text: \"This is my caption\"\n }\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "image",\n "content": {\n "url": "https://example.com/my_image.jpeg",\n "text: "This is my caption"\n }\n }'
response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"url\": \"https://example.com/my_image.jpeg\",\n \"text: \"This is my caption\"\n }\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"url\": \"https://example.com/my_image.jpeg\",\n \"text: \"This is my caption\"\n }\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"url": "https://example.com/my_image.jpeg",
"text: "This is my caption"
}
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Send Document Attachment Example
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_image.pdf"
}
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "document",\n "content": {\n "url": "https://example.com/my_image.pdf"\n }\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'document',
'content': {
'url': 'https://example.com/my_image.pdf'
}
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_image.pdf\"\n }\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'document',
'content' => {
'url' => 'https://example.com/my_image.pdf'
}
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_image.pdf"
}
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_image.pdf\"\n }\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'document',
'content': {
'url': 'https://example.com/my_image.pdf',
},
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "document",\n "content": {\n "url": "https://example.com/my_image.pdf"\n }\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_image.pdf\"\n }\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_image.pdf\"\n }\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_image.pdf"
}
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Send Audio Attachment Example
This is only available for accounts using the official WhatsApp Business API integration.
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_audio.mp3"
}
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "document",\n "content": {\n "url": "https://example.com/my_audio.mp3"\n }\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'document',
'content': {
'url': 'https://example.com/my_audio.mp3'
}
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_audio.mp3\"\n }\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'document',
'content' => {
'url' => 'https://example.com/my_audio.mp3'
}
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_audio.mp3"
}
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_audio.mp3\"\n }\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'document',
'content': {
'url': 'https://example.com/my_audio.mp3',
},
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "document",\n "content": {\n "url": "https://example.com/my_audio.mp3"\n }\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_audio.mp3\"\n }\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_audio.mp3\"\n }\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_audio.mp3"
}
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Send Video Attachment Example
This is only available for accounts using the official WhatsApp Business API integration.
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_video.mp4"
}
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "document",\n "content": {\n "url": "https://example.com/my_video.mp4"\n }\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'document',
'content': {
'url': 'https://example.com/my_video.mp4'
}
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_video.mp4\"\n }\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'document',
'content' => {
'url' => 'https://example.com/my_video.mp4'
}
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_video.mp4"
}
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_video.mp4\"\n }\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'document',
'content': {
'url': 'https://example.com/my_video.mp4',
},
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "document",\n "content": {\n "url": "https://example.com/my_video.mp4"\n }\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_video.mp4\"\n }\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"url\": \"https://example.com/my_video.mp4\"\n }\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_video.mp4"
}
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Send Template Messages
You can use the API to send an approved Template Message.
This is only available for accounts using the official WhatsApp Business API integration.
In order to send template messages template_uuid
and optin_contact
must be present in the payload.
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "John Doe"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "content": {\n "text": "John Doe"\n },\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'content': {
'text': 'John Doe'
},
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': true
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"John Doe\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'text',
'content' => {
'text' => 'John Doe'
},
'template_uuid' => 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact' => true
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "John Doe"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"John Doe\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'content': {
'text': 'John Doe',
},
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': True,
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "content": {\n "text": "John Doe"\n },\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"John Doe\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"John Doe\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "John Doe"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
In this context text
refers to the placeholder of the template message, for example let's say you have a template message like this:
Hello {{1}}, this is a template message example
The placeholder replacement will be done with the value passed in the payload, so in this case it will be the following:
Hello John Doe, this is a template message example
Send Multi-variables Template Messages
You can use the API to send an approved Template Message.
This is only available for accounts using the official WhatsApp Business API integration.
In order to send template messages template_uuid
and optin_contact
must be present in the payload.
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "John Doe"
},
"template_values": ["Jack", "template", "Cheers"],
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "content": {\n "text": "John Doe"\n },\n "template_values": ["Jack", "template", "Cheers"],\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'content': {
'text': 'John Doe'
},
'template_values': [
'Jack',
'template',
'Cheers'
],
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': true
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"John Doe\"\n },\n \"template_values\": [\"Jack\", \"template\", \"Cheers\"],\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'text',
'content' => {
'text' => 'John Doe'
},
'template_values' => [
'Jack',
'template',
'Cheers'
],
'template_uuid' => 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact' => true
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "John Doe"
},
"template_values": ["Jack", "template", "Cheers"],
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"John Doe\"\n },\n \"template_values\": [\"Jack\", \"template\", \"Cheers\"],\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'text',
'content': {
'text': 'John Doe',
},
'template_values': [
'Jack',
'template',
'Cheers',
],
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': True,
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "text",\n "content": {\n "text": "John Doe"\n },\n "template_values": ["Jack", "template", "Cheers"],\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"John Doe\"\n },\n \"template_values\": [\"Jack\", \"template\", \"Cheers\"],\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"John Doe\"\n },\n \"template_values\": [\"Jack\", \"template\", \"Cheers\"],\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "John Doe"
},
"template_values": ["Jack", "template", "Cheers"],
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
In this context template_values
refers to the placeholders of the template message, for example let's say you have a template message like this:
Hello {{1}}, this is a template {{2}} example. {{3}}!
The placeholders replacements will be done with the values passed in the payload inside an array, so in this case it will be the following:
Hello Jack, this is a template message example. Cheers!
When template_values
are valid, the values inside content
will be ignored, since it is used for template messages with only one variable.
Send Template Messages with Media Attachments
You can use the API to send an approved Template Message
This is only available for accounts using the official WhatsApp Business API integration.
In order to send template messages template_uuid
and optin_contact
must be present in the payload.
If you have media template messages approved, you can send them by including a valid url
of the media
Send Image Attachment
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_image.jpeg"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "image",\n "content": {\n "text": "John Doe",\n "url": "https://example.com/valid_image.jpeg"\n },\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'image',
'content': {
'text': 'John Doe',
'url': 'https://example.com/valid_image.jpeg'
},
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': true
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_image.jpeg\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'image',
'content' => {
'text' => 'John Doe',
'url' => 'https://example.com/valid_image.jpeg'
},
'template_uuid' => 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact' => true
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_image.jpeg"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_image.jpeg\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'image',
'content': {
'text': 'John Doe',
'url': 'https://example.com/valid_image.jpeg',
},
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': True,
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "image",\n "content": {\n "text": "John Doe",\n "url": "https://example.com/valid_image.jpeg"\n },\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_image.jpeg\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"image\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_image.jpeg\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_image.jpeg"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Send Document Attachment
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_document.pdf"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "document",\n "content": {\n "text": "John Doe",\n "url": "https://example.com/valid_document.pdf"\n },\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'document',
'content': {
'text': 'John Doe',
'url': 'https://example.com/valid_document.pdf'
},
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': true
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_document.pdf\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'document',
'content' => {
'text' => 'John Doe',
'url' => 'https://example.com/valid_document.pdf'
},
'template_uuid' => 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact' => true
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_document.pdf"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_document.pdf\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'document',
'content': {
'text': 'John Doe',
'url': 'https://example.com/valid_document.pdf',
},
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': True,
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "document",\n "content": {\n "text": "John Doe",\n "url": "https://example.com/valid_document.pdf"\n },\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_document.pdf\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"document\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_document.pdf\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_document.pdf"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Send Video Attachment
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "video",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_video.mp4"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/messages/send',
// '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "video",\n "content": {\n "text": "John Doe",\n "url": "https://example.com/valid_video.mp4"\n },\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }',
{
'to': '+31612345678',
'from': 'whatsapp',
'type': 'video',
'content': {
'text': 'John Doe',
'url': 'https://example.com/valid_video.mp4'
},
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': true
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/messages/send')
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"video\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_video.mp4\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }"
req.body = {
'to' => '+31612345678',
'from' => 'whatsapp',
'type' => 'video',
'content' => {
'text' => 'John Doe',
'url' => 'https://example.com/valid_video.mp4'
},
'template_uuid' => 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact' => true
}.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(`{
"to": "+31612345678",
"from": "whatsapp",
"type": "video",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_video.mp4"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/messages/send", 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/messages/send');
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"video\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_video.mp4\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'to': '+31612345678',
'from': 'whatsapp',
'type': 'video',
'content': {
'text': 'John Doe',
'url': 'https://example.com/valid_video.mp4',
},
'template_uuid': 'd980fb66fd5043d3ace1aa06ba044342',
'optin_contact': True,
}
response = requests.post('https://api.callbell.eu/v1/messages/send', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "to": "+31612345678",\n "from": "whatsapp",\n "type": "video",\n "content": {\n "text": "John Doe",\n "url": "https://example.com/valid_video.mp4"\n },\n "template_uuid": "d980fb66fd5043d3ace1aa06ba044342",\n "optin_contact": true\n }'
#response = requests.post('https://api.callbell.eu/v1/messages/send', 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/messages/send");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"video\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_video.mp4\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send");
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 \"to\": \"+31612345678\",\n \"from\": \"whatsapp\",\n \"type\": \"video\",\n \"content\": {\n \"text\": \"John Doe\",\n \"url\": \"https://example.com/valid_video.mp4\"\n },\n \"template_uuid\": \"d980fb66fd5043d3ace1aa06ba044342\",\n \"optin_contact\": true\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/messages/send")
.headers(headers)
.body(r#"
{
"to": "+31612345678",
"from": "whatsapp",
"type": "video",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_video.mp4"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Use the Templates API to the get the template_uuid
s your templates.