Skip to main content

Getting Started with WhatsApp Cloud API

Introduction

WhatsApp Cloud API, hosted by Meta, is the official WhatsApp Business Platform API used for business messaging. This collection contains common queries, sample responses, and links to supporting documentation that can help you quickly get started with the API.

Cloud API Overview

Cloud API allows medium and large businesses to communicate with customers at scale. Using the API, businesses can build systems that connect thousands of customers with agents or bots, enabling both programmatic and manual communication. Additionally, businesses can integrate the API with numerous backend systems, such as CRM and marketing platforms.

https://developers.facebook.com/docs/whatsapp/cloud-api/overview

Getting Started with Cloud API

To use the API and this collection you must have a Meta business portfolio, a WhatsApp Business Account, and a business phone number. If you complete the steps in the Cloud API Get Started guide, these assets will be created for you.

Get Started as a Solution Partner

This guide goes over the steps Solution Partners need to take in order to offer the Cloud API to their customers.

Migrating from On-Premises API to Cloud API

This guide explains how to migrate business phone numbers from On-Premises API to Cloud API.

Environment

This collection has a corresponding WhatsApp Cloud API Postman environment which you must select when using the collection. Set current values for the variables defined in this environment if you wish to use the collection to perform queries.

You can find most of these values in the WhatsApp Manager or the WhatsApp > Getting Started panel in the app dashboard. However, if you have an access token and your business portfolio ID, you can use queries in the collection to get the remaining values.

Access tokens

The API supports both user and system user access tokens. You can get a user access token by loading your app in the app dashboard and navigating to the WhatsApp > Getting Started panel. Alternatively you can use the Graph API Explorer to generate one.

Since user access tokens expire after 24 hours, you'll likely want to generate a system user access token, which lasts up to 60 days (or permanently, if you wish). See Access Tokens to learn how to create a system user and system user access token.

Once you have your token, save it as a current value in the environment.

Business portfolio ID

You can get your business portfolio ID by signing into the Meta Business Suite. The ID appears in the URL as the business_id query string parameter value. Once you save this as a current value in the environment, go to the WhatsApp Business Account (WABA) folder and run the Get all owned WABAs query. This will return your WABA ID, which you can save to your environment and then use to determine your business phone number ID.

Permissions

The API only relies on two permissions:

  • whatsapp_business_management

  • whatsapp_business_messaging

Note that if you get a user access token from the app dashboard, your app will automatically be granted these permissions (by you, on your behalf), so you can use the token to test right away.

Queries that target your business portfolio require the business_management permission, which you may also need based on your business use case. Most developers do not need this permission, however, as accessing your business portfolio is uncommon, and the Meta Business Suite provides nearly all of this functionality anyway.

Access token debugger

You can paste any token you generate into the access token debugger to see what type of token it is and what permission you have granted to your app.

Pagination

Endpoints that return lists/collections may paginate results (you'll see previous and next properties in the response). Use the URLs from these properties to get the previous or next set of results. Note that if you click one of these links in Postman, it will open a new query in a new tab which you must save before running (otherwise it can't read your environment variables), so you may wish to cut and paste the URL and run the query in the same tab in which it was returned.

Install the Package

The package is compatible with Python versions 3.7+. Install the package from PyPi using the following pip command:

pip install whatsapp-cloud-api-sdk==1.0.0

You can also view the package at: https://pypi.python.org/pypi/whatsapp-cloud-api-sdk/1.0.0

Test the SDK

You can test the generated SDK and the server with test cases. unittest is used as the testing framework and pytest is used as the test runner. You can run the tests as follows:

Navigate to the root directory of the SDK and run the following commands

pip install -r test-requirements.txt pytest

Initialize the API Client

Note: Documentation for the client can be found here.

The following parameters are configurable for the API Client:

Parameter Type Description
version str Default: 'DefaultParameterValue'
environment Environment The API environment.
Default: Environment.PRODUCTION
http_client_instance HttpClient The Http Client passed from the sdk user for making requests
override_http_client_configuration bool The value which determines to override properties of the passed Http Client from the sdk user
http_call_back HttpCallBack The callback value that is invoked before and after an HTTP call is made to an endpoint
timeout float The value to use for connection timeout.
Default: 60
max_retries int The number of times to retry an endpoint call if it fails.
Default: 0
backoff_factor float A backoff factor to apply between attempts after the second try.
Default: 2
retry_statuses Array of int The http statuses on which retry is to be done.
Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]
retry_methods Array of string The http methods on which retry is to be done.
Default: ['GET', 'PUT']
bearer_auth_credentials BearerAuthCredentials The credential object for OAuth 2 Bearer token

The API client can be initialized as follows:

from whatsappcloudapi.configuration import Environment
from whatsappcloudapi.http.auth.o_auth_2 import BearerAuthCredentials
from whatsappcloudapi.whatsappcloudapi_client import WhatsappcloudapiClient

client = WhatsappcloudapiClient(
    bearer_auth_credentials=BearerAuthCredentials(
        access_token='AccessToken'
    ),
    environment=Environment.PRODUCTION,
    version='DefaultParameterValue'
)

Authorization

This API uses the following authentication schemes.

List of APIs

SDK Infrastructure

HTTP

Utilities

Metadata

Release files for whatsapp-cloud-api-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whatsapp-cloud-api-sdk 1.0.0
File Size Uploaded Provenance Actions
whatsapp_cloud_api_sdk-1.0.0.tar.gz 106.1 kB Without provenance Details for whatsapp_cloud_api_sdk-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for whatsapp-cloud-api-sdk 1.0.0
File Interpreter ABI Platform Actions
whatsapp_cloud_api_sdk-1.0.0-py3-none-any.whl Python 3 none any Details for whatsapp_cloud_api_sdk-1.0.0-py3-none-any.whl

Total release size: 590.9 kB

Release files / whatsapp_cloud_api_sdk-1.0.0.tar.gz

Download URL whatsapp_cloud_api_sdk-1.0.0.tar.gz
Size 106.1 kB
Tags Source
SHA-256 checksum
How to use checksums
21b800b8175492462c6cb06002f533de0cdff77413ac27bbb3f598cf3db53868
BLAKE2b-256 checksum
How to use checksums
f51d866e081a4069d75a341de5d83da881b86c1b9db49dc3b89837bf972a0a93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Release files / whatsapp_cloud_api_sdk-1.0.0-py3-none-any.whl

Download URL whatsapp_cloud_api_sdk-1.0.0-py3-none-any.whl
Size 484.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b1e0b5570cfff5188815ad25a35bc877c1cd19342b6bc21a09d653d2664f77e
BLAKE2b-256 checksum
How to use checksums
6f3e3c3e08c3bb6c43fbee65c11336bf1b8354e444675c820646d71925564571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Security for whatsapp-cloud-api-sdk 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page