Free Numbers Pricing Reviews Feedback Terms & Policy API Docs Blog About
Log in Get Started
0 views 2 min read
Back to Blog
API & Developers

getStatus and setStatus: Read OTP Codes, Cancel for a Refund or Finish an Order

getStatus and setStatus: Read OTP Codes, Cancel for a Refund or Finish an Order

Buying the number is only half of the job. The other half is getting the code and closing the order correctly. That is what getStatus and setStatus are for.

getStatus: has the code arrived?

https://otpget.com/stubs/handler_api.php?api_key=YOUR_API_KEY&action=getStatus&id=YOUR_ORDER_ID

You will get one of these replies:

  • STATUS_WAIT_CODE - the number is waiting; keep polling.
  • STATUS_OK:123456 - the code arrived; the value after the colon is your OTP.
  • STATUS_CANCEL - the order was cancelled or expired.

A correct polling loop

import time, requests
url = "https://otpget.com/stubs/handler_api.php"
p = {"api_key": "YOUR_API_KEY", "action": "getStatus", "id": ORDER_ID}
for _ in range(60):
    r = requests.get(url, params=p).text
    if r.startswith("STATUS_OK:"):
        print("Code:", r.split(":", 1)[1]); break
    if r == "STATUS_CANCEL":
        print("Cancelled"); break
    time.sleep(5)

Poll every few seconds, not every few milliseconds. Even better, use webhooks so the code is pushed to you and you do not poll at all.

setStatus: finish or cancel

https://otpget.com/stubs/handler_api.php?api_key=YOUR_API_KEY&action=setStatus&id=YOUR_ORDER_ID&status=8
statusActionWhen allowed
8Cancel and refundOnly before a code arrives
6Finish the orderAfter the code arrived

Good habits

  • Cancel numbers you will not use. A refund is automatic and it keeps your stats clean.
  • Finish orders that succeeded so they are marked complete in your history.
  • If setStatus says the status was already changed, treat it as success. Do not loop.

Start building with OtpGet

Create a free account at otpget.com, copy your API key from the dashboard and open the API documentation. Our support team is available 24/7 if you get stuck.

Tags

#getStatus #setStatus #read OTP by API #cancel number refund #OTP polling
Contact us