Welcome to the Textbridges Developer API Documentation! This comprehensive guide is designed to help you seamlessly integrate with our API, providing you with all the necessary tools and information to harness the power of whatsapp business api.
First off you need to be an onboarded client on standard package and above. On your client panel you can access your api key which you will subsequently use to authorize your requests as explained in this document.
Document messages are messages that display a document icon, linked to a document, that a WhatsApp user can tap to download.
Use the POST / api.textbridges.com / messages endpoint to send a document message to a WhatsApp user.
POST / api.textbridges.com / messages
...
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "<WHATSAPP_USER_PHONE_NUMBER>",
"type": "document",
"document": {
"id" : "<MEDIA_ID>", /* Only if using uploaded media */
"link": "<MEDIA_URL>", /* Only if linking to your media */
"caption": "<DOCUMENT_CAPTION>",
"filename": "<DOCUMENT_FILENAME>"
...
Example request to send a PDF in a document message with a caption to a WhatsApp user.
...
curl 'https://api.textbridges.com / messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "+16505551234",
"type": "text",
"text": {
"preview_url": true,
"body": "As requested, here'\''s the link to our latest product: https://www.meta.com/quest/quest-3/"
}
}'
...
import requests
import json
url = 'https://api.textbridges.com / messages'
data = {
'messaging_product': 'whatsapp',
'recipient_type': 'individual',
'to': '+16505551234',
'type': 'text',
'text': {
'preview_url': True,
'body': "As requested, here's the link to our latest product: https://www.meta.com/quest/quest-3/"
}
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer EAAJB...'
}
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
print(json.dumps(response.json(), indent=2))
else:
print(f'Error: {response.status_code}')
print(response.text)
$url = 'https://api.textbridges.com / messages';
$headers = [
'Content-Type: application/json',
'Authorization: Bearer EAAJB...' // Replace with your actual bearer token
];
$data = [
'messaging_product' => 'whatsapp',
'recipient_type' => 'individual',
'to' => '+16505551234',
'type' => 'text',
'text' => [
'preview_url' => true,
'body' => "As requested, here's the link to our latest product: https://www.meta.com/quest/quest-3/"
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'cURL Error: ' . curl_error($ch);
} else {
echo 'Response: ' . $response;
}
curl_close($ch);
const axios = require('axios');
const data = {
messaging_product: "whatsapp",
recipient_type: "individual",
to: "+16505551234",
type: "text",
text: {
preview_url: true,
body: "As requested, here’s the link to our latest product: https://www.meta.com/quest/quest-3/"
}
};
const config = {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer EAAJB...'
}
};
axios.post('https://api.textbridges.com/messages', data, config)
.then(response => {
console.log(response.data);
})
.
< lang="en">
...
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "+16505551234",
"wa_id": "16505551234"
}
],
"messages": [
{
"id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA"
}
]
}
...
</>
Image messages are messages that display a single image and an optional caption.
Use the POST / api.textbridges.com / messages endpoint to send an image message to a WhatsApp user.
POST / api.textbridges.com / messages
...
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "<WHATSAPP_USER_PHONE_NUMBER>",
"type": "image",
"image": {
"id" : "<MEDIA_ID>", /* Only if using uploaded media */
"link": "<MEDIA_URL>", /* Only if linking to your media */
"caption": "<IMAGE_CAPTION_TEXT>"
}
}
...
Example request to send an image message with a caption to a WhatsApp user.
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "+16505551234",
"wa_id": "16505551234"
}
],
"messages": [
{
"id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA"
}
]
}
import requests
data = {
"messaging_product": "whatsapp",
"contacts": [
{
"input": "+16505551234",
"wa_id": "16505551234"
}
],
"messages": [
{
"id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA"
}
]
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer EAAJB...'
}
response = requests.post('https://api.textbridges.com/messages', json=data, headers=headers)
print(response.json())
$url = 'https://api.textbridges.com/messages';
$data = [
"messaging_product" => "whatsapp",
"contacts" => [
[
"input" => "+16505551234",
"wa_id" => "16505551234"
]
],
"messages" => [
[
"id" => "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA"
]
]
];
$headers = [
'Content-Type: application/json',
'Authorization: Bearer EAAJB...'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if ($response === false) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}
curl_close($ch);
$responseData = json_decode($response, true);
print_r($responseData);
const axios = require('axios');
const data = {
messaging_product: "whatsapp",
contacts: [
{
input: "+16505551234",
wa_id: "16505551234"
}
],
messages: [
{
id: "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA"
}
]
};
axios.post('https://api.textbridges.com/messages', data, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer EAAJB...'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "+16505551234",
"wa_id": "16505551234"
}
],
"messages": [
{
"id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA"
}
]
}
Text messages are messages containing only a text body and an optional link preview.
Use the POST / api.textbridges.com / messages endpoint to send an image message to a WhatsApp user.
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "<WHATSAPP_USER_PHONE_NUMBER>",
"type": "text",
"text": {
"preview_url": <ENABLE_LINK_PREVIEW>,
"body": "<BODY_TEXT>"
}
}
You can have the WhatsApp client attempt to render a preview of the first URL in the body text string, if it contains one. URLs must begin with http:// or https://. If multiple URLs are in the body text string, only the first URL will be rendered.
If omitted, or if unable to retrieve a link preview, a clickable link will be rendered instead.
Example request to send a text message with link previews enabled and a body text string that contains a link.
curl 'https://api.textbridges.com / messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "+16505551234",
"type": "text",
"text": {
"preview_url": true,
"body": "As requested, here'\''s the link to our latest product: https://www.meta.com/quest/quest-3/"
}
}'
import requests
url = 'https://api.textbridges.com/messages'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer EAAJB...'
}
data = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "+16505551234",
"type": "text",
"text": {
"preview_url": True,
"body": "As requested, here's the link to our latest product: https://www.meta.com/quest/quest-3/"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.status_code)
print(response.json())
$url = 'https://api.textbridges.com/messages';
$token = 'EAAJB...';
$phone_number = '+16505551234';
$data = [
"messaging_product" => "whatsapp",
"recipient_type" => "individual",
"to" => $phone_number,
"type" => "text",
"text" => [
"preview_url" => true,
"body" => "As requested, here's the link to our latest product: https://www.meta.com/quest/quest-3/"
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer ' . $token
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP Status Code: " . $http_code . "\n";
echo "Response: " . $response . "\n";
const axios = require('axios');
const url = 'https://api.textbridges.com/messages';
const token = 'EAAJB...';
const phoneNumber = '+16505551234';
const data = {
messaging_product: 'whatsapp',
recipient_type: 'individual',
to: phoneNumber,
type: 'text',
text: {
preview_url: true,
body: "As requested, here's the link to our latest product: https://www.meta.com/quest/quest-3/"
}
};
axios.post(url, data, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
})
.then(response => {
console.log('HTTP Status Code:', response.status);
console.log('Response Data:', response.data);
})
.catch(error => {
console.error('Error:', error.response ? error.response.data : error.message);
});
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "+16505551234",
"wa_id": "16505551234"
}
],
"messages": [
{
"id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA"
}
]
}
OTP messages are authentication messages
Use the POST / api.textbridges.com / otp endpoint to send an OTP to a WhatsApp user.
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "<WHATSAPP_USER_PHONE_NUMBER>",
"type": "OTP",
"text": {
"body": "<BODY_TEXT>"
}
}
For better usability include 'copy code' button in the message
Example request to send a text message with link previews enabled and a body text string that contains a link.
curl 'https://api.textbridges.com / otp' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "+16505551234",
"type": "otp",
"text": {
"body": "Your one time pin is 78992"
}
}'
import requests
url = 'https://api.textbridges.com/otp'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer EAAJB...'
}
data = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "+16505551234",
"type": "otp",
"text": {
"body": "Your one time pin is 78992"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.status_code)
print(response.json())
$url = 'https://api.textbridges.com/otp';
$token = 'EAAJB...';
$phone_number = '+16505551234';
$data = [
"messaging_product" => "whatsapp",
"recipient_type" => "individual",
"to" => $phone_number,
"type" => "otp",
"text" => [
"body" => "Your one time pin is 78992"
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer ' . $token
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP Status Code: " . $http_code . "\n";
echo "Response: " . $response . "\n";
const axios = require('axios');
const url = 'https://api.textbridges.com/otp';
const token = 'EAAJB...';
const phoneNumber = '+16505551234';
const data = {
messaging_product: 'whatsapp',
recipient_type: 'individual',
to: phoneNumber,
type: 'otp',
text: {
body: "Your one time pin is 78992"
}
};
axios.post(url, data, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
})
.then(response => {
console.log('HTTP Status Code:', response.status);
console.log('Response Data:', response.data);
})
.catch(error => {
console.error('Error:', error.response ? error.response.data : error.message);
});
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "+16505551234",
"wa_id": "16505551234"
}
],
"messages": [
{
"id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA"
}
]
}