0

Update Business Profile

by
Published today

Update the WhatsApp business profile of the business phone number. Only the provided fields are changed.

Script whatsapp_business Verified

The script

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

3
/**
4
 * Update Business Profile
5
 * Update the WhatsApp business profile of the business phone number. Only the provided fields are changed.
6
 */
7
export async function main(
8
  auth: RT.WhatsappBusiness,
9
  body: {
10
    about?: string
11
    address?: string
12
    description?: string
13
    email?: string
14
    websites?: string[]
15
    vertical?: string
16
    profile_picture_handle?: string
17
  }
18
) {
19
  const apiVersion = auth.api_version || "v25.0"
20
  const url = new URL(
21
    `https://graph.facebook.com/${apiVersion}/${auth.phone_number_id}/whatsapp_business_profile`
22
  )
23

24
  const response = await fetch(url, {
25
    method: "POST",
26
    headers: {
27
      Authorization: `Bearer ${auth.token}`,
28
      "Content-Type": "application/json",
29
      Accept: "application/json",
30
    },
31
    body: JSON.stringify({
32
      messaging_product: "whatsapp",
33
      ...body,
34
    }),
35
  })
36

37
  if (!response.ok) {
38
    throw new Error(`${response.status} ${await response.text()}`)
39
  }
40

41
  return await response.json()
42
}
43