Skip to content

Commit 2b4e0a0

Browse files
committed
[features] add messages reading guide
1 parent 727080e commit 2b4e0a0

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

docs/features/reading-messages.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Reading Messages
2+
3+
The app not only allows receiving incoming messages in real-time via webhooks but also enables reading previously received messages using the same webhook.
4+
5+
## How it works
6+
7+
To read messages, please follow these steps:
8+
9+
1. Register the `sms:received` webhook as described in the [Webhooks](../features/webhooks.md) guide if you haven't done so already.
10+
2. Determine the Device ID of the device you want to read messages from by calling the `GET /devices` endpoint:
11+
```
12+
curl -u <username>:<password> https://api.sms-gate.app/3rdparty/v1/devices
13+
```
14+
3. Send a request with `deviceId` and period to the `POST /messages/inbox/export` endpoint:
15+
```
16+
curl -u <username>:<password> \
17+
-H "Content-Type: application/json" \
18+
-d '{ "deviceId": "<device-id>", "since": "2024-01-01T00:00:00Z", "until": "2024-12-31T23:59:59Z" }' \
19+
https://api.sms-gate.app/3rdparty/v1/messages/inbox/export
20+
```
21+
4. After receiving the request, the device will send `sms:received` webhooks for each message in the inbox for the specified period.
22+
23+
## Notes
24+
25+
* The webhook will be sent for each message independently, so the order of messages is not guaranteed.
26+
* It is recommended to split long periods into shorter ones to avoid excessive load on your webhook receiver.
27+
* The export webhooks retry policy is the same as described in the [Webhooks](../features/webhooks.md) guide.
28+
* The ID for incoming messages is generated based on the content of the message and is not guaranteed to be unique.

docs/features/webhooks.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Webhooks offer a powerful mechanism to receive real-time notifications of events
77
Currently, the following event is supported:
88

99
- `sms:received` - Triggered when an SMS is received by the device. The payload for this event includes:
10+
* `messageId`: The ID of the SMS message. The ID is generated based on the content of the message and is not guaranteed to be unique.
1011
* `message`: The content of the SMS message.
1112
* `phoneNumber`: The phone number that sent the SMS.
1213
* `simNumber`: The SIM card number that received the SMS. May be `null` on some Android devices.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ nav:
4545
- Features:
4646
- Multi-SIM Support: features/multi-sim.md
4747
- Webhooks: features/webhooks.md
48+
- Reading Messages: features/reading-messages.md
4849
- Logging: features/logging.md
4950
- Pricing: pricing.md
5051
- Privacy:

0 commit comments

Comments
 (0)