Developers

API Documentation

Integrate WhichOtp directly into your application. Our REST API is designed to be predictable, resource-oriented, and easy to use across all popular programming languages.

Language:

Authentication

The WhichOtp API uses API keys to authenticate requests. You can view and manage your API keys in your Dashboard.

Your API requests must include the Authorization: Bearer header.

Base URL

All API requests should be made to the following base URL:

https://api.whichotp.com/api/v1

Errors

If an error occurs, the API will return an appropriate HTTP status code along with a JSON response containing an error key. For input validation errors, it returns detailed arrays.

Standard Error

json
{
  "error": "Insufficient balance"
}

Validation Error

json
{
  "success": false,
  "message": "Validation failed",
  "errors": [
    {
      "field": "serviceId",
      "message": "Invalid serviceId. Must be a valid UUID."
    }
  ]
}

GET

/balance

Retrieve your current account balance.

Request

curl
curl -X GET "text-blue-400 underline">https://api.whichotp.com/api/v1/balance \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

json
{
  "balance": 150.50,
  "currency": "USD"
}

GET

/services

List all currently available services and their exact pricing.

Request

curl
curl -X GET "text-blue-400 underline">https://api.whichotp.com/api/v1/services \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

json
{
  "services": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "WhatsApp",
      "price": 1.50,
      "available": true
    }
  ]
}

POST

/orders/buy

Purchase a temporary virtual number for verification.

Request

  • serviceId (Required) UUID of the service from the /services endpoint.
curl
curl -X POST "text-blue-400 underline">https://api.whichotp.com/api/v1/orders/buy \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"serviceId":"123e4567-e89b-12d3-a456-426614174000"}'

Response

json
{
  "id": "ord_89b12d3a456",
  "phoneNumber": "+1234567890",
  "cost": 1.50,
  "status": "waiting",
  "createdAt": "2023-10-01T12:00:00Z"
}

GET

/orders/:id

Poll this endpoint every 5-10 seconds to retrieve the SMS code once received.

Request

curl
curl -X GET "text-blue-400 underline">https://api.whichotp.com/api/v1/orders/ord_89b12d3a456 \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

json
{
  "id": "ord_89b12d3a456",
  "phoneNumber": "+1234567890",
  "status": "completed",
  "smsCode": "593821",
  "cost": 1.50
}

Status can be: waiting, completed, cancelled, or refunded.


POST

/orders/:id/cancel

Cancel a waiting order. Funds will be instantly returned to your balance.

Request

curl
curl -X POST "text-blue-400 underline">https://api.whichotp.com/api/v1/orders/ord_89b12d3a456/cancel \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

json
{
  "id": "ord_89b12d3a456",
  "status": "refunded",
  "refundedAmount": 1.50
}