Accessing CPanel UAPI from command line on Linux / Mac OS

chicagosky

Registered
Dec 8, 2014
2
0
1
cPanel Access Level
Website Owner
Hello

I am trying to access the CPanel UAPI functions via command line on Mac OS and am doing so using the below syntax
(am trying to add an email forwarder)

Code:
curl --user username:password -k  https://160.1.254.120:2083/execute/Email/add_forwarder?email=temp_forward&domain=mydomain.com&fwdopt=pipe&pipefwd=php/piper.php&
The response I get for this is as below
Code:
{"messages":null,"errors":null,"status":1,"metadata":{"transformed":1},"data":[]}
But when I check the cPanel, the new forwarder has not been added.

Am I doing something wrong?

Thanks in advance
 

AndrewH.

Well-Known Member
Dec 10, 2012
52
3
83
cPanel Access Level
Root Administrator
I tried running a similar command on my development box and got this response

Code:
devserver:2083/execute/Email/add_forwarder?email=reseller%40reseller.tld&fwdopt=pipe&pipefwd=echo
Code:
{"messages":null,"errors":null,"status":1,"metadata":{"transformed":1},"data":[{"email":"[email protected]","domain":"reseller.tld","forward":"|/home/reseller/echo"}]}
I also did this command to match yours

Code:
devserver:2083/execute/Email/add_forwarder?email=reseller&fwdopt=pipe&pipefwd=echo&domain=reseller.tld
Code:
{"messages":null,"errors":null,"status":1,"metadata":{"transformed":1},"data":[{"email":"[email protected]","domain":"reseller.tld","forward":"|/home/reseller/echo"}]}
and had success as well.

Now when I tried an account that I didn't have access to I got this response

Code:
devserver:2083/execute/Email/add_forwarder?email=reseller&fwdopt=pipe&pipefwd=echo&domain=notsomethingiown.tld
Code:
{"messages":null,"errors":["Error opening “/etc/valiases/notsomethingiown.tld” to write: Permission denied at /usr/local/cpanel/Cpanel/Email/Aliases.pm line 114.\n"],"status":0,"metadata":{},"data":null}
At this point I'm unsure why success or failure data isn't being generated for you. I would recommend opening a ticket as our support team is amazing and should be able to help you out.