Send OTP SMS
const url = 'https://api.contacta.mx/v2/otp/send';const options = { method: 'POST', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"msg":"Your otp code is [code], please don\'t share it with anyone.","phone":"8100001234","sender":"AWESOMEINC","id":"my-external-id"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.contacta.mx/v2/otp/send \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "msg": "Your otp code is [code], please don'\''t share it with anyone.", "phone": "8100001234", "sender": "AWESOMEINC", "id": "my-external-id" }'Sends an OTP SMS using a JSON payload in the request body.
Note: This endpoint generates an OTP code and sends it via SMS.
It is not an OTP verification route — use /v2/otp/verify for that.
Recommended for server-to-server integrations.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”JSON body for sending an OTP SMS.
object
GSM-encoded message (max 160 characters).
Note: If the [code] tag is omitted, it will be appended to the end of the message.
Example
Your otp code is [code], please don't share it with anyone.10-digit destination phone number (Mexico, without country code)
Example
8100001234Sender ID authorized by carrier (optional)
Example
AWESOMEINCExternal reference ID (optional)
Example
my-external-idResponses
Section titled “Responses”OTP SMS sent successfully
object
object
object
Example
{ "status": true, "error": false, "description": { "added_on": "2023-09-20 16:47:15", "charge": 0.99, "country": { "country": "MEXICO", "iso_code": "MX", "type": "MOVIL" }, "encoding": "gsm", "id": 199999, "job_id": "199999", "length": 12, "message": "Your otp code is 0000, please don't share it with anyone.", "number": "8100001234", "segments": 1, "sender": "AWESOMEINC" }}Missing required parameters
Example
{ "status": false, "error": true, "description": "Missing params, please verify or contact to support"}Your key auth is not valid
Example
{ "status": false, "error": true, "description": "Your key auth is not valid, please check with your administrator to get the new key"}Your account doesn’t have credits available for sending
Example
{ "status": false, "error": true, "description": "Your account doesn't have credits available for this, please contact your administrator"}Country or carrier not reachable or assigned to your account
Example
{ "status": false, "error": true, "description": "Country or carrier not reachable or assigned to your account, please contact an administrator or support"}Failed to append to the queue, no need to resend
Example
{ "status": false, "error": true, "description": "Failed to append to the queue, no need to resend"}Your account doesn’t have multi-message sending enabled
Example
{ "status": false, "error": true, "description": "Your account doesn't have multi-message sending enabled, please contact your administrator"}
