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

# Login

> Autentica o usuario e retorna tokens de acesso

## Descricao

Autentica com email e senha, retornando um `accessToken` (JWT, 1h) e um `refreshToken` (UUID, 7 dias).

<Note>
  Para integracao server-to-server, prefira usar [API Keys](/api-reference/api-keys/create) em vez de JWT.
</Note>

## Request

<ParamField body="email" type="string" required>
  Email do usuario cadastrado.
</ParamField>

<ParamField body="password" type="string" required>
  Senha do usuario.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.thalbank.com/login \
    -H "Content-Type: application/json" \
    -d '{
      "email": "usuario@empresa.com",
      "password": "sua_senha"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.thalbank.com/login", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      email: "usuario@empresa.com",
      password: "sua_senha",
    }),
  });
  const data = await response.json();
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refreshToken": "550e8400-e29b-41d4-a716-446655440000",
    "user": {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Nome do Usuario",
      "email": "usuario@empresa.com",
      "role": "SELLER"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "statusCode": 401,
    "message": "Invalid credentials",
    "error": "Unauthorized"
  }
  ```
</ResponseExample>
