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

# Authentication

> How to authenticate with the Nexus Mission Control API using JWT Bearer tokens.

# Authentication

The API uses **JWT (JSON Web Token)** Bearer authentication. All protected endpoints require a valid token in the `Authorization` header.

## Flow

<Steps>
  <Step title="Register a new account">
    Call `POST /api/v1/auth/register` with your name, email, and password.
  </Step>

  <Step title="Login to get a token">
    Call `POST /api/v1/auth/login` with your credentials. You'll receive an `access_token`.
  </Step>

  <Step title="Use the token in requests">
    Add the token to every protected request:

    ```
    Authorization: Bearer <your_access_token>
    ```
  </Step>
</Steps>

## Example

```bash theme={null}
# 1. Register
curl -X POST http://localhost:3000/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"name":"John","email":"john@example.com","password":"secret123"}'

# 2. Login
curl -X POST http://localhost:3000/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"john@example.com","password":"secret123"}'
# → { "access_token": "eyJ..." }

# 3. Authenticated request
curl http://localhost:3000/api/v1/projects \
  -H "Authorization: Bearer eyJ..."
```

## Token Lifetime

Tokens are configured via the `JWT_EXPIRATION` environment variable (default: `7d`).
