> ## 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 SMS with Node.js: Android SMS Gateway

> Send, schedule, list, and delete SMS from Node.js through your own Android phone and SIM card. The Hypersender SMS API works as an Android SMS gateway for apps.

## Overview

Use the Hypersender Node SDK to send SMS through the Hypersender SMS app on your Android phone, list your messages, and delete them. Set `HYPERSENDER_SMS_API_KEY` and `HYPERSENDER_SMS_INSTANCE_ID` first, as described in [Installation](https://docs.hypersender.com/v2/packages-and-sdks/node/installation.md).

Every method returns the parsed, typed response body. If the API answers with an error, the method throws a `HypersenderError` (imported from `hypersender-node/models/errors`), or a subclass such as `ValidationError` or `NotFoundError`, with the `statusCode` and `body` of the response.

> [!NOTE]
>
> If the instance is offline, the API answers `403`. If the phone has no push registration, it answers `422` with the code `PHONE_PUSH_NOT_REGISTERED`. See the [SMS heartbeats guide](https://docs.hypersender.com/v2/hypersender/overview/sms/sms-heartbeats-guide.md) and [How it works](https://docs.hypersender.com/v2/hypersender/overview/sms/how-it-works.md).

## Methods

### Send SMS Message

Queue an SMS to be sent by your Android phone. [(learn more)](https://docs.hypersender.com/v2/api-reference/sms/messages/send-message.md)

> [tab] Basic Usage
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> const result = await Hypersender.sms().sendMessage({
>   content: "Hello, this is a test message!",
>   requestId: "order-1042-confirmation",
>   to: "+201001234567",
>   // Optional parameters
>   // scheduleSendAt: "2025-01-01 12:00:00",
>   // maxSendAttempts: 3,
>   // messageExpirationSeconds: 300,
> });
>
> console.log(result.data?.id, result.data?.status);
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | content | string | yes | The text of the SMS. Up to 1600 characters. |
> | to | string | yes | The recipient's number, preferably in international format (for example `+201001234567`). Spaces, dashes, dots, and parentheses are removed. |
> | requestId | string | no | Your own ID for this message, up to 255 characters. Sending again with the same `requestId`, number, and text returns the first message with `200` instead of sending a second SMS. If you leave it out, a UUID is generated. |
> | scheduleSendAt | string | no | Send later, in `Y-m-d H:i:s` format. Must be in the future and less than 3 days away. |
> | maxSendAttempts | number | no | How many times to try sending if it fails, from 1 to 15. |
> | messageExpirationSeconds | number | no | Seconds the message stays valid. If the phone has not sent it by then, it is marked expired and never sent. Minimum 60. Useful for OTP codes. |

### List Messages

Get a paginated list of messages, with filters. [(learn more)](https://docs.hypersender.com/v2/api-reference/sms/messages/index-messages.md)

> [tab] Basic Usage
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> const result = await Hypersender.sms().listMessages();
>
> for (const message of result.data ?? []) {
>   console.log(message.id, message.status, message.content);
> }
> ```

> [tab] Basic Usage with Filters
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> const result = await Hypersender.sms().listMessages({
>   perPage: 50,
>   page: 2,
>   sort: "-updated_at",
>   include: "messageThread",
>   filterRequestId: "order-1042-confirmation",
>   filterStatus: "delivered",
>   // other filters (check Parameters tab)
> });
>
> console.log(result.meta?.currentPage, result.meta?.lastPage, result.meta?.total);
> ```

> [tab] Parameters
>
> All parameters are optional.
>
> | Parameter | Type | Description |
> | - | - | - |
> | perPage | number | Items per page (max 50) |
> | page | number | Page number |
> | sort | string | `created_at`, `updated_at`, `delivered_at`, `received_at`, `expired_at`, `failed_at`, or `schedule_send_at`. Add `-` for descending, for example `-updated_at`. |
> | include | string | `messageThread` to add the thread to each message, `phone` to add the phone, or both separated by a comma |
> | filterRequestId | string | Exact `request_id` you sent |
> | filterMessageThreadId | string | Exact thread ID |
> | filterFromPhoneNumber | string | Exact sender number |
> | filterToPhoneNumber | string | Exact recipient number |
> | filterContent | string | Part of the message text |
> | filterStatus | string | `pending`, `scheduled`, `sending`, `sent`, `delivered`, `failed`, `expired`, `received`, or `deleted` |
> | filterType | string | `sent` (outgoing) or `received` (incoming) |
> | filterDeliveredAt | string | Date or range. A range is two dates separated by a comma, for example `2025-01-01 00:00:00,2025-01-01 23:59:59`. |
> | filterReceivedAt | string | Date or range |
> | filterExpiredAt | string | Date or range |
> | filterFailedAt | string | Date or range |
> | filterScheduleSendAt | string | Date or range |
> | filterCreatedAt | string | Date or range |
> | filterUpdatedAt | string | Date or range |

### Delete Message

Delete a message by its ID. [(learn more)](https://docs.hypersender.com/v2/api-reference/sms/messages/delete-sms-message.md)

> [tab] Basic Usage
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> await Hypersender.sms().deleteMessage("9e03fc6b-ce90-4399-a472-6b029857e15b");
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | messageId | string | yes | The ID of the message to delete |


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