Skip to main content

zlogin Method


zlogin Method

The zlogin() method uses the Zuora  login() method to log into the Zuora server. You must invoke the zlogin() method on an instantiated zApi class before calling any other methods on that class.

You must configure an endpoint before calling the zlogin(). Use one of the following methods:

If the endpoint has been configured, you can use the no-argument login method. Otherwise, you can explicitly specify the endpoint and username and password.


The following versions of the zlogin() method are supported. If username and password are not given, the values in the connection setting pages are used.

  • Zuora.zApi.LoginResult zlogin ()
  • Zuora.zApi.LoginResult zlogin (String entityId)​
  • Zuora.zApi.LoginResult ​zlogin (String username, String password)
  • Zuora.zApi.LoginResult zlogin (String username, String password, String entityId)


The zlogin() method takes the following parameters.

Parameter Type Description
username String Zuora API Username
password String Zuora API Password in plain text
entityId String Id of the Zuora entity


The zlogin() method returns a Zuora.zApi.LoginResult class.


The zApi.LoginResult has the following properties.

Property Type Description
ServerUrl String The URL to redirect to for all subsequent API calls.
Session String The authentication token returned during the login process The session token contains information that confirms that the user making an API request is authenticated. 


The zlogin() method throws an exception if there is an error. The following classes are used to catch the exception:

  • zAPIException
  • zForceException
  • zRemoteException

Sample Code

Zuora.zApi zApiInstance = new Zuora.zApi();
try {
zApiInstance.zlogin('', 'test');
} catch (Zuora.zRemoteException ex) {
if ('INVALID_LOGIN' == ex.code) {
// The login credentials are invalid.
//more exception handling code here...
} catch (Zuora.zAPIException ex) {
//more exception handling code here...
} catch (Zuora.zForceException ex) {
//more exception handling code here...