Skip to main content
POST /api/auth/register Creates a new Tenant and admin User in a single database transaction. Returns a signed JWT token you can use to authenticate subsequent requests.
This is the only endpoint that creates a new Tenant. All other users must be added to an existing tenant after registration.

Request body

email
string
required
Admin user email address. Must be unique across all users.
password
string
required
Admin user password. Stored as a bcrypt hash (10 salt rounds).
tenantName
string
required
Name of the business or organization. Becomes the name field on the created Tenant.
adminName
string
required
Full name of the admin user.

Response

token
string
JWT bearer token. Include this in the Authorization header for all protected API routes.
user
object

Errors

StatusError messageDescription
400User already existsA user with the provided email is already registered.
500Registration failedAn unexpected server error occurred.

Examples

curl --request POST \
  --url http://localhost:5000/api/auth/register \
  --header 'Content-Type: application/json' \
  --data '{
    "email": "[email protected]",
    "password": "s3cur3p@ss",
    "tenantName": "Acme Corp",
    "adminName": "Jane Doe"
  }'

Success response

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "a3f1e2d4-bc56-4789-9012-3def45678901",
    "email": "[email protected]",
    "name": "Jane Doe",
    "tenantId": "b7c2d3e4-f567-4890-ab12-cdef01234567",
    "role": "admin"
  }
}

Build docs developers (and LLMs) love