CPanel API - How to get Security Token "cpsess##########" using webrequest/HttpClient in C#

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,139
2,404
363
cPanel Access Level
Root Administrator
Hey there! The best information I have for this will be found here:


as that covers creating a token, assigning permissions, and using the token with API calls. There is a Curl example provided at the bottom of the page as well, but I don't have any examples on my end for the C# language.
 

Alan_Scott

Registered
Oct 28, 2022
4
1
3
Wolverine
cPanel Access Level
Website Owner
CPanel API - How to get Security Token "cpsess##########" using webrequest/HttpClient in C#
Using Cpanel API - Authentication username password
The first way is to use the cPanel API. To do this, you will need to send a POST request to the /login page of the cPanel server. The body of the request should contain the following JSON:

{"cpanel_jsonapi_user":"your_cpanel_username","cpanel_jsonapi_module":"CPanel","cpanel_jsonapi_func":"get_security_token","cpanel_jsonapi_version":2}
The response from the server will be a JSON object containing the security token.
 
  • Like
Reactions: cPRex