Skip to main content

POST /api/register

Public endpoint for user registration with invite code validation.

Authentication

No authentication required (public endpoint).

Request Body

email
string
required
User email address
password
string
required
User password (minimum 8 characters recommended)
firstName
string
User’s first name
inviteCode
string
required
Valid invite code from AnythingLLM invite system

Response

ok
boolean
Whether registration was successful
userId
string
Created Directus user ID (on success)
error
string
Error message (on failure)

Example

cURL
curl -X POST http://localhost:3001/api/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "SecurePass123",
    "firstName": "Jane",
    "inviteCode": "ALPHA-2026"
  }'
{
  "ok": true,
  "userId": "abc123-def456-ghi789"
}

Registration Flow

1

Validate invite code

System checks AnythingLLM invite table to verify code is valid and unused
2

Create Directus user

User account created with admin token (bypasses public access restrictions)
3

Mark invite as used

Invite code status updated to prevent reuse
4

Return credentials

User ID returned for immediate login flow

Error Codes

StatusErrorDescription
400Missing required fieldsemail, password, or inviteCode not provided
400Invalid invite codeCode doesn’t exist or already used
409Email already existsUser with this email already registered
500Server misconfigurationDIRECTUS_ADMIN_TOKEN not configured

Implementation

Source: server/endpoints/api/register.js The registration endpoint uses Directus admin token to create users, allowing public registration without exposing Directus public access permissions.

Authentication

Learn about JWT authentication after registration

Build docs developers (and LLMs) love