Recovery tools

Use these tools if you (or the CAD owner) are locked out. They change the CAD database directly and require the recovery token stored on the server. Back up your database before making changes.

The token is stored on the API server in the file apps/api/.recovery-token (readable only by the user running SnailyCAD). It is never sent by email or shown in logs.

Database settings

If the recovery tools cannot be used (for example the API does not start), you can connect to the database directly. The settings are in the .env file in the SnailyCAD root folder. Never share these values.

ParameterVariable(s)Example
Database nameDATABASE_URL / POSTGRES_DBsnaily-cad-v4
UsernameDATABASE_URL / POSTGRES_USERpostgres
PasswordDATABASE_URL / POSTGRES_PASSWORD<your password>
HostDATABASE_URL / DB_HOST (POSTGRES_HOST in the recovery script)localhost
PortDATABASE_URL / DB_PORT (POSTGRES_PORT in the recovery script)5432

Prisma (the API) only reads DATABASE_URL. Its format is postgresql://USER:PASSWORD@HOST:PORT/DB_NAME?sslmode=prefer. In the default .env it is built from POSTGRES_USER, POSTGRES_PASSWORD, DB_HOST, DB_PORT and POSTGRES_DB, so if you change one of those, make sure DATABASE_URL still matches (or write the values directly into DATABASE_URL).

export PGPASSWORD=<your password>
psql -U postgres -d snaily-cad-v4 -h localhost -p 5432

Locating, rotating and replacing the token

  • Locate: on the API server, run cat apps/api/.recovery-token from the SnailyCAD folder. The exact absolute path is shown on the admin dashboard for the owner. Set RECOVERY_TOKEN_FILE in .env to use another location.
  • Rotate: as the owner, open the admin dashboard and click "Rotate token". The new token is shown once and replaces the old one immediately.
  • Replace: if you cannot log in, delete apps/api/.recovery-token and apps/api/.recovery-token.json and restart the API. A new token is generated, and you can read it from the file.

Full guide: sh/docs/RECOVERY.md

Back to login