Verificación OTP
Verificación en dos pasos (OTP) — generar, verificar, reenviar y restablecer códigos
The Verificación Otp object
Returned by the verificación otp endpoints.
{ "success": true, "message": "code_successfully_generated", "status": 200, "code": "verification_01", "total_messages": 1, "number": "525512345678", "credit": 1, "reference": "abc123def456ghi789jkl", "verification_code": "123456", "fallback": false }
Enviar Código de Verificación (OTP)
Genera y envía un código de verificación por SMS, WhatsApp o llamada de voz al número especificado. Usa `showcode=1` para recibir el código en la respuesta (útil en sandbox/testing).
abcdefghijklmnesen01alphanumericnumericletterscurl -X POST https://api.smsmasivos.com.mx/otp/send \
-H "Content-Type: application/json" \
-H "apikey: TU_API_KEY" \
-d '{
"phone_number": "5512345678",
"country_code": "52",
"company": "Mi Empresa",
"code_length": 6,
"code_type": "numeric"
}'
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.smsmasivos.com.mx/otp/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'apikey: ' . getenv('SMSMASIVOS_API_KEY')
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'phone_number' => '5512345678',
'country_code' => '52',
'company' => 'Mi Empresa',
'code_length' => 6,
'code_type' => 'numeric'
]));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import requests
response = requests.post(
'https://api.smsmasivos.com.mx/otp/send',
headers={
'Content-Type': 'application/json',
'apikey': 'TU_API_KEY'
},
json={
'phone_number': '5512345678',
'country_code': '52',
'company': 'Mi Empresa',
'code_length': 6,
'code_type': 'numeric'
}
)
print(response.json())
const response = await fetch('https://api.smsmasivos.com.mx/otp/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'apikey': process.env.SMSMASIVOS_API_KEY
},
body: JSON.stringify({
phone_number: '5512345678',
country_code: '52',
company: 'Mi Empresa',
code_length: 6,
code_type: 'numeric'
})
});
const data = await response.json();
console.log(data);
const axios = require('axios');
const { data } = await axios.post(
'https://api.smsmasivos.com.mx/otp/send',
{
phone_number: '5512345678',
country_code: '52',
company: 'Mi Empresa',
code_length: 6,
code_type: 'numeric'
},
{
headers: {
'Content-Type': 'application/json',
'apikey': process.env.SMSMASIVOS_API_KEY
}
}
);
console.log(data);
require 'net/http'
require 'json'
uri = URI('https://api.smsmasivos.com.mx/otp/send')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, {
'Content-Type' => 'application/json',
'apikey' => ENV['SMSMASIVOS_API_KEY']
})
request.body = {
phone_number: '5512345678',
country_code: '52',
company: 'Mi Empresa',
code_length: 6,
code_type: 'numeric'
}.to_json
response = http.request(request)
puts JSON.parse(response.body)
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("apikey", "TU_API_KEY");
var payload = new
{
phone_number = "5512345678",
country_code = "52",
company = "Mi Empresa",
code_length = 6,
code_type = "numeric"
};
var response = await client.PostAsJsonAsync(
"https://api.smsmasivos.com.mx/otp/send",
payload
);
var result = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine(result);
OkHttpClient client = new OkHttpClient();
String json = "{"
+ "\"phone_number\":\"5512345678\","
+ "\"country_code\":\"52\","
+ "\"company\":\"Mi Empresa\","
+ "\"code_length\":6,"
+ "\"code_type\":\"numeric\""
+ "}";
Request request = new Request.Builder()
.url("https://api.smsmasivos.com.mx/otp/send")
.post(RequestBody.create(json, MediaType.parse("application/json")))
.addHeader("apikey", "TU_API_KEY")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
{ "success": true, "message": "Código generado exitosamente", "status": 200, "code": "verification_01", "request_id": "550e8400-e29b-41d4-a716-446655440000", "verification_code": "A1B2" }
{ "success": false, "message": "API Key inválida o no existe.", "status": 401, "code": "<string>" }
{ "success": false, "message": "API Key inválida o no existe.", "status": 401, "code": "auth_05" }
{ "success": false, "message": "La dirección IP no está autorizada para acceder.", "status": 403, "code": "auth_04" }
{ "success": false, "message": "Demasiadas solicitudes. Límite: 100 mensajes/segundo (producción) o 100/día (sandbox).", "status": 429, "code": "rate_01" }
{ "success": false, "message": "Error interno del servidor. Contacta a soporte con el request_id.", "status": 500, "code": "server_01", "request_id": "550e8400-e29b-41d4-a716-446655440000" }
Verificar Código OTP
Verifica el código de verificación que el usuario ingresó. Una vez validado correctamente, el número queda verificado.
esencurl -X POST https://api.smsmasivos.com.mx/otp/verify \
-H "Content-Type: application/json" \
-H "apikey: TU_API_KEY" \
-d '{
"phone_number": "5512345678",
"verification_code": "A1B2"
}'
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.smsmasivos.com.mx/otp/verify');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'apikey: ' . getenv('SMSMASIVOS_API_KEY')
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'phone_number' => '5512345678',
'verification_code' => 'A1B2'
]));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import requests
response = requests.post(
'https://api.smsmasivos.com.mx/otp/verify',
headers={
'Content-Type': 'application/json',
'apikey': 'TU_API_KEY'
},
json={
'phone_number': '5512345678',
'verification_code': 'A1B2'
}
)
print(response.json())
const response = await fetch('https://api.smsmasivos.com.mx/otp/verify', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'apikey': process.env.SMSMASIVOS_API_KEY
},
body: JSON.stringify({
phone_number: '5512345678',
verification_code: 'A1B2'
})
});
const data = await response.json();
console.log(data);
const axios = require('axios');
const { data } = await axios.post(
'https://api.smsmasivos.com.mx/otp/verify',
{
phone_number: '5512345678',
verification_code: 'A1B2'
},
{
headers: {
'Content-Type': 'application/json',
'apikey': process.env.SMSMASIVOS_API_KEY
}
}
);
console.log(data);
require 'net/http'
require 'json'
uri = URI('https://api.smsmasivos.com.mx/otp/verify')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, {
'Content-Type' => 'application/json',
'apikey' => ENV['SMSMASIVOS_API_KEY']
})
request.body = {
phone_number: '5512345678',
verification_code: 'A1B2'
}.to_json
response = http.request(request)
puts JSON.parse(response.body)
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("apikey", "TU_API_KEY");
var payload = new
{
phone_number = "5512345678",
verification_code = "A1B2"
};
var response = await client.PostAsJsonAsync(
"https://api.smsmasivos.com.mx/otp/verify",
payload
);
var result = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine(result);
OkHttpClient client = new OkHttpClient();
String json = "{"
+ "\"phone_number\":\"5512345678\","
+ "\"verification_code\":\"A1B2\""
+ "}";
Request request = new Request.Builder()
.url("https://api.smsmasivos.com.mx/otp/verify")
.post(RequestBody.create(json, MediaType.parse("application/json")))
.addHeader("apikey", "TU_API_KEY")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
{ "success": true, "message": "Usuario verificado exitosamente", "status": 200, "code": "validation_01", "request_id": "550e8400-e29b-41d4-a716-446655440000" }
{ "success": false, "message": "API Key inválida o no existe.", "status": 401, "code": "<string>" }
{ "success": false, "message": "API Key inválida o no existe.", "status": 401, "code": "auth_05" }
{ "success": false, "message": "La dirección IP no está autorizada para acceder.", "status": 403, "code": "auth_04" }
{ "success": false, "message": "Demasiadas solicitudes. Límite: 100 mensajes/segundo (producción) o 100/día (sandbox).", "status": 429, "code": "rate_01" }
{ "success": false, "message": "Error interno del servidor. Contacta a soporte con el request_id.", "status": 500, "code": "server_01", "request_id": "550e8400-e29b-41d4-a716-446655440000" }
Reenviar Código de Verificación (OTP)
Reenvía el código de verificación al número especificado. Puedes cambiar el canal (SMS, WhatsApp, voz) y reiniciar el código con `reset_code=true`. Si el usuario no recibe el SMS, usa el parámetro `voice=true` para realizar una llamada en lugar de enviar un SMS.
abcdefghijklmnesen01alphanumericnumericletterscurl -X POST https://api.smsmasivos.com.mx/otp/resend \
-H "Content-Type: application/json" \
-H "apikey: TU_API_KEY" \
-d '{
"phone_number": "5512345678",
"country_code": "52",
"company": "Mi Empresa"
}'
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.smsmasivos.com.mx/otp/resend');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'apikey: ' . getenv('SMSMASIVOS_API_KEY')
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'phone_number' => '5512345678',
'country_code' => '52',
'company' => 'Mi Empresa'
]));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import requests
response = requests.post(
'https://api.smsmasivos.com.mx/otp/resend',
headers={
'Content-Type': 'application/json',
'apikey': 'TU_API_KEY'
},
json={
'phone_number': '5512345678',
'country_code': '52',
'company': 'Mi Empresa'
}
)
print(response.json())
const response = await fetch('https://api.smsmasivos.com.mx/otp/resend', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'apikey': process.env.SMSMASIVOS_API_KEY
},
body: JSON.stringify({
phone_number: '5512345678',
country_code: '52',
company: 'Mi Empresa'
})
});
const data = await response.json();
console.log(data);
const axios = require('axios');
const { data } = await axios.post(
'https://api.smsmasivos.com.mx/otp/resend',
{
phone_number: '5512345678',
country_code: '52',
company: 'Mi Empresa'
},
{
headers: {
'Content-Type': 'application/json',
'apikey': process.env.SMSMASIVOS_API_KEY
}
}
);
console.log(data);
require 'net/http'
require 'json'
uri = URI('https://api.smsmasivos.com.mx/otp/resend')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, {
'Content-Type' => 'application/json',
'apikey' => ENV['SMSMASIVOS_API_KEY']
})
request.body = {
phone_number: '5512345678',
country_code: '52',
company: 'Mi Empresa'
}.to_json
response = http.request(request)
puts JSON.parse(response.body)
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("apikey", "TU_API_KEY");
var payload = new
{
phone_number = "5512345678",
country_code = "52",
company = "Mi Empresa"
};
var response = await client.PostAsJsonAsync(
"https://api.smsmasivos.com.mx/otp/resend",
payload
);
var result = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine(result);
OkHttpClient client = new OkHttpClient();
String json = "{"
+ "\"phone_number\":\"5512345678\","
+ "\"country_code\":\"52\","
+ "\"company\":\"Mi Empresa\""
+ "}";
Request request = new Request.Builder()
.url("https://api.smsmasivos.com.mx/otp/resend")
.post(RequestBody.create(json, MediaType.parse("application/json")))
.addHeader("apikey", "TU_API_KEY")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
{ "success": true, "message": "Código generado exitosamente", "status": 200, "code": "verification_01", "request_id": "550e8400-e29b-41d4-a716-446655440000", "verification_code": "A1B2" }
{ "success": false, "message": "API Key inválida o no existe.", "status": 401, "code": "<string>" }
{ "success": false, "message": "API Key inválida o no existe.", "status": 401, "code": "auth_05" }
{ "success": false, "message": "La dirección IP no está autorizada para acceder.", "status": 403, "code": "auth_04" }
{ "success": false, "message": "Demasiadas solicitudes. Límite: 100 mensajes/segundo (producción) o 100/día (sandbox).", "status": 429, "code": "rate_01" }
{ "success": false, "message": "Error interno del servidor. Contacta a soporte con el request_id.", "status": 500, "code": "server_01", "request_id": "550e8400-e29b-41d4-a716-446655440000" }
Restablecer Verificación OTP
Restablece (reinicia) el registro de verificación asociado a un número. Este método no envía ningún mensaje — solo limpia el estado para permitir una nueva verificación. Útil para flujos de contraseñas únicas donde necesitas re-verificar al usuario.
curl https://api.smsmasivos.com.mx/otp/reset \ -d phone_number=5512345678 \ -d country_code=52 \ -d reset_code=true
const Verificación OTP = await sms.verificacinotp.create({ phone_number: '5512345678', country_code: '52', reset_code: 'true', })
Verificación OTP = sms.verificacinotp.create( phone_number="5512345678", country_code="52", reset_code="true", )
Verificación OTP, err := client.Verificacinotp.Create(ctx, &sms.VerificaciNOTPParams{ PhoneNumber: sms.String("5512345678"), CountryCode: sms.String("52"), ResetCode: sms.String("true"), })
{ "success": true, "message": "Usuario reiniciado correctamente", "status": 200, "code": "verification_01", "request_id": "550e8400-e29b-41d4-a716-446655440000" }
{ "success": false, "message": "API Key inválida o no existe.", "status": 401, "code": "<string>" }
{ "success": false, "message": "API Key inválida o no existe.", "status": 401, "code": "auth_05" }
{ "success": false, "message": "La dirección IP no está autorizada para acceder.", "status": 403, "code": "auth_04" }
{ "success": false, "message": "Demasiadas solicitudes. Límite: 100 mensajes/segundo (producción) o 100/día (sandbox).", "status": 429, "code": "rate_01" }
{ "success": false, "message": "Error interno del servidor. Contacta a soporte con el request_id.", "status": 500, "code": "server_01", "request_id": "550e8400-e29b-41d4-a716-446655440000" }