Before you start
API credentials are created on the sending platform, in the Account page. It takes a few minutes:
- You need an SMSMarket account and some SMS credit.
- Log in to the sending platform and open Account, the gear icon at the top right.
- Recommended: in the Tokens section press Aggiungi nuovo token, give the token a name (one per application) and copy it. Together with the token you need your
user_key: it is your API account number, a number you'll find in your details in your customer area. - Alternatively, set an API password in the API Password section with Cambio password. It is different from your login password for the website and the platform: if you change your login password, the APIs keep working.
- Optional: in Filtro IP consentiti you can list the authorised IP addresses. If you add IPs and switch the filter ON, only those addresses can call the APIs; any other gets
Accesso non consentito(access denied).
After every change press SALVA at the bottom of the Account page, or it won't be stored.
Security
- Use HTTPS connections only.
- Keep tokens and API password on your server: never in the code of a web page or of an app installed on phones.
- Create one token per application, so you can revoke one without stopping the others.
- If a token ends up in the wrong hands, delete it from the Tokens section and create a new one.
Message types
SMSMarket sells two types of SMS. In the APIs you set them with the message_type field, using only these two values:
N- SMS with delivery notification
LL- SMS without notification (low cost)
Message length
- An SMS holds up to 160 standard (GSM) characters. Longer messages are split into several parts and each part uses one credit.
- With
"encoding": "ucs2", needed for emoji and non-Latin alphabets, the limit drops to 70 characters per part. - Messages without notification (LL) may be limited to 160 characters.
- The maximum total length is 1000 characters (gsm) or 450 (ucs2).
Phone numbers
Always write numbers in international format, with the country code: +393471234567.
REST API (recommended)
Every call starts from this base URL:
https://sms.smsmarket.it/API/v1.0/REST/
1. Authentication
Every call carries two headers: your user_key and either a token or a session key.
Token (recommended)
Send user_key with your API account number and Access_token with the token created in Account → Tokens. No login call is needed.
user_key: 12345678
Access_token: IL_TUO_TOKEN
If user_key is missing the platform replies with HTTP 400.
Session (alternative)
GET
https://sms.smsmarket.it/API/v1.0/REST/login
You authenticate with HTTP Basic using your email and API password, not your login password. The response is plain text in the format USER_KEY;SESSION_KEY: in the following calls send the headers user_key and Session_key. With wrong credentials you get HTTP 404.
# Log in with your email and API password (not the login password):
# export SMSMARKET_EMAIL="TUA_EMAIL"
# export SMSMARKET_API_PASSWORD="TUA_PASSWORD_API"
# The response is "USER_KEY;SESSION_KEY".
AUTH=$(curl -sS --fail-with-body \
-u "$SMSMARKET_EMAIL:$SMSMARKET_API_PASSWORD" \
"https://sms.smsmarket.it/API/v1.0/REST/login")
USER_KEY=${AUTH%%;*}
SESSION_KEY=${AUTH#*;}
# Then send these headers on every call
curl -sS --fail-with-body "https://sms.smsmarket.it/API/v1.0/REST/status?typeAliases=true" \
-H "user_key: $USER_KEY" \
-H "Session_key: $SESSION_KEY"
Write the header names exactly like this, with capitals and underscore: some HTTP libraries rewrite them. In Perl, for example, prefix them with :.
2. Sending an SMS
POST
https://sms.smsmarket.it/API/v1.0/REST/sms
The request body is JSON, with Content-Type: application/json. These are the fields:
-
message_typestring · required - Message type:
"N"(with delivery notification) or"LL"(without notification). -
messagestring · required - The text of the message.
-
recipientarray of strings · required - The recipients' numbers, in international format.
-
senderstring · optional - Your custom sender name, up to 11 alphanumeric characters. If the message type does not allow a custom sender, leave it empty: it may not be available for SMS without notification (LL).
-
scheduled_delivery_timestring · optional - Date and time of a scheduled sending, in the format
yyyyMMddHHmmssoryyyy-MM-dd HH:mm. -
order_idstring · optional - Your own reference for the sending: up to 32 characters among letters, numbers, underscore, dot and dash.
-
returnCreditsboolean · optional - With
truethe response also includesused_credits, the credit used in euros. -
encodingstring · optional "gsm"(default) or"ucs2", needed for emoji and non-Latin alphabets.
If the sending succeeds you get HTTP 201 with this response:
{"result": "OK", "order_id": "6DD2A87ABF71485A8AFD29BA55FCFD83", "total_sent": 1, "used_credits": 0.07, "internal_order_id": "64007bd4-5625-42c2-b58b-06327e3a4a10"}
On error:
- 400 invalid input: the details are in the response body;
- 401 missing or invalid keys;
- 404 user key not found.
Example: log in and send an SMS
cURL
#!/usr/bin/env bash
# Credentials from environment variables:
# export SMSMARKET_USER_KEY="12345678" # your API account number
# export SMSMARKET_TOKEN="..." # Account → Tokens on the platform
set -euo pipefail
BASE_URL="https://sms.smsmarket.it/API/v1.0/REST/"
# Send an SMS (HTTP 201 on success; on error curl prints the body and exits)
curl -sS --fail-with-body -X POST "${BASE_URL}sms" \
-H "Content-Type: application/json; charset=utf-8" \
-H "user_key: $SMSMARKET_USER_KEY" \
-H "Access_token: $SMSMARKET_TOKEN" \
--data-binary @- <<'JSON'
{
"message_type": "N",
"message": "Ciao! Il tuo appuntamento è confermato per domani alle 10:00.",
"recipient": ["+393471234567"],
"sender": "MioNegozio"
}
JSON
echo
PHP
<?php
// PHP 8.1+ with the curl extension.
// Run: SMSMARKET_USER_KEY="12345678" SMSMARKET_TOKEN="..." php send.php
const BASE_URL = 'https://sms.smsmarket.it/API/v1.0/REST/';
$userKey = getenv('SMSMARKET_USER_KEY');
$token = getenv('SMSMARKET_TOKEN');
if (!$userKey || !$token) {
fwrite(STDERR, "Set SMSMARKET_USER_KEY and SMSMARKET_TOKEN.\n");
exit(1);
}
$body = json_encode([
'message_type' => 'N',
'message' => 'Ciao! Il tuo appuntamento è confermato per domani alle 10:00.',
'recipient' => ['+393471234567'],
'sender' => 'MioNegozio',
], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
$ch = curl_init(BASE_URL . 'sms');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json; charset=utf-8',
'user_key: ' . $userKey,
'Access_token: ' . $token,
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
$response = curl_exec($ch);
if ($response === false) {
fwrite(STDERR, 'Connection error: ' . curl_error($ch) . "\n");
exit(1);
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status !== 201) {
fwrite(STDERR, "Send failed (HTTP $status): $response\n");
exit(1);
}
$result = json_decode($response, true, flags: JSON_THROW_ON_ERROR);
echo "Sent: order_id {$result['order_id']}, total_sent {$result['total_sent']}\n";
Python
# Python 3.8+ with requests (pip install requests).
# Run: SMSMARKET_USER_KEY="12345678" SMSMARKET_TOKEN="..." python send.py
import os
import sys
import requests
BASE_URL = "https://sms.smsmarket.it/API/v1.0/REST/"
headers = {
"user_key": os.environ["SMSMARKET_USER_KEY"],
"Access_token": os.environ["SMSMARKET_TOKEN"],
}
# Send an SMS (json= encodes the body as UTF-8 JSON)
r = requests.post(
BASE_URL + "sms",
headers=headers,
json={
"message_type": "N",
"message": "Ciao! Il tuo appuntamento è confermato per domani alle 10:00.",
"recipient": ["+393471234567"],
"sender": "MioNegozio",
},
timeout=30,
)
if r.status_code != 201:
sys.exit(f"Send failed (HTTP {r.status_code}): {r.text}")
result = r.json()
print(f"Sent: order_id {result['order_id']}, total_sent {result['total_sent']}")
Node.js
// Node.js 18+ (global fetch), ES module: save as send.mjs
// Run: SMSMARKET_USER_KEY="12345678" SMSMARKET_TOKEN="..." node send.mjs
const BASE_URL = "https://sms.smsmarket.it/API/v1.0/REST/";
const userKey = process.env.SMSMARKET_USER_KEY;
const token = process.env.SMSMARKET_TOKEN;
if (!userKey || !token) {
console.error("Set SMSMARKET_USER_KEY and SMSMARKET_TOKEN.");
process.exit(1);
}
// Send an SMS
const res = await fetch(BASE_URL + "sms", {
method: "POST",
headers: {
"Content-Type": "application/json; charset=utf-8",
user_key: userKey,
Access_token: token,
},
body: JSON.stringify({
message_type: "N",
message: "Ciao! Il tuo appuntamento è confermato per domani alle 10:00.",
recipient: ["+393471234567"],
sender: "MioNegozio",
}),
});
const body = await res.text();
if (res.status !== 201) {
console.error(`Send failed (HTTP ${res.status}): ${body}`);
process.exit(1);
}
const result = JSON.parse(body);
console.log(`Sent: order_id ${result.order_id}, total_sent ${result.total_sent}`);
C#
// .NET 6+ console app (Program.cs, top-level statements).
// Set the environment variables SMSMARKET_USER_KEY (your API account number)
// and SMSMARKET_TOKEN (Account → Tokens on the platform).
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
const string BaseUrl = "https://sms.smsmarket.it/API/v1.0/REST/";
var userKey = Environment.GetEnvironmentVariable("SMSMARKET_USER_KEY");
var token = Environment.GetEnvironmentVariable("SMSMARKET_TOKEN");
if (string.IsNullOrEmpty(userKey) || string.IsNullOrEmpty(token))
{
Console.Error.WriteLine("Set SMSMARKET_USER_KEY and SMSMARKET_TOKEN.");
return 1;
}
using var http = new HttpClient { BaseAddress = new Uri(BaseUrl) };
http.DefaultRequestHeaders.Add("user_key", userKey);
http.DefaultRequestHeaders.Add("Access_token", token);
// Send an SMS (PostAsJsonAsync sends UTF-8 JSON)
using var response = await http.PostAsJsonAsync("sms", new
{
message_type = "N",
message = "Ciao! Il tuo appuntamento è confermato per domani alle 10:00.",
recipient = new[] { "+393471234567" },
sender = "MioNegozio",
});
var body = await response.Content.ReadAsStringAsync();
if (response.StatusCode != HttpStatusCode.Created)
{
Console.Error.WriteLine($"Send failed (HTTP {(int)response.StatusCode}): {body}");
return 1;
}
using var result = JsonDocument.Parse(body);
Console.WriteLine($"Sent: order_id {result.RootElement.GetProperty("order_id")}, " +
$"total_sent {result.RootElement.GetProperty("total_sent")}");
return 0;
Java
// Java 11+ (java.net.http). Save as SendSms.java (UTF-8) and run: java SendSms.java
// Set the environment variables SMSMARKET_USER_KEY (your API account number)
// and SMSMARKET_TOKEN (Account → Tokens on the platform).
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
public class SendSms {
private static final String BASE_URL = "https://sms.smsmarket.it/API/v1.0/REST/";
public static void main(String[] args) throws Exception {
String userKey = System.getenv("SMSMARKET_USER_KEY");
String token = System.getenv("SMSMARKET_TOKEN");
if (userKey == null || token == null) {
System.err.println("Set SMSMARKET_USER_KEY and SMSMARKET_TOKEN.");
System.exit(1);
}
// HTTP/1.1 keeps the header names exactly as written (user_key, Access_token).
HttpClient http = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
// The JDK has no JSON library: in a real project use Jackson or Gson.
String json = "{"
+ "\"message_type\": \"N\","
+ "\"message\": \"Ciao! Il tuo appuntamento è confermato per domani alle 10:00.\","
+ "\"recipient\": [\"+393471234567\"],"
+ "\"sender\": \"MioNegozio\""
+ "}";
// Send an SMS
HttpRequest send = HttpRequest.newBuilder(URI.create(BASE_URL + "sms"))
.header("Content-Type", "application/json; charset=utf-8")
.header("user_key", userKey)
.header("Access_token", token)
.POST(HttpRequest.BodyPublishers.ofString(json, StandardCharsets.UTF_8))
.build();
HttpResponse<String> response = http.send(send, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 201) {
System.err.println("Send failed (HTTP " + response.statusCode() + "): " + response.body());
System.exit(1);
}
System.out.println("Sent: " + response.body());
}
}
The program sends an SMS with delivery notification using the token. The credentials come from the environment variables SMSMARKET_USER_KEY (your API account number) and SMSMARKET_TOKEN.
3. Delivery status
GET
https://sms.smsmarket.it/API/v1.0/REST/sms/{order_id}
Replace {order_id} with the ID returned by the sending. The response gives the status of each recipient:
{
"recipient_number": 1,
"result": "OK",
"recipients": [
{
"status": "DLVRD",
"message": "Text message",
"destination": "+393471234567",
"delivery_date": "20261204175609"
}
]
}
Status values
- WAITING
- Pending
- SENT
- Sent to the carrier
- WAIT4DLVR
- Waiting for delivery confirmation
- DLVRD
- Delivered
- SCHEDULED
- Scheduled
- ERROR
- Error
- TIMEOUT
- Expired without confirmation
- UNKNRCPT
- Invalid number
- UNKNPFX
- Unknown prefix
- INVALIDDST
- Invalid recipient
- BLACKLISTED
- Number blacklisted
- TOOM4USER, TOOM4NUM
- Too many SMS in a short time
- INVALIDCONTENTS
- Invalid content
- KO
- Rejected by the carrier
- DEMO
- Sent in demo mode
Delivery confirmation is only available for SMS with notification (N).
4. Remaining credit
GET
https://sms.smsmarket.it/API/v1.0/REST/status?typeAliases=true
In sms you find, for each type, how many SMS you still have (quantity). For SMSMarket packages look at types N and LL: the response also lists type L (medium quality), which SMSMarket does not sell and is always zero for you.
{
"money": null,
"sms": [
{
"type": "N",
"quantity": 0
},
{
"type": "L",
"quantity": 0
},
{
"type": "LL",
"quantity": 200
}
],
"email": null
}
Example: delivery status and credit
cURL
#!/usr/bin/env bash
# Usage: ./status.sh ORDER_ID
# Credentials from environment variables:
# export SMSMARKET_USER_KEY="12345678" # your API account number
# export SMSMARKET_TOKEN="..." # Account → Tokens on the platform
set -euo pipefail
BASE_URL="https://sms.smsmarket.it/API/v1.0/REST/"
ORDER_ID="$1"
# 1. Delivery status of a sending
curl -sS --fail-with-body "${BASE_URL}sms/${ORDER_ID}" \
-H "user_key: $SMSMARKET_USER_KEY" \
-H "Access_token: $SMSMARKET_TOKEN"
echo
# 2. Remaining credit, as SMS available per type
curl -sS --fail-with-body "${BASE_URL}status?typeAliases=true" \
-H "user_key: $SMSMARKET_USER_KEY" \
-H "Access_token: $SMSMARKET_TOKEN"
echo
PHP
<?php
// PHP 8.1+ with the curl extension.
// Run: SMSMARKET_USER_KEY="12345678" SMSMARKET_TOKEN="..." php status.php ORDER_ID
const BASE_URL = 'https://sms.smsmarket.it/API/v1.0/REST/';
/** Authenticated GET request: returns the decoded JSON, or exits on error. */
function smsmarket_get(string $path): array
{
$ch = curl_init(BASE_URL . $path);
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => [
'user_key: ' . getenv('SMSMARKET_USER_KEY'),
'Access_token: ' . getenv('SMSMARKET_TOKEN'),
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
$body = curl_exec($ch);
if ($body === false) {
fwrite(STDERR, 'Connection error: ' . curl_error($ch) . "\n");
exit(1);
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status !== 200) {
fwrite(STDERR, "GET $path failed (HTTP $status): $body\n");
exit(1);
}
return json_decode($body, true, flags: JSON_THROW_ON_ERROR);
}
if (!isset($argv[1])) {
fwrite(STDERR, "Usage: php status.php ORDER_ID\n");
exit(1);
}
// 1. Delivery status of a sending
foreach (smsmarket_get('sms/' . rawurlencode($argv[1]))['recipients'] as $recipient) {
echo "{$recipient['destination']}: {$recipient['status']}\n";
}
// 2. Remaining credit, as SMS available per type
foreach (smsmarket_get('status?typeAliases=true')['sms'] as $credit) {
echo "{$credit['type']}: {$credit['quantity']} SMS\n";
}
Python
# Python 3.8+ with requests (pip install requests).
# Run: SMSMARKET_USER_KEY="12345678" SMSMARKET_TOKEN="..." python status.py ORDER_ID
import os
import sys
import requests
BASE_URL = "https://sms.smsmarket.it/API/v1.0/REST/"
HEADERS = {
"user_key": os.environ["SMSMARKET_USER_KEY"],
"Access_token": os.environ["SMSMARKET_TOKEN"],
}
def get(path):
r = requests.get(BASE_URL + path, headers=HEADERS, timeout=30)
if r.status_code != 200:
sys.exit(f"GET {path} failed (HTTP {r.status_code}): {r.text}")
return r.json()
if len(sys.argv) != 2:
sys.exit("Usage: python status.py ORDER_ID")
# 1. Delivery status of a sending
for recipient in get("sms/" + sys.argv[1])["recipients"]:
print(f"{recipient['destination']}: {recipient['status']}")
# 2. Remaining credit, as SMS available per type
for credit in get("status?typeAliases=true")["sms"]:
print(f"{credit['type']}: {credit['quantity']} SMS")
Node.js
// Node.js 18+ (global fetch), ES module: save as status.mjs
// Run: SMSMARKET_USER_KEY="12345678" SMSMARKET_TOKEN="..." node status.mjs ORDER_ID
const BASE_URL = "https://sms.smsmarket.it/API/v1.0/REST/";
const HEADERS = {
user_key: process.env.SMSMARKET_USER_KEY,
Access_token: process.env.SMSMARKET_TOKEN,
};
async function get(path) {
const res = await fetch(BASE_URL + path, { headers: HEADERS });
const body = await res.text();
if (res.status !== 200) {
console.error(`GET ${path} failed (HTTP ${res.status}): ${body}`);
process.exit(1);
}
return JSON.parse(body);
}
const orderId = process.argv[2];
if (!orderId) {
console.error("Usage: node status.mjs ORDER_ID");
process.exit(1);
}
// 1. Delivery status of a sending
const report = await get(`sms/${encodeURIComponent(orderId)}`);
for (const recipient of report.recipients) {
console.log(`${recipient.destination}: ${recipient.status}`);
}
// 2. Remaining credit, as SMS available per type
const credit = await get("status?typeAliases=true");
for (const { type, quantity } of credit.sms) {
console.log(`${type}: ${quantity} SMS`);
}
C#
// .NET 6+ console app (Program.cs, top-level statements). Run: dotnet run -- ORDER_ID
// Set the environment variables SMSMARKET_USER_KEY (your API account number)
// and SMSMARKET_TOKEN (Account → Tokens on the platform).
using System;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
const string BaseUrl = "https://sms.smsmarket.it/API/v1.0/REST/";
if (args.Length != 1)
{
Console.Error.WriteLine("Usage: dotnet run -- ORDER_ID");
return 1;
}
using var http = new HttpClient { BaseAddress = new Uri(BaseUrl) };
http.DefaultRequestHeaders.Add("user_key", Environment.GetEnvironmentVariable("SMSMARKET_USER_KEY"));
http.DefaultRequestHeaders.Add("Access_token", Environment.GetEnvironmentVariable("SMSMARKET_TOKEN"));
async Task<JsonDocument?> Get(string path)
{
using var response = await http.GetAsync(path);
var body = await response.Content.ReadAsStringAsync();
if (response.StatusCode == HttpStatusCode.OK) return JsonDocument.Parse(body);
Console.Error.WriteLine($"GET {path} failed (HTTP {(int)response.StatusCode}): {body}");
return null;
}
// 1. Delivery status of a sending
using var report = await Get($"sms/{Uri.EscapeDataString(args[0])}");
if (report is null) return 1;
foreach (var recipient in report.RootElement.GetProperty("recipients").EnumerateArray())
{
Console.WriteLine($"{recipient.GetProperty("destination")}: {recipient.GetProperty("status")}");
}
// 2. Remaining credit, as SMS available per type
using var credit = await Get("status?typeAliases=true");
if (credit is null) return 1;
foreach (var sms in credit.RootElement.GetProperty("sms").EnumerateArray())
{
Console.WriteLine($"{sms.GetProperty("type")}: {sms.GetProperty("quantity")} SMS");
}
return 0;
Java
// Java 11+ (java.net.http). Save as SmsStatus.java and run: java SmsStatus.java ORDER_ID
// Set the environment variables SMSMARKET_USER_KEY (your API account number)
// and SMSMARKET_TOKEN (Account → Tokens on the platform).
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
public class SmsStatus {
private static final String BASE_URL = "https://sms.smsmarket.it/API/v1.0/REST/";
// HTTP/1.1 keeps the header names exactly as written (user_key, Access_token).
private static final HttpClient HTTP = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.build();
private static String get(String path) throws Exception {
HttpRequest request = HttpRequest.newBuilder(URI.create(BASE_URL + path))
.header("user_key", System.getenv("SMSMARKET_USER_KEY"))
.header("Access_token", System.getenv("SMSMARKET_TOKEN"))
.GET()
.build();
HttpResponse<String> response = HTTP.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) {
System.err.println("GET " + path + " failed (HTTP " + response.statusCode() + "): " + response.body());
System.exit(1);
}
return response.body();
}
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Usage: java SmsStatus.java ORDER_ID");
System.exit(1);
}
// 1. Delivery status of a sending (JSON; parse it with Jackson or Gson)
System.out.println(get("sms/" + URLEncoder.encode(args[0], StandardCharsets.UTF_8)));
// 2. Remaining credit, as SMS available per type
System.out.println(get("status?typeAliases=true"));
}
}
This example reads the status of a sending (pass the ID as an argument) and then the remaining credit.
5. Delivery notifications (webhook)
Instead of asking for the status, you can be notified. In Account → Delivery receipts enter your server's address in the Settings Url Notifica Stato Invio SMS field and choose the GET or POST method; then press SALVA.
When an SMS reaches its final status, the platform calls your address with these fields:
delivery_date- Delivery date and time, in the format
yyyyMMddHHmmss. order_id- The ID of the sending.
status- The status, with the same values as the delivery status.
recipient- The recipient's number in international format, URL-encoded (
%2Binstead of+).
Example body sent with POST:
delivery_date=20261204175609&order_id=6DD2A87ABF71485A8AFD29BA55FCFD83&status=DLVRD&recipient=%2B393471234567
Your address must reply with HTTP 200. A minimal example in PHP:
<?php
// delivery.php: the address you set in Account → Delivery receipts.
// The platform sends delivery_date, order_id, status and recipient (GET or POST).
$data = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
$orderId = $data['order_id'] ?? '';
$recipient = $data['recipient'] ?? ''; // already decoded, e.g. +393471234567
$status = $data['status'] ?? ''; // DLVRD, ERROR, UNKNRCPT, ...
$deliveryDate = $data['delivery_date'] ?? ''; // yyyyMMddHHmmss
// Save the status in your database; here we just write it to the log.
error_log("SMS $orderId to $recipient: $status at $deliveryDate");
http_response_code(200);
Delivery confirmation only arrives for SMS with notification (N).
Simple HTTP API (compatibility)
This is the interface of the old SMSMarket and it is still active. Use it only if you already have software that relies on it: for new projects choose the REST API.
Always use HTTPS and prefer the POST method, with the parameters sent as a form (application/x-www-form-urlencoded).
As credentials use your account email and the API password set in Account → API Password, not your login password.
Sending one SMS
POST
https://sms.smsmarket.it/sms/send.php
user- Your account email.
pass- Your API password (Account → API Password), not your login password.
rcpt- The recipient's number, in international format.
data- The text of the message, up to 160 characters.
sender- The sender: up to 11 alphanumeric characters or a number in international format.
qtynfor SMS with notification,llfor SMS without notification.return_id- Optional: with
return_id=1the response also contains the sending ID.
Response: OK followed by the credit used, or KO followed by the error.
Sending to several recipients
POST
https://sms.smsmarket.it/sms/batch.php
Same parameters, but put several comma-separated numbers in rcpt. Response: OK or KO followed by the error.
Remaining credit
POST
https://sms.smsmarket.it/sms/credit.php
Parameters user and pass, plus an optional type:
creditcredit in euros (default);lqsSMS without notification available;hqsSMS with notification available.
Response: OK followed by the value.
Most common errors
KO Accesso non consentito: wrong credentials, or user or IP address not enabled.KO Parametro <nome> non impostatoKO Parametro <nome> non validoKO Credito insufficienteKO Impossibile accodare il/i messaggio/i
Example: sending an SMS
cURL
#!/usr/bin/env bash
# Credentials from environment variables:
# export SMSMARKET_EMAIL="TUA_EMAIL"
# export SMSMARKET_API_PASSWORD="TUA_PASSWORD_API" # Account → API Password, not the login password
set -euo pipefail
RESPONSE=$(curl -sS https://sms.smsmarket.it/sms/send.php \
--data-urlencode "user=$SMSMARKET_EMAIL" \
--data-urlencode "pass=$SMSMARKET_API_PASSWORD" \
--data-urlencode "rcpt=+393471234567" \
--data-urlencode "data=Ciao! Il tuo appuntamento è confermato per domani alle 10:00." \
--data-urlencode "sender=MioNegozio" \
--data-urlencode "qty=n")
# The response starts with "OK" or "KO"
case "$RESPONSE" in
OK*) echo "Sent: $RESPONSE" ;;
*) echo "Error: $RESPONSE" >&2; exit 1 ;;
esac
PHP
<?php
// PHP 8+ with the curl extension.
// Run: SMSMARKET_EMAIL="TUA_EMAIL" SMSMARKET_API_PASSWORD="TUA_PASSWORD_API" php send.php
$ch = curl_init('https://sms.smsmarket.it/sms/send.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query([
'user' => getenv('SMSMARKET_EMAIL'),
'pass' => getenv('SMSMARKET_API_PASSWORD'),
'rcpt' => '+393471234567',
'data' => 'Ciao! Il tuo appuntamento è confermato per domani alle 10:00.',
'sender' => 'MioNegozio',
'qty' => 'n',
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
$response = curl_exec($ch);
if ($response === false) {
fwrite(STDERR, 'Connection error: ' . curl_error($ch) . "\n");
exit(1);
}
$response = trim($response);
// The response starts with "OK" or "KO"
if (!str_starts_with($response, 'OK')) {
fwrite(STDERR, "Error: $response\n");
exit(1);
}
echo "Sent: $response\n";
Need help with your integration?
Email us: direct support, no switchboards or tickets.
The platform also offers advanced features, such as contact lists and campaigns: if you need them through the API, write to us and we will send you the instructions.