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
Parameter | Required | Note | Description |
---|---|---|---|
Yes | See in profile settings API Key | API key provides access to paid services | |
Yes | setRentStatus | Method name | |
Yes | Numeric value | Activation ID obtained when requesting the number | |
Yes | Numeric value | Rental status |
Status can take the following values:
1 - End usage of the number
2 - Cancel purchase
Server Response
{ "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 numberconst status = 1; # Insert the new status from the table abovetry {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 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 | |
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 |