SMS callbacks
Receive MO SMS via API callback.
The system can dispatch mobile originated (MO) SMS from endpoints as HTTP POST requests toward a user-configurable URL.
The URL of the receiving server needs to be specified in a service profile that the endpoint has assigned.
The emnify system then sends the MO SMS as a JSON payload if the destination address of the SMS is an invalid MSISDN (that is, 7 digits or less).
Example service profile with an API callback URL and API secret:
The application server receiving the API callback needs to respond with HTTP Code 2XX to accept the request.
API callback secret
If an API secret is provided in the service profile, callbacks using this URL contain an Authorization header with a JSON Web Token (JWT) included.
The api_secret is used as the signing key of the JWT in this header.
API callback auth header:
By verifying the signing key of the JWT, your server can ensure the request is coming from emnify.
If no api_secret exists in the service profile, the request won’t contain an Authorization header.
Example request body sent to API callback URL:
Delivery receipts
The callback URL may also be used to receive SMS delivery receipts in the form of a PATCH request.
When the SMS interface for an endpoint is set to use the REST API in the corresponding service profile, mobile terminated (MT) messages triggered via API generate payloads toward the callback URL with a payload in the following format:
A2P and P2P routing
The emnify system distinguishes application-to-peer (A2P) SMS from peer-to-peer (P2P) SMS based on the length of the source (MO SMS) or the destination (MT SMS) address.
- If there are 7 digits or less (that is, an invalid MSISDN), an SMS is considered A2P.
- If there are 8 digits or more, an SMS is processed as MSISDN and considered P2P.
To dispatch SMS MO to your application (A2P) and at the same time have P2P SMS enabled, the destination number (dest_address) must be limited to 7 digits or less.