Send OTP codes and SMS to Libyana and Almadar with one request
A simple REST API with a single API key. Sign-up is free and a test mode sends nothing and charges nothing. This is the static version of the docs; the interactive version and a Postman collection live in the dashboard.
Create a free API key Interactive docs in the dashboard → · Code examples & OpenAPI spec on GitHub →
Overview
| Base URL | https://dev.resala.ly/api/v1 |
|---|---|
| Format | JSON request and response, Content-Type: application/json |
| Networks | Libyana and Almadar; Libyan numbers as 2189XXXXXXXX (091/092/093/094 + 7 digits) |
| Price | 0.10 LYD per SMS, deducted from your balance on send (each 67 characters, or part of them, count as one message) |
| Test mode | Append ?test to any send request: nothing is sent or charged |
| Apps | Web dashboard plus iOS and Android apps to follow messages and balance |
Authentication
Create an API key in the dashboard (API → Create key) and send it in the header of every request. Keys can be paused or deleted, and each key tracks how many messages it sent.
Authorization: Bearer YOUR_API_KEYSend an OTP (verification code)
Generates a code, sends it by SMS and returns it in the response. Verifying the code is your job: store pin on your server, compare it with what the user types, and enforce your own expiry.
https://dev.resala.ly/api/v1/pins?service_name=MyAppQuery parameters
| Parameter | Description |
|---|---|
service_name | Your app name, appended to the SMS text |
test | Test mode: nothing sent, nothing charged |
len | Code length: 4, 5 or 6 (default 6) |
autofill | Android App Signature for SMS autofill |
sender | A sender name registered on your account (optional) |
Request body
| Parameter | Description |
|---|---|
phone | Required. International format. |
Examples
curl -X POST "https://dev.resala.ly/api/v1/pins?service_name=MyApp" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"phone": "218910001234"}' // Node.js 18+ / Deno / Bun
const res = await fetch("https://dev.resala.ly/api/v1/pins?service_name=MyApp", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RESALA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"phone": "218910001234"}),
});
const data = await res.json();
console.log(data);<?php
$ch = curl_init("https://dev.resala.ly/api/v1/pins?service_name=MyApp");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("RESALA_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(["phone" => "218910001234"], JSON_UNESCAPED_UNICODE),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);import os, requests
r = requests.post(
"https://dev.resala.ly/api/v1/pins?service_name=MyApp",
headers={"Authorization": f"Bearer {os.environ['RESALA_API_KEY']}"},
json={"phone": "218910001234"},
timeout=15,
)
r.raise_for_status()
print(r.json())// Flutter / Dart — package:http
import 'dart:convert';
import 'package:http/http.dart' as http;
final res = await http.post(
Uri.parse('https://dev.resala.ly/api/v1/pins?service_name=MyApp'),
headers: {
'Authorization': 'Bearer $resalaApiKey',
'Content-Type': 'application/json',
},
body: jsonEncode({"phone": "218910001234"}),
);
final data = jsonDecode(res.body);
print(data);package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"phone": "218910001234"}`)
req, _ := http.NewRequest("POST", "https://dev.resala.ly/api/v1/pins?service_name=MyApp", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("RESALA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}
Success response (201)
{
"id": "9b1f5b7e-3f1a-4c2e-8a5e-6f3d2c1b0a9e",
"pin": "482913",
"code": "218",
"region": "LY",
"number": "910001234",
"content": "رمز التحقق: 482913 - MyApp",
"hit_count": 0,
"created_at": "2026-09-16T12:00:00Z",
"sender_name": "MyBrand"
}Send a free-text message
Sends one message with your own text (up to 1000 characters). A successful send is charged immediately; do not retry automatically after a network error. Available to accounts with free-text permission.
https://dev.resala.ly/api/v1/messagesQuery parameters
| Parameter | Description |
|---|---|
test | Test mode |
sender | Registered sender name (optional) |
scheduled_at | Schedule: YYYY-MM-DD HH:MM Libya time or RFC 3339, in the future, within 30 days |
Request body
| Parameter | Description |
|---|---|
phone | Required. Libyan number. |
content | Required. Up to 1000 characters, sent as is. |
Examples
curl -X POST "https://dev.resala.ly/api/v1/messages" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"phone": "218910001234", "content": "Your order 2841 is on its way"}' // Node.js 18+ / Deno / Bun
const res = await fetch("https://dev.resala.ly/api/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RESALA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"phone": "218910001234", "content": "Your order 2841 is on its way"}),
});
const data = await res.json();
console.log(data);<?php
$ch = curl_init("https://dev.resala.ly/api/v1/messages");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("RESALA_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(["phone" => "218910001234", "content" => "Your order 2841 is on its way"], JSON_UNESCAPED_UNICODE),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);import os, requests
r = requests.post(
"https://dev.resala.ly/api/v1/messages",
headers={"Authorization": f"Bearer {os.environ['RESALA_API_KEY']}"},
json={"phone": "218910001234", "content": "Your order 2841 is on its way"},
timeout=15,
)
r.raise_for_status()
print(r.json())// Flutter / Dart — package:http
import 'dart:convert';
import 'package:http/http.dart' as http;
final res = await http.post(
Uri.parse('https://dev.resala.ly/api/v1/messages'),
headers: {
'Authorization': 'Bearer $resalaApiKey',
'Content-Type': 'application/json',
},
body: jsonEncode({"phone": "218910001234", "content": "Your order 2841 is on its way"}),
);
final data = jsonDecode(res.body);
print(data);package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"phone": "218910001234", "content": "Your order 2841 is on its way"}`)
req, _ := http.NewRequest("POST", "https://dev.resala.ly/api/v1/messages", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("RESALA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}
Success response (201)
{
"id": "1f0c8a54-2b77-4d6e-9f31-0a8b7c6d5e4f",
"code": "218",
"region": "LY",
"number": "910001234",
"content": "نص الرسالة",
"env": "production",
"price": 0.1,
"pages": 1,
"status": "accepted",
"created_at": "2026-09-16T12:00:00Z",
"sender_name": "MyBrand"
}Send an approved template
Sends a template approved in “Message templates” to one or more recipients, filling $1, $2… Each record may carry its own scheduled_at.
https://dev.resala.ly/api/v1/messages/send-template?sms_template_id=TEMPLATE_IDQuery parameters
| Parameter | Description |
|---|---|
sms_template_id | Required. Template id |
test | Cost is computed, nothing sent or charged |
sender | Sender name (optional) |
scheduled_at | Schedule (optional) |
Examples
curl -X POST "https://dev.resala.ly/api/v1/messages/send-template?sms_template_id=TEMPLATE_ID" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"records": [{"phone": "218910001234", "$1": "رسالة", "$2": "أحمد"}]}' // Node.js 18+ / Deno / Bun
const res = await fetch("https://dev.resala.ly/api/v1/messages/send-template?sms_template_id=TEMPLATE_ID", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RESALA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"records": [{"phone": "218910001234", "$1": "رسالة", "$2": "أحمد"}]}),
});
const data = await res.json();
console.log(data);<?php
$ch = curl_init("https://dev.resala.ly/api/v1/messages/send-template?sms_template_id=TEMPLATE_ID");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("RESALA_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(["records" => [["phone" => "218910001234", "$1" => "رسالة", "$2" => "أحمد"]]], JSON_UNESCAPED_UNICODE),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);import os, requests
r = requests.post(
"https://dev.resala.ly/api/v1/messages/send-template?sms_template_id=TEMPLATE_ID",
headers={"Authorization": f"Bearer {os.environ['RESALA_API_KEY']}"},
json={"records": [{"phone": "218910001234", "$1": "رسالة", "$2": "أحمد"}]},
timeout=15,
)
r.raise_for_status()
print(r.json())// Flutter / Dart — package:http
import 'dart:convert';
import 'package:http/http.dart' as http;
final res = await http.post(
Uri.parse('https://dev.resala.ly/api/v1/messages/send-template?sms_template_id=TEMPLATE_ID'),
headers: {
'Authorization': 'Bearer $resalaApiKey',
'Content-Type': 'application/json',
},
body: jsonEncode({"records": [{"phone": "218910001234", "$1": "رسالة", "$2": "أحمد"}]}),
);
final data = jsonDecode(res.body);
print(data);package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"records": [{"phone": "218910001234", "$1": "رسالة", "$2": "أحمد"}]}`)
req, _ := http.NewRequest("POST", "https://dev.resala.ly/api/v1/messages/send-template?sms_template_id=TEMPLATE_ID", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("RESALA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}
Success response (201)
{
"is_prod": true,
"total_messages": 1,
"total_cost": 0.1,
"succeeded": 1,
"failed": 0,
"failed_numbers": [],
"invalid_numbers": [],
"sender_names": { "libyana": "MyBrand", "almadar": "MyBrand" },
"sms_template_version": { "id": "6d2f9c41-…", "version_number": 3, "status": "APPROVED" }
}Bulk send from a CSV file
A CSV file in a multipart/form-data request; first line phone,content, optional scheduled_at column. The whole file is priced first; more than 50 numbers runs in the background and returns a batch_id to follow with GET /message-batches/{id}.
https://dev.resala.ly/api/v1/messages/bulk-sendcurl -X POST "https://dev.resala.ly/api/v1/messages/bulk-send" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "csv=@messages.csv"
phone,content,scheduled_at
218910001234,Hi Ahmed, your order is ready,
218920001234,Reminder: appointment tomorrow 10:00,2026-11-20 09:00Message log
Everything you sent, codes and messages, with the status of each. Delivery status updates after sending, so poll here instead of waiting on the send response.
https://dev.resala.ly/api/v1/sent-view?filters=source:message|pin| Parameter | Description |
|---|---|
filters | source:message or source:pin |
q | Search text and recipient number |
sorts | Sort column, prefix - for descending |
page / paginate | Page number and page size |
curl "https://dev.resala.ly/api/v1/sent-view?filters=source:message|pin&paginate=20" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"data": [{
"id": "1f0c8a54-2b77-4d6e-9f31-0a8b7c6d5e4f",
"number": "910001234",
"content": "نص الرسالة",
"source": "message",
"status": "delivered",
"pages": 1,
"created_at": "2026-09-16T12:00:00Z"
}],
"meta": { "total": 1, "per_page": 20, "current_page": 1, "last_page": 1 }
}Sender ID
Send under your brand by adding ?sender=MyBrand to any send request. The name is case-sensitive and must be active for your account on the recipient's network; otherwise the message goes out under your default name, then “Resala”, with no error. Request a sender name from the dashboard: English letters, up to 11 characters, about 10 working days for Libyana and Almadar approval.
POST https://dev.resala.ly/api/v1/pins?service_name=MyApp&sender=MyBrandMessage statuses
accepted | Handed to the carrier, awaiting its report |
|---|---|
sent | Sent at the carrier |
delivered | Delivered to the handset |
undelivered | Carrier reported non-delivery |
pending | Queued at the carrier, no decision yet |
failed | Rejected by every network, will not be retried |
Errors
Branch on type, not on message (the latter is localized and may change). Include request_id when contacting support.
{
"status": 400,
"type": "InsufficientCredit",
"message": "...",
"request_id": "01JQ8Z4K7M"
}
| HTTP | type | |
|---|---|---|
| 400 | AccountExpired | Your account subscription expired |
| 400 | InsufficientCredit | Not enough balance to send |
| 400 | BadRequest | The request could not be processed |
| 401 | Unauthorized | Missing or invalid API key |
| 401 | TokenExpired | Token expired |
| 403 | Forbidden | Not allowed to perform this action |
| 404 | NotFound | Resource not found |
| 422 | InputValidation | One or more fields failed validation (non-Libyan number, text over 1000 chars…) |
Developer FAQ
Do I need an international card or a company outside Libya?
No. Sign-up is free and you top up in Libyan dinars via Edfali, YusrPay, MobiCash, Libyan bank cards or bank transfer.
How do I test without paying?
Append ?test to the send request; you get the same response with nothing sent or charged.
Is there an SDK?
It is a plain REST API that works from any language with no SDK; the examples above cover six languages, there is an OpenAPI spec AI tools can generate code from directly, and a Postman collection in the dashboard. Everything is in the GitHub repository.
What is the Twilio alternative for SMS in Libya?
Resala delivers directly through Libyana and Almadar at 0.10 LYD per message, versus roughly $0.40 per message through international providers. Full comparison.