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!
SMS OTP is Openapi's API service that allows you to automatically generate a One-Time Password and send it via SMS to the user's mobile phone number. It is designed to quickly integrate verification, authentication, and authorization systems into applications, websites, and digital platforms.
An OTP is a code used within an authentication or verification process. It can be used, for example, to verify ownership of a mobile phone number, protect a login with two-factor authentication, confirm a registration, or authorize a sensitive operation.
Yes. Through the alphanumeric parameter, you can choose to generate:
By default, a numeric code is generated.
Yes. You can configure OTP codes with a length between 4 and 10 characters.
If the parameter is not specified, a default length of 5 characters is used.
Through the cacheSeconds parameter, you can define a time interval during which new requests for the same recipient reuse the same OTP code. The maximum configurable value is 600 seconds.
This feature is useful, for example, when a user clicks the "Resend code" button multiple times.
No. The message is automatically generated by the service. In addition, the text is automatically translated based on the recipient's country, simplifying the use of the service in international applications.
For SMS messages sent through the OTP endpoint, the default sender is OTP MOBILE.
Yes. You can configure a callback to automatically receive updates about the message status.
You can also use the API to view sent messages and retrieve information about a specific SMS.
The service uses the SMS Worldwide infrastructure and is designed for international sending. The SMS text is automatically adapted according to the country associated with the recipient's phone number.
Delivery conditions, any restrictions, and costs may vary depending on the country and mobile network operator.
SMS OTP is designed for companies, software houses, fintechs, marketplaces, ecommerce businesses, and digital platforms that need to integrate mobile phone number verification and authentication systems.
It is particularly suitable for 2FA, secure login, onboarding, account verification, password recovery, transaction confirmation, and authorization of sensitive operations.
SMS OTP follows the SMS Worldwide pricing model. The price depends on the recipient's country and mobile network operator. The actual sending cost is therefore determined by the destination.