HTTP API User's Guide
Overview
This section provides the HTTP API description for integration of external systems with ALTMEDIA SMS platform.
HTTP API enables SMS submission and SMS delivery status requests.
Authentication information (login/password) for connecting to ALTMEDIA SMS platform must be requested from the owner of ALTMEDIA SMS platform for each new interconnection. Credentials must be sent with each API request otherwise the user will be rejected as non-authorized.
Requests can be sent either with the GET or POST method to URL provided by the System owner in the format:
http(s)://<IP_address>:<port>/api? (e.g. https://1.1.1.1:8443/api? or http://1.1.1.1:443/api?)
SMS submission
Request format:
https://smsc.altmedia.ro:18002/api?username=<username>&password=<password>&ani=<ani>&dnis=<dnis>&message=<message>&command=submit&serviceType=<serviceType>&longMessageMode=<longMessageMode>
NOTE: To send multiple SMS messages, add several comma-separated DNIS to the <dnis> field.
Parameter |
Value |
Required |
Notes |
---|---|---|---|
username: |
Login |
Yes |
used when command = “submit”, “query” or “mo” |
password: |
Password |
Yes |
used when command = “submit”, “query” or “mo” |
ani: |
Caller ID. Technical limitation – alpha-numeric up to 32 symbols. Additional limitations can be caused by destination route peculiarities |
Yes |
used when command = “submit” or “mo” |
dnis: |
Destination number. Must be sent in international E.164 format (up to 15 digits allowed) |
Yes |
used when command = “submit” or “mo” |
message: |
Message text. |
Yes |
used when command = “submit” or “mo” |
messageId: |
Message ID |
No |
used when command = “query” |
command: |
Request type. Possible values: “submit”, “query”, “mo” |
Yes |
|
serviceType: |
Service type, provided by the system owner for the registered interconnection. Can be blank. |
No |
used when command = “submit” or “mo” |
longMessageMode: |
Type of long message processing. The following values allowed: cut (trim message text to 140 bytes) – shortens the message leaving only first 140 bytes to be sent. split and split_sar – split the message according to the logics described below. The difference between them is in the header to be used, for split it is UDH header, for split_sar it is sar accordingly. single_id_split – split the message but return the message ID common for all segments payload – message_payload field is used for sending the message text The splitting (options 2/3) depends on the coding: – dataCoding = 0, 1 or 3: one message can contain up to 160 bytes, if more – segment count = message length / 153 – dataCoding 2, 4 – 8: one message can contain up to 140 bytes, if more – segment count = message length / 134 bytes |
No |
used when command = “submit” or “mo” the default value is “сut” |
incMsgId (inc_msg_id) |
The client message ID (64 symbols maximum) that can be used for incoming HTTP requests with longMessageMode=cut or no longMessageMode (which equals to longMessageMode=cut). When the SMS switch receives this parameter it will use its value as a client ID. This will allow clients to use their ID to request information on the message if, for example, no routes are available. |
No |
used when longMessageMode=cut or no longMessageMode is indicated (which equals to longMessageMode=cut) |
srcTon, srcNpi, dstTon, dstNpi |
the respective parameters for Sender ID and Destination number. Format: integer. Optional |
No |
used when command = “submit” |
dataCoding |
data coding scheme for sending the SMPP to the client. Format: integer. Optional. Allowed values are: 0, 1, 3, 6, 7, 8, 10, 14, where: 0: SMSC Default Alphabet (SMPP 3.4)/MC Specific (SMPP 5.0) 1: IA5 (CCITT T.50)/ASCII (ANSI X3.4) 3: Latin 1 (ISO-8859-1) 6: Cyrillic (ISO-8859-5) 7: Latin/Hebrew (ISO-8859-8) 8: UCS2 (ISO/IEC-10646) 10: ISO-2022-JP (Music Codes) 14: KS C 5601 |
No |
used when command = “submit” |
esmClass |
corresponds to the same name parameter in SMPP. Format: integer. Optional. Allowed values are: 0-255 |
No |
used when command = “submit” |
priorityFlag |
corresponds to the same name parameter in SMPP. Format: integer. Optional. Allowed values are: 0 and 1 |
No |
used when command = “submit” |
registeredDelivery |
corresponds to the same name parameter in SMPP. Format: integer. Optional. Allowed values are: 0 and 1 |
No |
used when command = “submit” |
replaceIfPresentFlag |
corresponds to the same name parameter in SMPP. Format: integer. Optional. Allowed values are: 0 and 1 |
No |
used when command = “submit” |
silent |
Flag that allows sending silent SMS (message that arrives with no sound and is not displayed on the screen) Allowed values are: 0 and 1, where 0 means NOT silent. Any value other than 1 is treated as true, for example, silent=false is interpreted as silent=1. |
No |
Whether the silent SMS arrives as a silent one to the end user depends on the vendor and the other carriers that handle it |
Response format
In case of successful processing, the status in the header of the HTTP response is 200 OK. Response body contains the message_id.
Sample of a response in JSON format:
HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8
{“message_id”:”alss-a1b2c3d4-e5f67890″} |
In case
1) the request contains more than one DNIS (comma-separated)
2) the longMessageMode=split/split_sar and the message is longer than 160/70 byte (GSM/Unicode respectively),
the response will look as follows:
HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8
[{“dnis”:”791003044222″,”message_id”:”5b4c46a8-8dc9-44b4-f55f-3bef56819305″, “segment_num”:”1″},{“dnis”:”791003044222″, “message_id”:”5b4c46a8-46bc-7ee6-4a16-7d4e5a0d14af”,”segment_num”:”2″}] |
In case of rejected SMS (for example, no compatible routes found), the HTTP response status is – 400 Bad Request. The response body contains a string describing the reason for rejection, for example NO ROUTES.
HTTP/1.1 400 Bad Request Content-Type: text/html; charset=UTF-8
NO ROUTES |
In case an incorrect user name or password is provided, the HTTP status is 401 Unauthorized. The response body contains the string describing the reason for rejection.
HTTP/1.1 401 Unauthorized Content-Type: text/html; charset=UTF-8
not authorized (check login and password) |
SMS status request
Request format:
http://1.1.1.1:18001/api?username=<username>&password=<password>&messageId=<messageId>&command=query
https://1.1.1.1:18002/api?username=<username>&password=<password>&messageId=<messageId>&command=query
Parameters:
username: | Login |
---|---|
password: | Password |
messageId: | Message identifier received with the submission response |
command: | Request type. Must be set to “query” value |
All parameters are obligatory.
Response format:
In case of successful processing, the status in the header of the HTTP response is 200 OK. The response body contains the one of the following possible values:
ENROUTE: | Message is in routing stage. The status can be returned to the client if the message is in the SENT status |
DELIVRD: | Message is delivered to the Subscriber |
EXPIRED: | Message storage period expired |
DELETED: | Message was deleted |
UNDELIV: | Message cannot be delivered |
ACCEPTD: | Message is accepted by SMSC |
UNKNOWN: | Unknown message status. Information on statuses is stored in the in-memory database for 24 hours (by default). Therefore, this status may be returned if the client has requested a status quite late and it was already removed from the memory. |
REJECTD: | Message was rejected by SMSc |
Response sample:
HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8
{“status”: “DELIVRD”, “delivery_time”: “1807161404”, “mccmnc”: “250002”} |
where delivery_time is the done date received from the vendor (if not received the field will be empty), mccmnc is the E212 code
The status can be requested within 48 hours after the message submission.
In case the message with the requested message ID is not found the response HTTP status is 200 OK. The response body contains the error description in the “status” field:
HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8
{“status”: “UNKNOWN”, “delivery_time”: “”, “mccmnc”: “”} |
In case an incorrect user name or password is provided, the HTTP status is 401 Unauthorized. The response body contains the string describing the reason for rejection.
HTTP/1.1 401 Unauthorized Content-Type: text/html; charset=UTF-8
not authorized (check login and password) |
Allowed marker names for outgoing HTTP requests
This section contains allowed marker names for outgoing HTTP requests (sending of delivery report and MO SMS with the help of cURL in a generated script).
Deliver
Parameter | Description | Format | Allowed values |
---|---|---|---|
ani | Sender ID | string | |
app_msg_id | identifier of the submit that was sent to the client in the submit_sm_resp or HTTP response | string | |
clientChannelId | vendor channel ID that was used to receive the deliver_sm | integer | |
country_name | country name | string | if not defined, the marker is replaced by “Undefined” |
delivery_status | delivery status based on outgoing translations for the client side | string | |
delivery_time | time when the delivery report was generated by the switch | string | Date format: YYMMDDHHMMSS |
dlvrResultCodeDescr | response code description | string | |
dnis | DNIS | string | |
done_date | time value from the “done date:” field of the delivery report received from the vendor | string | Date format: YYMMDDHHMMSS. Depending on the date format in the source delivery report, the SS may be 00. Example: 2019-11-12Z08:06:18 |
done_date_t | the same as done_date marker but with replacing the Z delimiter by T | string | Example: 2019-11-12T08:06:18 |
im_channel | IM (instant messaging) channel name | string | Depend on the IM channels configured in the System. Examples: viber_promotion,whatsapp,sms |
message | delivery report text generated by the switch | string | |
message_id | message identifier, including the common ID of a concatenated message if the switch correctly detected concatenation and successfully put together all message segments | string | |
mcc | MCC | string | |
mccmnc | MCCMNC | string | |
mnc | MNC | string | |
mnc_no_zero | MNC without leading zeros | string | |
net_name | network name | string | if not defined, the marker is replaced by “Undefined” |
part_amount | number of message parts | string | number, from 1 and above |
rate | message cost in the client’s currency | string | number; up to 5 decimal places are allowed |
result_code | error code from the delivery report received from the vendor | string | The default value is “000” |
serviceType | for POIs with service type=’*’ it is replaced with the service type received from the client in the initial submit request | string |
|
system_delivery_time | the delivery report send time to the client | string | Date format: YYMMDDHHMMSS |
MO SMS
Parameter | Description | Format | Allowed values |
---|---|---|---|
clientChannelId | vendor channel ID that was used to receive the deliver_sm | integer | |
message_id | generated identifier associated with the message | string | |
delivery_status | delivery status | string value, always equal to “MO” | MO |
serviceType |
| string value, always equal to “MO” | MO |
localAddress | local address to which the deliver_sm is received | string | |
result_code |
| string value, always equal to “000” | 000 |
ani | Sender ID | string | |
dnis | DNIS | string | |
message | message text in UTF-8 | string | |
delivery_time | time when the message was generated by the switch | string | Date format: YYMMDDHHMMSS |
keyword | word templates used to remove words from the message text | string | |
messageWithoutKeyword | message text without the words that were removed based on the templates | string | |
mt_message_id | MT message ID to which the MO was sent. The MT ID is registered as the client ID for the MO. | string | |
udh | UDH in hexadecimal format | string | the allowed symbols are 0123456789ABCDEF. If the source message contains no UDH, the string is empty |
Parameters used for incoming delivery reports and MO SMS over HTTP
The System can accept Callback URLs (cURL) over HTTP to receive MO messages and delivery reports over HTTP. The table below contains a minimum set of parameters with which the System owner can provide its vendor so that the vendor can configure the callback URL and send delivery statuses and/or MO messages to the System owner.
A sample cURL for sending delivery reports:
A sample cURL for sending MO:
(the message field is obligatory for MO)
Parameters used for incoming delivery reports and MO SMS over HTTP
Parameter | Description | Format | Allowed values | Required |
---|---|---|---|---|
command | request type | string | mo deliver | Yes |
ani | from | string | Yes | |
dnis | DNIS (to) | string | Yes | |
message | text of delivery report | string | No for sending delivery reports and Yes for MO | |
dlvrMsgId | messageId, message_id – ID of the submit request related to the delivery report | string | Yes if command=deliver | |
dlvrMsgStat | status, messageStatus – SMS delivery status | string | Allowed values must either be equal to the standard set of statuses or the vendor status translation rules | Yes if command=deliver |
dlvrMsgErr | error code | string | No | |
username | authentication credentials used for vendor channel authentication | string | Quasi optional. If both parameters are missing from the request, the switch can use the parameter callbackAuthDatafrom its configuration file to substitute the default authentication data | |
password | ||||
srcTon | the respective parameters for Sender ID and Destination number | integer | No | |
srcNpi | ||||
dstTon | ||||
dstNpi | ||||
dataCoding | data coding scheme for sending the SMPP to the client | integer | 0, 1, 3, 6, 7, 8, 10, 14, where: 0: SMSC Default Alphabet (SMPP 3.4)/MC Specific (SMPP 5.0) 1: IA5 (CCITT T.50)/ASCII (ANSI X3.4) 3: Latin 1 (ISO-8859-1) 6: Cyrillic (ISO-8859-5) 7: Latin/Hebrew (ISO-8859-8) 8: UCS2 (ISO/IEC-10646) 10: ISO-2022-JP (Music Codes) 14: KS C 5601 | No |
NOTE: If the request contains an optional parameter and its value is not in the list of allowed values, the submit will be rejected with the appropriate status.
Submit placeholders
The following placeholders can be used in the URL template field for SMS submission.
Parameter | Value |
---|---|
username | Login |
password | Password |
ani | Sender ID |
dnis | Destination address |
text | Message text (URL-encoded) |
textUTF8 | Message text in UTF-8 (non URL-encoded) |
message | Message text (URL-encoded) |
message64 | Message text encoded in base64 |
onewayText | Hex-encoded text in UTF-16 for data coding 8, for other cases – UTF-8 non URL-encoded text |
hexText | Message text in hexadecimal format (applicable to UTF-8) |
hexUCS2 | Message text in hexadecimal format (applicable to UTF-16). For example, the symbol g is encoded as 0067 with the help of the marker |
hexUCS2U | The same as hexUCS2 but with \u prefix. For example, the g symbol is encoded as \u0067 with the help of this marker |
textUTF16BE | Message text in UTF-16 BE format |
serviceType | Service type, provided by the system owner for the registered interconnection. Can be blank. |
ownIntMessageId | Platform-generated message ID (decimal), the maximum length is 10 |
ownHexMessageId | Platform-generated message ID (hexadecimal), the maximum length is 10 |
srcTon, srcNpi, dstTon, dstNpi | TON and NPI for sender ID and destination address respectively. Format: integer. |
dataCoding | Data coding value – 0 or 8. Set as 0 if message can be encoded in GSM7bit, if not then set as 8. |
clientName | Client name (URL-encoded) from which submit_sm has been received (as configured in the Carriers page) |
validityPeriod | Validity period in yyyymmddhh24miss format (in UTC). If not set, the validityPeriod is set as current date + time of delivery reports storing (set in the system setting Delivery waiting period, sec) |
validityPeriodRelative | Validity period in relative format (in seconds) |
silent | Flag that allows sending silent SMS (message that arrives with no sound and is not displayed on the screen) |
localid | Message ID generated for client |
transactionid | Transaction ID |
submitsenttime | Message receive date |
mccmnc | Message MCCMNC |
protocolId | Protocol ID (taken from submit_sm respective field) |
hexUDH | UDH in hexadecimal, if message has no UDH, the marker value left blank |
isconcat | 0/1 flag, set to 1 if submit is a part of a long message |
sarId | UDH message ID in decimal format |
sarIdHex | UDH message ID in hexadecimal format |
sarPartNumber | Segment number |
sarParts | Total number of segments |
im-message | Message text (applicable when a message is sent through IM – instant messaging – provider) |
im_channels | List of IM channels to send a message (a message will be sent thorugh these channels in the specified order) |
im-ttl | TTL for sending of a message through IM channel(s) |
ttl_expiry_text | Message text after expiration of validity period |
image_url | Link to the button image for buttons sent in the message through IM channel(s) |
button_action_url | Link to the website where the user will be redirected after clicking the button (when a message is sent through IM channel(s) |
button_caption | Button caption (when a message is sent through IM channels) |
message_purpose | Applicable when a message is sent through Viber IM channels. Possible values are promotion and transaction |
deliver_only_via_im | Specifies if only IM channels can be used for message sending, proxied from a client submit |
NOTE: It is possible to add _noencode and _plencode suffixes (for example, $textUTF8_noencode$) to placeholders in the URL template and _plencode in the POST template of SMS channels. The noencode suffix serves to disable URL encoding; the plencode suffix replaces spaces with ‘+’ while the text is URL encoded (for example, ‘Two Factor Auth verification code is: 123456’ will be URL encoded as ‘Two+Factor+Auth+verification+code+is%3a+123456’ if the placeholder $text_plencode$ is used). All text markers except textUTF8 can be set with the _noencode and _plencode suffixes in the URL Template field.
Query placeholders
The following placeholders can be used in the Status template field for DLR request.
Parameter | Value |
---|---|
username | Login |
password | Password |
ani | Sender ID |
dnis | Destination address |
text | Message text |
messageId | Message ID |
ownIntMessageId | Altmedia message ID in integer (decimal), the maximum lenght is 10 |
ownHexMessageId | Altmedia message ID in hexadecimal, the maximum lenght is 10 |
serviceType | Service type, provided by the system owner for the registered interconnection. Can be blank. |
srcTon, srcNpi, dstTon, dstNpi | The respective parameters for Sender ID and Destination number. Format: integer. |
querySmId | The value of a specific key that is different from messageID and that was also received in the response to a message send request |