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

# Node.js WhatsApp and SMS API SDK: Installation

> Install the Hypersender Node.js SDK from npm to use the WhatsApp API, SMS API, and OTP API from JavaScript or TypeScript, with keys read from your .env file.

## Getting Started with Hypersender SDK

This guide will walk you through the process of installing and configuring the Hypersender Node SDK for your Node.js or TypeScript application.

## Prerequisites

Before you begin, ensure you have the following:

* **Node.js 18 or higher:** The SDK uses the built-in `fetch` API. Bun 1+ and Deno are supported too.
* **npm, pnpm, yarn, or bun:** For package management and dependency resolution
* **Hypersender account:** Sign up at [Hypersender](https://app.hypersender.com) to obtain your API key and Instance ID.

> [!TIP]
>
> You can find your API key and Instance ID in the Hypersender dashboard

![Hypersender Dashboard API Key](https://mintcdn.com/hypersender/oXq9uVgBJOXaL1p2/images/docs/whatsapp/img/api-key-and-instance-id.jpeg?fit=max\&auto=format\&n=oXq9uVgBJOXaL1p2\&q=85\&s=addd172bddcb335eeb1eb029473bac71)

## Installation

**1. Install the SDK via npm**

Run the following command in your terminal to install the Hypersender Node SDK:

```bash theme={null}
npm install hypersender-node
```

> [!TIP]
>
> After installation, you can verify the package is listed in your `package.json` file.

> [!NOTE]
>
> The package is published as an ES module. In CommonJS code, load it with `const { Hypersender } = await import("hypersender-node");`.

**2. Configure Environment Variables**

The SDK reads its credentials from environment variables, using the same names as the Laravel package. Set the variables for the APIs you use: WhatsApp, SMS, OTP, or any mix of them.

**`For WhatsApp API, set the following environment variables in your .env file:`**

```bash theme={null}
# API key from Hypersender dashboard
HYPERSENDER_WHATSAPP_API_KEY=
# Instance ID from Hypersender dashboard
HYPERSENDER_WHATSAPP_INSTANCE_ID=
```

> [!TIP]
>
> Learn how to get the Hypersender whatsapp `API token` and `Instance ID` from Dashboard: [Demo Link](https://docs.hypersender.com/v2/api-reference/whatsapp/how-to-send-a-whatsapp-message-in-postman.md).

**`For SMS API, set the following environment variables in your .env file:`**

```bash theme={null}
# API key from Hypersender dashboard
HYPERSENDER_SMS_API_KEY=
# Instance ID from Hypersender dashboard
HYPERSENDER_SMS_INSTANCE_ID=
```

> [!TIP]
>
> Learn how to get the Hypersender SMS `API token` and `Instance ID` from the dashboard: [Demo Link](https://docs.hypersender.com/v2/api-reference/sms/how-to-send-an-sms-message-in-postman.md).

**`For OTP API, set the following environment variables in your .env file:`**

```bash theme={null}
# API key from Hypersender dashboard
HYPERSENDER_OTP_API_KEY=
# Instance ID from Hypersender dashboard
HYPERSENDER_OTP_INSTANCE_ID=
```

> [!NOTE]
>
> Node.js does not read `.env` files on its own. Start your app with `node --env-file=.env app.js` (Node.js 20.6+), or load the file with a package such as `dotenv` before your first Hypersender call.

**3. Send your first message**

Import the `Hypersender` facade and call the API you need. It picks up the environment variables on first use.

```typescript theme={null}
import { Hypersender } from "hypersender-node";

const result = await Hypersender.whatsapp().sendText({
  chatId: "20123456789@c.us",
  text: "Hello from Hypersender!",
});

console.log(result.queuedRequestUuid);
```

## Configure in code instead of environment variables

If you can't use environment variables, pass the credentials once with `Hypersender.configure()` before your first call:

```typescript theme={null}
import { Hypersender } from "hypersender-node";

Hypersender.configure({
  whatsappInstanceId: "your-whatsapp-instance-id",
  smsInstanceId: "your-sms-instance-id",
  otpInstanceId: "your-otp-instance-id",
  security: {
    whatsappApiKey: "your-whatsapp-api-key",
    smsApiKey: "your-sms-api-key",
    otpApiKey: "your-otp-api-key",
  },
});
```

To work with more than one account at the same time, create a client for each one with `new HypersenderClient({ ... })`. It takes the same options and has the same `whatsapp`, `sms`, and `otp` properties.

## You're all set!

You have successfully installed and configured the Hypersender Node SDK in your application. You can now start using the SDK to send messages and manage your communications.

* **WhatsApp:** [Usage Guide](https://docs.hypersender.com/v2/packages-and-sdks/node/whatsapp/send-messages.md)
* **SMS:** [Usage Guide](https://docs.hypersender.com/v2/packages-and-sdks/node/sms/send-and-manage-sms-messages.md)
* **OTP codes (WhatsApp or SMS):** [OTP with Node](https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node.md)
* **WhatsApp OTP links:** [Generate a link with Node](https://docs.hypersender.com/v2/packages-and-sdks/node/otp/generate-whatsapp-otp-link-with-node.md)


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