Invia SMS OTP con le tue impostazioni

Assicurati che il tuo messaggio SMS OTP sia proprio come lo desideri. Le opzioni di personalizzazione per le password monouso (OTP) consentono ai destinatari di sapere chi ha inviato l'SMS e consentono di impostare i parametri di sicurezza per ogni password generata.

  • Impostare il testo del contenuto del messaggio OTP con segnaposto {{pin}}
  • Modello di testo per le lingue locali
  • Scegli la lunghezza del codice da 4 a 10 cifre
  • Impostare il tempo di scadenza del codice tra 60 e 1800 secondi
  • Personalizzazione dell'ID mittente come mittente di SMS (es. Verifica)
Esempio di SMS OTP di modello di testo

OTP inviato tramite SMS

Gli SMS sono noti per essere affidabili perché il 98% delle persone lo apre entro 30 secondi. L'invio di password monouso tramite SMS ti assicura di raggiungere i tuoi utenti ovunque si trovino. Anche quando gli utenti non hanno accesso a Internet, possono comunque utilizzare questa soluzione OTP.

Codice OTP SMS che scadrà tra 15 minuti

Esempi di codice per OTP SMS API

Integra la nostra API SMS OTP avanzata nella tua applicazione e inizia a verificare i numeri di telefono in pochi minuti.

Diventa subito operativo con i nostri wrapper API ufficiali e le librerie client. Sono disponibili con linguaggi popolari come Python, PHP, Node.js, Java e altri.

Non esiste una libreria client per la tua lingua? Usa una libreria HTTP generica di tua scelta - è abbastanza semplice.

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))

}