cPanel & WHM Version
96.0.11
Jun 23, 2021
1
0
1
South Africa
cPanel Access Level
DataCenter Provider
Hello guys,

What authentication method must be used in Postman to connect to UAPI?

The documentation here did not specify:

They did say:
Code:
curl -H'Authorization: cpanel username:APITOKEN' 'https://example.com:2083/execute/Module/function?parameter=value'
However this did not work


Code:
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://srvyyy.xxx.co.za:2083/execute/Contactus/is_enabled',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => array(
        'Authorization: cpanel ixxx1:FHNGxxxxxxxxxxxxGO5'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
All help will be appreciated.

What I want to achieve is:

Create a subdomains & Databases on Cpanel Server A (hosted at xyz), from Cpanel Server B (hosted my Raspberry Pi in my House).

I'd prefer to use UAPI, but if that is not possible, please suggest an alternative API to use.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,188
790
313
cPanel Access Level
Root Administrator
Hey there! API tokens are not used for the cPanel API, but only for root WHMAPI functions, so you wouldn't be able to use a token for this work. We have some additional details on the authentication tools available here: cPanel API Authentication questions

Can you work through that and see if that clears things up?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,188
790
313
cPanel Access Level
Root Administrator
@Ram Freedman - I don't know what me from a week ago was thinking, but the API tokens are definitely the way to go! I must have mis-read something that day.

I can't say how they would get integrated with Postman though, since that isn't something we make or support on our side. If you're performing the query remotely I would expect the example you provided to work (curl -H'Authorization: cpanel username:APITOKEN' 'https://example.com:2083/execute/Module/function?parameter=value') although I can't say for sure how to integrate that within PHP.