Usage examples: cURL
Here are some example API calls using cURL. These examples use the current API version (0.15), but legacy versions are similar enough that there should only be minor differences for supported commands.
cURL --data* parameters automatically set the Content-Type header to the required application/x-www-form-urlencoded so that is omitted from the examples. It could be set with the -H parameter, if necessary.
Sends a single SMS message per API call.
Sends multiple SMS messages in a single API call/
Creates a new empty SMS batch.
Adds recipient numbers to an existing batch.
Retrieves a list of assigned sender IDs.
Retrieves delivery reports for specified message IDs.
Retrieves full report about specified messageIDs.
cURL --data* parameters automatically set the Content-Type header to the required application/x-www-form-urlencoded so that is omitted from the examples. It could be set with the -H parameter, if necessary.
SendOne
Sends a single SMS message per API call.
Request:
curl -X POST https://traffic.sales.lv/API:0.15/ \
--data-urlencode "APIKey=YOURAPIKEY" \
--data-urlencode "Command=SendOne" \
--data-urlencode "Number=37199999999" \
--data-urlencode "Sender=YOURNAME" \
--data-urlencode "Content=Hello there"
Successful response:
{
"MSSID":"123456789012",
"CC":"371",
"Phone":"99999999",
"Length":"1",
"Unicode":"0",
"LongSMS":"0",
"Invalid":false,
"Network":"LMTLV",
"Validity":1440
}
Unsuccessful response:
{
"Error":"InvalidNumber"
}
SendMultiple
Sends multiple SMS messages in a single API call/
Request:
curl -X POST https://traffic.sales.lv/API:0.15/ \
--data-urlencode "APIKey=YOURAPIKEY" \
--data-urlencode "Command=SendMultiple" \
--data-urlencode "Sender=YOURNAME" \
--data-urlencode "Content=[[\"+37112341234\"\,"Lorem ipsum dolor sit amet\"],[\"+37198769876","consectetur adipscing elit.\"]]\"
Successful response:
{
"37112341234": {
"MSSID":"123456789012",
"CC":"371",
"Phone":"99999999",
"Content":"Lorem ipsum dolor sit amet",
"Length":"1",
"Unicode":"0",
"LongSMS":"0",
"Invalid":false,
"Network":"LMTLV",
"Validity":1440
},
"37198769876": {
"MSSID":"123456789019",
"CC":"371",
"Phone":"98769876",
"Content":"consectetur adipscing elit.",
"Length":"1",
"Unicode":"0",
"LongSMS":"0",
"Invalid":false,
"Network":"TELE2LV",
"Validity":1440
},
}
SendBatch
Creates a new empty SMS batch.
Request:
curl -X POST https://traffic.sales.lv/API:0.15/ \
--data-urlencode "APIKey=YOURAPIKEY" \
--data-urlencode "Command=SendBatch" \
--data-urlencode "Sender=YOURNAME" \
--data-urlencode "Content=Hello world"
Successful response:
{
"BatchID":999888777
}
AddBatchRecipients
Adds recipient numbers to an existing batch.
Request:
curl -X POST https://traffic.sales.lv/API:0.15/ \
--data-urlencode "APIKey=YOURAPIKEY" \
--data-urlencode "Command=AddBatchRecipients" \
--data-urlencode "BatchID=999888777" \
--data-urlencode "Recipients=[3712987654321, 37129999999]"
Successful response:
{
"3712987654321": {
"MSSID":"123456789012"
},
"37129999999": {
"MSSID":"123456789019"
},
}
GetSenders
Retrieves a list of assigned sender IDs.
Request:
curl -X POST https://traffic.sales.lv/API:0.15/ \
--data-urlencode "APIKey=YOURAPIKEY" \
--data-urlencode "Command=GetSenders"
Successful response:
{
"Senders":["YourBrand1","YourBrand2"]
}
GetDelivery
Retrieves delivery reports for specified message IDs.
Request:
curl -X POST https://traffic.sales.lv/API:0.15/ \
--data-urlencode "APIKey=YOURAPIKEY" \
--data-urlencode "Command=GetDelivery" \
--data-urlencode "MSSID=[999888777666,111222333444]"
Successful response:
{
"999888777666": "Delivered",
"111222333444": "Undelivered"
}
Unsuccessful response:
{
"Error":"InvalidMSSID"
}
GetReport
Retrieves full report about specified messageIDs.
Request:
curl -X POST https://traffic.sales.lv/API:0.15/ \
--data-urlencode "APIKey=YOURAPIKEY" \
--data-urlencode "Command=GetReport" \
--data-urlencode "MSSID=[999888777666,111222333444]"
Successful response:
{
"999888777666": {
"MSSID":"999888777666",
"CC":"371",
"Phone":"99999999",
"Content":"Lorem ipsum dolor sit amet",
"Unicode":"0",
"LongSMS":"0",
"Length":"1",
"Status":"Delivered",
"SendTime":"2021-12-01 09:42:00",
"DLRTime":"2021-12-01 09.42.02",
"Validity":1440
},
"111222333444": {
"MSSID":"111222333444",
"CC":"371",
"Phone":"11111111",
"Content":"Lorem ipsum dolor sit amet",
"Unicode":"0",
"LongSMS":"0",
"Length":"1",
"Status":"Undelivered",
"SendTime":"2021-12-03 14:44:30",
"DLRTime":"2021-12-04 14:45:12",
"Validity":1440
}
}
Unsuccessful response:
{
"Error":"InvalidMSSID"
}
Updated on: 11/01/2023
Thank you!