Send a message
curl --request POST \
--url https://shortext.ny-corp.io/api/messages/send \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"channel": "whatsapp",
"contact": {
"phone": "1234567890",
"profile": {
"lastname": "Yoan",
"firstname": "André",
"email": "celia@home.io",
"address": "Place to be",
"preferred_language": "en"
}
},
"from": "1234567890",
"message": {
"type": "text",
"content": {
"text": "Ceci est un message texte.",
"preview_url": true
}
}
}
'import requests
url = "https://shortext.ny-corp.io/api/messages/send"
payload = {
"channel": "whatsapp",
"contact": {
"phone": "1234567890",
"profile": {
"lastname": "Yoan",
"firstname": "André",
"email": "celia@home.io",
"address": "Place to be",
"preferred_language": "en"
}
},
"from": "1234567890",
"message": {
"type": "text",
"content": {
"text": "Ceci est un message texte.",
"preview_url": True
}
}
}
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({
channel: 'whatsapp',
contact: {
phone: '1234567890',
profile: {
lastname: 'Yoan',
firstname: 'André',
email: 'celia@home.io',
address: 'Place to be',
preferred_language: 'en'
}
},
from: '1234567890',
message: {type: 'text', content: {text: 'Ceci est un message texte.', preview_url: true}}
})
};
fetch('https://shortext.ny-corp.io/api/messages/send', 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://shortext.ny-corp.io/api/messages/send",
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([
'channel' => 'whatsapp',
'contact' => [
'phone' => '1234567890',
'profile' => [
'lastname' => 'Yoan',
'firstname' => 'André',
'email' => 'celia@home.io',
'address' => 'Place to be',
'preferred_language' => 'en'
]
],
'from' => '1234567890',
'message' => [
'type' => 'text',
'content' => [
'text' => 'Ceci est un message texte.',
'preview_url' => true
]
]
]),
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://shortext.ny-corp.io/api/messages/send"
payload := strings.NewReader("{\n \"channel\": \"whatsapp\",\n \"contact\": {\n \"phone\": \"1234567890\",\n \"profile\": {\n \"lastname\": \"Yoan\",\n \"firstname\": \"André\",\n \"email\": \"celia@home.io\",\n \"address\": \"Place to be\",\n \"preferred_language\": \"en\"\n }\n },\n \"from\": \"1234567890\",\n \"message\": {\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Ceci est un message texte.\",\n \"preview_url\": true\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://shortext.ny-corp.io/api/messages/send")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"channel\": \"whatsapp\",\n \"contact\": {\n \"phone\": \"1234567890\",\n \"profile\": {\n \"lastname\": \"Yoan\",\n \"firstname\": \"André\",\n \"email\": \"celia@home.io\",\n \"address\": \"Place to be\",\n \"preferred_language\": \"en\"\n }\n },\n \"from\": \"1234567890\",\n \"message\": {\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Ceci est un message texte.\",\n \"preview_url\": true\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://shortext.ny-corp.io/api/messages/send")
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 \"channel\": \"whatsapp\",\n \"contact\": {\n \"phone\": \"1234567890\",\n \"profile\": {\n \"lastname\": \"Yoan\",\n \"firstname\": \"André\",\n \"email\": \"celia@home.io\",\n \"address\": \"Place to be\",\n \"preferred_language\": \"en\"\n }\n },\n \"from\": \"1234567890\",\n \"message\": {\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Ceci est un message texte.\",\n \"preview_url\": true\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"success": "true",
"message_id": "abc123",
"recipient": {
"phone_number": "1234567890"
},
"data": {
"sent_at": "2024-10-05T10:01:00Z",
"delivered_at": "2024-10-05T10:05:00Z",
"read_at": "2024-10-05T10:07:00Z"
}
}Messages
Send a message
Envoie un message au destinataire via l’API Shortext
POST
/
messages
/
send
Send a message
curl --request POST \
--url https://shortext.ny-corp.io/api/messages/send \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"channel": "whatsapp",
"contact": {
"phone": "1234567890",
"profile": {
"lastname": "Yoan",
"firstname": "André",
"email": "celia@home.io",
"address": "Place to be",
"preferred_language": "en"
}
},
"from": "1234567890",
"message": {
"type": "text",
"content": {
"text": "Ceci est un message texte.",
"preview_url": true
}
}
}
'import requests
url = "https://shortext.ny-corp.io/api/messages/send"
payload = {
"channel": "whatsapp",
"contact": {
"phone": "1234567890",
"profile": {
"lastname": "Yoan",
"firstname": "André",
"email": "celia@home.io",
"address": "Place to be",
"preferred_language": "en"
}
},
"from": "1234567890",
"message": {
"type": "text",
"content": {
"text": "Ceci est un message texte.",
"preview_url": True
}
}
}
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({
channel: 'whatsapp',
contact: {
phone: '1234567890',
profile: {
lastname: 'Yoan',
firstname: 'André',
email: 'celia@home.io',
address: 'Place to be',
preferred_language: 'en'
}
},
from: '1234567890',
message: {type: 'text', content: {text: 'Ceci est un message texte.', preview_url: true}}
})
};
fetch('https://shortext.ny-corp.io/api/messages/send', 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://shortext.ny-corp.io/api/messages/send",
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([
'channel' => 'whatsapp',
'contact' => [
'phone' => '1234567890',
'profile' => [
'lastname' => 'Yoan',
'firstname' => 'André',
'email' => 'celia@home.io',
'address' => 'Place to be',
'preferred_language' => 'en'
]
],
'from' => '1234567890',
'message' => [
'type' => 'text',
'content' => [
'text' => 'Ceci est un message texte.',
'preview_url' => true
]
]
]),
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://shortext.ny-corp.io/api/messages/send"
payload := strings.NewReader("{\n \"channel\": \"whatsapp\",\n \"contact\": {\n \"phone\": \"1234567890\",\n \"profile\": {\n \"lastname\": \"Yoan\",\n \"firstname\": \"André\",\n \"email\": \"celia@home.io\",\n \"address\": \"Place to be\",\n \"preferred_language\": \"en\"\n }\n },\n \"from\": \"1234567890\",\n \"message\": {\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Ceci est un message texte.\",\n \"preview_url\": true\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://shortext.ny-corp.io/api/messages/send")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"channel\": \"whatsapp\",\n \"contact\": {\n \"phone\": \"1234567890\",\n \"profile\": {\n \"lastname\": \"Yoan\",\n \"firstname\": \"André\",\n \"email\": \"celia@home.io\",\n \"address\": \"Place to be\",\n \"preferred_language\": \"en\"\n }\n },\n \"from\": \"1234567890\",\n \"message\": {\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Ceci est un message texte.\",\n \"preview_url\": true\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://shortext.ny-corp.io/api/messages/send")
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 \"channel\": \"whatsapp\",\n \"contact\": {\n \"phone\": \"1234567890\",\n \"profile\": {\n \"lastname\": \"Yoan\",\n \"firstname\": \"André\",\n \"email\": \"celia@home.io\",\n \"address\": \"Place to be\",\n \"preferred_language\": \"en\"\n }\n },\n \"from\": \"1234567890\",\n \"message\": {\n \"type\": \"text\",\n \"content\": {\n \"text\": \"Ceci est un message texte.\",\n \"preview_url\": true\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"success": "true",
"message_id": "abc123",
"recipient": {
"phone_number": "1234567890"
},
"data": {
"sent_at": "2024-10-05T10:01:00Z",
"delivered_at": "2024-10-05T10:05:00Z",
"read_at": "2024-10-05T10:07:00Z"
}
}Authorizations
Basic Auth
Body
application/json
⌘I