Facebook has the following API -

https://graph.facebook.com/API_VERSION/me?fields=FIELDS&access_token=ACCESS_TOKEN 

Does WhatsApp have a similar API where I can get all account information, such as phone number ID and business account ID, by using only the access token and nothing else? I have searched the official documentation and all the APIs I have come across either use the business account ID or the phone number ID to retrieve account information.

I would really appreciate any suggestions provided. Thank you.

Tag:whatsapp, facebook-graph-api, whatsapp-cloud-api

8 comments.

  1. Remdex

    Just perhaps someone will find it usefull

    try { $response = $fb->get('me?fields=businesses'); $responseData = $response->getDecodedBody(); $phoneNumbers = []; foreach ($responseData['businesses']['data'] as $dataItem) { try { $response = $fb->get($dataItem['id']. '/owned_whatsapp_business_accounts'); $whatsAppBusinessAccounts = $response->getDecodedBody(); foreach ($whatsAppBusinessAccounts['data'] as $whatsAppBusinessAccount) { $response = $fb->get($whatsAppBusinessAccount['id'] . '/phone_numbers'); $phoneNumbersData = $response->getDecodedBody(); foreach ($phoneNumbersData['data'] as $phoneNumber) { $phoneNumber['whatsapp_business_account_id'] = $whatsAppBusinessAccount['id']; $phoneNumber['whatsapp_business_account_name'] = $whatsAppBusinessAccount['name']; $phoneNumber['business_id'] = $dataItem['id']; $phoneNumber['business_name'] = $dataItem['name']; $phoneNumbers[] = $phoneNumber; } } } catch (Exception $e) { // Not all business we can manage } } $tpl->set('phone_numbers', $phoneNumbers); } catch (Exception $e){ // Missing general permission to manage business }

    Required permissions

    'whatsapp_business_management', 'whatsapp_business_messaging', 'business_management'
  2. turivishal

    No there is no specific API for individual businesses, At least requires a business account ID, refer to this documentation, there are some APIs to access a single phone number and all phone numbers using business account ID.

    For Business Solutions Providers (BSPs), If you are then you have to use Embedded Signup for Business Solution Providers, https://developers.facebook.com/docs/whatsapp/embedded-signup

    1. sealabr

      I'm trying to follow this steps, but gives me Malformed access token

  3. basti4557

    Yes, it is possible.

    Take a look here: https://developers.facebook.com/docs/whatsapp/embedded-signup/manage-accounts

    use the https://graph.facebook.com/v19.0/debug_token route. Add as input_token your accessToken from the response and as Authorization: Bearer Header also the token and your good to go :)

    1. sealabr

      input_token parameter from responde of signupflow and Authorization: Bearer Header too?

    2. sealabr

      error: "message": "Malformed access token AQCUQBjz97tBWCbdMva;..."

    3. basti4557

      graph.facebook.com/v18.0/debug_token?input_token=AQCUQBjz97tB....

    4. basti4557

      As GET Request with "Authorization: Bearer AQCUQBjz97tB..." in header

Add a new comment.