Référence de l'API
API SMS
Envoyez un message ou une campagne groupée depuis un identifiant d'expéditeur ou un numéro approuvé. Insérez #OTP4# ou #OTP6# dans le texte du message pour générer un mot de passe à usage unique.
URL de base https://portal.par-infinity.com/api/v1 · Authentification · Erreurs · Présentation du produit
Envoyer un SMS
POST /sms/send
Envoie un SMS vers n'importe quel numéro dans le monde.
Corps de la requête application/json
| Nom | Type | Description |
|---|---|---|
from obligatoire |
string | Utilisez un identifiant d'expéditeur ou un numéro approuvé.
Exemple : 12345
|
to obligatoire |
string |
Exemple : 123456789
|
message obligatoire |
string | Utilisez #OTP4# et #OTP6# comme balises pour générer un OTP.
Exemple : This is a test message
|
bind_name obligatoire |
string |
Exemple : bind1
|
pe_id |
string | Pour le DLT national indien.
Exemple : 54342445353452
|
template_id |
string | Pour le DLT national indien.
Exemple : 2372168395432
|
Exemple de requête
cURL
curl -X POST 'https://portal.par-infinity.com/api/v1/sms/send/' \
-H 'Authorization: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"from": "12345",
"to": "123456789",
"message": "This is a test message",
"bind_name": "bind1",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}'
Python
import requests
url = "https://portal.par-infinity.com/api/v1/sms/send/"
headers = {"Authorization": "YOUR_API_KEY"}
payload = {
"from": "12345",
"to": "123456789",
"message": "This is a test message",
"bind_name": "bind1",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
response = requests.post(url, headers=headers, json=payload, timeout=30)
print(response.status_code, response.json())
Node.js
const res = await fetch("https://portal.par-infinity.com/api/v1/sms/send/", {
method: "POST",
headers: {
Authorization: process.env.PAR_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"from": "12345",
"to": "123456789",
"message": "This is a test message",
"bind_name": "bind1",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}),
});
console.log(res.status, await res.json());
PHP
<?php
$ch = curl_init('https://portal.par-infinity.com/api/v1/sms/send/');
$headers = ['Authorization: YOUR_API_KEY'];
$payload = <<<'JSON'
{
"from": "12345",
"to": "123456789",
"message": "This is a test message",
"bind_name": "bind1",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
JSON;
$headers[] = 'Content-Type: application/json';
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => $headers,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), ' ', $response, PHP_EOL;
curl_close($ch);
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
String payload = """
{
"from": "12345",
"to": "123456789",
"message": "This is a test message",
"bind_name": "bind1",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://portal.par-infinity.com/api/v1/sms/send/"))
.header("Authorization", "YOUR_API_KEY")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}
Go
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
payload := `{
"from": "12345",
"to": "123456789",
"message": "This is a test message",
"bind_name": "bind1",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}`
req, err := http.NewRequest("POST", "https://portal.par-infinity.com/api/v1/sms/send/", strings.NewReader(payload))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(data))
}
Ruby
require 'net/http'
require 'uri'
uri = URI('https://portal.par-infinity.com/api/v1/sms/send/')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = <<~JSON
{
"from": "12345",
"to": "123456789",
"message": "This is a test message",
"bind_name": "bind1",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }
puts response.code, response.body
C# (.NET)
using System.Net.Http.Headers;
using System.Text;
var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://portal.par-infinity.com/api/v1/sms/send/");
request.Headers.TryAddWithoutValidation("Authorization", "YOUR_API_KEY");
var payload = """
{
"from": "12345",
"to": "123456789",
"message": "This is a test message",
"bind_name": "bind1",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
""";
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
Exemple de réponse 200
{
"status": "ok",
"message": "Message Sent",
"origination_message_id": "acba1293an"
}
Erreurs
401 Non autorisé403 Interdit404 Introuvable422 Entité non traitable429 Trop de requêtes500 Erreur interne du serveur
Envoyer des SMS en masse
POST /sms/send/batch
Envoie un SMS à plusieurs numéros.
Corps de la requête application/json
| Nom | Type | Description |
|---|---|---|
from obligatoire |
string | Utilisez un identifiant d'expéditeur ou un numéro approuvé.
Exemple : 12345
|
phone_numbers obligatoire |
array<string> |
Exemple : ['15551231241', '155512846124', '15551246192']
|
message obligatoire |
string |
Exemple : This is a test message
|
bind_name obligatoire |
string |
Exemple : bind1
|
campaign_name obligatoire |
string |
Exemple : Test Campaign
|
pe_id |
string | Pour le DLT national indien.
Exemple : 54342445353452
|
template_id |
string | Pour le DLT national indien.
Exemple : 2372168395432
|
Exemple de requête
cURL
curl -X POST 'https://portal.par-infinity.com/api/v1/sms/send/batch/' \
-H 'Authorization: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"from": "12345",
"phone_numbers": [
"15551231241",
"155512846124",
"15551246192"
],
"message": "This is a test message",
"bind_name": "bind1",
"campaign_name": "Test Campaign",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}'
Python
import requests
url = "https://portal.par-infinity.com/api/v1/sms/send/batch/"
headers = {"Authorization": "YOUR_API_KEY"}
payload = {
"from": "12345",
"phone_numbers": [
"15551231241",
"155512846124",
"15551246192"
],
"message": "This is a test message",
"bind_name": "bind1",
"campaign_name": "Test Campaign",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
response = requests.post(url, headers=headers, json=payload, timeout=30)
print(response.status_code, response.json())
Node.js
const res = await fetch("https://portal.par-infinity.com/api/v1/sms/send/batch/", {
method: "POST",
headers: {
Authorization: process.env.PAR_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"from": "12345",
"phone_numbers": [
"15551231241",
"155512846124",
"15551246192"
],
"message": "This is a test message",
"bind_name": "bind1",
"campaign_name": "Test Campaign",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}),
});
console.log(res.status, await res.json());
PHP
<?php
$ch = curl_init('https://portal.par-infinity.com/api/v1/sms/send/batch/');
$headers = ['Authorization: YOUR_API_KEY'];
$payload = <<<'JSON'
{
"from": "12345",
"phone_numbers": [
"15551231241",
"155512846124",
"15551246192"
],
"message": "This is a test message",
"bind_name": "bind1",
"campaign_name": "Test Campaign",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
JSON;
$headers[] = 'Content-Type: application/json';
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => $headers,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), ' ', $response, PHP_EOL;
curl_close($ch);
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
String payload = """
{
"from": "12345",
"phone_numbers": [
"15551231241",
"155512846124",
"15551246192"
],
"message": "This is a test message",
"bind_name": "bind1",
"campaign_name": "Test Campaign",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://portal.par-infinity.com/api/v1/sms/send/batch/"))
.header("Authorization", "YOUR_API_KEY")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}
Go
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
payload := `{
"from": "12345",
"phone_numbers": [
"15551231241",
"155512846124",
"15551246192"
],
"message": "This is a test message",
"bind_name": "bind1",
"campaign_name": "Test Campaign",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}`
req, err := http.NewRequest("POST", "https://portal.par-infinity.com/api/v1/sms/send/batch/", strings.NewReader(payload))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(data))
}
Ruby
require 'net/http'
require 'uri'
uri = URI('https://portal.par-infinity.com/api/v1/sms/send/batch/')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = <<~JSON
{
"from": "12345",
"phone_numbers": [
"15551231241",
"155512846124",
"15551246192"
],
"message": "This is a test message",
"bind_name": "bind1",
"campaign_name": "Test Campaign",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }
puts response.code, response.body
C# (.NET)
using System.Net.Http.Headers;
using System.Text;
var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://portal.par-infinity.com/api/v1/sms/send/batch/");
request.Headers.TryAddWithoutValidation("Authorization", "YOUR_API_KEY");
var payload = """
{
"from": "12345",
"phone_numbers": [
"15551231241",
"155512846124",
"15551246192"
],
"message": "This is a test message",
"bind_name": "bind1",
"campaign_name": "Test Campaign",
"pe_id": "54342445353452",
"template_id": "2372168395432"
}
""";
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
Exemple de réponse 200
{
"status": "ok",
"message": "Message Sent"
}
Erreurs
401 Non autorisé403 Interdit404 Introuvable422 Entité non traitable429 Trop de requêtes500 Erreur interne du serveur