Create Webmail session with credentials

This function creates a temporary session with a password for the calling cPanel user to connect to Webmail.

Note:

  • The cPanel user must own the Webmail account.
  • This function works like the UAPI Session::create_webmail_session_for_mail_user function with one exception. This function requires a correct password to create the Webmail session. If you use an incorrect password or attempt to connect to a suspended account, the login will fail.

How to use this API

After you successfully call this API, you will need to log in to Webmail. To do this, send an HTTP POST to https://$URL_AUTHTY:2096$token/login with a message body of session=$session where:

  • $URL_AUTHTY represents the value from the hostname return.
    • If the hostname return value is null, enter the hostname of the server that answered the API function.
    • $token represents the value from the token return.
  • $session represents the value of the session return.

For example, an HTTP POST may resemble the following:

https://hostname.example.com:2096/cpsess2462418786/login

With a message body of:

session=username:D7NiAZv1nf4bXeg9:CREATE_WEBMAIL_SESSION_FOR_MAIL_USER,728fb86a7df1cf20690c65f349ac3137

Authorizations:
query Parameters
domain
required
string

The domain for the Webmail account.

Example: domain=example.com
login
required
string

The Webmail account's username.

Example: login=username
password
required
string

The password for the Webmail account.

Example: password=luggage12345
locale
string

The locale that the new session will use.

Note:

  • You must only enter lowercase characters.
  • This parameter defaults to the cPanel user's locale.
Example: locale=en
remote_address
string <ipv4>

The session's account's client IP address.

Note:

  • If you run this function from the command line, this parameter is required.
  • This parameter defaults to the API caller's IP address.
Example: remote_address=192.168.0.1

Responses

Response Schema: application/json
apiversion
integer

The version of the API.

func
string

The name of the method called.

module
string

The name of the module called.

object

Request samples

uapi --output=jsonpretty \
  --user=username \
  Session \
  create_webmail_session_for_mail_user_check_password \
  login='username' \
  domain='example.com' \
  password='luggage12345'

Response samples

Content type
application/json
{
  • "apiversion": 3,
  • "func": "create_webmail_session_for_mail_user_check_password",
  • "module": "Session",
  • "result": {
    • "data": {
      • "hostname": "hostname.example.com",
      • "session": "username:D7NiAZv1nf4bXeg9:CREATE_WEBMAIL_SESSION_FOR_MAIL_USER,728fb86a7df1cf20690c65f349ac3137",
      • "token": "/cpsess2462418786"
      },
    • "errors": null,
    • "messages": null,
    • "metadata": {
      • "transformed": 1
      },
    • "status": 1,
    • "warnings": null
    }
}