SMS OTP via API is the service that allows you to automatically generate and send OTP (One-Time Password) codes via SMS, simplifying the integration of authentication and verification systems into websites, applications, and digital platforms.
With a single API request, you can send a secure numeric or alphanumeric OTP code to the user's mobile phone number, configuring its length according to your process requirements.
The message is automatically translated based on the recipient's country, allowing you to use the same authentication flow internationally without having to manually manage different texts and languages.
The service uses OTP MOBILE as the default sender and applies the rates provided for the SMS Worldwide service.
It is ideal for quickly integrating processes such as:
The POST/otp method allows you to automatically generate a secure OTP code and send it via SMS to the specified mobile phone number.
You only need to specify the recipient and, optionally, configure the characteristics of the code.
The OTP code can be:
If not otherwise specified, a numeric code is generated. You can choose a length between 4 and 10 characters. The default value is 5. Through the cacheSeconds parameter, you can define how long the same OTP should be reused if multiple requests are made for the same recipient.
The value can be configured up to a maximum of 600 seconds. This feature helps, for example, prevent different codes from being generated when a user requests the OTP multiple times within a few minutes.
There is no need to manually create the SMS text. The service automatically generates the message containing the OTP code and translates it according to the country associated with the recipient's phone number. This allows you to use a single endpoint to manage international authentication processes, reducing development and maintenance complexity.
POST/otp
This is an example request:
{
"recipient": "+393331234567",
"alphanumeric": false,
"length": 5,
"cacheSeconds": 0,
"options": {
"dryRun": false,
"failOnMultipleMessages": false
},
"callback": {
"method": "JSON",
"field": "data",
"url": "https://www.mysite.com/myEndpoint",
"retry": 3,
"headers": {
"session_id": "9834r5fh589494"
},
"custom": {
"my_custom_id": "123456789"
}
}
}
In this example, a 5-digit numeric OTP is generated for the specified number.
POST/otp
The response returns information about the message and the generated OTP code:
{
"data": {
"id": "633aabe3e4a9a0e69811ad7f",
"username": "string",
"state": "NEW",
"sender": "string",
"recipient": "string",
"internationalPrefix": "39",
"countryCode": "IT",
"message": "string",
"encoding": "GSM-7",
"charactersCount": 0,
"messageCount": 0,
"price": 0,
"totalPrice": 0,
"blocklisted": true,
"blocklistedReason": "string",
"options": {
"dryRun": false,
"failOnMultipleMessages": false
},
"callback": {
"method": "JSON",
"field": "data",
"url": "https://www.mysite.com/myEndpoint",
"retry": 3,
"headers": {
"session_id": "9834r5fh589494"
},
"custom": {
"my_custom_id": "123456789"
}
},
"createdAt": "2026-08-24T07:34:19.961Z",
"updatedAt": "2026-08-24T07:34:19.961Z",
"sentAt": "2026-08-24T07:34:19.961Z",
"deliveredAt": "2026-08-24T07:34:19.961Z",
"isOtp": true,
"otp": "5F8A2",
"otpOptions": {
"length": 5,
"alphanumeric": false,
"cacheSeconds": 300
}
}
}
The returned data includes the generated OTP code, the settings used, and information about the SMS sent.
You can monitor the message status through the callback system. Openapi will automatically send SMS status updates to your endpoint, eliminating the need for continuous polling. You can also use the SMS v2 API endpoints to view the list of sent messages and retrieve the details of a specific message using its ID.
The SMS OTP service uses the SMS Worldwide pricing model. The cost of sending therefore varies depending on the recipient's destination country and mobile network operator.
To find the current cost for each destination, please refer to the SMS Worldwide pricing section.
Do you need help?
Haven't found the answer you're looking for?
Fill in all the details, we will get back to you as soon as possible!