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

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

## Overview

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

Every method returns the parsed JSON response body as a plain `dict`, and raises a `HypersenderError` (from `hypersender`) 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
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.sms.list_message_threads()
>
> for thread in result["data"]:
>     print(thread["id"], thread["to_phone_number"], thread["last_message_content"])
> ```

> [tab] Basic Usage with Filters
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.sms.list_message_threads(
>     per_page=50,
>     page=1,
>     sort="-updated_at",
>     include="lastMessage",
>     filters={
>         "is_archived": False,
>         "from_or_to_number": "+201001234567",
>         # other filters (check Parameters tab)
>     },
> )
>
> meta = result["meta"]
> print(meta["current_page"], meta["last_page"], meta["total"])
> ```

> [tab] Parameters
>
> All parameters are optional and keyword-only. Each key in `filters` is sent as `filter[key]`.
>
> | Parameter | Type | Description |
> | - | - | - |
> | per\_page | int | Items per page (max 50) |
> | page | int | Page number |
> | sort | str | `created_at`, `last_message_at`, or `updated_at`. Add `-` for descending. Default: `-updated_at` |
> | include | str | `lastMessage` to add the last message to each thread, `phone` to add the phone, or both separated by a comma |
> | filters\["last\_message\_content"] | str | Part of the last message's text |
> | filters\["is\_archived"] | bool | `True` for archived threads only, `False` for threads that are not archived |
> | filters\["last\_message\_id"] | str | Exact ID of the last message |
> | filters\["from\_or\_to\_number"] | str | 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
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.sms.edit_message_thread(
>     "9e03fc6b-ce90-4399-a472-6b029857e15b",
>     is_archived=True,
> )
>
> print(result["data"]["is_archived"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | message\_thread\_id | str | yes | The ID of the thread |
> | is\_archived | bool | yes | `True` to archive the thread, `False` to unarchive it (keyword-only) |

### 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
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.sms.delete_message_thread("9e03fc6b-ce90-4399-a472-6b029857e15b")
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | message\_thread\_id | str | yes | The ID of the thread to delete |


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