#
Messages Batch
#
Before You Start
Make sure to review the documentation for sending a single message before working with message batches.
#
Sending a Message Batch
To send multiple SMS messages in a batch, make a POST request to the /message/send-batch endpoint.
#
Parameters
#
Code Samples
curl -X POST "https://api.gosms.ro/v1/message/send-batch" \
-H "X-Authorization: [YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"recipient": "0712345678",
"message": "This is a test message."
},
{
"recipient": "0712345678",
"message": "This is another test message."
}
]
}'
try {
const res = await fetch("https://api.gosms.ro/v1/message/send-batch", {
method: "POST",
headers: {
"X-Authorization": "[YOUR_API_KEY]",
"Content-Type": "application/json"
},
body: JSON.stringify({
messages: [
{
recipient: "0712345678",
message: "This is a test message."
},
{
recipient: "0712345678",
message: "This is another test message."
}
]
})
})
const json = await res.json()
console.log(json)
} catch(err) {
console.log(err)
}
<?php
$apiKey = "[YOUR_API_KEY]";
$url = "https://api.gosms.ro/v1/message/send-batch";
$data = [
'messages' => [
[
"recipient" => "0712345678",
"message" => "This is a test message."
],
[
"recipient" => "0712345678",
"message" => "This is another test message."
]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-Authorization: $apiKey",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
#
Response
On success, the endpoint will return a response similar to the following:
{
"success": true,
"message": "Message orders registered.",
"balanceDeduction": "0.06",
"currency": "EUR",
"orderSummary": [
{
"arrayPosition": 0,
"amount": 0.03,
"recipient": "0712345678",
"messageId": "63ff4994-28d0-49c8-ac89-6ad5312525e5"
},
{
"arrayPosition": 1,
"amount": 0.03,
"recipient": "0712345678",
"messageId": "f2381e75-7fcb-4ace-a1c1-1afc0a101b95"
}
]
}