cURL
curl -sS -X POST "https://dashboard.ondial.ai/api/v1/numbers/purchase" \
-H "Authorization: Bearer $ONDIAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phoneNumberId": "66f0123456789abcdef01234"
}'const res = await fetch("https://dashboard.ondial.ai/api/v1/numbers/purchase", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.ONDIAL_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"phoneNumberId": "66f0123456789abcdef01234"
}),
});
const data = await res.json();
console.log(res.status, data);import os
import requests
res = requests.request(
"POST",
"https://dashboard.ondial.ai/api/v1/numbers/purchase",
headers={
"Authorization": f"Bearer {os.environ['ONDIAL_API_KEY']}",
},
json={
"phoneNumberId": "66f0123456789abcdef01234",
},
timeout=30,
)
print(res.status_code, res.json())<?php
$ch = curl_init("https://dashboard.ondial.ai/api/v1/numbers/purchase");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("ONDIAL_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
'phoneNumberId' => '66f0123456789abcdef01234',
]),
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status . " " . $response;import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://dashboard.ondial.ai/api/v1/numbers/purchase"))
.header("Authorization", "Bearer " + System.getenv("ONDIAL_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"phoneNumberId": "66f0123456789abcdef01234"
}
"""))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}using System;
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://dashboard.ondial.ai/api/v1/numbers/purchase");
request.Headers.Add("Authorization", "Bearer " + Environment.GetEnvironmentVariable("ONDIAL_API_KEY"));
request.Content = new StringContent("""
{
"phoneNumberId": "66f0123456789abcdef01234"
}
""", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode + " " + await response.Content.ReadAsStringAsync());package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{
"phoneNumberId": "66f0123456789abcdef01234"
}`)
req, _ := http.NewRequest("POST", "https://dashboard.ondial.ai/api/v1/numbers/purchase", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("ONDIAL_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))
}{
"purchased": [
{
"id": "66f0123456789abcdef01234",
"number": "+919876543210",
"country": "IN",
"countryName": "India",
"status": "purchased",
"provider": "pool",
"purchasedAt": "2026-08-26T10:00:00.000Z",
"cost": 7
}
],
"totalCost": 7,
"creditsRemaining": 241780.98
}{
"error": "phoneNumberId or phoneNumberIds required",
"reasonCode": "invalid_request"
}{
"error": "Invalid or inactive API key",
"reasonCode": "unauthorized"
}{
"error": "Insufficient credits. Need 7, have 2.00.",
"reasonCode": "insufficient_credits",
"requiredCredits": 7,
"creditsAvailable": 2
}{
"error": "Some numbers are no longer available",
"reasonCode": "numbers_unavailable",
"unavailablePhoneNumberIds": [
"000000000000000000000000"
]
}{
"error": "Pool number purchase is not enabled for this account.",
"reasonCode": "pool_purchase_unavailable"
}Purchase numbers
Buy pool DID(s) with the API-key tenant credits.
POST
https://dashboard.ondial.ai
/
api
/
v1
/
numbers
/
purchase
cURL
curl -sS -X POST "https://dashboard.ondial.ai/api/v1/numbers/purchase" \
-H "Authorization: Bearer $ONDIAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phoneNumberId": "66f0123456789abcdef01234"
}'const res = await fetch("https://dashboard.ondial.ai/api/v1/numbers/purchase", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.ONDIAL_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"phoneNumberId": "66f0123456789abcdef01234"
}),
});
const data = await res.json();
console.log(res.status, data);import os
import requests
res = requests.request(
"POST",
"https://dashboard.ondial.ai/api/v1/numbers/purchase",
headers={
"Authorization": f"Bearer {os.environ['ONDIAL_API_KEY']}",
},
json={
"phoneNumberId": "66f0123456789abcdef01234",
},
timeout=30,
)
print(res.status_code, res.json())<?php
$ch = curl_init("https://dashboard.ondial.ai/api/v1/numbers/purchase");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("ONDIAL_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
'phoneNumberId' => '66f0123456789abcdef01234',
]),
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status . " " . $response;import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://dashboard.ondial.ai/api/v1/numbers/purchase"))
.header("Authorization", "Bearer " + System.getenv("ONDIAL_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"phoneNumberId": "66f0123456789abcdef01234"
}
"""))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}using System;
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://dashboard.ondial.ai/api/v1/numbers/purchase");
request.Headers.Add("Authorization", "Bearer " + Environment.GetEnvironmentVariable("ONDIAL_API_KEY"));
request.Content = new StringContent("""
{
"phoneNumberId": "66f0123456789abcdef01234"
}
""", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode + " " + await response.Content.ReadAsStringAsync());package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{
"phoneNumberId": "66f0123456789abcdef01234"
}`)
req, _ := http.NewRequest("POST", "https://dashboard.ondial.ai/api/v1/numbers/purchase", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("ONDIAL_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))
}{
"purchased": [
{
"id": "66f0123456789abcdef01234",
"number": "+919876543210",
"country": "IN",
"countryName": "India",
"status": "purchased",
"provider": "pool",
"purchasedAt": "2026-08-26T10:00:00.000Z",
"cost": 7
}
],
"totalCost": 7,
"creditsRemaining": 241780.98
}{
"error": "phoneNumberId or phoneNumberIds required",
"reasonCode": "invalid_request"
}{
"error": "Invalid or inactive API key",
"reasonCode": "unauthorized"
}{
"error": "Insufficient credits. Need 7, have 2.00.",
"reasonCode": "insufficient_credits",
"requiredCredits": 7,
"creditsAvailable": 2
}{
"error": "Some numbers are no longer available",
"reasonCode": "numbers_unavailable",
"unavailablePhoneNumberIds": [
"000000000000000000000000"
]
}{
"error": "Pool number purchase is not enabled for this account.",
"reasonCode": "pool_purchase_unavailable"
}Body (one of):
Optional:
After purchase, create the agent with
{ "phoneNumberId": "66f..." }
{ "phoneNumberIds": ["66f...", "66g..."] }
concurrentCalls (integer, default 0), description.
Success 200
{
"purchased": [
{
"id": "66f...",
"number": "+91xxxxxxxxxx",
"country": "IN",
"countryName": "India",
"status": "purchased",
"provider": "pool",
"purchasedAt": "2026-08-26T10:00:00.000Z",
"cost": 7
}
],
"totalCost": 7,
"creditsRemaining": 241780.98
}
| Code | HTTP | When |
|---|---|---|
insufficient_credits | 402 | Balance lower than cost - no number assigned |
numbers_unavailable | 409 | Id invalid or already taken |
pool_purchase_unavailable | 422 | Tenant cannot buy pool inventory |
batch_limit_exceeded | 400 | More than 20 ids in one request |
phoneNumberId or E.164 via Create inbound agent.
See Healthcare HMS integration.Authorizations
Paste only your API key (ond_live_… or ond_test_…). Do not type the word Bearer - the playground adds it.
Body
application/json
Response
Purchase succeeded

