/buy-phone-number
curl --request POST \
--url https://api.daily.co/v1/buy-phone-number \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"number": "+18058700061"
}
'import requests
url = "https://api.daily.co/v1/buy-phone-number"
payload = { "number": "+18058700061" }
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({number: '+18058700061'})
};
fetch('https://api.daily.co/v1/buy-phone-number', 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.daily.co/v1/buy-phone-number",
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([
'number' => '+18058700061'
]),
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.daily.co/v1/buy-phone-number"
payload := strings.NewReader("{\n \"number\": \"+18058700061\"\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.daily.co/v1/buy-phone-number")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"number\": \"+18058700061\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.daily.co/v1/buy-phone-number")
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 \"number\": \"+18058700061\"\n}"
response = http.request(request)
puts response.read_body{
"id": "85a70a9a-e22f-4a8d-8302-bbf1b88dd909",
"number": "+18058700061"
}{
"error": "invalid-request-error",
"info": "missing required field"
}{
"errors": [
{
"detail": "Number is invalid.",
"status": "422",
"title": "Invalid Attribute",
"code": "422"
}
],
"status": 422
}Phone Numbers
Buy Phone Number
This will buy a phone number. In the POST request you can either provide the phone number you want to buy, or leave it empty. If the specified number is still available, it will be bought or the API will return a failure. Alternatively, if you skipped the number field, a random phone number from California (CA) will be bought.
POST
/
buy-phone-number
/buy-phone-number
curl --request POST \
--url https://api.daily.co/v1/buy-phone-number \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"number": "+18058700061"
}
'import requests
url = "https://api.daily.co/v1/buy-phone-number"
payload = { "number": "+18058700061" }
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({number: '+18058700061'})
};
fetch('https://api.daily.co/v1/buy-phone-number', 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.daily.co/v1/buy-phone-number",
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([
'number' => '+18058700061'
]),
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.daily.co/v1/buy-phone-number"
payload := strings.NewReader("{\n \"number\": \"+18058700061\"\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.daily.co/v1/buy-phone-number")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"number\": \"+18058700061\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.daily.co/v1/buy-phone-number")
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 \"number\": \"+18058700061\"\n}"
response = http.request(request)
puts response.read_body{
"id": "85a70a9a-e22f-4a8d-8302-bbf1b88dd909",
"number": "+18058700061"
}{
"error": "invalid-request-error",
"info": "missing required field"
}{
"errors": [
{
"detail": "Number is invalid.",
"status": "422",
"title": "Invalid Attribute",
"code": "422"
}
],
"status": 422
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The phone number to purchase, in E.164 format (e.g. "+18058700061"). If not provided, a random US number will be purchased.
Example:
"+18058700061"
Response
200
The response is of type object.
⌘I