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

# Manage SMS Threads with Node.js

> List, archive, and delete SMS conversation threads from Node.js with the Hypersender SMS API. Filter threads by phone number and archive state in TypeScript.

## Overview

A thread groups the messages exchanged with one phone number. Use the Hypersender Node SDK to list threads, archive or unarchive them, and delete them.

Every method returns the parsed, typed response body, and throws a `HypersenderError` (from `hypersender-node/models/errors`) if the API answers with an error.

## Methods

### List Message Threads

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

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

> [tab] Basic Usage with Filters
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> const result = await Hypersender.sms().listMessageThreads({
>   perPage: 50,
>   page: 1,
>   sort: "-updated_at",
>   include: "lastMessage",
>   filterIsArchived: false,
>   filterFromOrToNumber: "+201001234567",
>   // 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`, `last_message_at`, or `updated_at`. Add `-` for descending. Default: `-updated_at` |
> | include | string | `lastMessage` to add the last message to each thread, `phone` to add the phone, or both separated by a comma |
> | filterLastMessageContent | string | Part of the last message's text |
> | filterIsArchived | boolean | `true` for archived threads only, `false` for threads that are not archived |
> | filterLastMessageId | string | Exact ID of the last message |
> | filterFromOrToNumber | string | Exact phone number, as sender or recipient |

### Edit Message Thread

Archive or unarchive a thread. [(learn more)](https://docs.hypersender.com/v2/api-reference/sms/message-threads/edit-message-thread.md)

> [tab] Basic Usage
>
> ```typescript theme={null}
> import { Hypersender } from "hypersender-node";
>
> const result = await Hypersender.sms().editMessageThread({
>   isArchived: true,
>   messageThreadId: "9e03fc6b-ce90-4399-a472-6b029857e15b",
> });
>
> console.log(result.data?.isArchived);
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | isArchived | boolean | yes | `true` to archive the thread, `false` to unarchive it |
> | messageThreadId | string | yes | The ID of the thread |

### Delete Message Thread

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

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

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


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