Send Template Message
curl --request POST \
--url https://swiftchats.axis96.xyz/api/send/template \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "+254720055819",
"template": {
"name": "hello_world",
"language": {
"code": "en_US"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Daniel"
},
{
"type": "text",
"text": "14"
}
]
}
]
}
}
'import requests
url = "https://swiftchats.axis96.xyz/api/send/template"
payload = {
"phone": "+254720055819",
"template": {
"name": "hello_world",
"language": { "code": "en_US" },
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Daniel"
},
{
"type": "text",
"text": "14"
}
]
}
]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
phone: '+254720055819',
template: {
name: 'hello_world',
language: {code: 'en_US'},
components: [
{
type: 'body',
parameters: [{type: 'text', text: 'Daniel'}, {type: 'text', text: '14'}]
}
]
}
})
};
fetch('https://swiftchats.axis96.xyz/api/send/template', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://swiftchats.axis96.xyz/api/send/template",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phone' => '+254720055819',
'template' => [
'name' => 'hello_world',
'language' => [
'code' => 'en_US'
],
'components' => [
[
'type' => 'body',
'parameters' => [
[
'type' => 'text',
'text' => 'Daniel'
],
[
'type' => 'text',
'text' => '14'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://swiftchats.axis96.xyz/api/send/template"
payload := strings.NewReader("{\n \"phone\": \"+254720055819\",\n \"template\": {\n \"name\": \"hello_world\",\n \"language\": {\n \"code\": \"en_US\"\n },\n \"components\": [\n {\n \"type\": \"body\",\n \"parameters\": [\n {\n \"type\": \"text\",\n \"text\": \"Daniel\"\n },\n {\n \"type\": \"text\",\n \"text\": \"14\"\n }\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://swiftchats.axis96.xyz/api/send/template")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"+254720055819\",\n \"template\": {\n \"name\": \"hello_world\",\n \"language\": {\n \"code\": \"en_US\"\n },\n \"components\": [\n {\n \"type\": \"body\",\n \"parameters\": [\n {\n \"type\": \"text\",\n \"text\": \"Daniel\"\n },\n {\n \"type\": \"text\",\n \"text\": \"14\"\n }\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://swiftchats.axis96.xyz/api/send/template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phone\": \"+254720055819\",\n \"template\": {\n \"name\": \"hello_world\",\n \"language\": {\n \"code\": \"en_US\"\n },\n \"components\": [\n {\n \"type\": \"body\",\n \"parameters\": [\n {\n \"type\": \"text\",\n \"text\": \"Daniel\"\n },\n {\n \"type\": \"text\",\n \"text\": \"14\"\n }\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 200,
"data": {
"success": true,
"data": {
"messaging_product": "whatsapp",
"contacts": [
{
"input": "+254720055819",
"wa_id": "254720055819"
}
],
"messages": [
{
"id": "wamid.HBgMMjU0NzIwMDU1ODE5FQIAERgSOTBCNUMxNUY2MzVGQjIyMUU1AA==",
"message_status": "accepted"
}
],
"chat": {
"organization_id": 3,
"wam_id": "wamid.HBgMMjU0NzIwMDU1ODE5FQIAERgSOTBCNUMxNUY2MzVGQjIyMUU1AA==",
"contact_id": 1,
"type": "outbound",
"metadata": "{\"type\":\"text\",\"text\":{\"body\":\"Are you interested in quoting. Please send more details here.\",\"footer\":\"carplans a div of Socovered\"},\"buttons\":[{\"type\":\"QUICK_REPLY\",\"text\":\"Car insurance\",\"value\":\"Car insurance\"},{\"type\":\"QUICK_REPLY\",\"text\":\"Home Insurance\",\"value\":\"Home Insurance\"},{\"type\":\"QUICK_REPLY\",\"text\":\"Building insurance\",\"value\":\"Building insurance\"}]}",
"media_id": null,
"status": "accepted",
"created_at": "2024-07-01 10:27:37",
"uuid": "9196ab05-813f-4037-a323-c890b997ee0b",
"id": 14
}
}
}
}Messages
Send Template
API POST /api/send
This endpoint allows you to send a message to a specified phone number.
Request Body
phone(string, required): The phone number to which the message will be sent.message(string, required): The content of the message to be sent.
Response
- Status: 404
- Content-Type: text/html
The response will be a 404 Not Found error if the requested resource is not available.
Example Response
{
"statusCode": 0,
"data": {
"success": true,
"data": {
"messaging_product": "",
"contacts": [
{
"input": "",
"wa_id": ""
}
],
"messages": [
{
"id": ""
}
],
"chat": {
"id": 0,
"uuid": "",
"organization_id": 0,
"wam_id": "",
"contact_id": 0,
"type": "",
"metadata": "",
"media_id": null,
"status": "",
"deleted_by": null,
"deleted_at": null,
"created_at": "",
"contact": {
"id": 0,
"uuid": "",
"organization_id": 0,
"first_name": null,
"last_name": null,
"phone": "",
"email": null,
"avatar": null,
"address": null,
"contact_group_id": null,
"is_favorite": 0,
"created_by": 0,
"created_at": null,
"updated_at": null,
"deleted_at": null,
"full_name": ""
},
"media": null
}
}
}
}
POST
/
api
/
send
/
template
Send Template Message
curl --request POST \
--url https://swiftchats.axis96.xyz/api/send/template \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "+254720055819",
"template": {
"name": "hello_world",
"language": {
"code": "en_US"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Daniel"
},
{
"type": "text",
"text": "14"
}
]
}
]
}
}
'import requests
url = "https://swiftchats.axis96.xyz/api/send/template"
payload = {
"phone": "+254720055819",
"template": {
"name": "hello_world",
"language": { "code": "en_US" },
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Daniel"
},
{
"type": "text",
"text": "14"
}
]
}
]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
phone: '+254720055819',
template: {
name: 'hello_world',
language: {code: 'en_US'},
components: [
{
type: 'body',
parameters: [{type: 'text', text: 'Daniel'}, {type: 'text', text: '14'}]
}
]
}
})
};
fetch('https://swiftchats.axis96.xyz/api/send/template', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://swiftchats.axis96.xyz/api/send/template",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phone' => '+254720055819',
'template' => [
'name' => 'hello_world',
'language' => [
'code' => 'en_US'
],
'components' => [
[
'type' => 'body',
'parameters' => [
[
'type' => 'text',
'text' => 'Daniel'
],
[
'type' => 'text',
'text' => '14'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://swiftchats.axis96.xyz/api/send/template"
payload := strings.NewReader("{\n \"phone\": \"+254720055819\",\n \"template\": {\n \"name\": \"hello_world\",\n \"language\": {\n \"code\": \"en_US\"\n },\n \"components\": [\n {\n \"type\": \"body\",\n \"parameters\": [\n {\n \"type\": \"text\",\n \"text\": \"Daniel\"\n },\n {\n \"type\": \"text\",\n \"text\": \"14\"\n }\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://swiftchats.axis96.xyz/api/send/template")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"+254720055819\",\n \"template\": {\n \"name\": \"hello_world\",\n \"language\": {\n \"code\": \"en_US\"\n },\n \"components\": [\n {\n \"type\": \"body\",\n \"parameters\": [\n {\n \"type\": \"text\",\n \"text\": \"Daniel\"\n },\n {\n \"type\": \"text\",\n \"text\": \"14\"\n }\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://swiftchats.axis96.xyz/api/send/template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phone\": \"+254720055819\",\n \"template\": {\n \"name\": \"hello_world\",\n \"language\": {\n \"code\": \"en_US\"\n },\n \"components\": [\n {\n \"type\": \"body\",\n \"parameters\": [\n {\n \"type\": \"text\",\n \"text\": \"Daniel\"\n },\n {\n \"type\": \"text\",\n \"text\": \"14\"\n }\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 200,
"data": {
"success": true,
"data": {
"messaging_product": "whatsapp",
"contacts": [
{
"input": "+254720055819",
"wa_id": "254720055819"
}
],
"messages": [
{
"id": "wamid.HBgMMjU0NzIwMDU1ODE5FQIAERgSOTBCNUMxNUY2MzVGQjIyMUU1AA==",
"message_status": "accepted"
}
],
"chat": {
"organization_id": 3,
"wam_id": "wamid.HBgMMjU0NzIwMDU1ODE5FQIAERgSOTBCNUMxNUY2MzVGQjIyMUU1AA==",
"contact_id": 1,
"type": "outbound",
"metadata": "{\"type\":\"text\",\"text\":{\"body\":\"Are you interested in quoting. Please send more details here.\",\"footer\":\"carplans a div of Socovered\"},\"buttons\":[{\"type\":\"QUICK_REPLY\",\"text\":\"Car insurance\",\"value\":\"Car insurance\"},{\"type\":\"QUICK_REPLY\",\"text\":\"Home Insurance\",\"value\":\"Home Insurance\"},{\"type\":\"QUICK_REPLY\",\"text\":\"Building insurance\",\"value\":\"Building insurance\"}]}",
"media_id": null,
"status": "accepted",
"created_at": "2024-07-01 10:27:37",
"uuid": "9196ab05-813f-4037-a323-c890b997ee0b",
"id": 14
}
}
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The body is of type object.
Response
200 - application/json
OK
The response is of type object.
⌘I
