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

getNumber Explained: Buy a Temporary Phone Number Through the OtpGet API

getNumber Explained: Buy a Temporary Phone Number Through the OtpGet API

getNumber is the heart of the OtpGet SMS API. It reserves a temporary phone number for one service, charges your wallet, and gives you an order id to track the code.

The request

https://otpget.com/stubs/handler_api.php?api_key=YOUR_API_KEY&action=getNumber&server=SERVER&country=COUNTRY&service=SERVICE

You supply the server, the country and the service you found through the list calls. The exact parameter names and an interactive example are shown on the API documentation page.

The reply

On success you receive your order id and the phone number in a single plain-text line. Save the order id immediately. It is the key to every later call: getStatus, setStatus and webhook matching.

Common error replies

ReplyMeaningWhat to do
BAD_KEYAPI key invalidCheck the key
NO_BALANCEBalance too lowRecharge, then retry
NO_NUMBERSNothing in stock right nowTry another server or country
BAD_SERVICE / BAD_COUNTRYWrong id sentRe-fetch the lists

Best practices

  • Check the price first with getPrice so there are no surprises.
  • Handle NO_NUMBERS gracefully. Stock moves constantly; offer an alternative instead of showing an error page.
  • Never retry a purchase blindly after a timeout. First check whether the order was created, otherwise you may buy twice.
  • Store the order id in your database before showing the number to your user.

What happens if no code arrives?

You are protected. If the code never comes, cancel the order with setStatus and your balance is refunded, as long as the code has not arrived. Orders that expire without a code are refunded automatically.

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

#getNumber #buy virtual number API #temporary phone number #OtpGet API #OTP
Contact us