> ## 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 Node.js

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

Before you start, install the SDK and set your credentials as described in the [Node SDK installation guide](https://docs.hypersender.com/v2/packages-and-sdks/node/installation.md). This page is the reference for the SDK methods and parameters.

## 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 a `Promise` that resolves to the parsed, typed response and rejects with an error (a subclass of `HypersenderError`) when the request fails.

## Text Methods

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

### Safe Send Text Message

Send text with the Node SDK's `sendTextSafe` 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
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> const result = await Hypersender.whatsapp().sendTextSafe({
>   chatId: "20123456789@c.us",
>   text: "Hello from the Node SDK!",
> });
>
> console.log(result.queuedRequestUuid);
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp number to send the message to |
> | text | string | yes | The message content to send |
> | replyTo | string | no | The ID of the message to reply to |
> | linkPreview | boolean | no | Whether to show a link preview |
> | linkPreviewHighQuality | boolean | 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
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> const result = await Hypersender.whatsapp().sendText({
>   chatId: "20123456789@c.us",
>   text: "Hello from the Node SDK!",
> });
>
> console.log(result.queuedRequestUuid);
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp number to send the message to |
> | text | string | yes | The message content to send |
> | replyTo | string | no | The ID of the message to reply to |
> | linkPreview | boolean | no | Whether to show a link preview |
> | linkPreviewHighQuality | boolean | no | Whether to show a high-quality link preview |

> [!NOTE]
>
> The Node SDK sends requests as JSON, so media is sent by passing a publicly reachable `url`. Multipart file uploads are not supported by the Node SDK; host the file and pass its URL instead.

### Send Image Message

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

> [tab] Basic Usage
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> await Hypersender.whatsapp().sendImage({
>   chatId: "20123456789@c.us",
>   url: "https://example.com/image.jpeg",
>   filename: "image.jpeg",
>   mimetype: "image/jpeg",
>   caption: "Check out this image!",
> });
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp number to send the message to |
> | url | string | yes | The URL of the image to send |
> | filename | string | no | The name of the file to send |
> | mimetype | string | no | The MIME type of the file to send |
> | caption | string | no | The caption for the image |
> | replyTo | string | no | The ID of the message to reply to |

### Send Video Message

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

> [tab] Basic Usage
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> await Hypersender.whatsapp().sendVideo({
>   chatId: "20123456789@c.us",
>   url: "https://example.com/video.mp4",
>   caption: "Check out this video!",
> });
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp number to send the message to |
> | url | string | yes | The URL of the video to send |
> | filename | string | no | The name of the file to send |
> | mimetype | string | no | The MIME type of the file to send |
> | caption | string | no | The caption for the video |
> | replyTo | string | 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. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/send-messages/send-a-voice-message.md)

> [tab] Basic Usage
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> await Hypersender.whatsapp().sendVoice({
>   chatId: "20123456789@c.us",
>   url: "https://example.com/audio.opus",
>   caption: "Check out this audio!",
> });
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp number to send the message to |
> | url | string | yes | The URL of the audio to send |
> | caption | string | no | The caption for the audio |
> | replyTo | string | 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
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> await Hypersender.whatsapp().sendLocation({
>   chatId: "20123456789@c.us",
>   latitude: 37.7749,
>   longitude: -122.4194,
>   title: "San Francisco",
> });
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp number to send the message to |
> | latitude | number | yes | The latitude of the location to send |
> | longitude | number | yes | The longitude of the location to send |
> | title | string | no | The title of the location |
> | replyTo | string | 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
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> await Hypersender.whatsapp().sendPoll({
>   chatId: "20123456789@c.us",
>   poll: {
>     name: "Sample Poll",
>     options: ["Option 1", "Option 2", "Option 3"],
>     multipleAnswers: true,
>   },
> });
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp number to send the message to |
> | replyTo | string | no | The ID of the message to reply to |
> | poll | object | yes | The poll object containing `name` (string), `options` (string\[]), and `multipleAnswers` (boolean) |

### 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
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> await Hypersender.whatsapp().sendLinkCustomPreview({
>   chatId: "20123456789@c.us",
>   text: "Check this out: https://example.com",
>   highQuality: true,
>   previewTitle: "Example Title",
>   previewDescription: "A short description for the preview card",
>   previewUrl: "https://example.com",
>   previewImageUrl: "https://example.com/image.jpg",
> });
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp chat ID to send the message to |
> | text | string | yes | The message text (can include a link) |
> | replyTo | string | no | Message ID to reply to |
> | highQuality | boolean | no | Whether to use high-quality preview images |
> | previewTitle | string | yes | Title to display in the link preview |
> | previewDescription | string | yes | Description to display in the link preview |
> | previewUrl | string | yes | Link URL for the preview card |
> | previewImageUrl | string | yes | Direct URL to the preview image |

### Send File Message

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

> [tab] Basic Usage
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> await Hypersender.whatsapp().sendFile({
>   chatId: "20123456789@c.us",
>   url: "https://example.com/files/report.pdf",
>   filename: "report.pdf",
>   mimetype: "application/pdf",
>   caption: "Monthly report",
> });
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp chat ID to send the file to |
> | url | string | yes | Direct URL of the file to send |
> | filename | string | no | File name to display to the recipient |
> | mimetype | string | no | MIME type of the file |
> | caption | string | no | Optional caption for the file |
> | replyTo | string | 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
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> await Hypersender.whatsapp().sendContactCard({
>   chatId: "20123456789@c.us",
>   contacts: [
>     {
>       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 |
> | - | - | - | - |
> | chatId | string | yes | The WhatsApp chat ID to send the contact card to |
> | contacts | object\[] | yes | Array of contact objects (see note below) |

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


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