Skip to main content

POST /api/auth/register

Registers a new user account with username and password credentials. Supports optional invite codes when invites are enabled.

Request Body

username
string
required
Desired username (trimmed, minimum 1 character). Must be unique.
password
string
required
User’s password (trimmed, minimum 1 character)
code
string
Invite code. Required when invites are enabled and user registration is disabled.

Headers

x-zipline-client
string
Optional client identifier for tracking the source of the request

Response

user
object
The newly created user object

Rate Limiting

This endpoint is rate limited to 5 requests per second.

Registration Modes

The server can be configured in different registration modes:
  1. Open registration: Users can register without an invite code
  2. Invite-only: Users must provide a valid invite code
  3. Registration disabled: No new registrations allowed

Invite Code Validation

When an invite code is provided:
  • Code is matched against invite ID or code string
  • Checks expiration date (if set)
  • Checks maximum uses (if set)
  • Increments usage counter on successful registration

Error Responses

  • 400 Bad Request - Invites aren’t enabled (when code is provided but invites are disabled)
  • 400 Bad Request - User registration is disabled (when no code and registration disabled)
  • 400 Bad Request - Username is taken
  • 400 Bad Request - Invalid invite code (expired, max uses reached, or doesn’t exist)
  • 429 Too Many Requests - Rate limit exceeded

Example Request (Open Registration)

curl -X POST https://your-zipline-instance.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "newuser",
    "password": "securepassword123"
  }'

Example Request (With Invite Code)

curl -X POST https://your-zipline-instance.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "newuser",
    "password": "securepassword123",
    "code": "invite-abc-123"
  }'

Example Response

{
  "user": {
    "id": "clx9876543210",
    "username": "newuser",
    "role": "USER",
    "createdAt": "2024-03-03T12:00:00.000Z",
    "updatedAt": "2024-03-03T12:00:00.000Z",
    "view": {},
    "oauthProviders": [],
    "totpSecret": null,
    "quota": null,
    "avatar": null,
    "token": "zpl_xyz789abc123def456"
  }
}

Notes

  • Successfully registers the user and creates a session automatically
  • Generates a unique API token for the new user
  • Password is hashed using secure hashing before storage
  • New users are assigned the USER role by default

Build docs developers (and LLMs) love