Buy a number
Buy a number and make it an SMS channel in the same call. The purchase follows the same rules as POST /v1/phone-numbers, including regulatory requirements, and the number comes back with SMS on. There is no separate assign step. Where it lands: when the project’s default channel group has no number yet, the number joins that group (and becomes the project’s first channel and default when there is none); otherwise it gets a channel group of its own.
While the number is in regulatory review (number.regulatoryStatus: pending_review) it is attached but cannot send, and channels can be empty until it is approved. If the purchase succeeded but turning SMS on failed, the number is still bought and billed; the response says so in setupError rather than failing the call.
curl --request POST \
--url https://api.zavu.dev/v2/numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phoneNumber": "+15551234567",
"name": "<string>",
"regulatoryRequirements": [
{
"requirementType": "8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10",
"fieldValue": "jd7x2k3m4n5p6q7r8s9t0abc"
}
]
}
'import requests
url = "https://api.zavu.dev/v2/numbers"
payload = {
"phoneNumber": "+15551234567",
"name": "<string>",
"regulatoryRequirements": [
{
"requirementType": "8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10",
"fieldValue": "jd7x2k3m4n5p6q7r8s9t0abc"
}
]
}
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({
phoneNumber: '+15551234567',
name: '<string>',
regulatoryRequirements: [
{
requirementType: '8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10',
fieldValue: 'jd7x2k3m4n5p6q7r8s9t0abc'
}
]
})
};
fetch('https://api.zavu.dev/v2/numbers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zavu.dev/v2/numbers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phoneNumber' => '+15551234567',
'name' => '<string>',
'regulatoryRequirements' => [
[
'requirementType' => '8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10',
'fieldValue' => 'jd7x2k3m4n5p6q7r8s9t0abc'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zavu.dev/v2/numbers"
payload := strings.NewReader("{\n \"phoneNumber\": \"+15551234567\",\n \"name\": \"<string>\",\n \"regulatoryRequirements\": [\n {\n \"requirementType\": \"8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10\",\n \"fieldValue\": \"jd7x2k3m4n5p6q7r8s9t0abc\"\n }\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))
}HttpResponse<String> response = Unirest.post("https://api.zavu.dev/v2/numbers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phoneNumber\": \"+15551234567\",\n \"name\": \"<string>\",\n \"regulatoryRequirements\": [\n {\n \"requirementType\": \"8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10\",\n \"fieldValue\": \"jd7x2k3m4n5p6q7r8s9t0abc\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v2/numbers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phoneNumber\": \"+15551234567\",\n \"name\": \"<string>\",\n \"regulatoryRequirements\": [\n {\n \"requirementType\": \"8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10\",\n \"fieldValue\": \"jd7x2k3m4n5p6q7r8s9t0abc\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"number": {
"id": "<string>",
"phoneNumber": "+15551234567",
"capabilities": [
"sms",
"voice"
],
"status": "active",
"pricing": {
"monthlyPrice": 123,
"upfrontCost": 123,
"monthlyCost": 123,
"isFreeNumber": true
},
"regulatoryStatus": "approved",
"createdAt": "2023-11-07T05:31:56Z",
"name": "<string>",
"nextRenewalDate": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"channels": [
{
"address": "+13125551212",
"type": "sms",
"active": true,
"v1SenderId": "<string>"
}
],
"setupError": {
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Phone number in E.164 format.
"+15551234567"
Optional custom name for the phone number.
100Type the number was found under in GET /v2/numbers/available. Used to look the number up and to keep regulatory information for reuse. Required when regulatoryRequirements is sent. toll_free is accepted as an alias of tollFree. A number not listed under this type is refused with 400 number_unavailable saying so.
local, national, tollFree, mobile Regulatory information, for numbers whose requirements list is not empty. Get the list with GET /v1/phone-numbers/requirements?phoneNumber=... and send one entry per requirement id, except action requirements, which take no value. Every required id must be present, once, and no unknown id may be sent; otherwise the purchase is refused with 400 invalid_request before anything is charged.
The information is kept for your project under the number's country and type. A later purchase there may omit this field if what is kept still covers that number's requirements. Omit it for numbers without requirements.
50Show child attributes
Show child attributes
Response
Bought.
curl --request POST \
--url https://api.zavu.dev/v2/numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phoneNumber": "+15551234567",
"name": "<string>",
"regulatoryRequirements": [
{
"requirementType": "8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10",
"fieldValue": "jd7x2k3m4n5p6q7r8s9t0abc"
}
]
}
'import requests
url = "https://api.zavu.dev/v2/numbers"
payload = {
"phoneNumber": "+15551234567",
"name": "<string>",
"regulatoryRequirements": [
{
"requirementType": "8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10",
"fieldValue": "jd7x2k3m4n5p6q7r8s9t0abc"
}
]
}
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({
phoneNumber: '+15551234567',
name: '<string>',
regulatoryRequirements: [
{
requirementType: '8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10',
fieldValue: 'jd7x2k3m4n5p6q7r8s9t0abc'
}
]
})
};
fetch('https://api.zavu.dev/v2/numbers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zavu.dev/v2/numbers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phoneNumber' => '+15551234567',
'name' => '<string>',
'regulatoryRequirements' => [
[
'requirementType' => '8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10',
'fieldValue' => 'jd7x2k3m4n5p6q7r8s9t0abc'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zavu.dev/v2/numbers"
payload := strings.NewReader("{\n \"phoneNumber\": \"+15551234567\",\n \"name\": \"<string>\",\n \"regulatoryRequirements\": [\n {\n \"requirementType\": \"8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10\",\n \"fieldValue\": \"jd7x2k3m4n5p6q7r8s9t0abc\"\n }\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))
}HttpResponse<String> response = Unirest.post("https://api.zavu.dev/v2/numbers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phoneNumber\": \"+15551234567\",\n \"name\": \"<string>\",\n \"regulatoryRequirements\": [\n {\n \"requirementType\": \"8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10\",\n \"fieldValue\": \"jd7x2k3m4n5p6q7r8s9t0abc\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v2/numbers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phoneNumber\": \"+15551234567\",\n \"name\": \"<string>\",\n \"regulatoryRequirements\": [\n {\n \"requirementType\": \"8c5b1a2e-0f3d-4f5b-9a61-2c7e4d9b1f10\",\n \"fieldValue\": \"jd7x2k3m4n5p6q7r8s9t0abc\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"number": {
"id": "<string>",
"phoneNumber": "+15551234567",
"capabilities": [
"sms",
"voice"
],
"status": "active",
"pricing": {
"monthlyPrice": 123,
"upfrontCost": 123,
"monthlyCost": 123,
"isFreeNumber": true
},
"regulatoryStatus": "approved",
"createdAt": "2023-11-07T05:31:56Z",
"name": "<string>",
"nextRenewalDate": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"channels": [
{
"address": "+13125551212",
"type": "sms",
"active": true,
"v1SenderId": "<string>"
}
],
"setupError": {
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}