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

# Telegram Login

> Вход через Telegram Login Widget

<ParamField body="id" type="integer" required>
  Telegram ID пользователя.
</ParamField>

<ParamField body="first_name" type="string" required>
  Имя в Telegram.
</ParamField>

<ParamField body="auth_date" type="integer" required>
  Unix timestamp авторизации.
</ParamField>

<ParamField body="hash" type="string" required>
  HMAC-SHA256 подпись от Telegram Widget.
</ParamField>

<ParamField body="username" type="string">
  Ник в Telegram (необязательно).
</ParamField>

## Описание

Передайте объект данных, который возвращает [Telegram Login Widget](https://core.telegram.org/widgets/login), напрямую на этот endpoint.

## Запрос

```bash theme={null}
curl -X POST https://elumenta.ru/api/v2/auth/telegram \
  -H "Content-Type: application/json" \
  -d '{
    "id": 123456789,
    "first_name": "Иван",
    "username": "ivan_dev",
    "auth_date": 1741432800,
    "hash": "abc123..."
  }'
```

## Ответ

```json theme={null}
{
  "access_token": "eyJhbGciOiJIUzI1NiJ9...",
  "refresh_token": "eyJhbGciOiJIUzI1NiJ9...",
  "token_type": "bearer",
  "is_new_user": true,
  "user": {
    "id": 12345,
    "telegram_id": 123456789,
    "plan": "free",
    "token_balance": 50
  }
}
```
