API Examples HTTP POST

1. MOBILE TERMINATED MESSAGES

The section below contains an example of how the POST-request might look. Json text is always encoded using utf-8.

curl -i -X POST 'https://post.spiricom.spirius.com:55001/cgi-bin/sendsms' 
-H 'Content-Type: application/json' 
-d '{"User": "Username", "Pass": "Password", "To": "+46123456789", "From": "+46123456789", "Msg": "Hello world"}'

If everything is correct a 202-response will be returned:

HTTP/1.1 202 Accepted
Server: SPIRIcom/1.0
Date: Wed, 03 Oct 2018 12:01:24 GMT
Content-Length: 59
Content-type: text/html
Pragma: no-cache
Cache-Control: no-cache

Accepted for delivery, 28fc2e4a-abc2-4942-9eec-a61f9dcfb54d

2. MOBILE ORIGINATED MESSAGES

2.1 Push

The message below is an example of a POST-request sent from SMS Gateway, containing a MO-message. Note that the path can specified by the client.

POST /sms HTTP/1.1
Connection: keep-alive
User-Agent: SPIRIcom/1.0
Content-Type: application/json
Date: 2011-05-03 14:20:01
Content-Length: 148

{From": "+46712345678", "FromType": "I", "To": "+46712345678", "ToType": "I", "Msg": "Hello world", "MsgType": 0, "Timestamp": "2011-05-03 14:20:01"}

2.2 Pull

Example of getnextmessage request:

curl -i -X POST 'https://post2.spiricom.spirius.com:55001/cgi-bin/getnextmessage' -H 'Content-Type: application/json' -d '{"User": "Username", "Pass": "Password"}'

Example of getnextmessage response:

HTTP/1.1 200 OK
Server: SPIRIcom/1.0
Date: Wed, 03 Oct 2018 13:03:57 GMT
Content-Length: 164
Content-type: text/html
Pragma: no-cache
Cache-Control: no-cache

{"Result": 1, "From": "+46123456789", "FromType": "I", "To": "+46731297001", "ToType": "I", "Msg": "Hello world ", "MsgType": 0, "Timestamp": "2018-10-03 12:55:43"}

Example of getmessagelist request:

curl -i -X POST 'https://post2.spiricom.spirius.com:55001/cgi-bin/getmessagelist' -H 'Content-Type: application/json' -d '{"User": "Username", "Pass": "Password"}'

Example of getmessagelist response:

HTTP/1.1 200 OK
Server: SPIRIcom/1.0
Date: Wed, 03 Oct 2018 13:05:39 GMT
Content-Length: 145
Content-type: text/html
Pragma: no-cache
Cache-Control: no-cache

{"Result": 1, 
  "Messages": [
    {"TransactionId": "61a7d183-9df7-4248-a2d6-a9bd2717ad08"}, 
    {"TransactionId": "20c2bf35-7045-4ff9-a250-d83509963c59"}
  ]
}

Example of getmessageforid request:

curl -i -X POST 'https://post2.spiricom.spirius.com:55001/cgi-bin/getmessageforid' 
-H 'Content-Type: application/json' 
-d '{"User": "Username", "Pass": "Password", "TransactionId":"61a7d183-9df7-4248-a2d6-a9bd2717ad08"}'

Example of getmessageforid response:

HTTP/1.1 200 OK
Server: SPIRIcom/1.0
Date: Wed, 03 Oct 2018 13:08:18 GMT
Content-Length: 164
Content-type: text/html
Pragma: no-cache
Cache-Control: no-cache

{"Result": 1, "From": "+46123456789", "FromType": "I", "To": "+46731297001", "ToType": "I", "Msg": "Hello world ", "MsgType": 0, "Timestamp": "2018-10-03 13:00:41"}

3. DELIVERY REPORTS

3.1 Push

The message below is an example of a POST-request sent from SMS Gateway, containing the report for transaction id eda0ae82-98d7-40b3-bbaa-205b68b63c0b, which was delivered successfully.

POST /dlr HTTP/1.1
Connection: keep-alive
User-Agent: SPIRIcom/1.0
Content-Type: application/json
Date: 2011-05-03 14:32:07
Content-Length: 87

{"TransactionId": "eda0ae82-98d7-40b3-bbaa-205b68b63c0b", "Result": 1, "StatusCode": 1, "Timestamp": "2011-05-03 14:32:07"}

The message below is an example of a valid response to a delivery report. Delivery reports will be resent until acknowledged with HTTP status code 200 OK.

HTTP/1.1 200 OK
Connection: close

3.2 Pull

The message below is an example of a POST-request sent to SMS Gateway, to request the status of transaction id 0fa6c237-b2f1-48ca-a8d5-e2c020ff35cb.

curl -i -X POST 'https://post.spiricom.spirius.com:55001/cgi-bin/getmessagestatus' 
-H 'Content-Type: application/json' 
-d '{"User": "Username", "Pass": "Password", "TransactionId":"0fa6c237-b2f1-48ca-a8d5-e2c020ff35cb"}'

The message below is an example of a valid response to a delivery report pull request.

HTTP/1.1 200 OK
Server: SPIRIcom/1.0
Date: Wed, 03 Oct 2018 13:14:42 GMT
Content-Length: 30
Content-type: text/html
Pragma: no-cache
Cache-Control: no-cache

{"Result": 1, "StatusCode": 1}