API Documentation
Documentation for Sending OTP and Marketing Messages via iMessage Using GloID API
1. API Overview
The API allows you to send different types of messages on iMessage using pre-configured templates.
2. Endpoint URL
POST https://app.gloid.io/msg2/send
3. Requirements
- Content-Type: application/json
- Authorization: Bearer <token> (replace <token> with your API key)
4. Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
phone | string | Yes | Recipient's phone number in international format (e.g., +19870123456) |
type | string | Yes | Message type: "a" - authorization "i" – informational "m" – marketing text "mp" – marketing with media content |
code, url (any parameter) | string | No | Code, url to be inserted into the message template |
tid | string | Yes | Routing template ID for message delivery |
5. Usage Examples
Request:
curl -L 'https://app.gloid.io/msg2/send' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <token>' \ -d '{ "phone": "+19870123456", "type": "m", "code": "1234", "tid": "123456789" }'
Response:
{ "id": "18f5dec5-0aff-424b-88ee-abe1f719cfb9" "status": "error" | "pending" | "success" }
6. Message Template Examples
Template 1:
Message template:
GloID authorization code: <code>
Input parameters:
- code: "5615"
Final message:
GloID authorization code: 5615
Template 2:
Message template:
Here is the discounted insurance you asked us about. Check it out: url.com<url>. Reply STOP to opt out.
Input parameters:
- url: "/a/67615"
Final message:
Here is the discounted insurance you asked us about. Check it out: url.com/a/67615. Reply STOP to opt out.
7. Response Status Descriptions
Status | Description |
---|---|
error | The message failed to send (e.g., issues with the device, request, or iMessage permissions) |
pending | The message has been accepted for sending (the case of sending a message without checking the status in the same request) |
success | The message has been successfully delivered to the recipient |
8. Notes
- The field `tid` determines the routing template for SMS messages, which can include logic such as country codes, time of day, default routes, and fallback routes
- Ensure the recipient's device supports iMessage and the service is activated for successful delivery
9. Errors and Diagnostics
Common causes of the "error" status:
- Incorrect phone number format
- The recipient's device does not support iMessage (e.g., Android)
- iMessage is disabled on the recipient's device
- Authorization errors (invalid Bearer token)
10. Callback
It is possible to configure webhook notifications about the status of message delivery.
Example string URL to pass the result:
https://your_url/smsState?sms-id=<SMSID>&state=<state>
where status=1 – delivered, status=7 – not delivered (final status)
11. Code Examples
fetch("https://app.gloid.io/msg2/send", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer <token>" }, body: JSON.stringify({ phone: "+15552028765", type: "a", code: "1234", tid: "123456789" }) }) .then(response => response.text()) .then(console.log) .catch(console.error);