0

List Phone Numbers

by
Published today

List the phone numbers registered on the WhatsApp Business Account, with their verification status and quality rating.

Script whatsapp_business Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 hours ago
1
//native
2

3
/**
4
 * List Phone Numbers
5
 * List the phone numbers registered on the WhatsApp Business Account, with their verification status and quality rating.
6
 */
7
export async function main(auth: RT.WhatsappBusiness) {
8
  const apiVersion = auth.api_version || "v25.0"
9
  const url = new URL(
10
    `https://graph.facebook.com/${apiVersion}/${auth.business_account_id}/phone_numbers`
11
  )
12
  url.searchParams.append(
13
    "fields",
14
    "id,display_phone_number,verified_name,code_verification_status,quality_rating,platform_type"
15
  )
16

17
  const response = await fetch(url, {
18
    method: "GET",
19
    headers: {
20
      Authorization: `Bearer ${auth.token}`,
21
      Accept: "application/json",
22
    },
23
  })
24

25
  if (!response.ok) {
26
    throw new Error(`${response.status} ${await response.text()}`)
27
  }
28

29
  return await response.json()
30
}
31