curl --request POST \
--url https://app.timelines.ai/integrations/api/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "+14840000000",
"whatsapp_account_phone": "+14841111111",
"text": "hello, world!",
"file_uid": "afa9d4dd-978d-4a14-aa1b-bd65c272e645",
"label": "customer",
"chat_name": "MyChat",
"attachment_template_id": 123456
}
'import requests
url = "https://app.timelines.ai/integrations/api/messages"
payload = {
"phone": "+14840000000",
"whatsapp_account_phone": "+14841111111",
"text": "hello, world!",
"file_uid": "afa9d4dd-978d-4a14-aa1b-bd65c272e645",
"label": "customer",
"chat_name": "MyChat",
"attachment_template_id": 123456
}
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: '+14840000000',
whatsapp_account_phone: '+14841111111',
text: 'hello, world!',
file_uid: 'afa9d4dd-978d-4a14-aa1b-bd65c272e645',
label: 'customer',
chat_name: 'MyChat',
attachment_template_id: 123456
})
};
fetch('https://app.timelines.ai/integrations/api/messages', 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://app.timelines.ai/integrations/api/messages",
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' => '+14840000000',
'whatsapp_account_phone' => '+14841111111',
'text' => 'hello, world!',
'file_uid' => 'afa9d4dd-978d-4a14-aa1b-bd65c272e645',
'label' => 'customer',
'chat_name' => 'MyChat',
'attachment_template_id' => 123456
]),
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://app.timelines.ai/integrations/api/messages"
payload := strings.NewReader("{\n \"phone\": \"+14840000000\",\n \"whatsapp_account_phone\": \"+14841111111\",\n \"text\": \"hello, world!\",\n \"file_uid\": \"afa9d4dd-978d-4a14-aa1b-bd65c272e645\",\n \"label\": \"customer\",\n \"chat_name\": \"MyChat\",\n \"attachment_template_id\": 123456\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://app.timelines.ai/integrations/api/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"+14840000000\",\n \"whatsapp_account_phone\": \"+14841111111\",\n \"text\": \"hello, world!\",\n \"file_uid\": \"afa9d4dd-978d-4a14-aa1b-bd65c272e645\",\n \"label\": \"customer\",\n \"chat_name\": \"MyChat\",\n \"attachment_template_id\": 123456\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.timelines.ai/integrations/api/messages")
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\": \"+14840000000\",\n \"whatsapp_account_phone\": \"+14841111111\",\n \"text\": \"hello, world!\",\n \"file_uid\": \"afa9d4dd-978d-4a14-aa1b-bd65c272e645\",\n \"label\": \"customer\",\n \"chat_name\": \"MyChat\",\n \"attachment_template_id\": 123456\n}"
response = http.request(request)
puts response.read_body{
"status": "ok",
"data": {
"message_uid": "<string>"
}
}{
"message": "<string>",
"status": "error",
"error_code": "validation_error",
"errors": [
{
"fields": [
"url"
],
"msg": "must be a valid http(s) URL"
}
]
}{
"message": "<string>",
"status": "error",
"error_code": "validation_error",
"errors": [
{
"fields": [
"url"
],
"msg": "must be a valid http(s) URL"
}
]
}{
"message": "<string>",
"status": "error",
"error_code": "validation_error",
"errors": [
{
"fields": [
"url"
],
"msg": "must be a valid http(s) URL"
}
]
}Send Message to Phone
Send a message to a WhatsApp phone number. Doesn’t require a previous chat or contact with the recipient.
curl --request POST \
--url https://app.timelines.ai/integrations/api/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "+14840000000",
"whatsapp_account_phone": "+14841111111",
"text": "hello, world!",
"file_uid": "afa9d4dd-978d-4a14-aa1b-bd65c272e645",
"label": "customer",
"chat_name": "MyChat",
"attachment_template_id": 123456
}
'import requests
url = "https://app.timelines.ai/integrations/api/messages"
payload = {
"phone": "+14840000000",
"whatsapp_account_phone": "+14841111111",
"text": "hello, world!",
"file_uid": "afa9d4dd-978d-4a14-aa1b-bd65c272e645",
"label": "customer",
"chat_name": "MyChat",
"attachment_template_id": 123456
}
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: '+14840000000',
whatsapp_account_phone: '+14841111111',
text: 'hello, world!',
file_uid: 'afa9d4dd-978d-4a14-aa1b-bd65c272e645',
label: 'customer',
chat_name: 'MyChat',
attachment_template_id: 123456
})
};
fetch('https://app.timelines.ai/integrations/api/messages', 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://app.timelines.ai/integrations/api/messages",
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' => '+14840000000',
'whatsapp_account_phone' => '+14841111111',
'text' => 'hello, world!',
'file_uid' => 'afa9d4dd-978d-4a14-aa1b-bd65c272e645',
'label' => 'customer',
'chat_name' => 'MyChat',
'attachment_template_id' => 123456
]),
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://app.timelines.ai/integrations/api/messages"
payload := strings.NewReader("{\n \"phone\": \"+14840000000\",\n \"whatsapp_account_phone\": \"+14841111111\",\n \"text\": \"hello, world!\",\n \"file_uid\": \"afa9d4dd-978d-4a14-aa1b-bd65c272e645\",\n \"label\": \"customer\",\n \"chat_name\": \"MyChat\",\n \"attachment_template_id\": 123456\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://app.timelines.ai/integrations/api/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"+14840000000\",\n \"whatsapp_account_phone\": \"+14841111111\",\n \"text\": \"hello, world!\",\n \"file_uid\": \"afa9d4dd-978d-4a14-aa1b-bd65c272e645\",\n \"label\": \"customer\",\n \"chat_name\": \"MyChat\",\n \"attachment_template_id\": 123456\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.timelines.ai/integrations/api/messages")
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\": \"+14840000000\",\n \"whatsapp_account_phone\": \"+14841111111\",\n \"text\": \"hello, world!\",\n \"file_uid\": \"afa9d4dd-978d-4a14-aa1b-bd65c272e645\",\n \"label\": \"customer\",\n \"chat_name\": \"MyChat\",\n \"attachment_template_id\": 123456\n}"
response = http.request(request)
puts response.read_body{
"status": "ok",
"data": {
"message_uid": "<string>"
}
}{
"message": "<string>",
"status": "error",
"error_code": "validation_error",
"errors": [
{
"fields": [
"url"
],
"msg": "must be a valid http(s) URL"
}
]
}{
"message": "<string>",
"status": "error",
"error_code": "validation_error",
"errors": [
{
"fields": [
"url"
],
"msg": "must be a valid http(s) URL"
}
]
}{
"message": "<string>",
"status": "error",
"error_code": "validation_error",
"errors": [
{
"fields": [
"url"
],
"msg": "must be a valid http(s) URL"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
A JSON describing recipient and message payload.
a phone number, formatted according to international phone number standard, i.e.: [+][country code][area code][local phone number]
"+14840000000"
the WhatsApp account (as a phone number, in international format) to which the chat specified by JID belongs to. If omitted, the most recently connected WhatsApp account in the workspace will be used.
"+14841111111"
plain text message
2000"hello, world!"
attachment UID
"afa9d4dd-978d-4a14-aa1b-bd65c272e645"
Label name. Each label name can be up to 64 characters. Label-apply endpoints create a workspace label automatically when the supplied name does not already exist.
64"customer"
an exact name of the chat (or group) as appears in TimelinesAI)
256"MyChat"
a template ID of the attachment to be sent. The template must be created in the workspace before sending a message with it.
123456

