How do I provision a hosting package via the API?

Andrew Porter
Published: 26 March 2020
Share:
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?
POST /reseller/{id}/addWeb

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:

require_once "vendor/autoload.php"; //We specify the API wrapper location.
$bearer_token = "INSERT YOUR GENERAL API KEY"; //Your 20i API key.
$services_api = new \TwentyI\API\Services($bearer_token);
$domain = "test20i.com"; //The primary domain we wish to assign to our new package.
$addPackage = ["domain_name" => $domain, "type" => "811"]; //These are our supported arguments. For example, the name of the package we've just defined, and the package type we'd like to create the package as.
$response = $services_api->postWithFields("/reseller/*/addWeb", $addPackage);

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.

 

Add a hosting package via the API