Envoyez des SMS OTP avec vos propres paramètres

Assurez-vous que votre message SMS OTP est exactement comme vous le souhaitez. Les options de personnalisation des unique OTP permettent à vos destinataires de savoir qui a envoyé le SMS et de définir les paramètres de sécurité pour chaque mot de passe généré.

  • Définissez le texte du contenu du message OTP avec l’espace réservé {{pin}}
  • Modèle de texte pour les langues locales
  • Choisissez la longueur du code de 4 à 10 chiffres
  • Définissez la durée d’expiration du code entre 60 et 1800 secondes
  • Personnalisation de l’ID de l’expéditeur en tant qu’expéditeur SMS (par exemple Verifier)
Exemple de modèle de texte par mot de passe à usage unique SMS

OTP envoyé par SMS

Le SMS est connu pour être fiable car 98% des personnes l’ouvrent dans les 30 secondes. L’envoi de mots de passe à usage unique (OTP) par SMS vous permet d’atteindre vos utilisateurs où qu’ils se trouvent. Même lorsque les utilisateurs n’ont pas accès à Internet, ils peuvent toujours utiliser cette solution OTP.

Code OTP SMS qui expirera dans 15 minutes

Exemples de code pour l’API SMS OTP

Intégrez notre API SMS OTP avancée dans votre application et commencez à vérifier les numéros de téléphone en quelques minutes.

Soyez rapidement opérationnel grâce à nos wrappers d’API et bibliothèques clients officiels. Ils sont disponibles avec des langages populaires comme Python, PHP, Node.js, Java et autres.

Il n’y a pas de bibliothèque cliente pour votre langue ? Utilisez une bibliothèque HTTP générique de votre choix - c’est assez simple.

curl --request POST \
  --url https://api.sms.cx/otp \
  --header 'Authorization: Bearer REPLACE_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "phoneNumber": "+336124241xx",
    "from": "Verify",
    "template": "Your verification code is {{pin}}",
    "template_fr": "Votre code de vérification est {{pin}}",
    "template_de": "Ihr Bestätigungscode lautet {{pin}}",
    "template_es": "Tu código de verificación es {{pin}}",
    "template_it": "Il tuo codice di verifica è {{pin}}",
    "template_bg": "Вашият код за потвърждение е {{pin}}",    
    "ttl": 600,
    "maxAttempts": 6,
    "pinType": "numbers",
    "pinLength": 5,
    "otpCallbackUrl": "https://my-callback/receive-otp-status"
  }'
import requests

url = "https://api.sms.cx/otp"

payload = {
    "phoneNumber": "+336124241xx",
    "from": "Verify",
    "template": "Your verification code is {{pin}}",
    "template_fr": "Votre code de vérification est {{pin}}",
    "template_de": "Ihr Bestätigungscode lautet {{pin}}",
    "template_es": "Tu código de verificación es {{pin}}",
    "template_it": "Il tuo codice di verifica è {{pin}}",
    "template_bg": "Вашият код за потвърждение е {{pin}}",
    "ttl": 300,
    "maxAttempts": 5,
    "pinType": "numbers",
    "pinLength": 5,
    "otpCallbackUrl": "https://my-callback/receive-otp-status"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer REPLACE_ACCESS_TOKEN"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sms.cx/otp")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer REPLACE_ACCESS_TOKEN'
request.body = '{"phoneNumber":"+336124241xx","from":"Verify","template":"Your verification code is {{pin}}","template_fr":"Votre code de vérification est {{pin}}","template_de":"Ihr Bestätigungscode lautet {{pin}}","template_es":"Tu código de verificación es {{pin}}","template_it":"Il tuo codice di verifica è {{pin}}","template_bg":"Вашият код за потвърждение е {{pin}}","ttl":600,"maxAttempts":6,"pinType":"numbers","pinLength":5,"otpCallbackUrl":"https://my-callback/receive-otp-status"}'

response = http.request(request)
puts response.read_body
const data = JSON.stringify({
  "phoneNumber": "+336124241xx",
  "from": "Verify",
  "template": "Your verification code is {{pin}}",
  "template_fr": "Votre code de vérification est {{pin}}",
  "template_de": "Ihr Bestätigungscode lautet {{pin}}",
  "template_es": "Tu código de verificación es {{pin}}",
  "template_it": "Il tuo codice di verifica è {{pin}}",
  "template_bg": "Вашият код за потвърждение е {{pin}}", 
  "ttl": 300,
  "maxAttempts": 5,
  "pinType": "numbers",
  "pinLength": 5,
  "otpCallbackUrl": "https://my-callback/receive-otp-status"
});

const xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.sms.cx/otp");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer REPLACE_ACCESS_TOKEN");

