# First admin and sign-up

> Create the admin account, invite people, choose who can sign up, and get back in if you're locked out.

A new deployment has no accounts. The first person to open `/setup` creates the organization and becomes its admin. After that, people join by invitation, unless you turn on open sign-up.

## Create the admin account

1. Open `https://<your address>/setup` as soon as the app is running. Until someone completes this page, anyone who finds the address can claim the admin account.
2. Fill in **Organization name**, **Your name**, **Email**, **Password** (at least 8 characters) and **Time zone**.
3. Click **Create admin account**. You're signed in.

`/setup` only works while the database has no users. Once an account exists, it sends you to the app instead, and the API answers `Setup already completed`.

To check from a terminal whether setup is still open:

```sh
curl -fsS https://<your address>/api/bootstrap
```

The response contains `"needsSetup":true` until the admin exists. It also shows which features are on, for example `"features":{"google":false,"signup":false}`.

## Invite people

1. Go to **Settings > Members** (admins only).
2. Click **Invite member**, enter the email address, and choose the role: **Member** or **Admin**.
3. The person gets an email with an **Accept invite** link. It's valid for 7 days. Inviting the same address again replaces the old link.

The invite link opens a page where the person picks a name and password. If Google sign-in is set up, they can instead click **Continue with Google** on the sign-in page, using a Google account with the invited email address. Their account is created with the invited role.

If email isn't set up yet (`SMTP_URL` unset), the invite email is printed to the app logs instead, with the link. Look for a line starting with `[email:logged]` and send the `Accept invite: https://...` link to the person yourself.

## Roles

- **Admins** manage the organization settings, members and invites, and everything members can do.
- **Members** use the app (event types and bookings, or clients and invoices).

Admins can change other people's roles and remove members from **Settings > Members**. Nobody can change their own role or remove themselves. Another admin can, though, so only make people admins if you trust them. If you lose admin access anyway, see [If you're locked out](#if-youre-locked-out).

## Open sign-up

Set `ALLOW_SIGNUP=true` to let anyone who can reach the app create an account at `/signup`. New accounts get the member role. Leave it off (the default) unless you want a public server: with it on, strangers can create accounts.

Without `ALLOW_SIGNUP`, account creation is limited to:

- the first admin, through `/setup`
- people with a valid invite, through the invite link or Google sign-in with the invited address

Anyone else sees `Sign-up is invite-only on this server`.

## Demo data

`SEED_DEMO=true` fills an empty database with demo data on startup: people, event types and bookings for the Scheduler, or a business, clients and invoices for Invoicing. It only runs when the database has no users, and it skips `/setup` because it creates an admin itself:

- Email: `demo@example.com`
- Password: `demo-password`

That password is public, so never use `SEED_DEMO` on a deployment with real data. It's meant for demos and for trying the app.

## If you're locked out

**You forgot your password.** Click **Forgot your password?** on the sign-in page and enter your email. If email is set up, you get a reset link. If it isn't, the reset email is printed to the app logs: find the `[email:logged]` line and open the `Choose a new password: https://...` link.

**No admin is left, or you need to make someone an admin.** There's no command for this, but you can change the role in the database. Open a SQL shell (for Docker Compose: `docker compose exec db psql -U scheduler`, using the app's name) and run:

```sql
UPDATE "user" SET role = 'admin' WHERE email = 'you@example.com';
```

The person may need to sign out and back in.

**You want to start over.** `/setup` opens again only when there are no users at all. The clean way to start over is a new, empty database. Don't delete users from a database you want to keep: their data (bookings, invoices) is linked to them.