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

> List, archive, and delete SMS conversation threads from Golang 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 Go SDK to list threads, archive or unarchive them, and delete them.

Every method returns the parsed JSON response body as a `hypersender.Result` (a `map[string]any`), and a `*hypersender.Error` if the API answers with an error. The examples assume `ctx` is a `context.Context`, such as `context.Background()`.

## 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
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.SMS.ListMessageThreads(ctx, nil)
> if err != nil {
>     log.Fatal(err)
> }
>
> threads, _ := res["data"].([]any)
> for _, item := range threads {
>     thread, _ := item.(map[string]any)
>     fmt.Println(thread["id"], thread["to_phone_number"], thread["last_message_content"])
> }
> ```

> [tab] Basic Usage with Filters
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.SMS.ListMessageThreads(ctx, &hypersender.ListOptions{
>     PerPage: 50,
>     Page:    1,
>     Sort:    "-updated_at",
>     Include: "lastMessage",
>     Filters: map[string]string{
>         "is_archived":       "false",
>         "from_or_to_number": "+201001234567",
>         // other filters (check Parameters tab)
>     },
> })
> if err != nil {
>     log.Fatal(err)
> }
>
> meta, _ := res["meta"].(map[string]any)
> fmt.Println(meta["current_page"], meta["last_page"], meta["total"])
> ```

> [tab] Parameters
>
> All fields are optional; pass `nil` for none. Each key in `Filters` is sent as `filter[key]`.
>
> | Parameter | Type | Description |
> | - | - | - |
> | PerPage | int | Items per page (max 50) |
> | Page | int | 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 |
> | Filters\["last\_message\_content"] | string | Part of the last message's text |
> | Filters\["is\_archived"] | string | `"true"` for archived threads only, `"false"` for threads that are not archived |
> | Filters\["last\_message\_id"] | string | Exact ID of the last message |
> | Filters\["from\_or\_to\_number"] | 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
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.SMS.EditMessageThread(ctx, "9e03fc6b-ce90-4399-a472-6b029857e15b", true)
> if err != nil {
>     log.Fatal(err)
> }
>
> data, _ := res["data"].(map[string]any)
> fmt.Println(data["is_archived"])
> ```

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

### 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
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> if _, err := client.SMS.DeleteMessageThread(ctx, "9e03fc6b-ce90-4399-a472-6b029857e15b"); err != nil {
>     log.Fatal(err)
> }
> ```

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