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
| Reply | Meaning | What to do |
|---|---|---|
| BAD_KEY | API key invalid | Check the key |
| NO_BALANCE | Balance too low | Recharge, then retry |
| NO_NUMBERS | Nothing in stock right now | Try another server or country |
| BAD_SERVICE / BAD_COUNTRY | Wrong id sent | Re-fetch the lists |
Best practices
- Check the price first with
getPriceso 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.