> ## Documentation Index
> Fetch the complete documentation index at: https://docs.axottle.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Receiving a session token and using it when calling the Axottle API.

Axottle's administrative API uses session tokens, so you log in with your username and administrator password, you get a token, and you pass it on every subsequent request.

> [!NOTE]
>
> For whom: developer and administrator.
> Required rights: Panel administrator account.

## Two Ways to Transfer a Session

| Method | For What | Is Transmitted As |
| - | - | - |
| `Authorization: Bearer <token>` | CLI, scripts, integrations | Title of the request |
| Session Cookie | Browser (panel and portal) | `HttpOnly` Cookie, set automatically when you log in |

For integrations, use Bearer – it is not dependent on cookies and is not subject to browser checks.

> [!NOTE]
>
> Requests with cookies that change data (`POST`, `PUT`, `PATCH`, `DELETE`) are verified by the source: the header `Origin` or `Referer` must match the address of the panel. Requests with `Authorization: Bearer` do not pass this check and do not break because of it.

## Entry and receipt of the token

Send your login and password to the login method:

```bash theme={null}
curl -s https://panel.example.com/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"<пароль>"}'
```

The response returns the session token. Save it, it will be required for all secure methods. In the same response, the browser is given a session cookie.

> [!NOTE]
>
> If the account has 2FA enabled, the first request will return `401` with the code `TOTP_REQUIRED`. Repeat the request by adding the `totp_code` field to the body.

An account without a password (entry only through Telegram) cannot enter through this method - it is logged in via Telegram in the browser, see [Login via Telegram](https://docs.axottle.com/en/panel/telegram-login.md).

> [!WARNING]
>
> Never transfer a password or token in a URL or query settings and save them in shared logs. Only transfer secrets to the query body or `Authorization` header.

## Use of the token

Transfer the token in the title `Authorization`:

```bash theme={null}
curl -s https://panel.example.com/api/v1/system/status \
  -H "Authorization: Bearer <session-token>"
```

You can check the current session using the “who am I” method:

```bash theme={null}
curl -s https://panel.example.com/api/v1/auth/me \
  -H "Authorization: Bearer <session-token>"
```

## Conclusion of the session

```bash theme={null}
curl -s https://panel.example.com/api/v1/auth/logout \
  -H "Authorization: Bearer <session-token>"
```

After the release, the token becomes invalid.

## Authentication errors

| Status | Cause | What to do with |
| - | - | - |
| `401` | Token is missing, invalid or session expired | Enter again and get a new token |
| `403` | Insufficient permissions | Check the account permissions required for the requested action |

## Resetting the administrator password

If access to the panel is lost, the password is reset from the command line on the server (the action requires permissions on the server and is recorded in the audit):

```bash theme={null}
axottle admin reset-password
```

More information: [CLI](https://docs.axottle.com/en/reference/cli.md).

## Verification

> [!TIP]
>
> A request to `GET /api/v1/auth/me` with your token returns the current administrator data and the status of `200`.

## Rollback

Tokens are recalled by an exit (`logout`) or reset of the account password, after which the previous sessions cease to operate.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.