ES

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.

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 element cmd 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.

Example XML
<?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:

Example XML
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <code>0</code>
  <message>Command has been successfully processed</message>
</response>
</cmd>
Individual sending
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 element cmd 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.

Example XML
<?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:

Example XML
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <code>148</code>
  <message>Not enough credits to perform the adding command</message>
</response>
</cmd>
Individual sending
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 element cmd 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 values
    0Disable account
    1Enable account
    2Delete account
Example XML
<?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:

Example XML
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <code>147</code>
  <message>Trying to update a non-existing account</message>
</response>
</cmd>
Individual sending
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 response codes
HTTP CodeXML CodeDescription
200 OK0Command processed correctly
400 Bad Request130Internal or unexpected error
400 Bad Request141Required parameter not found in XML
400 Bad Request142Error in XML format
400 Bad Request143Parameter login not found
400 Bad Request144Parameter pwd not found
400 Bad Request145Parameter message message not found
400 Bad Request146Parameter status not found
400 Bad Request147Error modifying a non-existent account
400 Bad Request148There are not enough credits for this operation
400 Bad Request150Existing account with the same username
401 Bad Unauthorized151Incorrect credentials
401 Bad Unauthorized152No credentials found