curl --request POST \
--url https://api.pyai.com/v1/whatsapp/numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"waba_id": "<string>",
"phone_number_id": "<string>",
"display_phone_number": "+14155550123",
"access_token": "<string>",
"app_id": "<string>",
"agent_id": "<string>"
}
'import requests
url = "https://api.pyai.com/v1/whatsapp/numbers"
payload = {
"waba_id": "<string>",
"phone_number_id": "<string>",
"display_phone_number": "+14155550123",
"access_token": "<string>",
"app_id": "<string>",
"agent_id": "<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({
waba_id: '<string>',
phone_number_id: '<string>',
display_phone_number: '+14155550123',
access_token: '<string>',
app_id: '<string>',
agent_id: '<string>'
})
};
fetch('https://api.pyai.com/v1/whatsapp/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.pyai.com/v1/whatsapp/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([
'waba_id' => '<string>',
'phone_number_id' => '<string>',
'display_phone_number' => '+14155550123',
'access_token' => '<string>',
'app_id' => '<string>',
'agent_id' => '<string>'
]),
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.pyai.com/v1/whatsapp/numbers"
payload := strings.NewReader("{\n \"waba_id\": \"<string>\",\n \"phone_number_id\": \"<string>\",\n \"display_phone_number\": \"+14155550123\",\n \"access_token\": \"<string>\",\n \"app_id\": \"<string>\",\n \"agent_id\": \"<string>\"\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.pyai.com/v1/whatsapp/numbers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"waba_id\": \"<string>\",\n \"phone_number_id\": \"<string>\",\n \"display_phone_number\": \"+14155550123\",\n \"access_token\": \"<string>\",\n \"app_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pyai.com/v1/whatsapp/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 \"waba_id\": \"<string>\",\n \"phone_number_id\": \"<string>\",\n \"display_phone_number\": \"+14155550123\",\n \"access_token\": \"<string>\",\n \"app_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"object": "whatsapp.number",
"id": "wan_...",
"waba_id": "<string>",
"phone_number_id": "<string>",
"phone_number": "+14155550123",
"app_id": "<string>",
"agent_id": "<string>",
"calling_enabled": true,
"calling_settings": {},
"status": "active",
"created_at": 123,
"updated_at": 123,
"released_at": 123
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "invalid_request_error",
"param": "<string>"
}
}Register a WhatsApp Business number
Attach a WhatsApp Business number you already own on Meta’s Cloud API to your org so an Omni agent can answer its calls. You bring the WhatsApp Business Account id, the number’s phone_number_id, and a system-user access token with whatsapp_business_messaging; PyAI stores the token encrypted and never returns it. Point your Meta app’s calls and messages webhooks at https://api.pyai.com/public/whatsapp/webhook. Calling stays off until you enable it with POST /v1/whatsapp/numbers/{id}/calling. Requires the telephony:manage scope.
curl --request POST \
--url https://api.pyai.com/v1/whatsapp/numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"waba_id": "<string>",
"phone_number_id": "<string>",
"display_phone_number": "+14155550123",
"access_token": "<string>",
"app_id": "<string>",
"agent_id": "<string>"
}
'import requests
url = "https://api.pyai.com/v1/whatsapp/numbers"
payload = {
"waba_id": "<string>",
"phone_number_id": "<string>",
"display_phone_number": "+14155550123",
"access_token": "<string>",
"app_id": "<string>",
"agent_id": "<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({
waba_id: '<string>',
phone_number_id: '<string>',
display_phone_number: '+14155550123',
access_token: '<string>',
app_id: '<string>',
agent_id: '<string>'
})
};
fetch('https://api.pyai.com/v1/whatsapp/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.pyai.com/v1/whatsapp/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([
'waba_id' => '<string>',
'phone_number_id' => '<string>',
'display_phone_number' => '+14155550123',
'access_token' => '<string>',
'app_id' => '<string>',
'agent_id' => '<string>'
]),
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.pyai.com/v1/whatsapp/numbers"
payload := strings.NewReader("{\n \"waba_id\": \"<string>\",\n \"phone_number_id\": \"<string>\",\n \"display_phone_number\": \"+14155550123\",\n \"access_token\": \"<string>\",\n \"app_id\": \"<string>\",\n \"agent_id\": \"<string>\"\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.pyai.com/v1/whatsapp/numbers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"waba_id\": \"<string>\",\n \"phone_number_id\": \"<string>\",\n \"display_phone_number\": \"+14155550123\",\n \"access_token\": \"<string>\",\n \"app_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pyai.com/v1/whatsapp/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 \"waba_id\": \"<string>\",\n \"phone_number_id\": \"<string>\",\n \"display_phone_number\": \"+14155550123\",\n \"access_token\": \"<string>\",\n \"app_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"object": "whatsapp.number",
"id": "wan_...",
"waba_id": "<string>",
"phone_number_id": "<string>",
"phone_number": "+14155550123",
"app_id": "<string>",
"agent_id": "<string>",
"calling_enabled": true,
"calling_settings": {},
"status": "active",
"created_at": 123,
"updated_at": 123,
"released_at": 123
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "invalid_request_error",
"param": "<string>"
}
}Authorizations
Use Authorization: Bearer pyai_live_... (or pyai_test_...).
Body
The number in E.164.
"+14155550123"
Meta system-user token with whatsapp_business_messaging. Stored encrypted, never returned.
Meta app that owns the webhook subscription.
Optional agent to route inbound calls to.
Response
Registered
"whatsapp.number"
"wan_..."
WhatsApp Business Account id.
Meta's id for the business number (what the webhook carries).
E.164.
"+14155550123"
Agent that answers inbound WhatsApp calls.
Last calling settings pushed to Meta.
active, released Unix ms.
Unix ms.
Unix ms.