Request a rental number
The getRentNumber method is used to rent a virtual number for a specific period through the SMS.online API. It automates the process of acquiring a number for receiving SMS in a designated country from a specified service. You can set parameters for the country, service, and (optionally) operator to select an available number for long-term use.
This method is ideal for situations where a permanent virtual number is needed for several days, weeks, or months. It allows you to integrate the number into systems that require a stable SMS reception channel over an extended period.
A successful request returns an object with information about the number, including its identifier, rental period, and cost. This method is particularly useful for applications and services with long interaction cycles that require consistent access to a single number.
Example Request:
Input Data
Parameter | Required | Note | Description |
---|---|---|---|
Yes | See in profile settings API Key | API key provides access to paid services | |
Yes | getRentNumber | Method name | |
Yes | See the list of services in the left menu | Service for which the number needs to be obtained | |
Yes | See the list of countries in the left menu | Country whose number needs to be obtained | |
No | See the list of operators in the left menu | Mobile operator whose number needs to be obtained | |
No | 4, 8, 12, 24, 72, 168, 360, 720, 2160 | Rental time in hours | |
No | - | Webhook URL (default is not considered) |
Server Response
{ "status": "success", "phone": { "id": 1, "endDate": "2025-05-10T12:34:56", "number": "79999876543" } }
Example Code
const api_key = "API_KEY"; # Replace 'API_KEY' with your actual API key.const service = "SERVICE"; # Replace 'SERVICE' with the service identifier. All identifiers can be found in the documentation in the list on the left menu.const country = 1; # Insert the number of the desired country. Numbers for all countries can be found in the documentation in the list on the left menu.try {const response = await fetch(`https://api.sms.onlinestubs/handler_api.php?api_key=${api_key}&action=getRentNumber&service=${service}&country=${country}`);# Make a GET request to the specified URLconst data = await response.json();# Output the content of the server responseconsole.log(data);} catch (err) {# If an error occurred, output the error messageconsole.error(err);}
Possible Errors
Parameter | Description |
---|---|
Invalid action | |
Invalid API key | |
Error in query | |
Time until account is unbanned | |
Account is inactive | |
Invalid country name | |
Invalid service name | |
Invalid time | |
Balance not found | |
No available numbers | |
Account is blocked |