POST کلیه درخواستها باید با متد POST و هدر
Content-Type: application/json ارسال شوند.
{
"to": "09123456789",
"code": "123456"
}
✅ پاسخ موفق
{
"status": true,
"message": "Verification code sent successfully",
"recId": "3741437414"
}
❌ خطاهای احتمالی
📦 نمونه پاسخ خطا
{
"status": false,
"error": "Insufficient wallet balance. Please recharge your account."
}
برای ارسال درخواست، موارد زیر باید ارسال شوند:
https://apisms.nnehdi.ir/api/v2/sendsms/apiPOSTAuthorization: Bearer YOUR_API_KEY – کلید API خود را از پنل کاربری دریافت کنیدContent-Type: application/jsonto – شماره موبایل ۱۱ رقمی با 09 (مثال: 09123456789)code – کد تایید ۶ رقمی عددی (مثال: 123456)برای دریافت کلید API، وارد پنل کاربری خود شوید و از بخش «کلیدهای API» اقدام به ساخت کلید جدید کنید.
زبانی که میخواهید را از برگههای زیر انتخاب کنید.
<?php
$apiUrl = 'https://apisms.nnehdi.ir/api/v2/sendsms/api';
$apiKey = 'sk_YOUR_API_KEY';
$data = [
'to' => '09123456789',
'code' => '123456'
];
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $response;
?>
پاسخ دریافتی مشابه نمونه پاسخ موفق خواهد بود.
const apiUrl = 'https://apisms.nnehdi.ir/api/v2/sendsms/api';
const apiKey = 'sk_YOUR_API_KEY';
const data = {
to: '09123456789',
code: '123456'
};
fetch(apiUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));
پاسخ دریافتی به صورت JSON در کنسول لاگ میشود.
import requests
api_url = 'https://apisms.nnehdi.ir/api/v2/sendsms/api'
api_key = 'sk_YOUR_API_KEY'
payload = {
'to': '09123456789',
'code': '123456'
}
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
response = requests.post(api_url, json=payload, headers=headers, verify=True)
print(response.status_code)
print(response.json())
پاسخ دریافتی به صورت دیکشنری چاپ میشود.
import kong.unirest.Unirest;
import kong.unirest.HttpResponse;
import kong.unirest.JsonNode;
public class SendSms {
public static void main(String[] args) {
String apiUrl = "https://apisms.nnehdi.ir/api/v2/sendsms/api";
String apiKey = "sk_YOUR_API_KEY";
HttpResponse<JsonNode> response = Unirest.post(apiUrl)
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.body("{\"to\":\"09123456789\",\"code\":\"123456\"}")
.asJson();
System.out.println(response.getStatus());
System.out.println(response.getBody());
}
}
پاسخ به صورت JsonNode دریافت میشود.
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
class Program {
static async Task Main() {
string apiUrl = "https://apisms.nnehdi.ir/api/v2/sendsms/api";
string apiKey = "sk_YOUR_API_KEY";
var payload = new { to = "09123456789", code = "123456" };
var json = JsonConvert.SerializeObject(payload);
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(apiUrl, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(response.StatusCode);
Console.WriteLine(result);
}
}
پاسخ به صورت رشته JSON دریافت میشود.