API Reference#
- WhatsAppCloudApi.send_raw_request(method: str, endpoint: str, **kwargs) Any #
Send a raw request to WhatsApp Cloud API.
Use this method if you want to send a request that is not yet supported by pywa.
The endpoint can contain path parameters (e.g.
/{phone_id}/messages/
). onlyphone_id
is supported.Every request will automatically include the
Authorization
andContent-Type
headers. you can override them by passing them inkwargs
(headers={…}).
- Parameters:
method – The HTTP method to use (e.g.
POST
,GET
, etc.).endpoint – The endpoint to send the message to (e.g.
/{phone_id}/messages/
).**kwargs – Additional arguments to send with the request (e.g.
json={...}, headers={...}
).
Example
>>> wa = WhatsApp(...) >>> wa.api.send_raw_request( .. method="POST", .. endpoint="/{phone_id}/messages", .. json={"to": "1234567890", "type": "text", "text": {"body": "Hello, World!"}} .. ) { 'messaging_product': 'whatsapp', 'contacts': [{'input': '1234567890', 'wa_id': '1234567890'}], 'messages': [{'id': 'wamid.XXXXXXXXXXXXXXXX=='}] }
- Returns:
The response from the WhatsApp Cloud API.