Skip to main content

Register User

The first user registered in the system automatically becomes an ADMIN regardless of the requested role.
POST /register
curl -X POST https://api.sunschool.xyz/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "john_parent",
    "email": "john@example.com",
    "name": "John Doe",
    "role": "PARENT",
    "password": "securePassword123",
    "parentId": null
  }'
username
string
required
Unique username for the account
email
string
required
Email address for the account
name
string
required
Full name of the user
role
string
required
User role: ADMIN, PARENT, or LEARNER
password
string
required
Account password (will be hashed)
parentId
string
Required for LEARNER accounts - ID of the parent user

Response

token
string
JWT authentication token
user
object
Response Example
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": 1,
    "username": "john_parent",
    "email": "john@example.com",
    "name": "John Doe",
    "role": "PARENT",
    "parentId": null
  }
}

Error Codes

  • 400 - Missing required fields or invalid role
  • 400 - Username already exists
  • 400 - Invalid parent user specified (code 23503)
  • 503 - Database connection failed

Login

POST /login
curl -X POST https://api.sunschool.xyz/login \
  -H "Content-Type: application/json" \
  -d '{
    "username": "john_parent",
    "password": "securePassword123"
  }'
username
string
required
Username for the account
password
string
required
Account password

Response

token
string
JWT authentication token
user
object
User object (same structure as registration)
domain
string
Domain information for client-side handling
Response Example
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": 1,
    "username": "john_parent",
    "email": "john@example.com",
    "name": "John Doe",
    "role": "PARENT"
  },
  "domain": "sunschool.xyz"
}

Error Codes

  • 400 - Username and password are required
  • 401 - Invalid credentials
  • 500 - Authentication error

Logout

POST /logout
curl -X POST https://api.sunschool.xyz/logout \
  -H "Authorization: Bearer {token}"
This endpoint redirects to /api/logout with status 307.

Get Current User

GET /user
curl -X GET https://api.sunschool.xyz/user \
  -H "Authorization: Bearer {token}"
This endpoint redirects to /api/user with status 307.

Health Check

GET /api/healthcheck
curl -X GET https://api.sunschool.xyz/api/healthcheck

Response

{
  "status": "ok",
  "message": "Server is running"
}