Skip to main content
POST
/
v1
/
phone-numbers
/
purchase
Purchase Phone Number
curl --request POST \
  --url https://api-tokyo.oneinbox.ai/v1/phone-numbers/purchase \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "phone_number": "<string>",
  "country": "US",
  "area_code": "<string>",
  "contains": "<string>",
  "friendly_name": "<string>",
  "inbound_routing": {
    "agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "fallback": {
      "agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
    },
    "voicemail_message": "<string>"
  }
}
'
import requests

url = "https://api-tokyo.oneinbox.ai/v1/phone-numbers/purchase"

payload = {
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"phone_number": "<string>",
"country": "US",
"area_code": "<string>",
"contains": "<string>",
"friendly_name": "<string>",
"inbound_routing": {
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fallback": { "agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" },
"voicemail_message": "<string>"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
phone_number: '<string>',
country: 'US',
area_code: '<string>',
contains: '<string>',
friendly_name: '<string>',
inbound_routing: {
agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
fallback: {agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'},
voicemail_message: '<string>'
}
})
};

fetch('https://api-tokyo.oneinbox.ai/v1/phone-numbers/purchase', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api-tokyo.oneinbox.ai/v1/phone-numbers/purchase"

payload := strings.NewReader("{\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"phone_number\": \"<string>\",\n \"country\": \"US\",\n \"area_code\": \"<string>\",\n \"contains\": \"<string>\",\n \"friendly_name\": \"<string>\",\n \"inbound_routing\": {\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"fallback\": {\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"voicemail_message\": \"<string>\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
{
  "id": "<string>",
  "phone_number": "<string>",
  "friendly_name": "<string>",
  "provider": "<string>",
  "agent_id": "<string>",
  "status": "<string>",
  "inbound_trunk_id": "<string>",
  "outbound_trunk_id": "<string>",
  "dispatch_rule_id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "inbound_routing": {
    "agent_id": "<string>",
    "fallback": {
      "agent_id": "<string>"
    },
    "voicemail_message": "<string>"
  },
  "sms_capable": true
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}

Authorizations

Authorization
string
header
required

Your API key sent as a Bearer credential — Authorization: Bearer <api_key>, where <api_key> starts with oi_sk_ (create one via POST /v1/api-keys). Although the field is labelled 'token', paste your API key here. A dashboard JWT is also accepted on this header for the same endpoints.

Body

application/json

Buy a number through OneInbox. The carrier (Twilio today) is an internal implementation detail — the caller never supplies provider creds or trunk config; the number is bought on OneInbox's own account and wired automatically.

Either pass a specific phone_number from GET /phone-numbers/search, or leave it out and give search filters (country / area_code / contains) to auto-pick the first available match.

agent_id
string<uuid>
required
phone_number
string | null

A specific number from /phone-numbers/search. Omit to auto-pick.

Pattern: ^\+[1-9]\d{1,14}$
country
string
default:US
Required string length: 2
area_code
string | null

Area code (US/CA only)

contains
string | null

Digits/letters to match

friendly_name
string | null
inbound_routing
InboundRouting · object | null

Per-number routing override. Stored as JSONB so we can extend with business-hours and caller-id rules later without a schema change.

Response

Successful Response

id
string
required
phone_number
string
required
friendly_name
string | null
required
provider
string
required
agent_id
string
required
status
string
required
inbound_trunk_id
string | null
required
outbound_trunk_id
string | null
required
dispatch_rule_id
string | null
required
created_at
string<date-time>
required
updated_at
string<date-time>
required
inbound_routing
InboundRouting · object | null

Per-number routing override. Stored as JSONB so we can extend with business-hours and caller-id rules later without a schema change.

sms_capable
boolean | null