# Users, roles and permissions

URL: https://lyeve.com/docs/guides/user/roles-and-permissions/

Every request LyEve receives answers one question first: may this caller do
this? For a person, the answer comes from their **role** and, for content, the
[access rules](https://lyeve.com/docs/features/access-rules/) written for that role. For a
program, it comes from the credential it holds. This page says which
credential to use, what each role may do, and how to manage accounts.

## Which credential do I need?

| Who is calling | Use | Sent as | Home page |
|---|---|---|---|
| A person in LyEve Console, or code acting for them | A session from signing in | The console's cookie, or `Authorization: Bearer <token>` | [Quickstart](https://lyeve.com/docs/getting-started/quickstart/) |
| A site or app reading content | An API key with a role and scopes | `X-API-Key: ly_...` | [API keys](https://lyeve.com/docs/features/api-keys/) |
| A script or CI job on the Admin API | An admin token with grants | `Authorization: Bearer lyat_...` | [Admin tokens](https://lyeve.com/docs/how-to/admin-tokens/) |
| A service checking who a caller is | The public key, to verify a session token | `GET /.well-known/jwks.json` | [Validate tokens](https://lyeve.com/docs/integrations/validate-tokens-jwks/) |

People can also sign in through an identity provider or a magic link. See
[sign-in options](https://lyeve.com/docs/integrations/oauth-sso/).

## Roles

A role is a name on an account. Three names have built-in meaning:

| Role | Reach | What it may do |
|---|---|---|
| `super_admin` | Every tenant | Everything: users and their roles, access rules, sign-in providers, the license, tenants and every setting. Never limited by an access rule. |
| `admin` | Its own tenant | Run the tenant in the console: content types, content, media, flows, API keys and its own admin tokens. On the Content API it needs an access rule like any other role. |
| `editor` | Its own tenant | Create, change, publish and delete entries through the Content API, where an access rule allows it. A user created without a role gets this one. |

Any other role name is yours to define. It opens no admin route on its own,
and reaches content only through the access rules written for it.

:::caution
A fresh install has no access rules, so on the Content API only super admins
read or write content until you write some. Write rules before you hand out
accounts. See [access rules](https://lyeve.com/docs/features/access-rules/#try-it).
:::

## Manage users

A super admin manages accounts, in the console or through the Admin API from a signed-in
session. Roles are held per membership, so one person can be an `editor` in one tenant and an
`admin` in another.

<div class="paths">
<div data-path="console">

Open **Access > Users**. The list shows each account with its roles and the day it was created,
and the role filters above it narrow the list.

(Image: Access > Users: each account with its roles and creation date, filters by role and a New user button.)

To create an editor:

1. Choose **New user**.
2. Enter `sam@example.com` in **Email** and a password in **Password**.
3. Under **Roles**, untick **viewer**, which is ticked already, and tick
   **editor**. A user saved with no role ticked gets **viewer**.
4. Choose **Create**. The account appears in the list with its roles.

</div>
<div data-path="api">

| Method | Path | Does |
|---|---|---|
| `GET` | `/api/admin/users` | List users. |
| `POST` | `/api/admin/users` | Create a user: `email`, `password`, `roles`. `201`. `roles` is required and names at least one role. |
| `PUT` | `/api/admin/users/{id}/roles` | Replace a user's roles: `{"roles": [...]}`. |
| `PUT` | `/api/admin/users/{id}/state` | Disable or enable a user, or set an account expiry: `disabled`, `expires_at`. |
| `PUT` | `/api/admin/users/{id}/password` | Set a new password. It has to meet the password policy, and every session the user held ends. |
| `DELETE` | `/api/admin/users/{id}` | Delete a user. `204`. |
| `GET` | `/api/admin/users/{id}/memberships` | List the tenants a user belongs to. |
| `PUT` | `/api/admin/users/{id}/memberships` | Give a user membership of a tenant. |
| `DELETE` | `/api/admin/users/{id}/memberships/{tenant}` | Remove a membership. |

Create an editor:

```bash
curl -X POST http://localhost:3001/api/admin/users \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"email": "sam@example.com", "password": "Editor-Account-2026", "roles": ["editor"]}'
```

The answer is `201` with the user and `"roles": ["editor"]`. A request with no
`roles`, or an empty list, creates nothing and answers `422` with the code
`VALIDATION_REQUIRED`: there is no default role.

</div>
</div>

The password must meet the policy: by default at least 12 characters, with an upper-case
letter, a lower-case letter and a digit, and not a common password.

A free install holds three admin seats: accounts with the `admin` or
`super_admin` role, counted across every tenant. Creating a fourth, or giving a
fourth account one of those roles, answers `402` with `cap_exceeded` until a
license is in force. Access rules cover three roles until a license carries
`rbac-pro`. See
[licensing and tiers](https://lyeve.com/docs/concepts/licensing-and-tiers/#what-runs-free).

## `super_admin` and the tenant boundary

The difference between a tenant `admin` and a `super_admin` is the most
important boundary on an instance with several tenants.

- An `admin` works only inside the tenant its session belongs to. An
  `X-Tenant-ID` header has no effect on its requests.
- A `super_admin` may act in any tenant by sending `X-Tenant-ID` with the
  tenant's slug. A slug that names no tenant answers `404` with
  `tenant not found`.
- Deleting a tenant, managing users, writing access rules and configuring
  sign-in providers take `super_admin`.

Treat `super_admin` like root and give it to as few people as possible. See
[tenants](https://lyeve.com/docs/features/tenants/).

## How access is checked

(Image: Access > Permissions: rules by role, with create, read, update, delete and activate for each content type or flow, and how the engine reads the rules.)

Every request goes through the same steps, in order:

1. **Who is calling.** The session, the API key or the admin token becomes a
   caller. No valid credential answers `401`.
2. **The route's role.** Each route is public, open to any signed-in caller,
   or limited to `admin` and `super_admin`, or to `super_admin` alone. A
   caller without the role answers `403`.
3. **The tenant.** The request is held to the caller's tenant, or to the
   tenant a `super_admin` named.
4. **The credential's own limits.** An API key needs the scope the route
   needs. An admin token needs the grant the route declares.
5. **The access rule.** On the Content API, and on flows and reviews, the
   caller's roles need a rule that allows the action. An API key is judged by
   the roles it carries, so a key with no role reads no content.

`401` means "I do not know who you are": fix the credential. `403` means "I
know who you are, and you may not do this": fix the role, the rule, the scope
or the grant.

## Practical guidance

- **Grant the narrowest role that works.** Keep `super_admin` for the people
  who need every tenant.
- **Write access rules before you add editors.** Without a rule, an editor can
  sign in and reach no content.
- **Give programs their own credential.** A key or a token is logged and
  revoked on its own, and a shared account is neither.
- **Set an expiry on every key and token.** A credential that has to be
  rotated cannot linger forgotten.

## Related pages

- [Access rules](https://lyeve.com/docs/features/access-rules/): write and combine rules.
- [API keys](https://lyeve.com/docs/features/api-keys/): credentials for the Content API.
- [Admin tokens](https://lyeve.com/docs/how-to/admin-tokens/): credentials for scripts on the
  Admin API.
- [Harden your instance](https://lyeve.com/docs/how-to/secure-your-instance/): the settings a
  production instance needs.
