📖 Reading Messages
The app not only allows receiving incoming messages in real-time via webhooks but also enables reading previously received messages using the API or exporting them via webhooks.
📋 API Endpoints
The app provides three endpoints for reading messages:
| Endpoint | Method | Description |
|---|---|---|
GET /inbox | GET | List incoming messages with filtering and pagination |
POST /inbox/refresh | POST | Refresh inbox messages without triggering webhooks |
POST /messages/inbox/export | POST | Export messages via webhooks |
Note
The /inbox endpoints group is only available in the Local Server Mode.
GET /inbox
Retrieves incoming messages with filtering and pagination support.
Endpoint: GET /inbox
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | No | Filter by message type: SMS, DATA_SMS, MMS, MMS_DOWNLOADED |
limit | integer | No | Maximum messages to return (1-500, default: 50) |
offset | integer | No | Number of messages to skip (default: 0) |
from | string | No | Start of date range (ISO 8601 format) |
to | string | No | End of date range (ISO 8601 format) |
deviceId | string | No | Filter by device ID |
Example Request:
curl -u <username>:<password> \
"http://<device_local_ip>:8080/inbox?type=SMS&limit=10&offset=0"
Response:
[
{
"id": "PyDmBQZZXYmyxMwED8Fzy",
"type": "SMS",
"sender": "+79990001234",
"recipient": "+79990001234",
"simNumber": 1,
"contentPreview": "Hello World!",
"createdAt": "2020-01-01T00:00:00Z"
}
]
Response Headers: - X-Total-Count: Total number of messages available
POST /inbox/refresh
Refreshes inbox messages without triggering webhooks. This re-processes messages internally.
Endpoint: POST /inbox/refresh
Request Body:
{
"deviceId": "<device-id>",
"since": "2024-01-01T00:00:00Z",
"until": "2024-12-31T23:59:59Z"
}
Example Request:
curl -X POST -u <username>:<password> \
-H "Content-Type: application/json" \
-d '{ "deviceId": "<device-id>", "since": "2024-01-01T00:00:00Z", "until": "2024-12-31T23:59:59Z" }' \
http://<device_local_ip>:8080/inbox/refresh
POST /messages/inbox/export
Initiates export of inbox messages via webhooks. Triggers sms:received webhook for each message in the specified period.
Endpoint: POST /messages/inbox/export
Request Body:
{
"deviceId": "<device-id>",
"since": "2024-01-01T00:00:00Z",
"until": "2024-12-31T23:59:59Z"
}
Example Request:
curl -X POST -u <username>:<password> \
-H "Content-Type: application/json" \
-d '{ "deviceId": "<device-id>", "since": "2024-01-01T00:00:00Z", "until": "2024-12-31T23:59:59Z" }' \
https://api.sms-gate.app/3rdparty/v1/messages/inbox/export
🔧 How to Use
Option 1: Direct API Access (GET /inbox)
Use this for direct access to message history in the Local Server Mode:
Option 2: Export via Webhooks (POST /messages/inbox/export)
Use this to process historical messages through your existing webhook handler:
- Register the
sms:receivedwebhook as described in the Webhooks guide if you haven't done so already. - Send a request with
deviceIdand period to thePOST /messages/inbox/exportendpoint: - After receiving the request, the device will send
sms:receivedwebhooks for each message in the inbox for the specified period.
📝 Notes
- The webhook will be sent for each message independently, so the order of messages is not guaranteed.
- It is recommended to split long periods into shorter ones to avoid excessive load on your webhook receiver.
- The export webhooks retry policy is the same as described in the Webhooks guide.
- The ID for incoming messages is generated based on the content of the message and is not guaranteed to be unique.
- Use the
X-Total-Countheader from theGET /inboxresponse to implement pagination.
📚 See Also
- Webhooks Documentation - For real-time message notifications
- API Integration Guide - For detailed API specifications
- Local Server Mode - For inbox API in local mode