How do I retrieve a list of StackCP Users using 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 retrieve a list of StackCP users using the API?

GET  /reseller/{id}/susers

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:

require "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);
$sUsers = $services_api->getWithFields("/reseller/*/susers";

return $sUsers;

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.