Change Rental Status

The setRentStatus method is used to change the current status of a rented virtual number through the SMS.online API. This method allows for automated management of rental statuses, including ending usage, extending the rental period, or releasing the number.

This method is designed for systems that require real-time control over the status of rented numbers. It allows you to specify the end of the rental, extensions, or other status changes, keeping the information up to date.

A successful request returns an object confirming the rental status change, including updated rental parameters. This method is particularly useful in services where quick updates on the usage of rented numbers are needed.

Example Request:

Input Data

ParameterRequiredNoteDescription
YesSee in profile settings API KeyAPI key provides access to paid services
YessetRentStatusMethod name
YesNumeric valueActivation ID obtained when requesting the number
YesNumeric valueRental status

Status can take the following values:

1 - End usage of the number

2 - Cancel purchase

Server Response

JSON
{ 
  "status": "success"
}

Example Code

const api_key = "API_KEY"; # Replace 'API_KEY' with your actual API key.
const id = 1; # Insert the activation ID obtained when requesting the number
const status = 1; # Insert the new status from the table above
try {
const response = await fetch(`https://api.sms.onlinestubs/handler_api.php?api_key=${api_key}&action=setRentStatus&id=${id}&status=${status}`);
# 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
Rental ID not specified
Number rented by someone else (incorrect rental ID)
Missing or incorrectly specified status
Cannot cancel rental (more than 20 min.)
Rental already completed
Rental already canceled