# Messages

# Before You Start

There are two types of SMS messages, determined by their length:

  • Simple SMS – A message containing up to 160 characters.
  • Concatenated SMS – A message containing up to 39,015 characters, which is delivered as a single message on the recipient’s device.
    These are sent as multiple SMS segments, with each 153-character segment being charged separately.

# Sending a Message

To send an SMS, make a POST request to the /message/send endpoint.

# Parameters

Parameter Required? Description
recipient yes The mobile phone number of the recipient.
Format requirements:
• National (Romania): 07PPXXXXXX, 407PPXXXXXX.
• For international numbers, add the 00 prefix: 00359XXXXXXXXX.
message yes The text of the SMS message.
sender no The sender of the message. Must be pre-approved and configured by a GoSMS representative.
• Alphanumeric senders may not be supported by all operators.
• If missing or invalid, the default short number will be used.
scheduleDatetime no The date and time when the SMS should be sent.
Accepted formats: YYYY-MM-DDTHH:MM:SS.mmmZ or YYYY-MM-DD HH:MM:SS.
If missing or invalid, the server’s current time will be used.
validity no Validity period in minutes.
If provided and greater than 0, this defines how long the message remains valid from the scheduled date and time.
If not delivered within this period, it will expire and will not be charged.

# Code Samples

curl -X POST "https://api.gosms.ro/v1/message/send" \
     -H "X-Authorization: [YOUR_API_KEY]" \
     -H "Content-Type: application/json" \
     -d '{
           "recipient": "0712345678",
           "message": "This is a test message."
         }'
try {
    const res = await fetch("https://api.gosms.ro/v1/message/send", {
        method: "POST",
        headers: {
            "X-Authorization": "[YOUR_API_KEY]",
            "Content-Type": "application/json"
        },
        body: JSON.stringify({
            recipient: "0712345678",
            message: "This is a 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";

$data = [
    "recipient" => "0712345678",
    "message" => "This is a 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 returns a JSON response like the following:

{
  "success": true,
  "messageId": "dea3535d-2b1e-4c05-b3ea-6879c8d2516c",
  "balanceDeduction": "0.03",
  "currency": "EUR"
}