Guide · 4 min read
Automating SMS verification with an API
How developers and QA teams buy virtual numbers and read verification codes programmatically: the request flow, idempotent purchases, polling and refunds.
Updated
When an API makes sense
If you test sign-up flows, run a reseller shop or verify many accounts for your own business, buying numbers by hand does not scale. The API does everything the dashboard does — prices, purchase, reading the code, cancel and refund — from your own code, with the same balance and prices.
The flow
- Read the price for a service and country.
- Buy a number, sending the price you read as your ceiling and an Idempotency-Key for the order.
- Poll the activation every few seconds until the code appears.
- Complete it once you have the code, or cancel it for a refund if none arrives.
Retries without double charges
Networks fail. Every purchase carries an Idempotency-Key, and repeating a request with the same key returns the number that order already bought instead of buying another. And because you send the price you agreed to, a purchase is refused — not charged — if the price has risen in the meantime.
Getting started
API access is approved per account: request it in Settings → API, then create a key. The full reference, with examples and every error, is in the API documentation.