Introduction
LabsMobile JSON API
v2.5.2 (last modification 2021-02-16, Changelog)
Download PDF file (830KB)
Postman collection (41KB)
This API is designed for technicians and clients that wish to connect their applications to LabsMobile's SMS messaging platform. The purpose of integrating these applications is to send SMS (MT or Push SMS) messages and related communications (ACKs and balance requests).
We recommend to use our JSON SMS API for any integration with LabsMobile platform. But we have other API versions you can use depending on your technical requirements or integration purposes. These are our other API versions:
- SMS API HTTP/GET, for easy and fast integration by passing the parameters in the url.
- SMS API HTTP/POST XML, with all the functionalities but sending the parameters in an http/POST variable with XML format.
- SMS API WebService, to connect via WebService with our platform.
- SMS API SMTP - Mail, to transform emails into SMS messages.
- Admin API, to manage subaccounts automatically.
- OTP API, to send One Time Passwords in the safest way with our API.
Requirements
For the integration with the JSON API the following information provided by LabsMobile is essential:
API Endpoints:
https://api.labsmobile.com/json/send
https://api.labsmobile.com/json/balance
https://api.labsmobile.com/json/ack
https://api.labsmobile.com/json/prices
https://api.labsmobile.com/json/scheduled
https://api.labsmobile.com/hlr
- A LabsMobile account associated with an username (sign up email).
- Your account password or an API token.
- API Endpoint and request parameters.
Optionally you can configure your account with:
- IP Address where the messages will be sent. For security purposes the messaging platform will only admit messages from this/ these IP/s. This functionality is optional, this option is not activated by default and messages from any IP address will be accepted.
- Sender by default (default TPOA, by default is LABSMOBILE unless otherwise indicated).
- Messages daily limit, by default up to 50,000 sms/per day.
- Messages limit by batch, by default up to 10,000 sms/sending.
Authentication
Make sure to replace
myusername:mypassword
with your account username and API token.
curl --user myusername:mypassword -X POST \
https://api.labsmobile.com/json/send \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '...'
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.labsmobile.com/json/send");
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
curl_easy_setopt(hnd, CURLOPT_USERNAME, "myusername");
curl_easy_setopt(hnd, CURLOPT_PASSWORD, "mypassword");
var client = new RestClient("https://api.labsmobile.com/json/send");
client.Authenticator = new HttpBasicAuthenticator("myusername", "mypassword");
req, _ := http.NewRequest("POST", "https://api.labsmobile.com/json/send", "...")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic " + basicAuth("myusername","mypassword"))
req.Header.Add("Cache-Control", "no-cache")
HttpResponse<String> response = Unirest.post("https://api.labsmobile.com/json/send")
.basicAuth("myusername","mypassword")
.header("Content-Type", "application/json")
.header("Cache-Control", "no-cache")
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.labsmobile.com/json/send",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache",
},
"processData": false,
"data": "..."
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.open("POST", "https://api.labsmobile.com/json/send");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Basic " + btoa("myusername:mypassword"));
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.send(data);
var request = require("request");
var btoa = require("btoa");
var options = { method: 'POST',
url: 'https://api.labsmobile.com/json/send',
headers:
{ 'Cache-Control': 'no-cache',
Authorization: 'Basic ' + btoa("myusername:mypassword"),
'Content-Type': 'application/json' },
body:
{...}};
request(options, function (error, response, body) {});
NSString *authStr = [NSString stringWithFormat:@"%@:%@", [self myusername], [self mypassword]];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[theRequest setValue:authValue forHTTPHeaderField:@"Authorization"];
#!/usr/local/bin/perl
use strict;
use MIME::Base64;
use REST::Client;
my $api_key = "myusername";
my $api_pass = "mypassword";
my $client = REST::Client->new();
$client->setHost("https://api.labsmobile.com/json/send");
$client->addHeader("Authorization", "Basic " .
encode_base64("$api_key:$api_pass", ""));
<?php
$auth_basic = base64_encode("myusername:mypassword");
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.labsmobile.com/json/send",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Cache-Control: no-cache",
"Content-Type: application/json"
),
));
?>
import requests, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(usrPass)
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val,
'Cache-Control': "no-cache"
}
import http.client, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(bytes(usrPass, 'utf-8'))
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val.decode('utf-8'),
'Cache-Control': "no-cache"
}
require 'uri'
require 'net/http'
require 'base64'
url = URI("https://api.labsmobile.com/json/send")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Basic ' + Base64::encode64("myusername:mypassword")
request["Cache-Control"] = 'no-cache'
let username = "myusername"
let password = "mypassword"
let loginString = NSString(format: "%@:%@", username, password)
let loginData: NSData = loginString.dataUsingEncoding(NSUTF8StringEncoding)!
let base64LoginString = loginData.base64EncodedStringWithOptions([])
let url = NSURL(string: "https://api.labsmobile.com/json/send")
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "POST"
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")
Dim myReq As HttpWebRequest
myReq = HttpWebRequest.Create("https://api.labsmobile.com/json/send")
myReq.Method = "POST"
myReq.ContentType = "application/json"
myReq.Headers.add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes("myusername:mypassword")))
The authentication method used is Basic Authentication. We use a special HTTP header where we add myusername:mypassword
encoded in base64. The platform verifies all calls to the API-Interface SMS HTTP before processing the sending. Also the HTTP call must be done from a valid IP (optional) and meet all account limitations and filters.
Note that even though your credentials are encoded, they are not encrypted. All API requests can be made over HTTPS. Calls made over plain HTTP will also work but the username and password would be very easy to retrieve.
If the user name or password is not correct, the platform will respond with an HTTP 401 Unauthorized standard code. If the call or HTTP request is from an IP not set as a valid source, the platform will respond with an HTTP 403 Forbidden standard code.
Endpoints
Send SMS
This endpoint is used to send single or bulk SMS (MT or Push SMS) messages.
HTTP REST Request
Make sure to replace
myusername:mypassword
with your account username and API token.
curl --user myusername:mypassword -X POST \
https://api.labsmobile.com/json/send \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"message":"Text of the SMS message", "tpoa":"Sender","recipient":[{"msisdn":"12015550123"},{"msisdn":"447400123456"},{"msisdn":"5212221234567"}]}'
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.labsmobile.com/json/send");
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
curl_easy_setopt(hnd, CURLOPT_USERNAME, "myusername");
curl_easy_setopt(hnd, CURLOPT_PASSWORD, "mypassword");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Cache-Control: no-cache");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}");
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://api.labsmobile.com/json/send");
client.Authenticator = new HttpBasicAuthenticator("myusername", "mypassword");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.labsmobile.com/json/send"
payload := strings.NewReader("{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic " + basicAuth("myusername","mypassword"))
req.Header.Add("Cache-Control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api.labsmobile.com/json/send")
.header("Content-Type", "application/json")
.basicAuth("myusername","mypassword")
.header("Cache-Control", "no-cache")
.body("{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}")
.asString();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.labsmobile.com/json/send",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache",
},
"processData": false,
"data": "{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = JSON.stringify({
"message": "Text of the SMS message",
"tpoa": "Sender",
"recipient": [
{
"msisdn": "12015550123"
},
{
"msisdn": "447400123456"
},
{
"msisdn": "5212221234567"
}
]
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.labsmobile.com/json/send");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Basic " + btoa("myusername:mypassword"));
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.send(data);
var http = require("https");
var btoa = require("btoa");
var options = {
"method": "POST",
"hostname": [
"api",
"labsmobile",
"com"
],
"path": [
"json",
"send"
],
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ message: 'Text of the SMS message',
tpoa: 'Sender',
recipient:
[ { msisdn: '12015550123' },
{ msisdn: '447400123456' },
{ msisdn: '5212221234567' } ] }));
req.end();
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Content-Type": @"application/json",
@"Cache-Control": @"no-cache" };
NSDictionary *parameters = @{ @"message": @"Text of the SMS message",
@"tpoa": @"Sender",
@"recipient": @[ @{ @"msisdn": @"12015550123" }, @{ @"msisdn": @"447400123456" }, @{ @"msisdn": @"5212221234567" } ] };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.labsmobile.com/json/send"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSString *authStr = [NSString stringWithFormat:@"%@:%@", [self myusername], [self mypassword]];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[request setValue:authValue forHTTPHeaderField:@"Authorization"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
use REST::Client;
use MIME::Base64;
my $api_key = "myusername";
my $api_pass = "mypassword";
my $client = REST::Client->new();
$client->addHeader("Authorization", "Basic " .
encode_base64("$api_key:$api_pass", ""));
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');
$req = '{
"message" : "Text of the SMS message",
"tpoa" : "Sender",
"recipient" : [
{
"msisdn":"12015550123"
},
{
"msisdn":"447400123456"
},
{
"msisdn":"5212221234567"
}]
}';
$url = "https://api.labsmobile.com/json/send";
$client->POST($url, $req);
print $client->responseContent();
<?php
$auth_basic = base64_encode("myusername:mypassword");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.labsmobile.com/json/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"message":"Text of the SMS message", "tpoa":"Sender","recipient":[{"msisdn":"12015550123"},{"msisdn":"447400123456"},{"msisdn":"5212221234567"}]}',
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Cache-Control: no-cache",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(usrPass)
url = "https://api.labsmobile.com/json/send"
payload = "{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}"
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val,
'Cache-Control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
import http.client, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(bytes(usrPass, 'utf-8'))
conn = http.client.HTTPConnection("api.labsmobile.com")
payload = "{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}"
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val.decode('utf-8'),
'Cache-Control': "no-cache"
}
conn.request("POST", "/json/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
require 'base64'
url = URI("https://api.labsmobile.com/json/send")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Basic ' + Base64::encode64("myusername:mypassword")
request["Cache-Control"] = 'no-cache'
request.body = "{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}"
response = http.request(request)
puts response.read_body
import Foundation
let username = "myusername"
let password = "mypassword"
let loginString = NSString(format: "%@:%@", username, password)
let loginData: NSData = loginString.dataUsingEncoding(NSUTF8StringEncoding)!
let base64LoginString = loginData.base64EncodedStringWithOptions([])
let headers = [
"Content-Type": "application/json",
"Cache-Control": "no-cache"
]
let parameters = [
"message": "Text of the SMS message",
"tpoa": "Sender",
"recipient": [["msisdn": "12015550123"], ["msisdn": "447400123456"], ["msisdn": "5212221234567"]]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.labsmobile.com/json/send")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse
myReq = HttpWebRequest.Create("https://api.labsmobile.com/json/send")
myReq.Method = "POST"
myReq.ContentType = "application/json"
myReq.Headers.add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes("myusername:mypassword")))
Dim myData As String = "{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}"
myReq.GetRequestStream.Write(System.Text.Encoding.UTF8.GetBytes(myData), 0, System.Text.Encoding.UTF8.GetBytes(myData).Count)
myResp = myReq.GetResponse
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
Dim myText As String
myText = myreader.ReadToEnd
POST https://api.labsmobile.com/json/send
Request parameters
Simple send request:
{
"message":"Test message number 1",
"tpoa":"Sender",
"recipient":
[
{
"msisdn":"12015550123"
}
]
}
Multiple sending with test messages, subid and label identifiers:
{
"message":"Test message number 2",
"tpoa":"Sender",
"recipient":
[
{
"msisdn":"12015550123"
},
{
"msisdn":"12015550124"
},
{
"msisdn":"12015550125"
}
],
"test":"1",
"subid":"L-203",
"label":"from]=websms;[user]=admin[campaign]=salesJanuary"
}
Send Unicode SMS with ack reception:
{
"message":"Привет мир!",
"tpoa":"Sender",
"recipient":
[
{
"msisdn":"79123456789"
}
],
"ackurl":"http://clientserver.com/receive_ack.php"
}
Send SMS with variables and parameters:
{
"message":"Hello %name%, your balance is %balance%.",
"tpoa":"Sender",
"recipient":
[
{
"msisdn":"12015550123"
},
{
"msisdn":"12015550124"
},
{
"msisdn":"12015550125"
}
],
"parameters": [
{"name":{"msisdn":"12015550123","value":"John"}},
{"name":{"msisdn":"default","value":"Client"}},
{"balance":{"msisdn":"12015550123","value":"103"}},
{"balance":{"msisdn":"default","value":"0"}}
],
}
Parameter | Description | Values |
---|---|---|
msisdn | Required. Parameter that includes a mobile number recipient. The number must include the country code without ‘+’ ó ‘00’. Each customer account has a maximum number of msisdn per sending. See the terms of your account to see this limit. | 12015550123 447400826129 5212221234567 34609213718 |
message | Required. The message to be sent. The maximum message length is 160 characters. Only characters in the GSM 3.38 7bit alphabet, found at the end of this document, are valid. Otherwise you must send ucs2 parameter. |
Hello world! |
tpoa | Optional. Sender of the message. May have a numeric (maximum length, 14 digits) or an alphanumeric (maximum capacity, 11 characters) value. The messaging platform assigns a default sender if this parameter is not included. By including the sender's mobile number, the message recipient can easily respond from their mobile phone with the "Reply" button. The sender can only be defined in some countries due to the restrictions of the operators. Otherwise the sender is a random numeric value. | MYSENDER |
subid | Optional. Message ID included in the ACKs (delivery confirmations). It is a unique delivery ID issued by the API client. It has a maximum length of 20 characters. | 5aa3ea8028ce5 |
label | Optional. Identifies the message for statistical purposes. WebSMS and other applications use this field to organize and record the message. Maximum capacity of 255 characters. Typical information contained in this field: user that has sent the message, application or module, etc. ... | {account:myclient}{idc:T271} |
test | Optional. If the value is 1, the message will be considered a test. It will not be sent to the GSM network and, therefore, will not be received on any mobile devices. However, these messages are accessible using online search tools. This parameter is intended to enable performing integration tests without an associated cost. Operator and handset confirmations will not be received. | 1 |
ackurl | Optional. URL to which the corresponding delivery confirmation notifications will be sent. In the preferences section of WebSMS application you can set the default value for ackurl for all cases without having to send this parameter in each sending. | http://mydom.com/get_ack |
shortlink | Optional. If this field is present in the message and has a value of 1 the first URL would be replace by a short link of LabsMobile (format: http://lm0.es/XXXXX ). The statistics of visits can be seen in WebSMS application or can be received in an url with the parameter clickurl. |
1 |
clickurl | Optional. URL to which the corresponding click confirmation notifications will be sent if the parameter shortlink is enabled. In the preferences section of WebSMS application you can set the default value for clickurl for all cases without having to send this parameter in each sending. | http://mydom.com/get_clics |
scheduled | Optional. The message will be sent at the date and time indicated in this field. If this field has not been specified, the message will be sent immediately. Format: YYYY-MM-DD HH:MM:SS. IMPORTANT: the value of this field must be expressed using GMT time. | 2012-11-07 17:34:00 |
long | Optional. If this field is present in the message and has a value of 1, the message field may contain up to 459 characters. Each 153 characters will be considered a single message (in terms of charges) and the recipient will receive one, concatenated message. IMPORTANT: This option is only available in some countries due to the restrictions of the operators. | 1 |
crt | Optional. If this field is present in the message, it will be considered a certified SMS message. An email with the delivery certificate in an attachment will be sent to the address contained in this parameter. IMPORTANT: This option is only implemented in some countries. | info@client.es |
crt_id | Optional. If the message is a certified SMS message this field will be set as the tax identification number of the sender company or organization. You would see this value in the certificate in PDF format. | B622123442 |
crt_name | Optional. If the message is a certified SMS message this field will be set as the name of the sender company or organization. You would see this value in the certificate in PDF format. | info@client.es |
ucs2 | Optional. If this field is present in the message the message can contain any character in the UCS-2 alphabet. In this case the capacity of the message is 70 characters and can be sent concatenated to a maximum of 500 characters. | 1 |
nofilter | Opcional. If this field is present the platform won’t apply the duplicate filter, so no message will be blocked by this filter. | 1 |
parameters | Opcional. This field contains values to replace parameters in the text of the message. The message can contain one or more parameters (with the following format: %name% , %fieldn% , etc.). It is necessary to specify the value of each parameter for each of the recipients or establish a default value. Example: {"parameters": [{"name": {"msisdn":"12015550123", "value":"John"}}, {"name": {"msisdn":"default", "value":"Client"}}]} |
{"name":{"msisdn":"12015550123","value":"John"}} |
Return values
Return for a successful Send SMS request:
{
"code":"0",
"message":"Message has been successfully sent",
"subid":"56fbab0586192"
}
Return in case of incorrect username or password for a Send SMS request:
{
"code":"403",
"message":"Forbidden"
}
Return in case the account has not enough credits for a Send SMS request:
{
"code":"35",
"message":"The account has no enough credit for this sending"
}
Parameter | Description | Values |
---|---|---|
code | Code that identifies the result of the request. Complete list of return codes. | 0 21 22 ... 401 403 500 |
message | Description that explains the result of the request. | The account has no enough credit for this sending |
subid | This field will be present only ff the request has been successful (code = 0 ). If the request paramaters contains a subid value, this return field will adopt the same value. |
5aa3ea8e5cdb6 |
Get account credits
With a call to this endpoint it is possible to learn the SMS credit for an existing messaging account. The connection is made with a HTTP/GET call with authentication in the header of the HTTP connection.
HTTP REST Request
Make sure to replace
myusername:mypassword
with your account username and API token.
curl --user myusername:mypassword -X GET \
https://api.labsmobile.com/json/balance \
-H 'Cache-Control: no-cache' \
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.labsmobile.com/json/balance");
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
curl_easy_setopt(hnd, CURLOPT_USERNAME, "myusername");
curl_easy_setopt(hnd, CURLOPT_PASSWORD, "mypassword");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Cache-Control: no-cache");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://api.labsmobile.com/json/balance");
client.Authenticator = new HttpBasicAuthenticator("myusername", "mypassword");
var request = new RestRequest(Method.GET);
request.AddHeader("Cache-Control", "no-cache");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.labsmobile.com/json/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Basic " + basicAuth("myusername","mypassword"))
req.Header.Add("Cache-Control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.get("https://api.labsmobile.com/json/balance")
.basicAuth("myusername","mypassword")
.header("Cache-Control", "no-cache")
.asString();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.labsmobile.com/json/balance",
"method": "GET",
"headers": {
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache",
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.labsmobile.com/json/balance");
xhr.setRequestHeader("Authorization", "Basic " + btoa("myusername:mypassword"));
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.send(data);
var http = require("https");
var btoa = require("btoa");
var options = {
"method": "GET",
"hostname": [
"api",
"labsmobile",
"com"
],
"path": [
"json",
"balance"
],
"headers": {
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache",
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Cache-Control": @"no-cache" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.labsmobile.com/json/balance"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSString *authStr = [NSString stringWithFormat:@"%@:%@", [self myusername], [self mypassword]];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[request setValue:authValue forHTTPHeaderField:@"Authorization"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
use REST::Client;
use MIME::Base64;
my $api_key = "myusername";
my $api_pass = "mypassword";
my $client = REST::Client->new();
$client->addHeader("Authorization", "Basic " .
encode_base64("$api_key:$api_pass", ""));
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');
$url = "https://api.labsmobile.com/json/balance";
$client->GET($url);
print $client->responseContent();
<?php
$auth_basic = base64_encode("myusername:mypassword");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.labsmobile.com/json/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Cache-Control: no-cache",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(usrPass)
url = "https://api.labsmobile.com/json/balance"
headers = {
'Authorization': "Basic %s" % b64Val,
'Cache-Control': "no-cache"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
import http.client, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(bytes(usrPass, 'utf-8'))
conn = http.client.HTTPConnection("api.labsmobile.com")
payload = ""
headers = {
'Authorization': "Basic %s" % b64Val.decode('utf-8'),
'Cache-Control': "no-cache"
}
conn.request("GET", "/json/balance", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
require 'base64'
url = URI("https://api.labsmobile.com/json/balance")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Basic ' + Base64::encode64("myusername:mypassword")
request["Cache-Control"] = 'no-cache'
response = http.request(request)
puts response.read_body
import Foundation
let username = "myusername"
let password = "mypassword"
let loginString = NSString(format: "%@:%@", username, password)
let loginData: NSData = loginString.dataUsingEncoding(NSUTF8StringEncoding)!
let base64LoginString = loginData.base64EncodedStringWithOptions([])
let headers = [
"Cache-Control": "no-cache"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.labsmobile.com/json/balance")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse
myReq = HttpWebRequest.Create("https://api.labsmobile.com/json/balance")
myReq.Method = "GET"
myReq.ContentType = "application/json"
myReq.Headers.add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes("myusername:mypassword")))
myResp = myReq.GetResponse
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
Dim myText As String
myText = myreader.ReadToEnd
GET https://api.labsmobile.com/json/balance
Return values
Return for a successful Get account credits request:
{
"code":"0",
"credits":"33.02"
}
Return in case of incorrect username or password for a Get account credits request:
{
"code":"403",
"message":"Forbidden"
}
Parameter | Description | Values |
---|---|---|
code | Code that identifies the result of the request. Complete list of return codes. | 0 401 500 |
credits | Number of credits of the requested account. This field contains a numeric value in float format. | 102.23 |
Get message status
With a call to this endpoint it is possible to know the status of an SMS message. The request must identify the message with two HTTP/POST JSON parameters: subid and msisdn. Authentication should be done with user account and password in the header of the HTTP connection.
HTTP REST Request
Make sure to replace
myusername:mypassword
with your account username and API token.
curl --user myusername:mypassword -X POST \
https://api.labsmobile.com/json/ack \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"subid":"5a9fe45c7adc3","msisdn":"12015550123"}'
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.labsmobile.com/json/ack");
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
curl_easy_setopt(hnd, CURLOPT_USERNAME, "myusername");
curl_easy_setopt(hnd, CURLOPT_PASSWORD, "mypassword");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Cache-Control: no-cache");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"subid\":\"5a9fe45c7adc3\",\"msisdn\":\"12015550123\"}");
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://api.labsmobile.com/json/ack");
client.Authenticator = new HttpBasicAuthenticator("myusername", "mypassword");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\"subid\":\"5a9fe45c7adc3\",\"msisdn\":\"12015550123\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.labsmobile.com/json/ack"
payload := strings.NewReader("{\"subid\":\"5a9fe45c7adc3\",\"msisdn\":\"12015550123\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic " + basicAuth("myusername","mypassword"))
req.Header.Add("Cache-Control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api.labsmobile.com/json/ack")
.header("Content-Type", "application/json")
.basicAuth("myusername","mypassword")
.header("Cache-Control", "no-cache")
.body("{\"subid\":\"5a9fe45c7adc3\",\"msisdn\":\"12015550123\"}")
.asString();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.labsmobile.com/json/ack",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache",
},
"processData": false,
"data": "{\"subid\":\"5a9fe45c7adc3\",\"msisdn\":\"12015550123\"}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = JSON.stringify({
"subid": "5a9fe45c7adc3",
"msisdn": "12015550123"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.labsmobile.com/json/ack");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Basic " + btoa("myusername:mypassword"));
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.send(data);
var http = require("https");
var btoa = require("btoa");
var options = {
"method": "POST",
"hostname": [
"api",
"labsmobile",
"com"
],
"path": [
"json",
"ack"
],
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ subid: '5a9fe45c7adc3', msisdn: '12015550123' }));
req.end();
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Content-Type": @"application/json",
@"Cache-Control": @"no-cache" };
NSDictionary *parameters = @{ @"subid": @"5a9fe45c7adc3",
@"msisdn": @"12015550123" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.labsmobile.com/json/ack"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSString *authStr = [NSString stringWithFormat:@"%@:%@", [self myusername], [self mypassword]];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[request setValue:authValue forHTTPHeaderField:@"Authorization"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
use REST::Client;
use MIME::Base64;
my $api_key = "myusername";
my $api_pass = "mypassword";
my $client = REST::Client->new();
$client->addHeader("Authorization", "Basic " .
encode_base64("$api_key:$api_pass", ""));
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');
$req = '{
"subid" : "5a9fe45c7adc3",
"msisdn" : "12015550123"
}';
$url = "https://api.labsmobile.com/json/ack";
$client->POST($url, $req);
print $client->responseContent();
<?php
$auth_basic = base64_encode("myusername:mypassword");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.labsmobile.com/json/ack",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"subid":"5a9fe45c7adc3","msisdn":"12015550123"}',
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Cache-Control: no-cache",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(usrPass)
url = "https://api.labsmobile.com/json/ack"
payload = "{\"subid\":\"5a9fe45c7adc3\",\"msisdn\":\"12015550123\"}"
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val,
'Cache-Control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
import http.client, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(bytes(usrPass, 'utf-8'))
conn = http.client.HTTPConnection("api.labsmobile.com")
payload = "{\"subid\":\"5a9fe45c7adc3\",\"msisdn\":\"12015550123\"}"
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val.decode('utf-8'),
'Cache-Control': "no-cache"
}
conn.request("POST", "/json/ack", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
require 'base64'
url = URI("https://api.labsmobile.com/json/ack")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Basic ' + Base64::encode64("myusername:mypassword")
request["Cache-Control"] = 'no-cache'
request.body = "{\"subid\":\"5a9fe45c7adc3\",\"msisdn\":\"12015550123\"}"
response = http.request(request)
puts response.read_body
import Foundation
let username = "myusername"
let password = "mypassword"
let loginString = NSString(format: "%@:%@", username, password)
let loginData: NSData = loginString.dataUsingEncoding(NSUTF8StringEncoding)!
let base64LoginString = loginData.base64EncodedStringWithOptions([])
let headers = [
"Content-Type": "application/json",
"Cache-Control": "no-cache"
]
let parameters = [
"subid": "5a9fe45c7adc3",
"msisdn": "12015550123"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.labsmobile.com/json/ack")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse
myReq = HttpWebRequest.Create("https://api.labsmobile.com/json/ack")
myReq.Method = "POST"
myReq.ContentType = "application/json"
myReq.Headers.add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes("myusername:mypassword")))
Dim myData As String = "{\"subid\":\"5a9fe45c7adc3\",\"msisdn\":\"12015550123\"}"
myReq.GetRequestStream.Write(System.Text.Encoding.UTF8.GetBytes(myData), 0, System.Text.Encoding.UTF8.GetBytes(myData).Count)
myResp = myReq.GetResponse
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
Dim myText As String
myText = myreader.ReadToEnd
POST https://api.labsmobile.com/json/ack
Request parameters
Parameter | Description | Values |
---|---|---|
subid | Required. Identifier of the sending request. | 5aa3ea8e5cdb6 |
msisdn | Required. Phone number within the sending request to check the status, credits and other associated details. | 12015550123 447400826129 5212221234567 34609213718 |
Return values
Return for a successful Get message status request:
{
"code":"0",
"subid":"56fbab0611391",
"msisdn":"12015550123",
"status":"handset",
"credits":"1.04",
"desc":"",
"timestamp":"2018-03-18 15:23:10"
}
Return in case of incorrect
subid
ormsisdn
for a Get message status request:
{
"code":"403",
"message":"Forbidden"
}
Parameter | Description | Values |
---|---|---|
code | Code that identifies the result of the request. Complete list of return codes. | 0 400 401 403 500 |
message | Description that explains the result of the request. | Bad Request |
subid | Identifier of the sending request. | 5aa3ea8e5cdb6 |
msisdn | Phone number within the sending request to check the status, credits and other associated details. | 12015550123 447400826129 5212221234567 34609213718 |
status | Current status of the message. | processed test error gateway operator handset |
credits | Number of credits that the message has consumed. | 0.76 |
desc | Additional description of the status of the message in case of error. | REJECTD EXPIRED BLOCKED UNDELIV UNKNOWN |
timestamp | Day and time of the last change of state in UTC timezone (format: YYYY-MM-DD HH:MM:SS) | 2018-03-18 15:23:10 |
The list of possible status are:
Status | Description |
---|---|
processed | Processed message. |
test | Message sent in simulated mode with the test parameter enabled. |
error | Error in message delivery. Then desc field specifies the error type: REJECTD , EXPIRED , BLOCKED , UNDELIV , UNKNOWN . |
gateway | Message delivered to the GSM network. |
operator | Message received by the local operator. |
handset | Message delivered to the device. |
Get prices by country
With a call to this endpoint it is possible to know the credits that a single sending will take depending on the country of delivery.
HTTP REST Request
Make sure to replace
myusername:mypassword
with your account username and API token.
curl --user myusername:mypassword -X POST \
https://api.labsmobile.com/json/prices \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"format":"JSON","countries":["ES","FR","US","MX"]}'
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.labsmobile.com/json/prices");
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
curl_easy_setopt(hnd, CURLOPT_USERNAME, "myusername");
curl_easy_setopt(hnd, CURLOPT_PASSWORD, "mypassword");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Cache-Control: no-cache");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"format\":\"JSON\",\"countries\":[\"ES\",\"FR\",\"US\",\"MX\"]}");
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://api.labsmobile.com/json/prices");
client.Authenticator = new HttpBasicAuthenticator("myusername", "mypassword");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\"format\":\"JSON\",\"countries\":[\"ES\",\"FR\",\"US\",\"MX\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.labsmobile.com/json/prices"
payload := strings.NewReader("{\"format\":\"JSON\",\"countries\":[\"ES\",\"FR\",\"US\",\"MX\"]}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic " + basicAuth("myusername","mypassword"))
req.Header.Add("Cache-Control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api.labsmobile.com/json/prices")
.header("Content-Type", "application/json")
.basicAuth("myusername","mypassword")
.header("Cache-Control", "no-cache")
.body("{\"format\":\"JSON\",\"countries\":[\"ES\",\"FR\",\"US\",\"MX\"]}")
.asString();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.labsmobile.com/json/prices",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache"
},
"processData": false,
"data": "{\"format\":\"JSON\",\"countries\":[\"ES\",\"FR\",\"US\",\"MX\"]}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = JSON.stringify({
"format": "JSON",
"countries": [
"ES",
"FR",
"US",
"MX"
]
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.labsmobile.com/json/prices");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Basic " + btoa("myusername:mypassword"));
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.send(data);
var http = require("https");
var btoa = require("btoa");
var options = {
"method": "POST",
"hostname": [
"api",
"labsmobile",
"com"
],
"path": [
"json",
"prices"
],
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ format: 'JSON', countries: [ 'ES', 'FR', 'US', 'MX' ] }));
req.end();
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Content-Type": @"application/json",
@"Cache-Control": @"no-cache" };
NSDictionary *parameters = @{ @"format": @"JSON",
@"countries": @[ @"ES", @"FR", @"US", @"MX" ] };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.labsmobile.com/json/prices"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSString *authStr = [NSString stringWithFormat:@"%@:%@", [self myusername], [self mypassword]];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[request setValue:authValue forHTTPHeaderField:@"Authorization"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
use REST::Client;
use MIME::Base64;
my $api_key = "myusername";
my $api_pass = "mypassword";
my $client = REST::Client->new();
$client->addHeader("Authorization", "Basic " .
encode_base64("$api_key:$api_pass", ""));
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');
$req = '{
"format" : "JSON",
"countries" :
[
"ES",
"FR",
"US",
"MX"
]
}';
$url = "https://api.labsmobile.com/json/prices";
$client->POST($url, $req);
print $client->responseContent();
<?php
$auth_basic = base64_encode("myusername:mypassword");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.labsmobile.com/json/prices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"format":"JSON","countries":["ES","FR","US","MX"]}',
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Cache-Control: no-cache",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(bytes(usrPass, 'utf-8'))
url = "https://api.labsmobile.com/json/prices"
payload = "{\"format\":\"JSON\",\"countries\":[\"ES\",\"FR\",\"US\",\"MX\"]}"
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val.decode('utf-8'),
'Cache-Control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
import http.client, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(usrPass)
conn = http.client.HTTPConnection("api.labsmobile.com")
payload = "{\"format\":\"JSON\",\"countries\":[\"ES\",\"FR\",\"US\",\"MX\"]}"
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val,
'Cache-Control': "no-cache"
}
conn.request("POST", "/json/prices", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
require 'base64'
url = URI("https://api.labsmobile.com/json/prices")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Basic ' + Base64::encode64("myusername:mypassword")
request["Cache-Control"] = 'no-cache'
request.body = "{\"format\":\"JSON\",\"countries\":[\"ES\",\"FR\",\"US\",\"MX\"]}"
response = http.request(request)
puts response.read_body
import Foundation
let username = "myusername"
let password = "mypassword"
let loginString = NSString(format: "%@:%@", username, password)
let loginData: NSData = loginString.dataUsingEncoding(NSUTF8StringEncoding)!
let base64LoginString = loginData.base64EncodedStringWithOptions([])
let headers = [
"Content-Type": "application/json",
"Cache-Control": "no-cache"
]
let parameters = [
"format": "JSON",
"countries": ["ES", "FR", "US", "MX"]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.labsmobile.com/json/prices")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse
myReq = HttpWebRequest.Create("https://api.labsmobile.com/json/prices")
myReq.Method = "POST"
myReq.ContentType = "application/json"
myReq.Headers.add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes("myusername:mypassword")))
Dim myData As String = "{\"format\":\"JSON\",\"countries\":[\"ES\",\"FR\",\"US\",\"MX\"]}"
myReq.GetRequestStream.Write(System.Text.Encoding.UTF8.GetBytes(myData), 0, System.Text.Encoding.UTF8.GetBytes(myData).Count)
myResp = myReq.GetResponse
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
Dim myText As String
myText = myreader.ReadToEnd
POST https://api.labsmobile.com/json/prices
Request parameters
Parameter | Description | Values |
---|---|---|
countries | Optional. List of ISO country codes to obtain the updated tariff in credits and other details. If this field if not set or it contains the value ALL the result will contain the information of all the available countries. |
ES FR US CL ALL |
format | Optional. Desired format of the result. Default value: JSON . |
JSON XML CSV |
Return values
Return for a successful Get prices by country request in JSON format:
{
"FR":
{
"isocode":"FR",
"prefix":"33",
"name":"France",
"credits":1.114
},
"DE":
{
"isocode":"DE",
"prefix":"49",
"name":"Germany",
"credits":1.8
}
}
Return for a successful Get prices by country request in XML format:
<?xml version="1.0" encoding="UTF-8"?>
<prices>
<country>
<isocode>FR</isocode>
<prefix>33</prefix>
<name>France</name>
<credits>1.114</credits>
</country>
<country>
<isocode>DE</isocode>
<prefix>49</prefix>
<name>Germany</name>
<credits>1.8</credits>
</country>
</prices>
Return for a successful Get prices by country request in CSV format:
FR,33,France,1.114
DE,49,Germany,1.8
Return in case of incorrect username of password for a Get prices by country request:
{
"code":"403",
"message":"Forbidden"
}
Parameter | Description | Values |
---|---|---|
isocode | ISO country code. | FR CO DE |
prefix | International phone prefix of the country. | 33 57 49 |
name | Country name. | France Colombia Germany |
credits | Current number of credits that will consume a standard SMS sending. | 0.76 |
Manage scheduled sendings
With a call to this endpoint you can cancel or execute the scheduled sendings that are pending for execution. The connection is made with an HTTP/POST JSON call with the authentication parameters, the command and the identifier of the sending to be canceled.
HTTP REST Request
Make sure to replace
myusername:mypassword
with your account username and API token.
curl --user myusername:mypassword -X POST \
https://api.labsmobile.com/json/scheduled \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"cmd":"cancel","subid":"5a9fe45c7adc3"}'
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.labsmobile.com/json/scheduled");
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
curl_easy_setopt(hnd, CURLOPT_USERNAME, "myusername");
curl_easy_setopt(hnd, CURLOPT_PASSWORD, "mypassword");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Cache-Control: no-cache");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"cmd\":\"cancel\",\"subid\":\"5a9fe45c7adc3\"}");
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://api.labsmobile.com/json/scheduled");
client.Authenticator = new HttpBasicAuthenticator("myusername", "mypassword");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\"cmd\":\"cancel\",\"subid\":\"5a9fe45c7adc3\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.labsmobile.com/json/scheduled"
payload := strings.NewReader("{\"cmd\":\"cancel\",\"subid\":\"5a9fe45c7adc3\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic " + basicAuth("myusername","mypassword"))
req.Header.Add("Cache-Control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api.labsmobile.com/json/scheduled")
.header("Content-Type", "application/json")
.basicAuth("myusername","mypassword")
.header("Cache-Control", "no-cache")
.body("{\"cmd\":\"cancel\",\"subid\":\"5a9fe45c7adc3\"}")
.asString();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.labsmobile.com/json/scheduled",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache",
},
"processData": false,
"data": "{\"cmd\":\"cancel\",\"subid\":\"5a9fe45c7adc3\"}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = JSON.stringify({
"cmd": "cancel",
"subid": "5a9fe45c7adc3"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.labsmobile.com/json/scheduled");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Basic " + btoa("myusername:mypassword"));
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.send(data);
var http = require("https");
var btoa = require("btoa");
var options = {
"method": "POST",
"hostname": [
"api",
"labsmobile",
"com"
],
"path": [
"json",
"scheduled"
],
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ cmd: 'cancel', subid: '5a9fe45c7adc3' }));
req.end();
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Content-Type": @"application/json",
@"Cache-Control": @"no-cache" };
NSDictionary *parameters = @{ @"cmd": @"cancel",
@"subid": @"5a9fe45c7adc3" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.labsmobile.com/json/scheduled"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSString *authStr = [NSString stringWithFormat:@"%@:%@", [self myusername], [self mypassword]];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[request setValue:authValue forHTTPHeaderField:@"Authorization"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
use REST::Client;
use MIME::Base64;
my $api_key = "myusername";
my $api_pass = "mypassword";
my $client = REST::Client->new();
$client->addHeader("Authorization", "Basic " .
encode_base64("$api_key:$api_pass", ""));
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');
$req = '{
"cmd" : "cancel",
"subid" : "5a9fe45c7adc3"
}';
$url = "https://api.labsmobile.com/json/scheduled";
$client->POST($url, $req);
print $client->responseContent();
<?php
$auth_basic = base64_encode("myusername:mypassword");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.labsmobile.com/json/scheduled",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"cmd":"cancel","subid":"5a9fe45c7adc3"}',
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Cache-Control: no-cache",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(usrPass)
url = "https://api.labsmobile.com/json/scheduled"
payload = "{\"cmd\":\"cancel\",\"subid\":\"5a9fe45c7adc3\"}"
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val,
'Cache-Control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
import http.client, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(bytes(usrPass, 'utf-8'))
conn = http.client.HTTPConnection("api.labsmobile.com")
payload = "{\"cmd\":\"cancel\",\"subid\":\"5a9fe45c7adc3\"}"
headers = {
'Content-Type': "application/json",
'Authorization': "Basic %s" % b64Val.decode('utf-8'),
'Cache-Control': "no-cache"
}
conn.request("POST", "/json/scheduled", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
require 'base64'
url = URI("https://api.labsmobile.com/json/scheduled")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Basic ' + Base64::encode64("myusername:mypassword")
request["Cache-Control"] = 'no-cache'
request["Postman-Token"] = 'ce253604-0324-4c71-a839-855adc5ca50d'
request.body = "{\"cmd\":\"cancel\",\"subid\":\"5a9fe45c7adc3\"}"
response = http.request(request)
puts response.read_body
import Foundation
let username = "myusername"
let password = "mypassword"
let loginString = NSString(format: "%@:%@", username, password)
let loginData: NSData = loginString.dataUsingEncoding(NSUTF8StringEncoding)!
let base64LoginString = loginData.base64EncodedStringWithOptions([])
let headers = [
"Content-Type": "application/json",
"Cache-Control": "no-cache"
]
let parameters = [
"cmd": "cancel",
"subid": "5a9fe45c7adc3"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.labsmobile.com/json/scheduled")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse
myReq = HttpWebRequest.Create("https://api.labsmobile.com/json/scheduled")
myReq.Method = "POST"
myReq.ContentType = "application/json"
myReq.Headers.add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes("myusername:mypassword")))
Dim myData As String = "{\"cmd\":\"cancel\",\"subid\":\"5a9fe45c7adc3\"}"
myReq.GetRequestStream.Write(System.Text.Encoding.UTF8.GetBytes(myData), 0, System.Text.Encoding.UTF8.GetBytes(myData).Count)
myResp = myReq.GetResponse
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
Dim myText As String
myText = myreader.ReadToEnd
POST https://api.labsmobile.com/json/scheduled
Request parameters
Parameter | Description | Values |
---|---|---|
subid | Required. Identifier of the sending request. This fiedl can contain the symbol * that will affect all the scheduled and pending sendings of the account. |
5aa3ea8e5cdb6 |
cmd | Command to execute. The possibles values are cancel and send to delete or execute now the selected scheduled sendings. |
cancel send |
Return values
Return for a successful Manage scheduled sendings request for
cancel
command:
{
"code":"0",
"message":"Scheduled messages successfully cancelled."
}
Return for a successful Manage scheduled sendings request for
send
command:
{
"code":"0",
"message":"Scheduled messages successfully sent."
}
Return values
Return in case of incorrect
subid
for a Manage scheduled sendings request:
{
"code":"52",
"message":"Scheduled messages not found."
}
Parameter | Description | Values |
---|---|---|
code | Code that identifies the result of the request. Complete list of return codes. | 0 401 403 500 |
message | Description that explains the result of the request. | Scheduled messages successfully cancelled. |
HLR Request
This endpoint is used to create HLR requests for one or multiple mobile phone numbers. A HLR request queries the mobile phone status with the related information like current operator, format, active, ported information, subscription country, etc.
The results and information of any mobile phone number is obtained in response to the request in the format described below.
HTTP REST Request
Make sure to replace
myusername:mypassword
with your account username and API token.
curl --user myusername:mypassword -X GET \
https://api.labsmobile.com/hlr/ \
-H 'Cache-Control: no-cache' \
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125");
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
curl_easy_setopt(hnd, CURLOPT_USERNAME, "myusername");
curl_easy_setopt(hnd, CURLOPT_PASSWORD, "mypassword");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Cache-Control: no-cache");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125");
client.Authenticator = new HttpBasicAuthenticator("myusername", "mypassword");
var request = new RestRequest(Method.GET);
request.AddHeader("Cache-Control", "no-cache");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Basic " + basicAuth("myusername","mypassword"))
req.Header.Add("Cache-Control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.get("https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125")
.basicAuth("myusername","mypassword")
.header("Cache-Control", "no-cache")
.asString();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125",
"method": "GET",
"headers": {
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache",
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125");
xhr.setRequestHeader("Authorization", "Basic " + btoa("myusername:mypassword"));
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.send(data);
var http = require("https");
var btoa = require("btoa");
var options = {
"method": "GET",
"hostname": [
"api",
"labsmobile",
"com"
],
"path": [
"json",
"balance"
],
"headers": {
"Authorization": "Basic " + btoa("myusername:mypassword"),
"Cache-Control": "no-cache",
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Cache-Control": @"no-cache" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSString *authStr = [NSString stringWithFormat:@"%@:%@", [self myusername], [self mypassword]];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[request setValue:authValue forHTTPHeaderField:@"Authorization"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
use REST::Client;
use MIME::Base64;
my $api_key = "myusername";
my $api_pass = "mypassword";
my $client = REST::Client->new();
$client->addHeader("Authorization", "Basic " .
encode_base64("$api_key:$api_pass", ""));
$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');
$url = "https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125";
$client->GET($url);
print $client->responseContent();
<?php
$auth_basic = base64_encode("myusername:mypassword");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Cache-Control: no-cache",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(usrPass)
url = "https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125"
headers = {
'Authorization': "Basic %s" % b64Val,
'Cache-Control': "no-cache"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
import http.client, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(bytes(usrPass, 'utf-8'))
conn = http.client.HTTPConnection("api.labsmobile.com")
payload = ""
headers = {
'Authorization': "Basic %s" % b64Val.decode('utf-8'),
'Cache-Control': "no-cache"
}
conn.request("GET", "/json/hlr/?numbers=12015550123,12015550124,12015550125", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
require 'base64'
url = URI("https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Basic ' + Base64::encode64("myusername:mypassword")
request["Cache-Control"] = 'no-cache'
response = http.request(request)
puts response.read_body
import Foundation
let username = "myusername"
let password = "mypassword"
let loginString = NSString(format: "%@:%@", username, password)
let loginData: NSData = loginString.dataUsingEncoding(NSUTF8StringEncoding)!
let base64LoginString = loginData.base64EncodedStringWithOptions([])
let headers = [
"Cache-Control": "no-cache"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse
myReq = HttpWebRequest.Create("https://api.labsmobile.com/hlr/?numbers=12015550123,12015550124,12015550125")
myReq.Method = "GET"
myReq.ContentType = "application/json"
myReq.Headers.add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes("myusername:mypassword")))
myResp = myReq.GetResponse
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
Dim myText As String
myText = myreader.ReadToEnd
GET https://api.labsmobile.com/hlr
Request parameters
Parameter | Description | Values |
---|---|---|
numbers | Required. List of mobile numbers that will be included in the HLR request. The numbers must include the country code without ‘+’ ó ‘00’. This parameter can contain a single number or a list of numbers separated by commas with a maximum of 100 cell phones. | 12015550123,12015550124,12015550125 |
Return values
Return for a successful HLR request:
{
"result":"ok",
"error":"",
"numbers":[{
"msisdn":"34609033163",
"status":"not_active",
"hni":"21407",
"cic":"340175",
"country_name":"Spain",
"country_code":"34",
"country_iso":"ES",
"carrier":"TELEFONICA MOVILES ESPANA, S.A.U.",
"network":"Movistar",
"mcc":"214",
"mnc":"5,07"
},{
"msisdn":"34609033161",
"status":"active",
"hni":"21407",
"cic":"340175",
"country_name":"Spain",
"country_code":"34",
"country_iso":"ES",
"carrier":"TELEFONICA MOVILES ESPANA, S.A.U.",
"network":"Movistar",
"mcc":"214",
"mnc":"5,07"}],
"count":"2",
"credits":"0.2"
}
Return in case of incorrect username or password for a HLR request:
{
"result":"ko",
"error":"invalidauth"
}
Parameter | Description | Values |
---|---|---|
result | Satisfactory or erroneous result of the request. | ok ko |
error | Description in case of error. No value in case the request was successful. | requiredfields internalerror numberslimit nocredits invalidauth |
numbers | List of results by telephone number. | |
size | Number of HLR checks that have been made with the request. | 3 |
credits | Number of credits of the requested action. This field contains a numeric value in float format. | 102.23 |
Results for each number
Parameter | Description | Values |
---|---|---|
msisdn | Mobile number of this HLR request. | 12015550123 12015550124 |
status | Indicates if the number is currently correct and active or not. | active not_active not_mobile unknown |
hni | Mobile Country Code + Mobile Network Code. | 21407 |
cic | Six-digit NNID that uniquely identifies the destination service provider. | 340175 |
country_name | Country name of subscription of the mobile number. | US DE PT |
country_code | Prefix of the country of mobile number. | 1 49 35 |
country_iso | Country of subscription of the mobile number. | US DE PT |
carrier | Name of the current operator of the mobile number. | Vodafone AT&T |
network | Name of the current network of the operator. | Vodafone AT&T |
mcc | Mobile Country Code. | 214 |
mnc | Mobile Network Code. | 01 |
Callbacks
Receive message status
With this callback you could receive delivery confirmations (or any other change in status of a message sent) in any URL. It is necessary to configure the parameters subid
and ackurl
in the sending request. There will be a JSON HTTP/GET notification for each mobile number included in the message.
?acklevel=[gateway|operator|handset|error]
&msisdn=[phone]
&status=[ok|ko]
&desc=[REJECTD|EXPIRED|BLOCKED|UNDELIV|UNKNOWN]
&subid=[identifier]
×tamp=YYYY-MM-DD%20HH:MM:SS
Values
Parameter | Description | Values |
---|---|---|
acklevel | Identifier of the sending request. This fiedl can contain the symbol * that will affect all the scheduled and pending sendings of the account. |
gateway operator handset error |
status | The value of this field indicates whether the message follows the normal delivery process or an error has occurred. | ko ok |
desc | Description of the status of the message in case of error. | REJECTD EXPIRED BLOCKED UNDELIV UNKNOWN |
The acklevel
field can contain the following values:
Parameter | Description |
---|---|
gateway | When the message is processed and sent to the GSM network. |
operator | When the final operator takes charge of the delivery. |
handset | When the mobile device receives the message. |
error | An error occurred while delivering the message. The status will have the value ko and the desc field specifies the error type. |
Receive clics
With this callback you could receive visit confirmations in an url that was labeled as shortlink. Using the parameters subid
, shortlink
and clickurl
in the sending request. There will be a JSON HTTP/POST notification for each visit or click.
To receive these visit notifications is necessary that the message contains the parameter shortlink
and its value should be 1
. When a visit or click on the shortlink which will replace the original url occur you will be notified with a HTTP/POST JSON call with all the user details.
The destination URL can be specified in each sending with the parameter clickurl
or you can set a default url for all sendings in WebSMS Preferences.
Values
{
"ip" : "98.139.180.149",
"useragent" : "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0",
"subid" : "5aa3ea8e5cdb6",
"msisdn" : "5212221234567",
"timestamp" : "2018-03-18 15:23:10"
}
Parameter | Description | Values |
---|---|---|
ip | IP address from the user that has visited the url. | 98.139.180.149 |
useragent | User agent of the browser or device that has visited the url. | Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0 |
subid | Identifier of the sending request. | 5aa3ea8e5cdb6 |
msisdn | Phone number within the sending request to check the status, credits and other associated details. | 12015550123 447400826129 5212221234567 34609213718 |
timestamp | Day and time of the last change of state in UTC timezone (format: YYYY-MM-DD HH:MM:SS) | 2018-03-18 15:23:10 |
Receive messages
Once a virtual number has been contracted, messages can be received via API, receiving these messages in a certain URL with a JSON HTTP/GET call. Each received message will call the URL with all the message data included in JSON parameters.
Values
{
"inbound_number":"12015576234",
"service_number":"12015576234",
"msisdn":"12015550123",
"message":"Test message",
"timestamp":"2014-06-07 19:21:43"
}
Parameter | Description | Values |
---|---|---|
inbound_number | Virtual number. | 13098212823 |
service_number | Virtual number. | 13098212823 |
msisdn | Phone number that has sent the inbound message. | 12015550123 447400826129 5212221234567 34609213718 |
message | Inbound message value. | Hello, I'm sending a message to this service. |
timestamp | Day and time when the message has been received in UTC timezone (format: YYYY-MM-DD HH:MM:SS). | 2018-03-18 15:23:10 |
Supported characters
The LabsMobile messaging platform supports the GSM (GSM 3.38 7-bit) standard charset and Unicode SMS messages. The message field therefore must only contain characters in GSM charset for standard SMS.
GSM 3.38 7-bit (available characters for standard SMS) | |||||||
---|---|---|---|---|---|---|---|
LF
- Line feedCR
- Carriage returnESC
- EscapeSP
- Space
Messages sent containing unsupported characters will be returned along with the corresponding error message. From LabsMobile, we advise substituting some of these character for others that are permitted while conserving the message's meaning. Examples are presented below:
Include the
ucs2
field as a JSON parameter in your request to send Unicode messages:
{
...
"ucs2": 1,
...
}
á => a
Á => A
í => i
Í => I
ó => o
Ó => O
ú => u
Ú => U
Account sign up and testing
Include the
test
field as a JSON parameter in your request to send testing messages:
{
...
"test": 1,
...
}
You can request your own account following the steps to create an account on https://www.labsmobile.com/en/signup. You will instantly receive an email with your account details (username/password). This account can be used through the online application (WebSMS) or on any of the SMSAPI (POST XML, JSON, GET, Mail, and WebService) interfaces.
During the integration process, the test
parameter is available for test messages. These are simulated messages that will NOT be sent to the specified mobile device and are useful for performing initial tests at no cost. Test messages will not generate an acknowledgement of receipt (ACK) and may be accessed on the WebSMS application.
Results and errors
These are some examples of JSON response messages to an HTTP/POST request:
{
"code":"403",
"message":"Forbidden"
}
{
"code":"35",
"message":"The account has no enough credit for this sending"
}
{
"code":"0",
"message":"Message has been successfully sent",
"subid":"56fbab0586192"
}
Every HTTP REST call or request will be be verified by the messaging platform. Both if the request is correct or if an error is found, a JSON message will be returned with the code corresponding with the verification result. The only exception is if an authentication error occurs (HTTP 401 Unauthorized) or if a request is made from an invalid IP address (HTTP 403 Forbidden).
If the request is processed correctly the result will always contain a subid
field that will identify the sending.
This is the complete response code list:
Error Code | Description |
---|---|
0 | Message has been successfully sent |
21 | The message element cannot be empty |
22 | Message too long. There is a limit of 160 7-bit characters |
23 | There are no recipients |
24 | Too many recipients |
25 | TPOA is exceeding max length |
26 | TPOA change is not allowed for this account |
27 | This message contained one or more invalid character(s) |
28 | Subid is exceeding maximum length |
30 | There was an error while sending the message |
31 | AckLevel has been given but missing AckUrl |
32 | AckUrl has been given but missing AckLevel |
33 | An unknown value for AckLevel has been given. Allowed values are gateway, operator or handset. |
34 | Label field too long |
35 | The account has no enough credit for this sending |
36 | Msisdn format [number] is not allowed |
37 | The account has reach the maximum messages per day |
38 | There was an error while sending the message to this MSISDNs (‘ |
39 | The value of the Scheduled field is not a valid datetime format |
40 | The username cannot send scheduled messages |
41 | Scheduled messages cannot be send in test mode |
52 | Scheduled messages not found. |
400 | Bad Request |
401 | Unauthorized |
403 | Forbidden |
500 | Internal error |
Changelog
v2.01 2018-03-19
- Initial JSON API.
v2.2 2019-05-27
- Added
parameters
to the Request parameters in Send SMS command.
v2.3 2019-09-20
- Added
crt_id
andcrt_name
to the Request parameters in Send SMS command.
v2.4 2019-10-10
- Added HRL Request and Get HLR results commands.
v2.5 2019-12-03
- Improved Javascript examples.
- Added Postman collection file.
v2.5.2 2021-02-16
- Added Python 3 code examples