Subaccount Create
The Subaccount Create method allows you to create a subaccount for your master account without the need to do it through admin panel, with just a single request. Subaccounts can be useful in multi-level projects that require separation and for the convenience of managing such large projects.
IMPORTANT: This method allows the use of a Web Hook, but the data about the successful creation request is sent when the system has fully created the sub-account and it is ready for use.
Request
IMPORTANT: Do not send more than 10 concurrent API requests.
Body Example
{
"subAccount": {
"subscription": "month",
"country": "EE",
"name": "ApiSubAccount",
"timezone": "Europe/Tallinn"
},
"owner": {
"email": "subaccount@domain.test",
"password": "password",
"firstName": "John",
"lastName": "Smith"
},
"webHookUri": "YOUR_WEBHOOK_URI"
}
Parameters
Title | Type | Default | Description |
---|---|---|---|
subAccount required
|
object |
Object containing the details needed to create a sub-account. |
|
subAccount.name required
|
string |
Name of the sub-account that will be created. Must be unique within your account. |
|
subAccount.subscription required
|
string |
The subscription type of the sub-account that will be created. The pricing plan is set when enabling the functionality to create sub-accounts via API. For any changes, please contact our support team support@wooxy.com. |
|
subAccount.country required
|
string |
The country of the sub-account should be specified. To specify the date, the correct ISO 3166-1 alpha-2 format must be used. |
|
subAccount.timezone required
|
string |
The time zone of your sub-account. |
|
owner required
|
object |
Object with sub-account owner user parameters. |
|
owner.email required
|
string |
Email address of the sub-account owner. |
|
owner.password required
|
string |
Password for your sub-account. |
|
owner.firstName required
|
string |
First name of your sub-account owner. |
|
owner.lastName required
|
string |
Last name of your sub-account owner. |
|
webHookUri optional
|
string |
webHookURL - A parameter that specifies the webhook address where you'll receive notifications about sub-account creation status. Important! The Web Hook is sent after the sub-account creation is completed in Wooxy system. |
Response
{ "result": true }
Parameters
Title | Type | Description |
---|---|---|
result |
boolean |
Indicated that the query was successful or not:
|
Method Errors
{
"result": false,
"error": [
"Error description text"
]
}
Error |
---|
"Argument subAccount must be an object" |
"Argument name must be a string" |
"Argument name must be a non-empty string" |
"Argument name must be a string with max length within 250 characters" |
"Invalid subscription type. Allowed: month, year" |
"Invalid ISO alpha 2 country code" |
"Argument timezone must be a valid timezone string" |
"Argument owner must be an object" |
"Argument email must be a non-empty string" |
"Invalid RFC2822 email {email}" |
"Argument password must be a string" |
"Argument password must be a non-empty string" |
"Argument password must be a string with max length within 64 characters" |
"Argument firstName must be a string" |
"Argument firstName must be a non-empty string" |
"Argument firstName must be a string with max length within 250 characters" |
"Argument lastName must be a string" |
"Argument lastName must be a non-empty string" |
"Argument lastName must be a string with max length within 250 characters" |
"Argument webHookUri must be a non-empty string" |
"Argument webHookUri must be a valid URI" |
"Argument webHookUri can not be longer than 2048" |
"You are not allowed to use this API method" |
"There is no defined billing plan for your subaccounts. Please contact our support" |
"Payment required" |
"User email {email} is already registered. Try another one" |
"Account with name {name} is already registered. Try another one" |
"Invalid authorization token!" |
"Internal server error" |
"Bad Request" |
"no matches found for access token {accessToken}" |
"user {id} not enabled" |
"no data found for key {userId}" |
"access token check failed for key/secret $key/$accessToken" |
"Argument {argument} required" |
Code Examples
$accessToken = 'YOUR_API_KEY';
$url = 'https://api.wooxy.com/v3/subaccount/create';
$body = json_encode([
'subAccount' => [
'subscription' => 'month',
'country' => 'EE',
'name' => 'ApiSubAccount',
'timezone' => 'Europe/Tallinn',
],
'owner' => [
'email' => 'subaccount@domain.test',
'password' => 'password',
'firstName' => 'John',
'lastName' => 'Smith',
],
'webHookUri' => 'YOUR_WEBHOOK_URI',
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Access-Token: $accessToken",
'Content-Type: application/json',
'Content-Length: ' . strlen($body),
]);
$result = curl_exec($ch);
if ($result === false) {
echo 'cURL error: ' . curl_error($ch) . PHP_EOL;
} else {
echo strval($result) . PHP_EOL;
}
curl_close($ch);