- Requirements
- Installation
- Getting Started
- Async
- Raw HTTP Response
- Reference
whatsappbusiness.application.get_settings
whatsappbusiness.application.list_media_providers
whatsappbusiness.application.remove_provider
whatsappbusiness.application.reset_settings
whatsappbusiness.application.set_shards
whatsappbusiness.application.update_media_providers
whatsappbusiness.application.update_settings
whatsappbusiness.backup/restore.settings_post
whatsappbusiness.backup/restore.settings_post_0
whatsappbusiness.business_profile.get
whatsappbusiness.business_profile.update
whatsappbusiness.certificates.delete_webhook_ca
whatsappbusiness.certificates.download_ca_certificate
whatsappbusiness.certificates.download_webhook_ca_certificate
whatsappbusiness.certificates.upload_external_certificate
whatsappbusiness.certificates.upload_webhook_ca_certificate
whatsappbusiness.contacts.create_contact
whatsappbusiness.groups.create_group
whatsappbusiness.groups.delete_group_icon
whatsappbusiness.groups.delete_invite
whatsappbusiness.groups.demote_admin
whatsappbusiness.groups.get_all
whatsappbusiness.groups.get_icon_binary
whatsappbusiness.groups.get_info
whatsappbusiness.groups.get_invite_details
whatsappbusiness.groups.leave_group
whatsappbusiness.groups.promote_to_admin
whatsappbusiness.groups.remove_participant
whatsappbusiness.groups.set_group_icon
whatsappbusiness.groups.update_info
whatsappbusiness.health.check_status
whatsappbusiness.health.get_app_stats
whatsappbusiness.health.get_db_stats
whatsappbusiness.health.get_metrics_data
whatsappbusiness.health.get_support_info
whatsappbusiness.media.download
whatsappbusiness.media.remove_media
whatsappbusiness.media.upload_media
whatsappbusiness.messages.mark_as_read
whatsappbusiness.messages.send_message
whatsappbusiness.profile.get_about
whatsappbusiness.profile.get_photo
whatsappbusiness.profile.remove_photo
whatsappbusiness.profile.update_about
whatsappbusiness.profile.update_photo
whatsappbusiness.registration.request_code
whatsappbusiness.registration.verify_account
whatsappbusiness.two_step_verification.disable
whatsappbusiness.two_step_verification.enable_account
whatsappbusiness.users.create_user
whatsappbusiness.users.get_by_username
whatsappbusiness.users.perform_login
whatsappbusiness.users.perform_logout
whatsappbusiness.users.remove_user
whatsappbusiness.users.update_user
Python >=3.7
from pprint import pprint
from whats_app_business_python_sdk import WhatsAppBusiness, ApiException
whatsappbusiness = WhatsAppBusiness(access_token="YOUR_BEARER_TOKEN")
try:
# Get-Application-Settings
get_settings_response = whatsappbusiness.application.get_settings()
print(get_settings_response)
except ApiException as e:
print("Exception when calling ApplicationApi.get_settings: %s\n" % e)
pprint(e.body)
pprint(e.headers)
pprint(e.status)
pprint(e.reason)
pprint(e.round_trip_time)
async
support is available by prepending a
to any method.
import asyncio
from pprint import pprint
from whats_app_business_python_sdk import WhatsAppBusiness, ApiException
whatsappbusiness = WhatsAppBusiness(access_token="YOUR_BEARER_TOKEN")
async def main():
try:
# Get-Application-Settings
get_settings_response = await whatsappbusiness.application.aget_settings()
print(get_settings_response)
except ApiException as e:
print("Exception when calling ApplicationApi.get_settings: %s\n" % e)
pprint(e.body)
pprint(e.headers)
pprint(e.status)
pprint(e.reason)
pprint(e.round_trip_time)
asyncio.run(main())
To access raw HTTP response values, use the .raw
namespace.
from pprint import pprint
from whats_app_business_python_sdk import WhatsAppBusiness, ApiException
whatsappbusiness = WhatsAppBusiness(access_token="YOUR_BEARER_TOKEN")
try:
# Get-Application-Settings
get_settings_response = whatsappbusiness.application.raw.get_settings()
pprint(get_settings_response.body)
pprint(get_settings_response.body["callback_backoff_delay_ms"])
pprint(get_settings_response.body["callback_persist"])
pprint(get_settings_response.body["heartbeat_interval"])
pprint(get_settings_response.body["max_callback_backoff_delay_ms"])
pprint(get_settings_response.body["media"])
pprint(get_settings_response.body["on_call_pager"])
pprint(get_settings_response.body["pass_through"])
pprint(get_settings_response.body["sent_status"])
pprint(get_settings_response.body["unhealthy_interval"])
pprint(get_settings_response.body["webhooks"])
pprint(get_settings_response.headers)
pprint(get_settings_response.status)
pprint(get_settings_response.round_trip_time)
except ApiException as e:
print("Exception when calling ApplicationApi.get_settings: %s\n" % e)
pprint(e.body)
pprint(e.headers)
pprint(e.status)
pprint(e.reason)
pprint(e.round_trip_time)
Get-Application-Settings
get_settings_response = whatsappbusiness.application.get_settings()
/settings/application
get
Get-Media-Providers
list_media_providers_response = whatsappbusiness.application.list_media_providers()
/settings/application/media/providers
get
Delete-Media-Providers
whatsappbusiness.application.remove_provider(
provider_name="ProviderName_example",
)
Provider Name
/settings/application/media/providers/{ProviderName}
delete
Reset-Application-Settings
whatsappbusiness.application.reset_settings()
/settings/application
delete
Set-Shards
whatsappbusiness.application.set_shards(
cc="<Country Code>",
phone_number="<Phone Number>",
pin="<Two-Step PIN>",
shards=32,
)
/account/shards
post
Update-Media-Providers
whatsappbusiness.application.update_media_providers(
body=[
{
"config": {"bearer": "<Bearer Auth Token>"},
"name": "<Provider Name>",
"type": "www",
}
],
)
ApplicationUpdateMediaProvidersRequest
/settings/application/media/providers
post
If a field is not present in the request, no change is made to that setting. For example, if on_call_pager is not sent with the request, the existing configuration for on_call_pager is unchanged.
update_settings_response = whatsappbusiness.application.update_settings(
callback_backoff_delay_ms="3000",
callback_persist=True,
heartbeat_interval=5,
max_callback_backoff_delay_ms="900000",
media={
"auto_download": ["audio"],
},
on_call_pager="<WA_ID of valid WhatsApp contact>",
pass_through=True,
sent_status=False,
unhealthy_interval=30,
webhooks={
"max_concurrent_requests": 6,
"url": "<Webhook URL, https>",
},
)
Backoff delay for a failed callback in milliseconds This setting is used to configure the amount of time the backoff delays before retrying a failed callback. The backoff delay increases linearly by this value each time a callback fails to get a HTTPS 200 OK response. The backoff delay is capped by the max_callback_backoff_delay_ms setting.
Stores callbacks on disk until they are successfully acknowledged by the Webhook or not. Restart required.
Multiconnect: Interval of the Master node monitoring of Coreapp nodes in seconds
Maximum delay for a failed callback in milliseconds
media: Media
Set to valid WhatsApp Group with users who wish to see alerts for critical errors and messages.
When true, removes messages from the local database after they are delivered to or read by the recipient. When false, saves all messages on local storage until they are explicitly deleted. When messages are sent, they are stored in a local database. This database is used as the application's history. Since the business keeps its own history, you can specify whether you want message pass_through or not. Restart required.
Receive a notification that a message is sent to server. When true, you will receive a message indicating that a message has been sent. If false (default), you will not receive notification.
Multiconnect: Maximum amount of seconds a Master node waits for a Coreapp node to respond to a heartbeat before considering it unhealthy and starting the failover process.
webhooks: Webhooks
/settings/application
patch
Backup-Settings
settings_post_response = whatsappbusiness.backup / restore.settings_post(
password="<Password for Backup>",
)
Used to encrypt backup data for security
/settings/backup
post
Restore-Settings
whatsappbusiness.backup / restore.settings_post_0(
data="<Data to Restore, from Backup API>",
password="<Password for Backup>",
)
The data that was returned by the /v1/settings/backup API call
The password you used in the /v1/settings/backup API call to encrypt the backup data
/settings/restore
post
Get-Business-Profile
get_response = whatsappbusiness.business_profile.get()
/settings/business/profile
get
Update-Business-Profile
whatsappbusiness.business_profile.update(
description="<Business Profile Description>",
address="<Business Profile Address>",
email="<Business Profile Email>",
vertical="<Business Profile Vertical>",
websites=["string_example"],
)
Description of the business Maximum of 256 characters
Address of the business Maximum of 256 characters
Email address to contact the business Maximum of 128 characters
Industry of the business Maximum of 128 characters
websites: BusinessProfileWebsites
/settings/business/profile
post
Delete Webhook CA Certificate
whatsappbusiness.certificates.delete_webhook_ca()
/certificates/webhooks/ca
delete
Download-CA-Certificate
download_ca_certificate_response = (
whatsappbusiness.certificates.download_ca_certificate()
)
/certificates/external/ca
get
Download Webhook CA Certificate
download_webhook_ca_certificate_response = (
whatsappbusiness.certificates.download_webhook_ca_certificate()
)
/certificates/webhooks/ca
get
Upload-Certificate
whatsappbusiness.certificates.upload_external_certificate(
body=open("/path/to/file", "rb"),
)
IO
/certificates/external
post
Upload Webhook CA Certificate
whatsappbusiness.certificates.upload_webhook_ca_certificate(
body=open("/path/to/file", "rb"),
)
IO
/certificates/webhooks/ca
post
Check-Contact
create_contact_response = whatsappbusiness.contacts.create_contact(
contacts=["string_example"],
blocking="no_wait",
)
contacts: CheckContactRequestBodyContacts
Blocking determines whether the request should wait for the processing to complete (synchronous) or not (asynchronous).
/contacts
post
Create-Group
create_group_response = whatsappbusiness.groups.create_group(
subject="<Group Subject>",
)
/groups
post
Delete-Group-Icon
whatsappbusiness.groups.delete_group_icon(
group_id="GroupId_example",
file=open("/path/to/file", "rb"),
)
/groups/{GroupId}/icon
delete
Delete-Group-Invite
whatsappbusiness.groups.delete_invite(
group_id="GroupId_example",
)
/groups/{GroupId}/invite
delete
Demote-Group-Admin
whatsappbusiness.groups.demote_admin(
wa_ids=["string_example"],
group_id="GroupId_example",
)
wa_ids: GroupAdminRequestBodyWaIds
/groups/{GroupId}/admins
delete
Get-All-Groups
get_all_response = whatsappbusiness.groups.get_all()
/groups
get
Get-Group-Icon-Binary
whatsappbusiness.groups.get_icon_binary(
group_id="GroupId_example",
)
/groups/{GroupId}/icon
get
Get-Group-Info
get_info_response = whatsappbusiness.groups.get_info(
group_id="GroupId_example",
)
/groups/{GroupId}
get
Get-Group-Invite
get_invite_details_response = whatsappbusiness.groups.get_invite_details(
group_id="GroupId_example",
)
/groups/{GroupId}/invite
get
Leave-Group
whatsappbusiness.groups.leave_group(
group_id="GroupId_example",
)
/groups/{GroupId}/leave
post
Promote-To-Group-Admin
whatsappbusiness.groups.promote_to_admin(
wa_ids=["string_example"],
group_id="GroupId_example",
)
wa_ids: GroupAdminRequestBodyWaIds
/groups/{GroupId}/admins
patch
Remove-Group-Participant
whatsappbusiness.groups.remove_participant(
wa_ids=["string_example"],
group_id="GroupId_example",
)
RemoveGroupParticipantRequestBody
/groups/{GroupId}/participants
delete
Set-Group-Icon
whatsappbusiness.groups.set_group_icon(
group_id="GroupId_example",
file=open("/path/to/file", "rb"),
)
/groups/{GroupId}/icon
post
Update-Group-Info
whatsappbusiness.groups.update_info(
subject="<New Group Subject>",
group_id="GroupId_example",
)
/groups/{GroupId}
put
Check-Health
whatsappbusiness.health.check_status()
/health
get
Get-App-Stats
get_app_stats_response = whatsappbusiness.health.get_app_stats(
format="prometheus",
)
/stats/app
get
Get-DB-Stats
get_db_stats_response = whatsappbusiness.health.get_db_stats(
format="prometheus",
)
/stats/db
get
Get-Metrics (since v2.21.3)
get_metrics_data_response = whatsappbusiness.health.get_metrics_data(
format="prometheus",
)
/metrics
get
Get-Support-Info
get_support_info_response = whatsappbusiness.health.get_support_info()
/support
get
Download-Media
download_response = whatsappbusiness.media.download(
media_id="MediaId_example",
)
/media/{MediaId}
get
Delete-Media
whatsappbusiness.media.remove_media(
media_id="MediaId_example",
)
/media/{MediaId}
delete
Upload-Media
upload_media_response = whatsappbusiness.media.upload_media(
body=open("/path/to/file", "rb"),
)
IO
/media
post
Mark-Message-As-Read
whatsappbusiness.messages.mark_as_read(
status="read",
message_id="MessageID_example",
)
Message ID from Webhook
/messages/{MessageID}
put
Send-Message
send_message_response = whatsappbusiness.messages.send_message(
to="{whatsapp-id}",
audio={},
contacts=[
{
"birthday": "2012-08-18T00:00:00.000Z",
}
],
document={},
hsm={
"element_name": "hello_world",
"language": {
"code": "en",
"policy": "deterministic",
},
"localizable_params": [
{
"default": "<param value>",
}
],
"namespace": "business_a_namespace",
},
image={},
location={
"address": "<Location's Address>",
"latitude": "<Latitude>",
"longitude": "<Longitude>",
"name": "<Location Name>",
},
preview_url=True,
recipient_type="individual",
text={
"body": "your-text-message-content",
},
ttl={},
type="text",
video={},
)
When recipient_type is individual, this field is the WhatsApp ID (phone number) returned from contacts endpoint. When recipient_type is group, this field is the WhatsApp group ID.
audio: Audio
document: Document
hsm: Hsm
image: Image
location: Location
Specifying preview_url in the request is optional when not including a URL in your message. To include a URL preview, set preview_url to true in the message body and make sure the URL begins with http:// or https://. For more information, see the Sending URLs in Text Messages section.
Determines whether the recipient is an individual or a group Specifying recipient_type in the request is optional when the value is individual. However, recipient_type is required when using group. If sending a text message to a group, see the Sending Group Messages documentation.
text: Text
type: MessageType
video: Video
/messages
post
Get-Profile-About
get_about_response = whatsappbusiness.profile.get_about()
/settings/profile/about
get
Get-Profile-Photo
get_photo_response = whatsappbusiness.profile.get_photo(
format="link",
)
/settings/profile/photo
get
Delete-Profile-Photo
whatsappbusiness.profile.remove_photo()
/settings/profile/photo
delete
Update-Profile-About
whatsappbusiness.profile.update_about(
text="your-profile-about-text",
)
Text to display in your profile's About section The max length for the string is 139 characters.
/settings/profile/about
patch
Update-Profile-Photo
whatsappbusiness.profile.update_photo(
file=open("/path/to/file", "rb"),
)
/settings/profile/photo
post
Request-Code
whatsappbusiness.registration.request_code(
cc="<Country Code>",
cert="<Valid Cert from Business Manager>",
method="< sms | voice >",
phone_number="<Phone Number>",
pin="<Two-Step Verification PIN",
)
Numerical country code for the phone number you are registering
Base64-encoded Verified Name certificate
Method of receiving your registration code
Phone number you are registering, without the country code or plus symbol (+)
Existing 6-digit PIN — This is only required when two-factor verification is enabled on this account.
/account
post
Register-Account
whatsappbusiness.registration.verify_account(
code="your-registration-code-received-by-sms-or-voice-call",
)
/account/verify
post
Disable-Two-Step
whatsappbusiness.two_step_verification.disable()
/settings/account/two-step
delete
Enable-Two-Step
whatsappbusiness.two_step_verification.enable_account(
pin="your-6-digit-pin",
)
/settings/account/two-step
post
Create-User
create_user_response = whatsappbusiness.users.create_user(
password="password",
username="username",
)
username
password
/users
post
Get-User
get_by_username_response = whatsappbusiness.users.get_by_username(
user_username="UserUsername_example",
)
/users/{UserUsername}
get
Login-User
perform_login_response = whatsappbusiness.users.perform_login(
new_password="<New Admin Password>",
)
/users/login
post
Logout-User
whatsappbusiness.users.perform_logout()
/users/logout
post
Delete-User
remove_user_response = whatsappbusiness.users.remove_user(
user_username="UserUsername_example",
)
/users/{UserUsername}
delete
Update-User
update_user_response = whatsappbusiness.users.update_user(
password="New Password",
user_username="UserUsername_example",
)
password
/users/{UserUsername}
put
This Python package is automatically generated by Konfig