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

ParameterRequiredNoteDescription
YesSee in profile settings API KeyAPI key provides access to paid services
YesgetRentNumberMethod name
YesSee the list of services in the left menuService for which the number needs to be obtained
YesSee the list of countries in the left menuCountry whose number needs to be obtained
NoSee the list of operators in the left menuMobile operator whose number needs to be obtained
No4, 8, 12, 24, 72, 168, 360, 720, 2160Rental time in hours
No-Webhook URL (default is not considered)

Server Response

JSON
{ 
  "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 URL
const data = await response.json();
# Output the content of the server response
console.log(data);
} catch (err) {
# If an error occurred, output the error message
console.error(err);
}

Possible Errors

ParameterDescription
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