Create subaccount

Create a new subaccount.

Endpoint

https://api.gateway360.com/api/3.0/subaccount/create

Request

api_key Parent account API Key.
user_name Username for the subaccount.
email Email for the subaccount.
name Name of the user of the subaccount.
surname Surname of the user of the subaccount.
password Password for the subaccount.
language Subaccount language.
Mandatory
Optional
{
	"api_key":"399d2b438a53ebed3db8a7d52107f846",
	"user_name":"new_subaccount_user_name",
	"email":"me@email.com",
	"name":"John",
	"surname":"Doe",
	"password":"new_subaccount_password",
	"language":"es"
}
curl -X POST \
 -H 'Content-Type: application/json' \
 -H 'Accept: application/json' \
 -d '{
	"api_key":"399d2b438a53ebed3db8a7d52107f846",
	"user_name":"new_subaccount_user_name",
	"email":"me@email.com",
	"name":"John",
	"surname":"Doe",
	"password":"new_subaccount_password",
	"language":"es"
}' https://api.gateway360.com/api/3.0/subaccount/create
$request = '{
	"api_key":"399d2b438a53ebed3db8a7d52107f846",
	"user_name":"new_subaccount_user_name",
	"email":"me@email.com",
	"name":"John",
	"surname":"Doe",
	"password":"new_subaccount_password",
	"language":"es"
}';

$headers = array('Content-Type: application/json');            

$ch = curl_init('https://api.gateway360.com/api/3.0/subaccount/create');

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);

$result = curl_exec($ch);

if( !curl_errno($ch) )
    $result = json_decode($result);
else
    $result = curl_error($ch);
    
print_r($result);
/** Imports */
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
/** End imports */


HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("https://api.gateway360.com/api/3.0/subaccount/create");

StringEntity params = new StringEntity(
"{" +
"    \"api_key\":\"399d2b438a53ebed3db8a7d52107f846\"," +
"    \"user_name\":\"new_subaccount_user_name\"," +
"    \"email\":\"me@email.com\"," +
"    \"name\":\"John\"," +
"    \"surname\":\"Doe\"," +
"    \"password\":\"new_subaccount_password\"," +
"    \"language\":\"es\"" +
"}");

request.addHeader("content-type", "application/json");
request.addHeader("Accept","application/json");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
require 'uri'
require 'net/http'

url = URI("https://api.gateway360.com/api/3.0/subaccount/create")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["accept"] = 'application/json'

request.body = '{
	"api_key":"399d2b438a53ebed3db8a7d52107f846",
	"user_name":"new_subaccount_user_name",
	"email":"me@email.com",
	"name":"John",
	"surname":"Doe",
	"password":"new_subaccount_password",
	"language":"es"
}'

response = http.request(request)
puts response.read_body
conn = http.client.HTTPSConnection("api.gateway360.com")

payload = '{
	"api_key":"399d2b438a53ebed3db8a7d52107f846",
	"user_name":"new_subaccount_user_name",
	"email":"me@email.com",
	"name":"John",
	"surname":"Doe",
	"password":"new_subaccount_password",
	"language":"es"
}'

headers = {
    'content-type': "application/json",
    'accept': "application/json"
    }

conn.request("POST", "/api/3.0/subaccount/create", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
var client = new RestClient("https://api.gateway360.com/api/3.0/subaccount/create");

var request = new RestRequest(Method.POST);
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", '{
	"api_key":"399d2b438a53ebed3db8a7d52107f846",
	"user_name":"new_subaccount_user_name",
	"email":"me@email.com",
	"name":"John",
	"surname":"Doe",
	"password":"new_subaccount_password",
	"language":"es"
}', ParameterType.RequestBody);

IRestResponse response = client.Execute(request);
Private Sub Command1_Click()
Dim objHTTP As Object
Dim Json As String
Dim result As String


    Json = fJSON
    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    URl = "https://api.gateway360.com/api/3.0/subaccount/create"
    objHTTP.Open "POST", URl, False
    objHTTP.setRequestHeader "Content-type", "application/json"
    objHTTP.send (Json)
    result = objHTTP.responseText
   Set objHTTP = Nothing
End Sub

Private Function fJSON() As String
    fJSON = "{"
    fJSON = fJSON & """api_key"":""399d2b438a53ebed3db8a7d52107f846"","
    fJSON = fJSON & """user_name"":""new_subaccount_user_name"","
    fJSON = fJSON & """email"":""me@email.com"","
    fJSON = fJSON & """name"":""John"","
    fJSON = fJSON & """surname"":""Doe"","
    fJSON = fJSON & """password"":""new_subaccount_password"","
    fJSON = fJSON & """language"":""es"""
    fJSON = fJSON & "}"
End Function
var data = JSON.stringify({
	"api_key":"399d2b438a53ebed3db8a7d52107f846",
	"user_name":"new_subaccount_user_name",
	"email":"me@email.com",
	"name":"John",
	"surname":"Doe",
	"password":"new_subaccount_password",
	"language":"es"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.gateway360.com/api/3.0/subaccount/create");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("accept", "application/json");

xhr.send(data);

Response

status The sending status of request - either "ok", "error"
result Object with the result.
user_name The username of the new subaccount
password The password introduced in the request or, if it was empty, the password auto-generated
api_key Subaccount API key
error_id In case the status values "error" we will indicate you here the error id.
error_msg In case the status values "error" this param has additional information. This param should be use just for debugging.
200 OK
{
    "status":"ok",
    "result":{
        "user_name":"new_subaccount_user_name",
        "password":"new_subaccount_password",
        "api_key":"1234abcd5678efgh0db8a9d48100f123"
    }
}
The user new_subaccount_user_name with password new_subaccount_password has been created.
401 Unauthorized
{
    "status":"error",
    "error_id":"UNAUTHORIZED",
    "error_msg":"Your API key may be invalid or your IP is blocked."
}
We didn't continue processing your request because your API Key wasn't valid.
400 Bad Request
{
    "status":"error",
    "error_id":"JSON_PARSE_ERROR",
    "error_msg":"Your JSON was formatted incorrectly."
}
We couldn't process your request.
400 Bad Request
{
    "status":"error",
    "error_id":"INVALID_NAME",
    "error_msg":"You can't keep a sub-account with that username."
}
We didn't continue processing your request because the new username wasn't valid. May be it was repeated
400 Bad Request
{
    "status":"error",
    "error_id":"INVALID_LANGUAGE",
    "error_msg":"Language not supported."
}
We didn't continue processing your request because the language wasn't valid.

Errors

Error ID Explanation
INVALID_CONTENT_TYPE The content type must be: Content-Type: application/json
JSON_PARSE_ERROR Your JSON was formatted incorrectly or was considered otherwise improper or incomplete. Check it here.
MISSING_PARAMS Your request is incomplete and missing some mandatory parameters.
UNAUTHORIZED Your API key may be invalid, double-check that your API key was input correctly or see if your current IP is blocked in your account API settings.
INVALID_NAME The new username is invalid, there may be a user with that username.
INVALID_EMAIL The new email has an incorrect format.
INVALID_LANGUAGE Language not supported.