xhr.send(data);
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.sms.cx",
  "port": null,
  "path": "/otp",
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer REPLACE_ACCESS_TOKEN"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  phoneNumber: '+336124241xx',
  from: 'Verify',
  template: 'Your verification code is {{pin}}',
  template_fr: 'Votre code de vérification est {{pin}}"',
  template_de: 'Ihr Bestätigungscode lautet {{pin}}',
  template_es: 'Tu código de verificación es {{pin}}',
  template_it: 'Il tuo codice di verifica è {{pin}}',
  template_bg: 'Вашият код за потвърждение е {{pin}}',   
  ttl: 300,
  maxAttempts: 5,
  pinType: 'numbers',
  pinLength: 5,
  otpCallbackUrl: 'https://my-callback/receive-otp-status'
}));
req.end();
<?php

$curl = curl_init();

$payload = [
    "phoneNumber" => "+336124241xx",
    "from" => "Verify",
    "template" => "Your verification code is {{pin}}",
    "template_fr" => "Votre code de vérification est {{pin}}",
    "template_de" => "Ihr Bestätigungscode lautet {{pin}}",
    "template_es" => "Tu código de verificación es {{pin}}",
    "template_it" => "Il tuo codice di verifica è {{pin}}",
    "template_bg" => "Вашият код за потвърждение е {{pin}}",    
    "ttl" => 600,
    "maxAttempts" => 6,
    "pinType" => "numbers",
    "pinLength" => 5,
    "otpCallbackUrl" => "https://my-callback/receive-otp-status",
];

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.sms.cx/otp",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode($payload),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer REPLACE_ACCESS_TOKEN",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"phoneNumber\":\"+336124241xx\",\"from\":\"Verify\",\"template\":\"Your verification code is {{pin}}\",\"template_fr\":\"Votre code de v\u00E9rification est {{pin}}\",\"template_de\":\"Ihr Best\u00E4tigungscode lautet {{pin}}\",\"template_es\":\"Tu c\u00F3digo de verificaci\u00F3n es {{pin}}\",\"template_it\":\"Il tuo codice di verifica \u00E8 {{pin}}\",\"template_bg\":\"\u0412\u0430\u0448\u0438\u044F\u0442 \u043A\u043E\u0434 \u0437\u0430 \u043F\u043E\u0442\u0432\u044A\u0440\u0436\u0434\u0435\u043D\u0438\u0435 \u0435 {{pin}}\",\"ttl\":600,\"maxAttempts\":6,\"pinType\":\"numbers\",\"pinLength\":5,\"otpCallbackUrl\":\"https:\/\/my-callback\/receive-otp-status\"}");
Request request = new Request.Builder()
  .url("https://api.sms.cx/otp")
  .post(body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer REPLACE_ACCESS_TOKEN")
  .build();

Response response = client.newCall(request).execute();
var client = new RestClient("https://api.sms.cx/otp");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer REPLACE_ACCESS_TOKEN");
request.AddParameter("application/json", "{\"phoneNumber\":\"+336124241xx\",\"from\":\"Verify\",\"template\":\"Your verification code is {{pin}}\",\"template_fr\":\"Votre code de v\u00E9rification est {{pin}}\",\"template_de\":\"Ihr Best\u00E4tigungscode lautet {{pin}}\",\"template_es\":\"Tu c\u00F3digo de verificaci\u00F3n es {{pin}}\",\"template_it\":\"Il tuo codice di verifica \u00E8 {{pin}}\",\"template_bg\":\"\u0412\u0430\u0448\u0438\u044F\u0442 \u043A\u043E\u0434 \u0437\u0430 \u043F\u043E\u0442\u0432\u044A\u0440\u0436\u0434\u0435\u043D\u0438\u0435 \u0435 {{pin}}\",\"ttl\":600,\"maxAttempts\":6,\"pinType\":\"numbers\",\"pinLength\":5,\"otpCallbackUrl\":\"https:\/\/my-callback\/receive-otp-status\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.sms.cx/otp"

	payload := strings.NewReader("{\"phoneNumber\":\"+336124241xx\",\"from\":\"Verify\",\"template\":\"Your verification code is {{pin}}\",\"template_fr\":\"Votre code de v\u00E9rification est {{pin}}\",\"template_de\":\"Ihr Best\u00E4tigungscode lautet {{pin}}\",\"template_es\":\"Tu c\u00F3digo de verificaci\u00F3n es {{pin}}\",\"template_it\":\"Il tuo codice di verifica \u00E8 {{pin}}\",\"template_bg\":\"\u0412\u0430\u0448\u0438\u044F\u0442 \u043A\u043E\u0434 \u0437\u0430 \u043F\u043E\u0442\u0432\u044A\u0440\u0436\u0434\u0435\u043D\u0438\u0435 \u0435 {{pin}}\",\"ttl\":600,\"maxAttempts\":6,\"pinType\":\"numbers\",\"pinLength\":5,\"otpCallbackUrl\":\"https:\/\/my-callback\/receive-otp-status\"}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("Authorization", "Bearer REPLACE_ACCESS_TOKEN")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}