API Admin
The API Admin is designed for technicians and customers who want to manage sub-accounts.
The functions of the Admin API are:
- The creation and registration of subaccounts.
- Modification of the balance of subaccount receivables.
- Enable, disable and delete subaccounts.
To start an integration with the Admin API the following requirements are essential:
- A LabsMobile account associated with a username (registration email). Create an account here.
- API token used as password and generated from the API Settings section of your account.
- URL of the Admin API endpoint and the parameter values for making requests.
Postman API Admin collection
Download
To be taken into account
The LabsMobile API Admin uses HTTP POST parameters in XML format and a common base URL for all requests: https://api.labsmobile.com/admin/
.
Authentication
The authentication method used in any Admin API request is Basic Auth HTTP.
This type of authentication consists of username:tokenapi
credentials that are included in the HTTP request header encoded in base64()
.
Example of authentication header value:Authorization: Basic 9yewaXic21vYmlsZqS5jmSk04enFTbUU=
Recommendation You can generate API tokens from the API Settings of the account. We recommend changing the token frequently and using different tokens for each use, connection or integration.
Create an account
This command allows you to create a sub-account.
The sub-account created will be controlled by the administrator account that executes this function and the status and balance of credits can be modified through the functions of this API.
ENDPOINT
POST https://api.labsmobile.com/admin/cmd/cmd_createaccount.php
PARAMETERS
The parameters or data are sent in an http/POST variable named
XmlData
with the root elementcmd
and the other elements described below:login email mandatory
Username of the new account. This username can be used to access the WebSMS application or API.
pwd password mandatory
Password of the new account.
<?xml version="1.0" encoding="UTF-8"?> <cmd> <login>newaccount@test.com</login> <pwd>hteRW42w</pwd> </cmd>
RESULT
The result of any SMS http/POST API request is obtained in
XML
format with the root element<response>
and the following child elements:code integer
Identifier code indicating whether the request could be processed successfully or if an error occurred. Possible values in the Errors section.
Example:
<code>0</code>
.message string
Description indicating whether the request could be processed successfully or if an error occurred. Possible values in the Errors section.
Example:
<message>Parameter login not found in XML</message>
.
<?xml version="1.0" encoding="UTF-8"?> <response> <code>0</code> <message>Command has been successfully processed</message> </response> </cmd>
curl --user myUsername:myToken -X POST \ https://api.labsmobile.com/admin/cmd/cmd_createaccount.php \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'XmlData=<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><pwd>hteRW42w</pwd></cmd>'
#include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(curl, CURLOPT_URL, "https://api.labsmobile.com/admin/cmd/cmd_createaccount.php"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC); curl_easy_setopt(curl, CURLOPT_USERNAME, "myUsername"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "myToken"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); const char *data = 'XmlData=<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><pwd>hteRW42w</pwd></cmd>'; curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); res = curl_easy_perform(curl); if(res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); curl_easy_cleanup(curl); } return 0; }
using System; using RestSharp; namespace CreateAccount { class Program { static void MainSend(string[] args) { var client = new RestClient("https://api.labsmobile.com"); var request = new RestRequest("/admin/cmd/cmd_createaccount.php", Method.Post); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", "Basic " + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("myUsername" + ":" + "myToken"))); var body = @"XmlData=<?xml version=""1.0"" encoding=""UTF-8""?><cmd><login>newaccount@test.com</login><pwd>hteRW42w</pwd></cmd>"; request.AddParameter("application/x-www-form-urlencoded", body, ParameterType.RequestBody); RestResponse response = client.Execute(request); if (response.ErrorException != null) { Console.WriteLine("Error: " + response.ErrorException.Message); } else { Console.WriteLine("Response content: " + response.Content); } } } }
package com.example; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; import com.mashape.unirest.http.exceptions.UnirestException; public class App { public static void main(String[] args) throws UnirestException { Unirest.setTimeouts(0, 0); HttpResponse<String> response = Unirest.post("https://api.labsmobile.com/admin/cmd/cmd_createaccount.php") .header("Content-Type", "application/x-www-form-urlencoded") .basicAuth("myUsername", "myToken") .body("XmlData=<?xml version=\"1.0\" encoding=\"UTF-8\"?><cmd><login>newaccount@test.com</login><pwd>hteRW42w</pwd></cmd>") .asString(); System.out.println("Status code: " + response.getBody()); } }
<?php $curl = curl_init(); $xmlData = '<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><pwd>hteRW42w</pwd></cmd>'; $postFields = 'XmlData=' . $xmlData; $auth_basic = base64_encode("myUsername:myToken"); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.labsmobile.com/admin/cmd/cmd_createaccount.php', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $postFields, CURLOPT_HTTPHEADER => array( 'Content-Type: application/x-www-form-urlencoded', 'Authorization: Basic '. $auth_basic ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
import requests, base64, json userToken = "myUsername:myToken" credentials = (base64.b64encode(userToken.encode()).decode()) url = "https://api.labsmobile.com/admin/cmd/cmd_createaccount.php" payload = "XmlData=<?xml version=\"1.0\" encoding=\"UTF-8\"?><cmd><login>newaccount@test.com</login><pwd>hteRW42w</pwd></cmd>"headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic %s' % credentials, } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)
const axios = require('axios'); let data = 'XmlData=<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><pwd>hteRW42w</pwd></cmd>'; let config = { method: 'post', maxBodyLength: Infinity, url: 'https://api.labsmobile.com/admin/cmd/cmd_createaccount.php', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic ' + Buffer.from("myUsername:myToken").toString('base64') }, data : data }; axios.request(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); });
require "uri" require 'base64' require "net/http" url = URI("https://api.labsmobile.com/admin/cmd/cmd_createaccount.php") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = "application/x-www-form-urlencoded" request["Authorization"] = "Basic " + Base64.strict_encode64("myUsername:myToken") request.body = "XmlData=<?xml version=\"1.0\" encoding=\"UTF-8\"?><cmd><login>newaccount@test.com</login><pwd>hteRW42w</pwd></cmd>" response = https.request(request) puts response.read_body
Change balance
This command allows adding or subtracting credits to the balance of an existing subaccount controlled by the administrator account executing this call.
ENDPOINT
POST https://api.labsmobile.com/admin/cmd/.php
PARAMETERS
The parameters or data are sent in an http/POST variable named
XmlData
with the root elementcmd
and the other elements described below:login string mandatory
User name of the account to which you want to modify the credits.
messages float mandatory
Number of credits to be added or subtracted to the account.
<?xml version="1.0" encoding="UTF-8"?> <cmd> <login>newaccount@test.com</login> <messages>30</messages> </cmd>
RESULT
The result of any SMS http/POST API request is obtained in
XML
format with the root element<response>
and the following child elements:code integer
Identifier code indicating whether the request could be processed successfully or if an error occurred. Possible values in the Errors section.
Example:
<code>0</code>
.message string
Description indicating whether the request could be processed successfully or if an error occurred. Possible values in the Errors section.
Example:
<message>Command has been successfully processed</message>
.
<?xml version="1.0" encoding="UTF-8"?> <response> <code>148</code> <message>Not enough credits to perform the adding command</message> </response> </cmd>
curl --user myUsername:myToken -X POST \ https://api.labsmobile.com/admin/cmd/cmd_addbalance.php \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'XmlData=<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><messages>30</messages></cmd>'
#include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(curl, CURLOPT_URL, "https://api.labsmobile.com/admin/cmd/cmd_addbalance.php"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC); curl_easy_setopt(curl, CURLOPT_USERNAME, "myUsername"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "myToken"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); const char *data = 'XmlData=<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><messages>30</messages></cmd>'; curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); res = curl_easy_perform(curl); if(res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); curl_easy_cleanup(curl); } return 0; }
using System; using RestSharp; namespace AddBalance { class Program { static void MainSend(string[] args) { var client = new RestClient("https://api.labsmobile.com"); var request = new RestRequest("/admin/cmd/cmd_addbalance.php", Method.Post); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", "Basic " + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("myUsername" + ":" + "myToken"))); var body = @"XmlData=<?xml version=""1.0"" encoding=""UTF-8""?><cmd><login>newaccount@test.com</login><messages>30</messages></cmd>"; request.AddParameter("application/x-www-form-urlencoded", body, ParameterType.RequestBody); RestResponse response = client.Execute(request); if (response.ErrorException != null) { Console.WriteLine("Error: " + response.ErrorException.Message); } else { Console.WriteLine("Response content: " + response.Content); } } } }
package com.example; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; import com.mashape.unirest.http.exceptions.UnirestException; public class App { public static void main(String[] args) throws UnirestException { Unirest.setTimeouts(0, 0); HttpResponse<String> response = Unirest.post("https://api.labsmobile.com/admin/cmd/cmd_addbalance.php") .header("Content-Type", "application/x-www-form-urlencoded") .basicAuth("myUsername", "myToken") .body("XmlData=<?xml version=\"1.0\" encoding=\"UTF-8\"?><cmd><login>newaccount@test.com</login><messages>30</messages></cmd>") .asString(); System.out.println("Status code: " + response.getBody()); } }
<?php $curl = curl_init(); $xmlData = '<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><messages>30</messages></cmd>'; $postFields = 'XmlData=' . $xmlData; $auth_basic = base64_encode("myUsername:myToken"); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.labsmobile.com/admin/cmd/cmd_addbalance.php', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $postFields, CURLOPT_HTTPHEADER => array( 'Content-Type: application/x-www-form-urlencoded', 'Authorization: Basic '. $auth_basic ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
import requests, base64, json userToken = "myUsername:myToken" credentials = (base64.b64encode(userToken.encode()).decode()) url = "https://api.labsmobile.com/admin/cmd/cmd_addbalance.php" payload = payload = "XmlData=<?xml version=\"1.0\" encoding=\"UTF-8\"?><cmd><login>newaccount@test.com</login><messages>30</messages></cmd>" headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic %s' % credentials, } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)
const axios = require('axios'); let data = 'XmlData=<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><messages>30</messages></cmd>'; let config = { method: 'post', maxBodyLength: Infinity, url: 'https://api.labsmobile.com/admin/cmd/cmd_addbalance.php', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic ' + Buffer.from("myUsername:myToken").toString('base64') }, data : data }; axios.request(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); });
require "uri" require 'base64' require "net/http" url = URI("https://api.labsmobile.com/admin/cmd/cmd_addbalance.php") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = "application/x-www-form-urlencoded" request["Authorization"] = "Basic " + Base64.strict_encode64("myUsername:myToken") request.body = "XmlData=<?xml version=\"1.0\" encoding=\"UTF-8\"?><cmd><login>newaccount@test.com</login><messages>30</messages></cmd>" response = https.request(request) puts response.read_body
Modify account
This command allows modifying the status of an existing subaccount controlled by the administrator account executing this call.
ENDPOINT
POST https://api.labsmobile.com/admin/cmd/cmd_statusaccount.php
PARAMETERS
The parameters or data are sent in an http/POST variable named
XmlData
with the root elementcmd
and the other elements described below:login string mandatory
User name of the account whose status is to be changed.
status 0 | 1 | 2 mandatory
State to which you want to change the account.
Status values0
Disable account 1
Enable account 2
Delete account
<?xml version="1.0" encoding="UTF-8"?> <cmd> <login>newaccount@test.com</login> <status>0</status> </cmd>
RESULT
The result of any SMS http/POST API request is obtained in
XML
format with the root element<response>
and the following child elements:code integer
Identifier code indicating whether the request could be processed successfully or if an error occurred. Possible values in the Errors section.
Example:
<code>0</code>
.message string
Description indicating whether the request could be processed successfully or if an error occurred. Possible values in the Errors section.
Example:
<message>Command has been successfully processed</message>
.
<?xml version="1.0" encoding="UTF-8"?> <response> <code>147</code> <message>Trying to update a non-existing account</message> </response> </cmd>
curl --user myUsername:myToken -X POST \ https://api.labsmobile.com/admin/cmd/cmd_statusaccount.php \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'XmlData=<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><status>0</status></cmd>'
#include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(curl, CURLOPT_URL, "https://api.labsmobile.com/admin/cmd/cmd_statusaccount.php"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC); curl_easy_setopt(curl, CURLOPT_USERNAME, "myUsername"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "myToken"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); const char *data = '<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com<</login><status>0</status></cmd>'; curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); res = curl_easy_perform(curl); if(res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); curl_easy_cleanup(curl); } return 0; }
using System; using RestSharp; namespace Status { class Program { static void MainSend(string[] args) { var client = new RestClient("https://api.labsmobile.com"); var request = new RestRequest("/admin/cmd/cmd_statusaccount.php", Method.Post); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", "Basic " + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("myUsername" + ":" + "myToken"))); var body = @"XmlData=<?xml version=""1.0"" encoding=""UTF-8""?><cmd><login>newaccount@test.com</login><status>0</status></cmd>"; request.AddParameter("application/x-www-form-urlencoded", body, ParameterType.RequestBody); RestResponse response = client.Execute(request); if (response.ErrorException != null) { Console.WriteLine("Error: " + response.ErrorException.Message); } else { Console.WriteLine("Response content: " + response.Content); } } } }
package com.example; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; import com.mashape.unirest.http.exceptions.UnirestException; public class App { public static void main(String[] args) throws UnirestException { Unirest.setTimeouts(0, 0); HttpResponse<String> response = Unirest.post("https://api.labsmobile.com/admin/cmd/cmd_statusaccount.php") .header("Content-Type", "application/x-www-form-urlencoded") .basicAuth("myUsername", "myToken") .body("XmlData=<?xml version=\"1.0\" encoding=\"UTF-8\"?><cmd><login>newaccount@test.com</login><status>0</status></cmd>") .body() .asString(); System.out.println("Status code: " + response.getBody()); } }
<?php $curl = curl_init(); $xmlData = '<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com<</login><status>0</status></cmd>'; $postFields = 'XmlData=' . $xmlData; $auth_basic = base64_encode("myUsername:myToken"); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.labsmobile.com/admin/cmd/cmd_statusaccount.php', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $postFields, CURLOPT_HTTPHEADER => array( 'Content-Type: application/x-www-form-urlencoded', 'Authorization: Basic '. $auth_basic ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
import requests, base64, json userToken = "myUsername:myToken" credentials = (base64.b64encode(userToken.encode()).decode()) url = "https://api.labsmobile.com/admin/cmd/cmd_statusaccount.php" payload = "XmlData=<?xml version=\"1.0\" encoding=\"UTF-8\"?><cmd><login>newaccount@test.com</login><status>0</status></cmd>"headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic %s' % credentials, } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)
const axios = require('axios'); let data = 'XmlData=<?xml version="1.0" encoding="UTF-8"?><cmd><login>newaccount@test.com</login><status>0</status></cmd>'; let config = { method: 'post', maxBodyLength: Infinity, url: 'https://api.labsmobile.com/admin/cmd/cmd_statusaccount.php', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic ' + Buffer.from("myUsername:myToken").toString('base64') }, data : data }; axios.request(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); });
require "uri" require 'base64' require "net/http" url = URI("https://api.labsmobile.com/admin/cmd/cmd_statusaccount.php") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = "application/x-www-form-urlencoded" request["Authorization"] = "Basic " + Base64.strict_encode64("myUsername:myToken") request.body = "XmlData=<?xml version=\"1.0\" encoding=\"UTF-8\"?><cmd><login>newaccount@test.com</login><status>0</status></cmd>" response = https.request(request) puts response.read_body
Errors
The HTTP error codes that may be returned by a request to the Admin API are described below.
HTTP Code | XML Code | Description |
---|---|---|
200 OK | 0 | Command processed correctly |
400 Bad Request | 130 | Internal or unexpected error |
400 Bad Request | 141 | Required parameter not found in XML |
400 Bad Request | 142 | Error in XML format |
400 Bad Request | 143 | Parameter login not found |
400 Bad Request | 144 | Parameter pwd not found |
400 Bad Request | 145 | Parameter message message not found |
400 Bad Request | 146 | Parameter status not found |
400 Bad Request | 147 | Error modifying a non-existent account |
400 Bad Request | 148 | There are not enough credits for this operation |
400 Bad Request | 150 | Existing account with the same username |
401 Bad Unauthorized | 151 | Incorrect credentials |
401 Bad Unauthorized | 152 | No credentials found |
Support resources
We recommend that you consult and take into account the following support resources in your integration:
- Description, manual and code examples of the SMS sending API.
- Technical guide to an OTP validation or authentication process by SMS.
- All LabsMobile API versions and functionalities.
- First Steps to API Integration Tutorial
- Create a demo account
- Recommendations and best practices in any integration.
- Plugins, modules and extensions.
- Need help? Contact our technicians