Send an SMS
Send an SMS #
POST /v1/sms/sendParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
to |
string | array | Yes | Recipient number, or a list of numbers, in international format |
message |
string | Yes | Text of the message (1530 characters at most) |
sender |
string | No | Sender ID (11 characters max), approved on your account. Optional: see "Default sender name" below. |
scheduled_at |
datetime | No | When to send, as YYYY-MM-DD HH:MM:SS. |
skip_duplicated |
boolean | No | If true, an identical message (same number, same text) already sent in the last 24 hours is not sent or charged again: it appears in skipped. |
Default sender name
Without sender, the SMS goes out under your organization's default sender name, the one you mark "Default" among your senders. If your organization has none, it goes out under the platform's sender name for the recipient's network. A sender you name is never replaced: if it does not exist or is not approved, the call is refused (400). The call is also refused when no name is available.
Not enough credits
If your balance does not cover every recipient, the call answers 402 with the code INSUFFICIENT_CREDITS. Nothing is charged and no message is created. An invalid number, a number in an unsupported country, or an organization without a country (set it in Settings > Organization) answers 400; nothing is charged.
{
"message": "Insufficient credits. Required: 25, Available: 10",
"code": "INSUFFICIENT_CREDITS",
"trace": []
}
Example request
// Envoyer un SMS
const credentials = btoa('ACCESS_KEY:ACCESS_SECRET');
const res = await fetch('https://api.callistosignal.com/v1/sms/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + credentials
},
body: JSON.stringify({
to: '+22507XXXXXXXX',
message: 'Bonjour',
sender: 'MyApp'
})
});
if (!res.ok) {
// 400, 401, 429… : le corps porte le motif du refus
const { message } = await res.json();
throw new Error(`SMS refusé (${res.status}) : ${message}`);
}
const data = await res.json();
// Envoyer un SMS via cURL
$ch = curl_init('https://api.callistosignal.com/v1/sms/send');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_USERPWD => 'ACCESS_KEY:ACCESS_SECRET',
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'to' => '+22507XXXXXXXX',
'message' => 'Bonjour',
'sender' => 'MyApp',
]),
]);
$response = curl_exec($ch);
curl_close($ch);
# Envoyer un SMS (pip install requests)
import requests
res = requests.post(
'https://api.callistosignal.com/v1/sms/send',
auth=('ACCESS_KEY', 'ACCESS_SECRET'),
json={
'to': '+22507XXXXXXXX',
'message': 'Bonjour',
'sender': 'MyApp',
},
timeout=10,
)
if not res.ok:
# 400, 401, 429… : le corps porte le motif du refus
raise RuntimeError('SMS refusé (%d) : %s' % (res.status_code, res.json().get('message')))
data = res.json()
// Envoyer un SMS
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]any{
"to": "+22507XXXXXXXX",
"message": "Bonjour",
"sender": "MyApp",
})
req, _ := http.NewRequest("POST", "https://api.callistosignal.com/v1/sms/send", bytes.NewReader(body))
req.SetBasicAuth("ACCESS_KEY", "ACCESS_SECRET")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
var out map[string]any
json.NewDecoder(res.Body).Decode(&out)
if res.StatusCode >= 300 {
// 400, 401, 429… : le corps porte le motif du refus
panic(fmt.Sprintf("SMS refusé (%d) : %v", res.StatusCode, out["message"]))
}
fmt.Println(out["status"], out["recipient_count"])
}
# Envoyer un SMS
curl -u 'ACCESS_KEY:ACCESS_SECRET' \
-X POST https://api.callistosignal.com/v1/sms/send \
-H 'Content-Type: application/json' \
-d '{
"to": "+22507XXXXXXXX",
"message": "Bonjour",
"sender": "MyApp"
}'
Response
{
"total_amount": 25,
"available_credit": 975,
"status": "sent",
"recipient_count": 1,
"scheduled": false,
"messages": [
{ "id": "550e8400-e29b-41d4-a716-446655440000", "recipient": "22507XXXXXXXX" }
],
"skipped": []
}