curl --request POST \
--url https://n-api.leadstaker.com/v1/messages/send-by-phone \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"phone": "<string>",
"channelId": "<string>",
"method": "MESSAGES",
"messages": [
"<string>"
],
"contactId": "<string>",
"deliveryTimeoutMs": 43200000
}
'import requests
url = "https://n-api.leadstaker.com/v1/messages/send-by-phone"
payload = {
"phone": "<string>",
"channelId": "<string>",
"method": "MESSAGES",
"messages": ["<string>"],
"contactId": "<string>",
"deliveryTimeoutMs": 43200000
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
phone: '<string>',
channelId: '<string>',
method: 'MESSAGES',
messages: ['<string>'],
contactId: '<string>',
deliveryTimeoutMs: 43200000
})
};
fetch('https://n-api.leadstaker.com/v1/messages/send-by-phone', 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://n-api.leadstaker.com/v1/messages/send-by-phone",
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' => '<string>',
'channelId' => '<string>',
'method' => 'MESSAGES',
'messages' => [
'<string>'
],
'contactId' => '<string>',
'deliveryTimeoutMs' => 43200000
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://n-api.leadstaker.com/v1/messages/send-by-phone"
payload := strings.NewReader("{\n \"phone\": \"<string>\",\n \"channelId\": \"<string>\",\n \"method\": \"MESSAGES\",\n \"messages\": [\n \"<string>\"\n ],\n \"contactId\": \"<string>\",\n \"deliveryTimeoutMs\": 43200000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://n-api.leadstaker.com/v1/messages/send-by-phone")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"<string>\",\n \"channelId\": \"<string>\",\n \"method\": \"MESSAGES\",\n \"messages\": [\n \"<string>\"\n ],\n \"contactId\": \"<string>\",\n \"deliveryTimeoutMs\": 43200000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://n-api.leadstaker.com/v1/messages/send-by-phone")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phone\": \"<string>\",\n \"channelId\": \"<string>\",\n \"method\": \"MESSAGES\",\n \"messages\": [\n \"<string>\"\n ],\n \"contactId\": \"<string>\",\n \"deliveryTimeoutMs\": 43200000\n}"
response = http.request(request)
puts response.read_body{
"chatId": "6713cc481f52bb0014a7d3e9",
"messageIds": [
"6716d2a57e63cc0015b9f4d1"
],
"delivery": "NOT_REPORTED"
}{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}Send a message to a phone number
Starts or reuses a chat for the number and answers with its id and the ids the queued messages will be stored under; delivery is queued. MESSAGES sends a sequence in order, one message after the other: each item a text, or a typed message (text or media) as MESSAGE takes it, every type checked against the chat before anything is queued. A request repeated by the same caller with the same Idempotency-Key header and body answers from the first run instead of sending again; the key with a different body answers 422 IDEMPOTENCY_KEY_REUSED.
curl --request POST \
--url https://n-api.leadstaker.com/v1/messages/send-by-phone \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"phone": "<string>",
"channelId": "<string>",
"method": "MESSAGES",
"messages": [
"<string>"
],
"contactId": "<string>",
"deliveryTimeoutMs": 43200000
}
'import requests
url = "https://n-api.leadstaker.com/v1/messages/send-by-phone"
payload = {
"phone": "<string>",
"channelId": "<string>",
"method": "MESSAGES",
"messages": ["<string>"],
"contactId": "<string>",
"deliveryTimeoutMs": 43200000
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
phone: '<string>',
channelId: '<string>',
method: 'MESSAGES',
messages: ['<string>'],
contactId: '<string>',
deliveryTimeoutMs: 43200000
})
};
fetch('https://n-api.leadstaker.com/v1/messages/send-by-phone', 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://n-api.leadstaker.com/v1/messages/send-by-phone",
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' => '<string>',
'channelId' => '<string>',
'method' => 'MESSAGES',
'messages' => [
'<string>'
],
'contactId' => '<string>',
'deliveryTimeoutMs' => 43200000
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://n-api.leadstaker.com/v1/messages/send-by-phone"
payload := strings.NewReader("{\n \"phone\": \"<string>\",\n \"channelId\": \"<string>\",\n \"method\": \"MESSAGES\",\n \"messages\": [\n \"<string>\"\n ],\n \"contactId\": \"<string>\",\n \"deliveryTimeoutMs\": 43200000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://n-api.leadstaker.com/v1/messages/send-by-phone")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"<string>\",\n \"channelId\": \"<string>\",\n \"method\": \"MESSAGES\",\n \"messages\": [\n \"<string>\"\n ],\n \"contactId\": \"<string>\",\n \"deliveryTimeoutMs\": 43200000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://n-api.leadstaker.com/v1/messages/send-by-phone")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phone\": \"<string>\",\n \"channelId\": \"<string>\",\n \"method\": \"MESSAGES\",\n \"messages\": [\n \"<string>\"\n ],\n \"contactId\": \"<string>\",\n \"deliveryTimeoutMs\": 43200000\n}"
response = http.request(request)
puts response.read_body{
"chatId": "6713cc481f52bb0014a7d3e9",
"messageIds": [
"6716d2a57e63cc0015b9f4d1"
],
"delivery": "NOT_REPORTED"
}{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}Authorizations
Body
- Option 1
- Option 2
- Option 3
- Option 4
11"MESSAGES"Sent in order, one after the other. Each is a text, or a typed message (text or media: IMAGE, VIDEO, AUDIO, DOCUMENT, ...) as MESSAGE takes it; messageIds answers one id per item, in the same order.
111Automations only: how long the calling step waits to hear how the send went. A message still queued by then is not sent, and the step is told it failed with DELIVERY_TIMEOUT.
1 <= x <= 86400000Response
Success
1Ids the queued messages will be stored under, in order. Empty for AI, which writes its own.
1REPORTED when the calling automation step will be told how the send went.
REPORTED, NOT_REPORTED