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

# Thread Management

> List, edit, and delete SMS message threads using Hypersender's Laravel Package

## Overview

Manage SMS message threads programmatically with Hypersender's Laravel SDK. This page covers listing threads with filters, editing archived status, and deleting threads.

## Methods

### List Message Threads

Index all message threads with pagination and filtering. [(learn more)](/api-reference/sms/message-threads/message-threads)

<Tabs>
  <Tab title="Basic Usage" icon="code">
    ```php theme={null}
    use Hypersender\Hypersender;

    $response = Hypersender::sms()->messageThreads();
    ```
  </Tab>

  <Tab title="Basic Usage with Filters" icon="code">
    ```php theme={null}
    use Hypersender\Hypersender;

    $request = app(MessageThreadsIndexRequest::class, [
        'perPage' => '50',
        'page' => '1',
        'sort' => '-updated_at',
        'include' => 'last_message',
        'filter' => [
            'last_message_content' => 'otp',
            'is_archived' => false,
            'last_message_id' => '9e03fc6b-ce90-4399-a472-6b029857e15b',
            'from_or_to_number' => '+201234567890',
            // other filters (check Parameters tab)
        ],
    ]);

    $response = Hypersender::sms()->messageThreads($request);
    ```
  </Tab>

  <Tab title="Parameters" icon="sliders">
    | Parameter                       | Type   | Required | Description                                             |
    | ------------------------------- | ------ | -------- | ------------------------------------------------------- |
    | per\_page                       | int    | no       | Number of items per page (max 50)                       |
    | page                            | int    | no       | Page number to retrieve                                 |
    | sort                            | string | no       | Sort fields (default: `-updated_at`)                    |
    | include                         | string | no       | Related resources to include (comma-separated)          |
    | filter\[last\_message\_content] | string | no       | Filter by the content of the last message in the thread |
    | filter\[is\_archived]           | bool   | no       | Filter by archived status                               |
    | filter\[last\_message\_id]      | string | no       | Filter by the ID of the last message in the thread      |
    | filter\[from\_or\_to\_number]   | string | no       | Filter by phone number (either sender or recipient)     |
  </Tab>
</Tabs>

### Edit Message Thread

Edit a message thread's archived status. [(learn more)](/api-reference/sms/message-threads/edit-message-thread)

<Tabs>
  <Tab title="Basic Usage" icon="code">
    ```php theme={null}
    use Hypersender\Hypersender;

    Hypersender::sms()->editMessageThread(
        isArchived: true,
        messageThreadId: 'thread_01HXYZABCDEF1234567'
    );
    ```
  </Tab>

  <Tab title="Parameters" icon="sliders">
    | Parameter       | Type   | Required | Description                                     |
    | --------------- | ------ | -------- | ----------------------------------------------- |
    | isArchived      | bool   | yes      | Whether the thread should be marked as archived |
    | messageThreadId | string | yes      | The ID of the message thread to edit            |
  </Tab>
</Tabs>

### Delete Message Thread

Delete a message thread and all associated messages. [(learn more)](/api-reference/sms/message-threads/delete-message-thread)

<Tabs>
  <Tab title="Basic Usage" icon="code">
    ```php theme={null}
    use Hypersender\Hypersender;

    Hypersender::sms()->deleteMessageThread(
        messageThreadId: 'thread_01HXYZABCDEF1234567'
    );
    ```
  </Tab>

  <Tab title="Parameters" icon="sliders">
    | Parameter       | Type   | Required | Description                            |
    | --------------- | ------ | -------- | -------------------------------------- |
    | messageThreadId | string | yes      | The ID of the message thread to delete |
  </Tab>
</Tabs>
