WHM API.
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/
https://{host}:{port}/json-api/
Request
This function creates a new temporary user session for a specified service. This allows users with WHM access to log in to third-party applications (for example, billing systems) without storing the account password.
Note:
- The system destroys the temporary session after 15 minutes of inactivity.
- For more information about the Single Sign On feature, read our Guide to API Authentication documentation.
The session's service.
The session's cPanel account username or a valid email address.
The cPanel or WHM application to which the session will link. This parameter defaults to a blank string, which redirects the user to the cPanel Home interface.
- A valid application name, to link the session to an application.
- An invalid application name, to create the session but not link it to an application.
The session's locale. This parameter defaults to the Server Locale setting in WHM's Tweak Settings interface (WHM >> Home >> Server Configuration >> Tweak Settings).
Note:
- If you specify a locale, the server sends a cookie to your browser with that locale setting. The cookie expires after one year.
- Users can change the locale with the language options at the bottom of the login interface.
The hostname or IP address for the function to use in the url return. This parameter's value defaults to the server's hostname.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/create_user_session
- A server running WHM.
https://whm-server.tld:2087/json-api/create_user_session
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://api.docs.cpanel.net/_mock/specifications/whm.openapi/create_user_session?service=cpaneld&user=user%40example.com&app=Backups_Home&cp_security_token=cpsess1234567890&locale=fr&preferred_domain=example.com&promptToken=SSB3YW50IHRvIGNyZWF0ZSBhIHJlc3RhdXJhbnQgd2Vic2l0ZQ%3D%3D'{ "data": { "cp_security_token": "/cpsess1234567890", "expires": 1401993893, "service": "cpaneld", "session": "username:RFw6MUp9S8sRwTSgqaUJWUCq8ZQg2Zkopx5KaTHRNQXBfT3n8xvfBEF9JJC3iiwa", "url": "https://example.com:2083/cpsess1234567890/login/?session=username:RFw6MUp9S8sRwTSgqaUJWUCq8ZQg2Zkopx5KaTHRNQXBfT3n8xvfBEF9JJC3iiwa&locale=fr" }, "metadata": { "command": "create_user_session", "reason": "Created session", "result": 1, "version": 1 } }