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

# Messages Management

> Full Guide to Sending and Managing SMS Messages using Hypersender's Laravel Package through your Android Phone

## Overview

The Send Message Module in Hypersender's Laravel SDK allows you to send and manage SMS messages programmatically. This guide provides a comprehensive overview of the available methods and how to use them effectively in your Laravel applications through your Android Phone.

## Methods

### Send SMS Message

Send a new SMS message to be sent by your android phone. [(learn more)](/api-reference/sms/messages/send-message)

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

    Hypersender::sms()
      ->sendMessage(
          content: 'Hello, this is a test message!',
          requestId: 'e7b8a3c0-2d1a-4f9b-9f6c-1b2c3d4e5f6a',
          to: '+1234567890',
          // Optional parameters
          // scheduleSendAt: '2025-01-01 12:00:00',
          // maxSendAttempts: 3,
          // messageExpirationSeconds: 120,
        );
    ```
  </Tab>

  <Tab title="Parameters" icon="sliders">
    | Parameter                | Type   | Required | Description                                                                                                                               |
    | ------------------------ | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
    | content                  | string | yes      | The content of your SMS message                                                                                                           |
    | requestId                | string | yes      | A unique identifier you can later use to find this message (preferably a UUID)                                                            |
    | to                       | string | yes      | The recipient's phone number (e.g. +201234567890)                                                                                         |
    | scheduleSendAt           | string | no       | Optional date-time to schedule sending (e.g. 2025-01-01 12:00:00). You can schedule up to 3 days ahead (relative to your phone timezone). |
    | maxSendAttempts          | int    | no       | How many times to retry sending if it fails. Max: 15.                                                                                     |
    | messageExpirationSeconds | int    | no       | Message validity window in seconds (useful for OTPs, e.g. 120 for 2 minutes).                                                             |
  </Tab>
</Tabs>

### List Messages

Retrieve a paginated list of messages with powerful filtering. [(learn more)](/api-reference/sms/messages/index-messages)

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

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

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

    $request = app(MessagesIndexRequest::class, [
        'perPage' => '50',
        'page' => '2',
        'sort' => '-updated_at',
        'include' => 'thread',
        'filter' => [
            'request_id' => 'e7b8a3c0-2d1a-4f9b-9f6c-1b2c3d4e5f6a',
            'status' => 'delivered',
            // other filters (check Parameters tab)
        ],
    ]);

    $response = Hypersender::sms()->messages($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 (e.g. `updated_at` or `-updated_at` for desc) |
    | include                      | string | no       | Related resources to include (comma-separated)            |
    | filter\[request\_id]         | string | no       | Filter by your custom request id                          |
    | filter\[message\_thread\_id] | string | no       | Filter by message thread id                               |
    | filter\[from\_phone\_number] | string | no       | Filter by sender phone number                             |
    | filter\[to\_phone\_number]   | string | no       | Filter by recipient phone number                          |
    | filter\[content]             | string | no       | Filter by message content (search)                        |
    | filter\[status]              | string | no       | Filter by status (e.g. sent, delivered, failed, expired)  |
    | filter\[type]                | string | no       | Filter by message type                                    |
    | filter\[delivered\_at]       | string | no       | Filter by delivered\_at timestamp/range                   |
    | filter\[received\_at]        | string | no       | Filter by received\_at timestamp/range                    |
    | filter\[expired\_at]         | string | no       | Filter by expired\_at timestamp/range                     |
    | filter\[failed\_at]          | string | no       | Filter by failed\_at timestamp/range                      |
    | filter\[schedule\_send\_at]  | string | no       | Filter by scheduled send time                             |
    | filter\[created\_at]         | string | no       | Filter by created\_at timestamp/range                     |
    | filter\[updated\_at]         | string | no       | Filter by updated\_at timestamp/range                     |
  </Tab>
</Tabs>

### Delete Message

Delete a message by its ID. [(learn more)](/api-reference/sms/messages/delete-message)

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

    Hypersender::sms()->deleteMessage(
        messageId: 'msg_01HXYZABCDEF1234567'
    );
    ```
  </Tab>

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