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

# Authentication overview

> Bludia end-user authentication: attach a guard to a collection such as users, then register, log in, refresh, and log out users over the API. Sessions use short-lived JWT access tokens (15 min default) and rotating refresh tokens (14 days default).

Bludia authenticates **your app's users** (end users) against a collection in your own project. There's no separate user database: a user is a record in a collection like `users`, `customers`, or `staff`.

```text theme={null}
users collection                 Authentication guard "users"
├── email      (login field)  ◄── login field: email
├── password   (auto-added)   ◄── password field (hashed)
├── full_name
└── phone
```

## The flow

```text theme={null}
1. Register    POST /auth/users/register   { email, password, full_name }   → session
2. Log in      POST /auth/users/login      { login, password }              → session
3. Use the API GET  /collections/orders/records   Authorization: Bearer <access_token>
4. Refresh     POST /auth/users/refresh    { refresh_token }                → new session
5. Log out     POST /auth/users/logout     { refresh_token }
```

A **session** looks like this:

```json theme={null}
{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "refresh_token": "q3Jx...(80 characters)",
  "token_type": "Bearer",
  "expires_in": 900,
  "record_id": 42
}
```

## Set up authentication

**1. Create a users collection**

Add a collection (for example `users`) with a login field such as `email`, plus any profile fields.

**2. Create a guard**

Go to **Authentication** → **Guards** → **Create guard**. Pick the collection and the login field. Bludia adds a `password` field and a default role, `user`. See [Guards](https://docs.bludia.com/authentication/guards.md).

**3. Grant permissions**

Give the `user` role access to the collections your app needs. See [Roles & permissions](https://docs.bludia.com/authorization/roles-and-permissions.md).

**4. Create an end\_users API key**

In **API** → **API Keys**, create a key with auth type `end_users` and add your app's origin. See [API keys](https://docs.bludia.com/api/api-keys.md).

**5. Build login and sign-up screens**

Call the auth endpoints from your app. See [Register & login](https://docs.bludia.com/authentication/register-and-login.md).

## Features

> [card] [Guards](https://docs.bludia.com/authentication/guards.md)
>
> Connect login to a collection, choose the login field, configure tokens.

> [card] [Register & login](https://docs.bludia.com/authentication/register-and-login.md)
>
> Sign-up and sign-in endpoints, payloads, and errors.

> [card] [Sessions & tokens](https://docs.bludia.com/authentication/sessions-and-tokens.md)
>
> Access tokens, refresh rotation, logout, and logout everywhere.

> [card] [Email verification](https://docs.bludia.com/authentication/email-verification.md)
>
> Send a verification code at sign-up and confirm it.

> [card] [Password reset](https://docs.bludia.com/authentication/password-reset.md)
>
> Forgot-password and reset flows.

> [card] [Current user](https://docs.bludia.com/authentication/current-user.md)
>
> Get the signed-in user's profile with `/me`.

## Security built in

| Protection | How |
| :- | :- |
| Password storage | Hashed with bcrypt; never returned by the API |
| Minimum password length | 8 characters (add more rules on the password field) |
| Brute-force protection | Auth endpoints allow 10 requests per minute per IP and route |
| Login auditing | Every login attempt is logged with IP, user agent, and result |
| Refresh token rotation | Each refresh revokes the old refresh token |
| Account status | Users with status `inactive`, `banned`, or `suspended` can't log in |
| Password reset | Revokes all of the user's sessions |
| Tenant isolation | Tokens only work for the project and guard that issued them |

> [!NOTE]
>
> **End users vs team members.** This section is about people who use *your app*. To give colleagues access to the Bludia dashboard, see [Team members](https://docs.bludia.com/authorization/team-members.md).


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