APIリファレンス
SMS API
承認済みの送信者IDまたは番号から、1通のメッセージや一括キャンペーンを送信します。メッセージ本文に#OTP4#または#OTP6#を入れると、ワンタイムパスワードが生成されます。
ベースURL https://portal.par-infinity.com/api/v1 · 認証 · エラー · 製品の概要
SMSを送信
POST /sms/send
世界中の任意の番号にSMSを送信します。
リクエストボディ application/json
| 名前 | 型 | 説明 |
|---|---|---|
from 必須 |
string | 承認済みの送信者IDまたは番号を使用してください。
例: 12345
|
to 必須 |
string |
例: 123456789
|
message 必須 |
string | OTPを生成するには、#OTP4#と#OTP6#をプレースホルダーとして使用します。
例: This is a test message
|
bind_name 必須 |
string |
例: bind1
|
pe_id |
string | インド国内DLT用。
例: 54342445353452
|
template_id |
string | インド国内DLT用。
例: 2372168395432
|
リクエスト例
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()}");
レスポンス例 200
{
"status": "ok",
"message": "Message Sent",
"origination_message_id": "acba1293an"
}
エラー
401 認証エラー403 アクセス禁止404 見つかりません422 処理できないエンティティ429 リクエストが多すぎます500 内部サーバーエラー
SMSを一括送信
POST /sms/send/batch
複数の番号にSMSを送信します。
リクエストボディ application/json
| 名前 | 型 | 説明 |
|---|---|---|
from 必須 |
string | 承認済みの送信者IDまたは番号を使用してください。
例: 12345
|
phone_numbers 必須 |
array<string> |
例: ['15551231241', '155512846124', '15551246192']
|
message 必須 |
string |
例: This is a test message
|
bind_name 必須 |
string |
例: bind1
|
campaign_name 必須 |
string |
例: Test Campaign
|
pe_id |
string | インド国内DLT用。
例: 54342445353452
|
template_id |
string | インド国内DLT用。
例: 2372168395432
|
リクエスト例
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()}");
レスポンス例 200
{
"status": "ok",
"message": "Message Sent"
}
エラー
401 認証エラー403 アクセス禁止404 見つかりません422 処理できないエンティティ429 リクエストが多すぎます500 内部サーバーエラー