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

# Registration

> How a login and its account are created by e-mail or with a provider, in the app and on the web, and which endpoints are involved.

There are two ways to register: **by e-mail**, with a password and e-mail verification, or **with a
provider** (Google, Apple or Microsoft), without a password. Both exist in the MaihueGO app and on the
web (horizon-authenticate). Registration always starts at the e-mail step of
[sign-in](https://docs.bbrands.io/maihuego/authentication/sign-in.md): if `verify-email` says there is no login, the client opens
registration. UI copy is quoted in Spanish, as the app shows it.

## E-mail registration

> [tab] MaihueGO app
>
> **1. E-mail**
>
> The person types their e-mail on the welcome screen and confirms it on the next step.
>
> **2. Password**
>
> They create the password with its confirmation. The rule is 4 of 5 criteria (see the note
> below).
>
> **3. Verifica tu correo**
>
> The app calls `POST /api/v3/auth/register` and shows the verification screen. Resend unlocks
> after **60 seconds**; the deadline is stored per e-mail in wall-clock time, so it holds even if
> the app goes to the background.
>
> **4. E-mail link**
>
> When the link is opened, the app signs in by itself ("Iniciando sesión...") and shows "¡Ya
> casi!", with "Continuar a MaihueGO" and "Cerrar sesión".
>
> **5. Welcome**
>
> If the person has courtesy recharges available (`courtesy_recharge_limit` greater than
> `courtesy_recharge_used`), they see "¡Tu cuenta fue creada!" with "Recarga de regalo" (opens the
> QR scanner) and "Usar en otro momento". Otherwise they go straight to Home.

> [tab] Web (horizon-authenticate)
>
> The `auth/register` page asks for full name, e-mail, password with confirmation ("Cumple al menos 4
> de: 8 caracteres, minúscula, mayúscula, número y símbolo.") and terms acceptance. The action goes
> through Vercel BotID before calling the backend and then asks the person to check their inbox. On
> "Verifica tu correo" (`auth/verify-account`) the person types the 6-digit code or opens the link in
> the e-mail.

> [!NOTE]
>
> **Password rule in the app.** MaihueGO's create-password screen enabled the button only at
> "excellent" strength (all five rules, decision D-331). ADR 0132 sets **4 of 5 plus confirmation
> everywhere** and supersedes that decision; the app change (T-05) was merged in PR #1960.

### Verification and resend

* `POST /api/v3/auth/register` creates the Supabase user with `email_confirm=false` and resends the
  `signup` e-mail with the `SUPABASE_AUTH_REGISTER_REDIRECT_TO` target. If the resend fails,
  registration continues and only a warning is logged.
* `POST /api/v3/auth/verify-account` confirms the e-mail and `POST /api/v3/auth/resend-confirmation`
  resends the link (3 per hour per e-mail). It answers `200` to every e-mail, unknown or already
  confirmed included, and only an unconfirmed login gets the e-mail.
* An **unconfirmed e-mail younger than 24 hours** answers `409` ("check the inbox"). After 24 hours the
  e-mail can be registered again and the login is reused.
* An already confirmed e-mail answers `409`.

## Required data and the identity flag

Registration is progressive: the POST creates the login and the PATCH completes the profile. The
account is created **only** with the first identifying data (`type_dni` and `dni`, or `phone`, or
`firstname` and `lastname`); until then the login has no account (deferred registration). A POST with
`CHL_RUT`, `dni` and a verified identity attestation creates the account right away.

The `maihuego-application-registration-identity` flag picks the path in the app:

| Path | Flag | What the app asks |
| - | - | - |
| Path 1 | off | Only e-mail and password. Personal data is asked only when contracting a plan, in "Completa tu perfil" (RUT or passport and basic data, no phone). |
| Path 2 | on | "Valida tus datos" (RUT with serial number, validated with Floid on the server, or passport), then "Confirma tus datos" (names and birthdate) and then the password. |

* If the document already belongs to another person's account (`CHL_RUT` or `CHL_PASSPORT`), the app
  shows the conflict screen with the owner's masked e-mail. For a provider login, that screen offers
  "Es mi cuenta, vincular" (see [Identity linking](https://docs.bbrands.io/maihuego/authentication/identity-linking.md)).
* Under 13: "Menor de edad" screen. The RUT hash stays blocked until the 13th birthday and the e-mail
  hash for 30 days, in `registration_block` (HMAC hashes are stored, never the values).
* `dni_validated` becomes true only with an identity attestation.

## Provider registration, without a password

From 2026.11.3, registering with Google, Apple or Microsoft **asks for no password** (ADR 0132). The
person can create one later from Home or Settings (see [Password](https://docs.bbrands.io/maihuego/authentication/password.md)).

> [tab] MaihueGO app
>
> | Path | The provider sent first and last name | What happens |
> | - | - | - |
> | Path 1 | Yes | `POST /api/v3/auth/oauth/register` without a password → Home |
> | Path 1 | No | "Confirma tus datos" (names and birthdate) → `oauth/register` |
> | Path 2 | Either | "Valida tus datos" → "Confirma tus datos" prefilled from the provider → `oauth/register` |
>
> `oauth/register` receives the Supabase tokens and, when present, a password that must meet 4 of 5.
> A password is only accepted while the login has no account: once the registration is done it
> answers `409 registration-already-completed`, and the password is created with
> `POST /api/v3/auth/password`, which sends the security e-mail.
> Without a password, the login gets `has_created_password=false`. It stores `provider` and
> `is_private_email`, and answers `409 password-already-created` if the login already had a password.

> [tab] Web (horizon-authenticate)
>
> **1. oauth/complete**
>
> Back from the provider, the web calls `POST /api/v3/auth/oauth/complete` with the tokens in the
> body. If the login is new and has no `user_metadata`, horizon-api creates the profile and the
> person account with the same service as web e-mail registration. It answers `jwt`,
> `is_new_user`, `needs_terms` and `needs_name`.
>
> **2. oauth/welcome**
>
> If the terms or the name are missing, the web shows `auth/oauth/welcome`: "Acepta los términos
> para terminar de crear tu cuenta." (or "Cuéntanos tu nombre y acepta los términos…" when the name
> is missing). It sends `POST /api/v3/auth/oauth/welcome` with `terms_accepted: true` and, when
> missing, `firstname` and `lastname` (max 250). It never replaces an existing name.
>
> **3. Destination**
>
> 2FA gate (inert today) and redirect to `next`.

## Abandoning a registration

In a half-done provider registration, going back from "Valida tus datos" or "Iniciar sesión con otro
correo" calls `POST /api/v3/auth/abandon-registration`. It deletes the Supabase user **only** if it has
no password identity and no person account, and only after reading its metadata. Limit: 10 per 10
minutes per user.

## Account migration

`POST /api/v3/auth/register/migration` (permission `auth:register-migration`) provisions accounts coming
from earlier systems **without a password**: account, users, metadata, roles, subscription type and
migration segment. It is idempotent by `dni`, `type` and `type_dni` (`201` on create, `200` on update),
never deletes pre-existing auth users and **never sends welcome e-mails** (`receive_creation_email`
stays `false`). These accounts sign in with the [magic link](https://docs.bbrands.io/maihuego/authentication/magic-link.md),
because they have neither a password nor a provider.

## Endpoints

| Method and path | Use |
| - | - |
| `POST /api/v3/auth/register` | Creates the login (`201` with `userId` and `accountId: null`, or with `accountId` when an attested `CHL_RUT` is sent). `422` if under 13. |
| `PATCH /api/v3/auth/register` | Completes the profile and creates the account with the first identifying data. `409` with the owner's masked e-mail if the document belongs to another account; `409 identity-locked` for already validated civil data. |
| `POST /api/v3/auth/verify-account` | Confirms the e-mail. |
| `POST /api/v3/auth/resend-confirmation` | Resends the confirmation e-mail. |
| `POST /api/v3/auth/validate-identity` | Server-side Floid validation (15 s timeout); returns the attestation the PATCH must present. |
| `POST /api/v3/auth/verify-dni` | Checks whether the document already has an account. |
| `POST /api/v3/auth/underage-email` | Records the e-mail hash of a minor. |
| `POST /api/v3/auth/oauth/register` | App registration after a provider. |
| `POST /api/v3/auth/oauth/complete` | Web sign-in or registration after a provider. |
| `POST /api/v3/auth/oauth/welcome` | Terms and missing name on the web. |
| `POST /api/v3/auth/abandon-registration` | Deletes a half-done provider registration. |
| `POST /api/v3/auth/register/migration` | Passwordless account migration. |

> [!NOTE]
>
> **Pending.** The anonymous PATCH is still allowed while the server flag
> `authenticate-register-anonymous-patch` is `true` (user younger than 24 hours and without
> `account_user`): `true` in every environment until 2026-11-14, when the forced app update lets it be
> turned off from Horizon without a deploy.
> Binding the PATCH to the session JWT is tracked in `security-hardening` (T-101).

## Limits

| Bucket | Limit | Window | Per |
| - | - | - | - |
| `register` | 5 | 1 h | IP |
| `register-patch` | 20 | 1 h | IP and user |
| `resend-confirmation` | 3 | 1 h | e-mail |
| `validate-identity` | 10 | 10 min | IP |
| `verify-dni` | 30 | 10 min | IP |
| `floid-identity` | 5 | 1 h | user |
| `underage-email` | 10 | 10 min | IP and e-mail |
| `abandon-registration` | 10 | 10 min | user |

## See also

* [E-mail-first sign-in](https://docs.bbrands.io/maihuego/authentication/sign-in.md)
* [Google, Apple and Microsoft](https://docs.bbrands.io/maihuego/authentication/oauth.md)
* [Identity linking](https://docs.bbrands.io/maihuego/authentication/identity-linking.md)
* [Password](https://docs.bbrands.io/maihuego/authentication/password.md)
* [`registration` initiative](https://github.com/bbrandslab/bbrands-monorepo/blob/develop/docs/initiatives/authenticate/registration/README.md)


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