API Questions
How do I retrieve a list of packages via the API?
What is the 20i Reseller Hosting API?
The 20i Reseller API gives you access to all the features and functionality of StackCP, allowing you to create a hosting control panel from scratch or integrate external services such as WHMCS.
This is for advanced hosting resellers and the support we provide for the Reseller API is service-based only.
How to retrieve a list of packages via the API?
An array of objects will be returned, the objects pertaining to current hosting packages held within the 20i account.
PHP examples use our API wrapper, which can be downloaded here: https://my.20i.com/reseller/api
PHP
Request:
Result:
[
{
"id": 797701,
"created": "2020-01-15T16:30:30+00:00",
"enabled": true,
"name": "20i-wp.com",
"names": [
"20i-wp.com"
],
"packageTypeName": "Linux Unlimited",
"productSpec": null,
"stackUsers": [
"stack-user:989901"
],
"typeRef": 811,
"packageLabels": []
},
{
"id": 527649,
"created": "2019-03-14T18:43:17+00:00",
"enabled": true,
"name": "20iclone.com",
"names": [
"20iclone.com"
],
"packageTypeName": "Unlimited Hosting",
"productSpec": null,
"stackUsers": [
"stack-user:612771"
],
"typeRef": 814,
"packageLabels": []
},
{
"id": 32025,
"created": "2017-04-10T09:41:44+00:00",
"enabled": true,
"name": "20isupport.com",
"names": [
"20isupport.com",
"tools.20isupport.com"
],
"packageTypeName": "Linux Unlimited",
"productSpec": null,
"stackUsers": [
"stack-user:33487"
],
"typeRef": 811,
"packageLabels": []
}
The response, shows a list of hosting packages and various other details about each package instance. For example, in the response, we can see the name and id of packages, the name of the package type the package is assigned-to, as well as any StackUsers assigned to those packages.
Andrew PorterHow do I provision a mailbox via the API?
What is the 20i Reseller Hosting API?
The 20i Reseller API gives you access to all the features and functionality of StackCP, allowing you to create a hosting control panel from scratch or integrate external services such as WHMCS.
This is for advanced web hosting resellers and the support we provide for the Reseller API is service-based only.
How to provision a mailbox via the API?
This endpoint permits the creation of mail objects, for example, mailboxes, and email forwarders.
The example below details an example payload for the creation of a mailbox.
PHP examples use our API wrapper, which can be downloaded here: https://my.20i.com/reseller/api
PHP
Request:
require_once "vendor/autoload.php";
$bearer_token = "INSERT API KEY"; //Your 20i API key.
$services_api = new \TwentyI\API\Services($bearer_token);
$packageId = "32025"; //The ID of the 20i package you wish to provision a mail object to.
$domain = "20isupport.com"; //The intended domain.
$prefix = "info"; //The prefix for the mailbox/mail object.
$password = "Password123"; //In this example, this is the password you wish to set for the mailbox.
$newMailbox = ["new" => ["mailbox" => ["local" => $prefix, "send" => "true", "receive" => "true", "password" => $password ] ] ];
$response = json_encode($services_api->postWithFields("/package/$packageId/email/$domain", $newMailbox), JSON_PRETTY_PRINT);
print_r($response);
Response:
{
"result": {
"result": [
{
"type": "mailbox",
"id": "info",
"generatedId": null,
"password": "Password123"
}
],
"name": "20isupport.com"
}
}
The response indicates that a mailbox object has been created with the details we specified in our payload. The mailbox can then be accessed as usual via the 20i control panel.
Andrew PorterHow do I retrieve a list of StackCP Users using the API?
What is the 20i Reseller Hosting API?
The 20i Reseller API gives you access to all the features and functionality of StackCP, allowing you to create a hosting control panel from scratch or integrate external services such as WHMCS.
This is for advanced reseller hosting users and the support we provide for the Reseller API is service-based only.
How to retrieve a list of StackCP users using the API?
This endpoint can be used to get information about StackCP Users within a 20i account. Specifically, the response will contain an array of objects detailing the contact(s) assigned to the StackCP User(s), and a grant map of services the StackCP User has been assigned to.
PHP examples use our API wrapper, which can be downloaded here: https://my.20i.com/reseller/api
PHP
Request:
Result:
{
"contact": {
"stack-user:808833": {
"address": "Hawthorn House\nSouthwell Road West\n",
"avatarUrl": "",
"cc": "GBR",
"ccAlpha2": "GB",
"ccAlpha3": "GBR",
"city": "Rainworth, Mansfield",
"company_name": "",
"company_number": "",
"createdAt": "2019-08-20T19:55:56+00:00",
"email": "supportteam@example.com",
"ext_billing_ref": null,
"nominet_contact_type": "IND",
"notes": "",
"pc": "NG21 0HJ",
"person_name": "20i Ltd",
"sp": "Nottinghamshire",
"trading_name": "",
"voice": "+44.800000000",
"firstName": "20i",
"lastName": "Ltd"
}
},
"grant_map": {
"stack-user:74562": {
"package:2680": 1,
"package:208423": 1,
"package:6463": 1,
"package:593453": 1,
"package:593459": 1,
"domain:6535": 1,
"package:32025": 1,
"vps:2301": 1,
"package:93517": 1,
"package:797247": 1
},
If an object needs to be accessed specifically, we can specify this as follows:
$sUsers->contact
This would then have the effect of only showing the contact object.

Andrew PorterHow do I provision a hosting package via the API?
What is the 20i Reseller Hosting API?
The 20i Reseller API gives you access to all the features and functionality of StackCP, allowing you to create a hosting control panel from scratch or integrate external services such as WHMCS.
This is for advanced reseller hosting users and the support we provide for the Reseller API is service-based only.
How to provision a hosting package via the API?
The /reseller/{id}/addWeb endpoint permits the creation of hosting packages.
PHP examples use our API wrapper, which can be downloaded here: https://my.20i.com/reseller/api
PHP
Request:
Result:
{
"result": 866239
}
The response will contain the ID of the newly created package.
Supported arguments
| "type" | string |
A web type reference, equivalent to the id in /packageTypes |
| "domain_name" | string |
The initial domain name for the site |
| "extra_domain_names" | string[] |
Array of zero or more extra domain names |
| "label" | string |
The memorable name for the package |
| "documentRoots" | object |
A map of domain names to intended document roots |
| "stackUser" | string|null |
eg. "stack-user:1". An existing Stack user to link to the package. |

Andrew PorterHow do I use the API with my Cloud Hosting?
It’s possible to set up your new Cloud Hosting using the Reseller API – doing so can allow you to automate functionality such as creating packages, activating services or resetting your cloud profiles. A full list of available endpoints, as well as full code examples for each is available within our API Documentation.
require_once "vendor/autoload.php"; //We specify the API wrapper location. $bearer_token = "YOUR API KEY"; //Your 20i API key. $services_api = new \TwentyI\API\Services($bearer_token); $response = $services_api→getWithFields("/cloud_server");Result:
The response will contain details on your Cloud Server with an array, including the ID. Make note of that ID, as you’ll need it to make requests to that specific Cloud setup, such as for creating a package. For example:
Array
(
[0] => stdClass Object
(
[configuration] => stdClass Object
(
[CpuCores] => 1
[RamMb] => 1024
[OsDiskSizeGb] => 25
[DataDiskSizeGb] => 0
[Provider] => 20i
[Zone] => 20i
[Country] => GB
[VpsOsId] => 1
[spec] => micro
)
[externalId] => 1111
[location] => dc_location-uk
[name] => vps-123456.mvps.stackcp.net
[productSpec] => cloud-20i
[count] => INF
[cpanel] =>
[cpanelInfo] =>
[cpanelRebuilding] =>
[id] => 1111
[isCloud] => 1
[isManaged] => 1
[packageIds] => Array
(
)
[profileId] => 1
[timelineService] => normal
)
)How do I create a package on my Cloud Server using the API?
Now that we have our ID, we can now make use of it to create our first package. We can do this using the following endpoint:
POST /cloud_server/cloudServerId/addWeb
The below code is how we’d call for that endpoint using PHP:
PHP
Request:
<?php
require_once "vendor/autoload.php"; //We specify the API wrapper location.
$bearer_token = "YOUR API KEY"; //Your 20i API key.
$services_api = new \TwentyI\API\Services($bearer_token);
$domain = "myclouddomain.com"; //The primary domain we wish to assign to our new package.
$extra_domain_names = []; // Any extra domains we wish to assign to the package as an array.
$addPackage = ["domain_name" => $domain, "extra_domain_names" => $extra_domain_names];
// The constructed payload for the endpoint, containing the domains and extra domains for the package.
$response = $services_api->postWithFields("/cloud_server/4838/addWeb", $addPackage);Result:
The response will contain the ID of your newly created package on your Cloud Server, returned as an object:
stdClass Object
(
[result] => 1234567
)And your new package should show in the Manage Cloud Hosting area of My20i, ready to use.
Further endpoints and code examples are available within the API Documentation available in My20i for your perusal, and the above should help you with getting started with this approach to Cloud Server hosting and provisioning – happy coding!
Ruth TurnerUsing the Browser Console to view API calls in 20i API
The 20i Reseller API is a powerful tool that will allow you to take advantage of all the features and functionality of StackCP, allowing for the creation of your own customised hosting control panel from the ground up or the possibility to seamlessly integrate external services to build upon your existing systems. Making use of the API can also make the management of your Reseller hosting more efficient by allowing you to automate repetitive tasks.
We do provide in-depth API documentation. You can access the API documentation directly from your account by navigating to Manage Reseller > API > View Documentation.
Our documentation covers the functions which we deem the most critical and those most commonly used to allow you to manage your Reseller hosting. However, there are certain functions and use cases, where the API documentation will not provide all the information you require. In these cases it is possible to reverse engineer these API calls to be able to implement these yourself.
Making use of the browser console to view API Calls.
Almost every action on our platform has an associated API call, and whilst our documentation does not cover all of these you can figure out these API calls yourself using the browser console.
On Windows, you can access the browser console by pressing F12, and we are specifically looking for the Network tab. This tab will record all requests and their responses that happen while it is open. We can use the information in the Network tab to figure out the API endpoint, as well as the payload used in certain actions. Let us take adding an email forwarder as an example. If you navigate to a package, and go to the Email Forwarder section. With the Network tab open, if you then add a forwarder, you should see a response appear that is titled yourdomain.com. If you click on this request you should see then see the Headers of the request.
From the headers section, you will want to make note of the Request URL as part of this will be used as the endpoint. This example, it is specifically the package/2706442/email/20itesting.com section. To get the full API Endpoint, you will want to add that section to the URL https://api.20i.com/. You can use this to get a general endpoint which would be something along the lines of https://api.20i.com/package/$packageID/email/$domainName.
Now that we have the endpoint for a given request, we need to retrieve the payload. If you click on the Payload tab, just next to the header one you will see something similar to the following.
In this case, the raw payload is: {"new":{"forward":{"local":"enquiries","remote":"testing@20i.com"}}}.
From this, we can get a general payload of {"new":{"forward":{"local":"$mailboxToForward","remote":"$destinationAddress"}}}. Another common way of writing this would be:
["new" =>
["forward" =>
["local" => "$mailboxToForward",
"remote" => "$destinationAddress"
]
]
]The process of retrieving the API end-point and payload is the same across the board and you can use it to figure out the API calls for those actions and functions that are not covered in our API documentation.
Josh SargentManaged Cloud Server API Guide
Contents
$general_api_key = "API_KEY"; $services_api = new \TwentyI\API\Services($general_api_key); $request = $services_api->postWithFields("/reseller/{resellerId}/addCloudServer", [ "configuration" => [ "spec" => "string", "zone" => "string", "bandwidth" => "string", "disk" => "string", "provider" => "string", "mvpsName" => "string", ], "periodMonths" => "string", "type" => "string", "forUser" => "string", ]);Cloud Server Specifications
20iCloud/Reseller Branded Specifications:
| Spec | CPU | RAM | Disk | Bandwidth |
| micro | 1 | 1 | 25 | 1000 |
| small | 1 | 2 | 50 | 2000 |
| medium | 2 | 4 | 80 | 4000 |
| large | 4 | 8 | 160 | 5000 |
| x-large | 8 | 16 | 320 | 10000 |
| 2x-large | 12 | 32 | 640 | 20000 |
| 4x-large | 16 | 32 | 640 | 30000 |
| 8x-large | 24 | 64 | 1280 | 40000 |
| 16x-large | 32 | 96 | 1440 | 40000 |
| 32x-large | 48 | 128 | 1920 | 40000 |
AWS Specifications:
| Spec | CPU | RAM | Disk | Bandwidth |
| micro | 2 | 1 | 20 | 2 |
| small | 2 | 2 | 20 | 2 |
| medium | 2 | 4 | 20 | 2 |
| large | 2 | 8 | 20 | 2 |
| x-large | 4 | 16 | 20 | 2 |
| 2x-large | 8 | 32 | 20 | 2 |
| 4x-large | 16 | 64 | 20 | 2 |
| 8x-large | 32 | 128 | 20 | 2 |
Disk space
GCP Specifications:
| Spec | CPU | RAM | Disk | Bandwidth |
| micro | 1 | 3.75 | 20 | 2 |
| small | 2 | 8 | 20 | 2 |
| medium | 4 | 16 | 20 | 2 |
| large | 8 | 32 | 20 | 2 |
| x-large | 16 | 64 | 20 | 2 |
| 2x-large | 32 | 128 | 20 | 2 |
| 4x-large | 48 | 192 | 20 | 2 |
| 8x-large | 64 | 256 | 20 | 2 |
Cloud Server Locations
20iCloud Locations:
- London, England (dc_location-uk)
- Dallas TX, USA (dc_location-usa)
AWS Locations:
- North Virginia, USA (us-east-1)
- Ohio, USA (us-east-2)
- North California, USA (us-west-1)
- Oregon, USA (us-west-2)
- Mumbai, India (ap-south-1)
- Hyderabad, India (ap-south-2)
- Tokyo, Japan (ap-northeast-1)
- Seoul, South Korea (ap-northeast-2)
- Osaka, Japan (ap-northeast-3)
- Singapore, Asia (ap-southeast-1)
- Sydney, Australia (ap-southeast-2)
- Canada (Central) (ca-central-1)
- Frankfurt, Germany (eu-central-1)
- Dublin, Ireland (eu-west-1)
- London, UK (eu-west-2)
- Paris, France (eu-west-3)
- Stockholm, Sweden (eu-north-1)
- São Paulo, Brazil (sa-east-1)
- Hong Kong, Asia (ap-east-1)
- Cape Town, SA (af-south-1)
- Jakarta, Indonesia (ap-southeast-3)
- Melbourne, Australia (ap-southeast-4)
- Milan, Italy (eu-south-1)
- Zaragoza, Spain (eu-south-2)
- Zurich, Switzerland (eu-central-2)
- Bahrain (me-south-1)
- UAE (me-central-1)
GCP Locations:
- Changhua, Taiwan (asia-east1)
- Hong Kong, Asia (asia-east2)
- Tokyo, Japan (asia-northeast1)
- Osaka, Japan (asia-northeast2)
- Seoul, South Korea (asia-northeast3)
- Mumbai, India (asia-south1)
- Delhi, India (asia-south2)
- Singapore, Asia (asia-southeast1)
- Jakarta, Indonesia (asia-southeast2)
- Sydney, Australia (australia-southeast1)
- Melbourne, Australia (australia-southeast2)
- Warsaw, Poland (europe-central2)
- Hamina, Finland (europe-north1)
- Madrid, Spain (europe-southwest1)
- St. Ghislain, Belgium (europe-west1)
- Turin, Italy (europe-west12)
- London, England (europe-west2)
- Frankfurt, Germany (europe-west3)
- Eemshaven, Netherlands (europe-west4)
- Zurich, Switzerland (europe-west6)
- Milan, Italy (europe-west8)
- Paris, France (europe-west9)
- Tel Aviv, Israel (me-west1)
- Montréal, Québec (northamerica-northeast1)
- Toronto, Ontario (northamerica-northeast2)
- São Paulo, Brazil (southamerica-east1)
- Santiago, Chile (southamerica-west1)
- Iowa, USA (us-central1)
- South Carolina, USA (us-east1)
- Virginia, USA (us-east4)
- Ohio, USA (us-east5)
- Texas, USA (us-south1)
- Oregon, USA (us-west1)
- California, USA (us-west2)
- Utah, USA (us-west3)
- Nevada, USA (us-west4)
Setting your Brand Name and Cloud Server Logo
If you want to sell Cloud Servers (20iCloud) under your own brand you need to set your brand name and logo from Your Brand in My20i. These will be returned in the response headers when querying the Cloud Server ID, and returned within the StackCP management interface.
Provisioning Cloud Servers under your Own Brand
To use your brand name and logo to replace the 20iCloud text and logo, you can can set the resellerCloudBranded parameter in the configuration to true:
<?php
$general_api_key = "API_KEY";
$services_api = new \TwentyI\API\Services($general_api_key);
$request = $services_api->postWithFields("/reseller/{resellerId}/addCloudServer", [
"configuration" => [
"spec" => "string",
"zone" => "string",
"bandwidth" => "string",
"disk" => "string",
"provider" => "string",
"mvpsName" => "string",
"resellerCloudBranded" => true
],
"periodMonths" => "string",
"type" => "string",
"forUser" => "string",
]);
Austin B.
Dominic Elford