<!-- ZenPays documentation · https://docs.zenpayz.com/docs/api-reference/auth -->

# Authentication

Merchant dashboard authentication — login, 2FA, password management, and session handling.

## Methods

### login

<Tabs groupId="language">
  <TabItem value="javascript" label="JavaScript" default>

```typescript
const result = await zenpays.auth.login({
  email: 'merchant@example.com',
  password: 'your-password',
})

if (result.requires2FA) {
  // Prompt for 2FA code
  const verified = await zenpays.auth.verify2FALogin({
    tempToken: result.tempToken,
    code: '123456',
  })
}
```

  </TabItem>
  <TabItem value="python" label="Python">

```python
result = zenpays.auth.login({
    "email": "merchant@example.com",
    "password": "your-password",
})

if result.get("requires2FA"):
    verified = zenpays.auth.verify_2fa_login({
        "tempToken": result["tempToken"],
        "code": "123456",
    })
```

  </TabItem>
</Tabs>

### verify2FALogin

```typescript
const result = await zenpays.auth.verify2FALogin({
  tempToken: 'temp_xxx',
  code: '123456',
})
```

### refreshToken

```typescript
const tokens = await zenpays.auth.refreshToken({
  refreshToken: 'refresh_xxx',
})
```

### logout

```typescript
await zenpays.auth.logout()
```

### changePassword

```typescript
await zenpays.auth.changePassword({
  currentPassword: 'old-password',
  newPassword: 'new-password',
})
```

### forgotPassword

```typescript
await zenpays.auth.forgotPassword({
  email: 'merchant@example.com',
})
```

### verifyResetToken

```typescript
const result = await zenpays.auth.verifyResetToken({
  token: 'reset_xxx',
})
```

### resetPassword

```typescript
await zenpays.auth.resetPassword({
  token: 'reset_xxx',
  newPassword: 'new-password',
})
```
