This guide explains how to integrate with the SMS API using API keys. The API provides endpoints for sending individual and bulk SMS messages, checking message status, and managing SIM numbers.
Production: https://prosendi.com/api
Development: http://localhost:8000/api
All API requests require authentication using an API key. The API key must be:
The system automatically validates your API key on every request:
active field is trueexpires_dateIf any validation fails, the request is rejected with a 401 Unauthorized response.
Include your API key in one of the following ways:
X-API-Key: your_api_key_here
Authorization: Bearer your_api_key_here
curl -X POST https://prosendi.com/api/sms/send \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"recipient": "+22370123456", "message": "Hello World"}'
Send a single SMS message to a recipient.
Endpoint: POST /api/sms/send
Authentication: Required (API Key + Quota Check)
Request Body:
{
"recipient": "+22370123456",
"message": "Your message text here (max 1600 characters)",
"sim_number_id": 1,
"campaign_id": 5
}
Success Response (200):
{
"success": true,
"message": "SMS envoyé avec succès",
"data": {
"sms_id": "uuid-here",
"task_id": "17617592691708",
"sim_number": "+22366603716",
"recipient": "+22370123456",
"status": "sent"
}
}
Error Responses:
| Status Code | Error Type | Description |
|---|---|---|
| 400 | Bad Request | Invalid phone number format or message too long |
| 401 | Unauthorized | Missing or invalid API key |
| 403 | Forbidden | Company account is inactive |
| 429 | Too Many Requests | Quota exceeded |
| 500 | Internal Error | Server error or SIM unavailable |
Send multiple SMS messages in a single request.
Endpoint: POST /api/sms/send-bulk
Authentication: Required (API Key + Quota Check)
Request Body:
{
"messages": [
{ "recipient": "+22370123456", "message": "Message 1" },
{ "recipient": "+22370987654", "message": "Message 2" }
],
"sim_number_id": 1,
"campaign_id": 5
}
Constraints:
Success Response (200):
{
"success": true,
"message": "Envoi terminé: 2 succès, 0 échecs",
"summary": { "total": 2, "success": 2, "failed": 0 },
"results": [
{
"recipient": "+22370123456",
"success": true,
"sms_id": "uuid-1",
"task_id": "17617592691708",
"sim_number": "+22366603716"
},
{
"recipient": "+22370987654",
"success": true,
"sms_id": "uuid-2",
"task_id": "17617592691709",
"sim_number": "+22366603716"
}
]
}
Retrieve the status of a previously sent SMS.
Endpoint: GET /api/sms/status/{sms_id}
Authentication: Required (API Key only)
Parameters:
sms_id (path parameter): UUID of the SMS messageSuccess Response (200):
{
"success": true,
"data": {
"sms_id": "uuid-here",
"recipient": "+22370123456",
"sender": "+22366603716",
"message": "Your message text",
"status": "sent",
"status_label": "Sent",
"sent_at": "2025-10-30T14:30:00.000000Z",
"delivered_at": null,
"failed_at": null,
"failure_reason": null,
"cost": 0.05,
"retry_count": 0,
"sim_number": "+22366603716"
}
}
Status Values:
| Status | Description |
|---|---|
pending |
Message queued for sending |
sent |
Message sent successfully |
delivered |
Message delivered to recipient |
failed |
Message failed to send |
cancelled |
Message was cancelled |
List all available SIM cards for SMS sending.
Endpoint: GET /api/sms/sims/available
Authentication: Required (API Key only)
Success Response (200):
{
"success": true,
"data": {
"assigned_sim": {
"id": 1,
"number": "+22366603716",
"name": "Orange Mali SIM",
"operator": "Orange",
"can_send_sms": true
},
"available_sims": [
{
"id": 1,
"number": "+22366603716",
"name": "Orange Mali SIM",
"operator": "Orange",
"port": 8,
"slot": 2,
"is_default": true,
"balance": 0,
"daily_limit": 100,
"monthly_limit": 3000,
"usage_stats": {
"today_sent": 45,
"today_failed": 2,
"this_month_sent": 1250
},
"can_send_sms": true,
"assigned_to": "Orange Mali"
}
],
"total_available": 1
}
}
Test the 1SIMPLE1 gateway connection (Administration only).
Endpoint: GET /api/sms/test-connection
Authentication: Required (API Key only)
Success Response (200):
{
"success": true,
"message": "Connexion 1SIMPLE1 réussie",
"data": { "result": "success" },
"status_code": 200
}
^(\+223)?[67][0-9]{7}$
Valid Examples:
+22370123456223709876547012345670987654Invalid Examples:
2237012345672631234567822350123456Always include:
Content-Type: application/json
Accept: application/json
{
"success": false,
"message": "Human-readable error message",
"error": "error_code",
"data": {}
}
| Error Code | HTTP Status | Description |
|---|---|---|
missing_api_key |
401 | API key not provided |
invalid_api_key |
401 | API key is invalid |
inactive_api_key |
401 | API key is expired or deactivated |
inactive_company |
403 | Company account is inactive |
service_type_mismatch |
403 | API key is not valid for this service type |
quota_exceeded |
429 | SMS quota exceeded |
invalid_request |
400 | Request validation failed |
sim_unavailable |
400 | No available SIM for sending |
company_not_found |
500 | Company not found for this API key |
{
"success": false,
"message": "API key has expired",
"error": "inactive_api_key",
"data": {
"expired": true,
"deactivated": false,
"expires_date": "2025-01-15T00:00:00.000000Z",
"active": true
}
}
{
"success": false,
"message": "API key is not valid for this service type",
"error": "service_type_mismatch",
"data": { "api_key_service": "email", "requested_service": "sms" }
}
{
"success": false,
"message": "Quota exceeded",
"error": "quota_exceeded",
"data": {
"service_type": "sms",
"requested": 10,
"remaining": 0,
"total_quota": 1000,
"usage_percentage": 100.0
}
}
Check your quota status:
Total Quota: 1,000 SMS/month
Sent This Month: 750
Remaining: 250
Usage: 75%
const axios = require("axios");
const API_KEY = "your_api_key_here";
const BASE_URL = "https://prosendi.com/api";
async function sendSMS(recipient, message) {
const response = await axios.post(
`${BASE_URL}/sms/send`,
{ recipient, message },
{
headers: {
"X-API-Key": API_KEY,
"Content-Type": "application/json",
},
}
);
return response.data;
}
import requests
API_KEY = 'your_api_key_here'
BASE_URL = 'https://prosendi.com/api'
def send_sms(recipient, message):
url = f'{BASE_URL}/sms/send'
headers = {'X-API-Key': API_KEY, 'Content-Type': 'application/json'}
data = {'recipient': recipient, 'message': message}
return requests.post(url, json=data, headers=headers).json()
<?php
$apiKey = 'your_api_key_here';
$baseUrl = 'https://prosendi.com/api';
$ch = curl_init($baseUrl . '/sms/send');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-API-Key: ' . $apiKey,'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['recipient' => '+22370123456','message' => 'Hello from PHP!']));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
API_KEY="your_api_key_here"
BASE_URL="https://prosendi.com/api"
curl -X POST "$BASE_URL/sms/send" -H "X-API-Key: $API_KEY" -H "Content-Type: application/json" -d '{"recipient": "+22370123456", "message": "Hello from bash!"}'
Note: Webhooks are not yet implemented but planned for future releases.
Implement robust error handling.
Validate using regex before sending.
/api/documentation (coming soon)© 2025 Your Company. All rights reserved.