SMS API Documentation
All requests require an API key for authorization. The API key must be included in the x-api-key
header for each request.
1. Send SMS
POST /sms
Sends an SMS message. The message can be directly specified or templated.
Headers
x-api-key
(required): API key for authorization.
Request Body
Field | Type | Required | Description | Default |
---|---|---|---|---|
messageType | string | No | Type of message, should be "sms" . | "sms" |
to | string | Yes | Recipient phone number in E.164 format. Example: +1234567890 . | - |
from | string | Yes | Sender ID (shortcode or long code). | - |
message | string | Conditionally required | Text message body, up to 160 characters. | - |
templateId | string | Conditionally required | Template ID for the message content. | - |
variables | object | No | Key-value pairs for templating variables. | - |
notBefore | string | No | UTC date-time to schedule the message. | - |
notAfter | string | No | UTC date-time for message expiration. | - |
callbackUrl | string | No | Callback URL for message delivery notifications. | - |
clientId | string | No | Client identifier, max length 100 characters. | "" |
Sample Request (Non Templated)
{
"to": "+1234567890",
"from": "XXXXXXXXXX",
"message": "Hello, this is a test SMS message."
}
Sample Request (Templated)
{
"to" : "1234567890",
"from" : "XXXXXXXXXX",
"templateId" : "gPVTbWpwQHXgg8KSZ6sX",
"clientId" : "23948729438slkdfjwkfjhsdfsdf",
"variables" : {
"name" : "Jane Doe",
"etor" : "10:49pm"
}
}
Sample Response
200 OK
{
"message": "SMS received successfully",
"trackingId": "1234567890abcdef"
}
Response Fields
Field | Type | Description |
---|---|---|
message |
string | A confirmation message indicating the SMS has been successfully received by the API. |
trackingId |
string | A unique identifier for tracking the SMS. This ID can be used in subsequent API calls to retrieve the SMS status and any associated events. |
Rate Limiting
To ensure fair usage of resources, the Send SMS API endpoint is rate-limited based on each client’s API key. If the rate limit is exceeded, subsequent requests will be temporarily blocked until the rate limit resets.
Current Rate Limit
The current rate limit may vary based on your subscription plan and usage agreement. Please refer to the API’s response headers to monitor your rate limit status, or contact us for your specific rate limit settings.
Rate Limit Headers
On each response, the following headers provide rate limit details:
Header | Description |
---|---|
X-RateLimit-Limit |
The maximum number of requests allowed per minute for the API key. |
X-RateLimit-Remaining |
The number of requests remaining in the current time window. |
X-RateLimit-Reset |
The time (in seconds) until the rate limit resets and the full quota is available again. |
Exceeded Rate Limit Response
If the rate limit is exceeded, the following response will be returned:
{
"error": "Rate limit exceeded"
}
Increasing Rate Limit
If your application requires a higher rate limit, please reach out to the eMsgNow support team to discuss rate limit adjustments that suit your requirements. We are happy to accommodate higher traffic where possible. Contact us via email at support@emsgnow.com or through your eMsgNow representative.
2. Get SMS Details
GET /sms/:messageId
Retrieves the full details of an SMS message, including events related to the SMS.
Headers
x-api-key
(required): API key for authorization.
Sample Request
GET /sms/1234567890abcdef
Sample Response
{
"to": "1234567890",
"from": "XXXXXXXXXX",
"message": "Utility Alert: We think your power is out",
"clientId": "23948729438slkdfjwkfjhsdfsdf",
"messageType": "sms",
"trackingId": "1234567890abcdef",
"notBefore": "2024-11-10T02:48:08.004Z",
"notAfter": "2024-11-10T08:48:08.004Z",
"created": "2024-11-10T18:18:31.050Z",
"updated": "2024-11-10T18:18:31.050Z",
"events": [
{
"id": "5mogLKKETFjg7c3eNNvH",
"message": {
"channel": "sms",
"trackingId": ""1234567890abcdef",
"clientId": "23948729438slkdfjwkfjhsdfsdf",
"status": "processing",
"statusAt": "2024-11-10T02:48:08.019Z",
"additionalInfo": {}
},
"timestamp": "2024-11-10T18:18:31.050Z"
},
{
"id": "C98OWsv63rVLJoE5QAns",
"message": {
"channel": "sms",
"trackingId": ""1234567890abcdef",
"clientId": "23948729438slkdfjwkfjhsdfsdf",
"status": "sent to provider",
"statusAt": "2024-11-10T02:48:08.019Z",
"additionalInfo": {}
},
"timestamp": "2024-11-10T18:18:31.050Z"
},
{
"id": "thwRO3qA1lJnsMv7zfbr",
"message": {
"channel": "sms",
"trackingId": ""1234567890abcdef",
"clientId": "23948729438slkdfjwkfjhsdfsdf",
"status": "delivered",
"statusAt": "2024-11-10T02:48:08.019Z",
"additionalInfo": {}
},
"timestamp": "2024-11-10T18:18:31.050Z"
}
]
}
Response Fields
Field | Type | Description |
---|---|---|
to |
string | Recipient's phone number. |
from |
string | Sender ID (shortcode or long code). |
message |
string | The body of the SMS message. |
clientId |
string | Client identifier for the SMS message. |
messageType |
string | Type of message, typically sms . |
trackingId |
string | Unique identifier for tracking the SMS. |
notBefore |
string (UTC Date-Time) | Date-time after which the SMS is eligible to be sent. |
notAfter |
string (UTC Date-Time) | Date-time after which the SMS should not be sent. |
created |
string (UTC Date-Time) | Timestamp when the SMS was created. |
updated |
string (UTC Date-Time) | Timestamp when the SMS was last updated. |
Events Array
Each SMS can have multiple associated events with their own details.
Field | Type | Description |
---|---|---|
id |
string | Unique identifier for the event. |
message.channel |
string | Channel used for the message, typically sms . |
message.trackingId |
string | Tracking ID of the original SMS message. |
message.clientId |
string | Client identifier for the SMS. |
message.status |
string | Status of the SMS at the time of the event (e.g., processing , sent to provider , delivered ). |
message.statusAt |
string (UTC Date-Time) | Timestamp indicating when the status was recorded. |
message.additionalInfo |
object | Additional information related to the event, if available. |
timestamp |
string (UTC Date-Time) | Timestamp of when the event was created. |
3. Get SMS Events
GET /sms/:messageId/events
Retrieves a list of events associated with a specific SMS message.
Headers
x-api-key
(required): API key for authorization.
Sample Request
GET /sms/1234567890abcdef/events
Sample Response
{
"messageId": "1234567890abcdef",
"events": [
{
"id": "5mogLKKETFjg7c3eNNvH",
"message": {
"channel": "sms",
"trackingId": ""1234567890abcdef",
"clientId": "23948729438slkdfjwkfjhsdfsdf",
"status": "processing",
"statusAt": "2024-11-10T02:48:08.019Z",
"additionalInfo": {}
},
"timestamp": "2024-11-10T18:18:31.050Z"
},
{
"id": "C98OWsv63rVLJoE5QAns",
"message": {
"channel": "sms",
"trackingId": ""1234567890abcdef",
"clientId": "23948729438slkdfjwkfjhsdfsdf",
"status": "sent to provider",
"statusAt": "2024-11-10T02:48:08.019Z",
"additionalInfo": {}
},
"timestamp": "2024-11-10T18:18:31.050Z"
},
{
"id": "thwRO3qA1lJnsMv7zfbr",
"message": {
"channel": "sms",
"trackingId": ""1234567890abcdef",
"clientId": "23948729438slkdfjwkfjhsdfsdf",
"status": "delivered",
"statusAt": "2024-11-10T02:48:08.019Z",
"additionalInfo": {}
},
"timestamp": "2024-11-10T18:18:31.050Z"
}
]
}
Response Fields
Field | Type | Description |
---|---|---|
messageId |
string | Unique identifier for the SMS message being tracked. |
Events Array
Each event object within the events
array provides details about the status of the SMS message at different stages.
Field | Type | Description |
---|---|---|
id |
string | Unique identifier for the event. |
message.channel |
string | Channel used for the message, typically sms . |
message.trackingId |
string | Tracking ID of the original SMS message. |
message.clientId |
string | Client identifier associated with the SMS. |
message.status |
string | Status of the SMS at the time of the event (e.g., processing , sent to provider , delivered ). |
message.statusAt |
string (UTC Date-Time) | Date-time when the status was recorded. |
message.additionalInfo |
object | Additional information related to the event, if available. |
timestamp |
string (UTC Date-Time) | Date-time when the event was created. |
4. Get Single SMS Event
GET /sms/:messageId/events/:eventId
Retrieves a specific event associated with an SMS message.
Headers
x-api-key
(required): API key for authorization.
Sample Request
GET /sms/1234567890abcdef/events/5mogLKKETFjg7c3eNNvH
Sample Response
{
"messageId": "1234567890abcdef",
"id": "5mogLKKETFjg7c3eNNvH",
"message": {
"channel": "sms",
"trackingId": "1234567890abcdef",
"clientId": "1",
"status": "processing",
"statusAt": "2024-11-10T02:48:08.019Z",
"additionalInfo": {}
},
"timestamp": "2024-11-10T18:18:31.050Z"
}
Get Single SMS Event Response Data
Field | Type | Description |
---|---|---|
messageId |
string | Unique identifier for the SMS message associated with this event. |
id |
string | Unique identifier for this specific event. |
timestamp |
string (UTC Date-Time) | Date-time when this event was created. |
Message Object
The message
object within the event provides additional details about the SMS status at the time of the event.
Field | Type | Description |
---|---|---|
channel |
string | Channel used for the message, typically sms . |
trackingId |
string | Tracking ID of the original SMS message. |
clientId |
string | Client identifier associated with the SMS. |
status |
string | Status of the SMS at the time of the event (e.g., processing , sent to provider , delivered ). |
statusAt |
string (UTC Date-Time) | Date-time when the status was recorded. |
additionalInfo |
object | Additional information related to the event, if available. |
Error Responses
401 Unauthorized
{
"error": "API key is required"
}
403 Forbidden
{
"error": "Invalid API key"
}
500 Internal Server Error
{
"error": "Failed to retrieve SMS status"
}
429 Too Many Requests
{
"error": "Rate limit exceeded"
}