> For the complete documentation index, see [llms.txt](https://docs.zaui.com/zapi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zaui.com/zapi/zapi-calls/agent-calls/agent-login.md).

# Agent Login

This call will return the API token, API User ID and API Account ID, which can then be used on subsequent calls.

This routine is intended to be used when you wish to have the system create and issue a new API Token, API User ID and API Account ID. This routine authenticates first that the agent is an active agent in your system (based on the expiry date of their account).

## zapiAgentLogin

<mark style="color:green;">`POST`</mark> `https://{yourdomainname}.zaui.net/zapi/`

#### Request Body

| Name                                           | Type   | Description                        |
| ---------------------------------------------- | ------ | ---------------------------------- |
| zapiUsername<mark style="color:red;">\*</mark> | string | Username set in the agent profile. |
| zapiPassword<mark style="color:red;">\*</mark> | string | Password set in the agent profile. |
| methodName<mark style="color:red;">\*</mark>   | string | The method being called.           |

{% tabs %}
{% tab title="200: OK " %}

```xml
<?xml version="1.0" encoding="utf-8"?>
<response>
    <zapiVersion>2.1</zapiVersion>
    <error>0</error>
    <message>OK</message>
    <methodResponse>
        <methodName>zapiAgentLogin</methodName>
        <methodErrorCode>0</methodErrorCode>
        <methodErrorMessage>Login Successful</methodErrorMessage>
        <zapiUsername>joesmith</zapiUsername>
        <zapiAccountId>398</zapiAccountId>
        <zapiUserId>1227</zapiUserId>
        <firstName>Joe</firstName>
        <lastName>Smith</lastName>
        <zapiApiToken>58ac1371783bc1091e5248f6c4ef8ff5cb0e4f1a</zapiApiToken>
        <cartId>b17d62046cde010f18c10285f3f85c82</cartId>
    </methodResponse>
</response>
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Request" %}

```xml
<request>
	<zapiUsername></zapiUsername>
	<zapiPassword></zapiPassword>
	<zapiMethod>
		<methodName>zapiAgentLogin</methodName>
	</zapiMethod>
</request>
```

{% endtab %}

{% tab title="Response" %}

```xml
<?xml version="1.0" encoding="utf-8"?>
<response>
	<zapiVersion>2.1</zapiVersion>
	<error>0</error>
	<message>OK</message>
	<methodResponse>
		<methodName>zapiMobileLogin</methodName>
		<methodErrorCode></methodErrorCode>
		<methodErrorMessage></methodErrorMessage >
		<zapiUsername></zapiUsername>
		<zapiAccountId></zapiAccountId>
		<zapiUserId></zapiUserId>
		<firstName></firstName>
		<lastName></lastName>
		<zapiApiToken/>
		<cartId></cartId>
	</methodResponse>
</response> 
```

{% endtab %}
{% endtabs %}
