Create a Subaccount

Request

POST https://api.46elks.com/a1/subaccounts

Request parameters

Parameter Description
name The name of the subaccount

Sample code

curl https://api.46elks.com/a1/subaccounts \
  -u <Username>:<API Password> \
  -d name=CompanyXYZ \
  -d usagelimit=9000000 
import HTTPotion.base
authdata = [basic_auth: {'',

request = %{
            "name"    => "CompanyXYZ",
            "usagelimit"      => "9000000"
           }

request_data = URI.encode_query(request)

HTTPotion.start
HTTPotion.post("https://api.46elks.com/a1/subaccounts",
  [body: request_data , ibrowse: authdata]
)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

public class UnirestSendcalls {
  public static void main(String[] args) {
    try {
      System.out.println("Sending calls");

      HttpResponse response = Unirest.post("https://api.46elks.com/a1/subaccounts")
        .basicAuth("","")
        .field("usagelimit", "9000000")
        .field("name", "CompanyXYZ")
        .asString();

      System.out.println(response.getBody());
      }

    catch (Exception e){
        System.out.println(e);
    }
  }
}
function allocatenumber ($calls) {
  $username = "USERNAME";
  $password = "PASSWORD";
  $context = stream_context_create(array(
    'http' => array(
      'method' => 'POST',
      'header'  => 'Authorization: Basic '.
                   base64_encode($username.':'.$password). "\r\n".
                   "Content-type: application/x-www-form-urlencoded\r\n",
      'content' => http_build_query($calls,'','&'),
      'timeout' => 10
  )));
  $response = file_get_contents("https://api.46elks.com/a1/subaccounts",
    false, $context);

  if (!strstr($http_response_header[0],"200 OK"))
    return $http_response_header[0];
  return $response;
}
$number = array(
  "name" => "CompanyXYZ",
  "usagelimit" => "9000000"
);
echo allocatenumber($number);
import requests

auth = (
    '',
    ''
    )

fields = {
    'name': 'CompanyXYZ',
    'usagelimit': '9000000'
    }

response = requests.post(
    "https://api.46elks.com/a1/subaccounts",
    data=fields,
    auth=auth
    )

print(response.text)
require 'net/http'

uri = URI('https://api.46elks.com/a1/subaccounts')
req = Net::HTTP::Post.new(uri)
req.basic_auth '', ''
req.set_form_data(
  :name => 'CompanyXYZ',
  :usagelimit => '9000000'
)

res = Net::HTTP.start(
    uri.host,
    uri.port,
    :use_ssl => uri.scheme == 'https') do |http|
  http.request req
end

puts res.body

More examples
C - C# - Go - Google App Script - Haskell - Node.js - Postman

Optional request parameters

Parameter Description
usagelimit This will limit the amount of traffic the subaccount can send.

Response structure

Example JSON response
{
  "secret": "D81DEF1B65E19A83DBCEA0BE0D89D082",
  "created": "2014-12-08T13:18:07.625000",
  "id": "af3d05a159669e1951c5301bc6a61bac",
  "name": "This Co2"
}
Parameter Type Description
id string ID of the subaccount, used as API username for requests by the subaccount.
secret string The secret of the account, used as API password for requests by the subaccount.
name string Name of the account.
created string Time and date when the account was created.