> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hypersender.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send WhatsApp Messages with Python

> Send WhatsApp messages from Python with the Hypersender WhatsApp API: text, images, files, video, voice, polls, locations, and contact cards.

Before you start, install the SDK and set your credentials as described in the [Python SDK installation guide](https://docs.hypersender.com/v2/packages-and-sdks/python/installation.md). This page is the reference for the SDK methods and parameters. Building a Python WhatsApp bot? See [Build a WhatsApp bot in Python](https://docs.hypersender.com/v2/packages-and-sdks/python/whatsapp/whatsapp-bot.md).

## Overview

The Send Message module provides comprehensive methods for sending various message types, managing interactions, and controlling chat on WhatsApp. Build engaging, feature-rich messaging experiences with safe sending options, link previews, and more.

> [!NOTE]
>
> Every method returns the parsed JSON response as a plain `dict` and raises `hypersender.HypersenderError` (with `status_code`, `message`, and `body`) when the request fails. The chat ID and other required values are positional; optional parameters are keyword-only.

## Text Methods

Send various types of content to engage your audience with multimedia and interactive elements.

### Safe Send Text Message

Send text with the Python SDK's `send_text_safe` method. See the [endpoint reference](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-text-safe.md) for its request fields and response flow.

> [tab] Basic usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.whatsapp.send_text_safe("20123456789@c.us", "Hello from the Python SDK!")
>
> print(result["queued_request_uuid"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp number to send the message to |
> | text | str | yes | The message content to send |
> | reply\_to | str | no | The ID of the message to reply to |
> | link\_preview | bool | no | Whether to show a link preview |
> | link\_preview\_high\_quality | bool | no | Whether to show a high-quality link preview |

### Send Text Message

Send plain text messages with link preview (optional) [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-text.md)

> [!WARNING]
>
> We highly recommend using the [`send-text-safe`](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-text-safe) endpoint for regular messaging operations to maintain a more natural communication pattern, and keep your whatsapp number safe from being blocked.

> [tab] Basic usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.whatsapp.send_text("20123456789@c.us", "Hello from the Python SDK!")
>
> print(result["queued_request_uuid"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp number to send the message to |
> | text | str | yes | The message content to send |
> | reply\_to | str | no | The ID of the message to reply to |
> | link\_preview | bool | no | Whether to show a link preview |
> | link\_preview\_high\_quality | bool | no | Whether to show a high-quality link preview |

> [!NOTE]
>
> Media methods take either `url=` (a publicly reachable URL) or `file=` (a local file path, `bytes`, or a file opened in binary mode). Pass exactly one of them. With `file=`, the SDK uploads the file as multipart form data.

### Send Image Message

Send images to WhatsApp users via URL or local file. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-image.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.whatsapp.send_image(
>     "20123456789@c.us",
>     url="https://example.com/image.jpeg",
>     filename="image.jpeg",
>     mimetype="image/jpeg",
>     caption="Check out this image!",
> )
>
> # Or upload a local file
> hs.whatsapp.send_image("20123456789@c.us", file="image.jpeg", caption="Check out this image!")
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp number to send the message to |
> | url | str | one of `url`/`file` | The URL of the image to send |
> | file | str \| bytes \| file | one of `url`/`file` | A local path, bytes, or binary file to upload |
> | filename | str | no | The name of the file to send |
> | mimetype | str | no | The MIME type of the file to send |
> | caption | str | no | The caption for the image |
> | reply\_to | str | no | The ID of the message to reply to |

### Send Video Message

Send videos to WhatsApp users via URL or local file. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-video.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.whatsapp.send_video(
>     "20123456789@c.us",
>     url="https://example.com/video.mp4",
>     caption="Check out this video!",
> )
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp number to send the message to |
> | url | str | one of `url`/`file` | The URL of the video to send |
> | file | str \| bytes \| file | one of `url`/`file` | A local path, bytes, or binary file to upload |
> | filename | str | no | The name of the file to send |
> | mimetype | str | no | The MIME type of the file to send |
> | caption | str | no | The caption for the video |
> | reply\_to | str | no | The ID of the message to reply to |

> [!WARNING]
>
> You can send videos only in mp4 formats - so make sure the url contains the correct extension
>
> Max allowed file size is `20MB`.

### Send Voice Message

Send voice messages to WhatsApp users via URL or local file. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-a-voice-message.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.whatsapp.send_voice(
>     "20123456789@c.us",
>     url="https://example.com/audio.opus",
>     caption="Check out this audio!",
> )
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp number to send the message to |
> | url | str | one of `url`/`file` | The URL of the audio to send |
> | file | str \| bytes \| file | one of `url`/`file` | A local path, bytes, or binary file to upload |
> | caption | str | no | The caption for the audio |
> | reply\_to | str | no | The ID of the message to reply to |

### Send Location Message

Send location messages to WhatsApp users. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-location.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.whatsapp.send_location(
>     "20123456789@c.us",
>     37.7749,
>     -122.4194,
>     title="San Francisco",
> )
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp number to send the message to |
> | latitude | float | yes | The latitude of the location to send |
> | longitude | float | yes | The longitude of the location to send |
> | title | str | no | The title of the location |
> | reply\_to | str | no | The ID of the message to reply to |

### Send Poll Message

Send poll messages to WhatsApp users. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-poll.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.whatsapp.send_poll(
>     "20123456789@c.us",
>     "Sample Poll",
>     ["Option 1", "Option 2", "Option 3"],
>     multiple_answers=True,
> )
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp number to send the message to |
> | name | str | yes | The poll question |
> | options | list\[str] | yes | The poll options |
> | multiple\_answers | bool | no | Whether users can pick more than one option (default: `False`) |
> | reply\_to | str | no | The ID of the message to reply to |

### Send Link Custom Preview

Send a text message with a custom link preview. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-link-custom-preview.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.whatsapp.send_link_custom_preview(
>     "20123456789@c.us",
>     "Check this out: https://example.com",
>     high_quality=True,
>     preview_title="Example Title",
>     preview_description="A short description for the preview card",
>     preview_url="https://example.com",
>     preview_image_url="https://example.com/image.jpg",
> )
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp chat ID to send the message to |
> | text | str | yes | The message text (can include a link) |
> | reply\_to | str | no | Message ID to reply to |
> | high\_quality | bool | no | Whether to use high-quality preview images |
> | preview\_title | str | yes | Title to display in the link preview |
> | preview\_description | str | yes | Description to display in the link preview |
> | preview\_url | str | yes | Link URL for the preview card |
> | preview\_image\_url | str | no | Direct URL to the preview image |
> | preview\_image\_file | str \| bytes \| file | no | A local preview image to upload instead of a URL |

### Send File Message

Send any file type via URL or local file. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-file.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.whatsapp.send_file(
>     "20123456789@c.us",
>     url="https://example.com/files/report.pdf",
>     filename="report.pdf",
>     mimetype="application/pdf",
>     caption="Monthly report",
> )
>
> # Or upload a local file
> hs.whatsapp.send_file("20123456789@c.us", file="report.pdf", caption="Monthly report")
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp chat ID to send the file to |
> | url | str | one of `url`/`file` | Direct URL of the file to send |
> | file | str \| bytes \| file | one of `url`/`file` | A local path, bytes, or binary file to upload |
> | filename | str | no | File name to display to the recipient |
> | mimetype | str | no | MIME type of the file |
> | caption | str | no | Optional caption for the file |
> | reply\_to | str | no | Message ID to reply to |

### Send Contact Card

Send contact cards (vCard) to WhatsApp users. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-contact-card.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.whatsapp.send_contact_card(
>     "20123456789@c.us",
>     [
>         {
>             "vcard": "BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nORG:Acme Inc\nTEL;type=CELL:+12025550123\nEND:VCARD",
>             "fullName": "John Doe",
>             "organization": "Acme Inc",
>             "phoneNumber": "12025550123",
>             "whatsappId": "12025550123@c.us",
>         },
>     ],
> )
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | The WhatsApp chat ID to send the contact card to |
> | contacts | list\[dict] | yes | List of contact dicts (see note below) |

> [!NOTE]
>
> Each contact dict supports the API's keys: `vcard`, `fullName`, `organization`, `phoneNumber`, `whatsappId`.
>
> You can send one or multiple contacts in a single message by including multiple items in the `contacts` list.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.