Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/praveenarya123/sps-backend/llms.txt

Use this file to discover all available pages before exploring further.

POST /api/auth/register Creates a new user account. No authentication is required. The password is hashed with bcrypt before being stored.
The response includes the hashed password field as the API does not exclude it. Avoid logging or exposing the full response object in client applications.

Request body

name
string
required
Full name of the user.
email
string
required
Email address of the user. Must be unique across all accounts. Attempting to register with a duplicate email will cause a MongoDB duplicate key error.
password
string
required
Plain-text password. Hashed with bcrypt (10 salt rounds) before storage.
role
string
required
Role assigned to the user. Must be one of the following values:
  • SUPER_ADMIN
  • ACADEMIC_ADMIN
  • STUDENT_ADMIN
  • FINANCE_ADMIN
  • OPERATIONS_ADMIN
  • TEACHER
  • STUDENT

Response

Returns the newly created user document as stored in MongoDB.
_id
string
MongoDB ObjectId of the created user.
name
string
Full name of the user.
email
string
Email address of the user.
role
string
Role assigned to the user.
password
string
Bcrypt-hashed password. Returned by the API because the User model does not apply select: false to this field.
__v
number
MongoDB document version key.

Error cases

ConditionResult
email already existsMongoDB E11000 duplicate key error (unhandled — the server returns a 500-level response)
Missing required fieldsThe document is saved with undefined values — no validation error is thrown unless the schema is updated to enforce required fields
Invalid role valueMongoDB validation error due to the enum constraint
The current implementation does not include explicit error handling middleware. Duplicate email errors and validation failures will surface as unformatted MongoDB errors in the response body.

Examples

curl --request POST \
  --url http://localhost:5000/api/auth/register \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Priya Sharma",
    "email": "priya.sharma@school.edu",
    "password": "SecurePass123",
    "role": "TEACHER"
  }'
{
  "_id": "64f1a2b3c4d5e6f7a8b9c0d1",
  "name": "Priya Sharma",
  "email": "priya.sharma@school.edu",
  "password": "$2b$10$Xv8QkL2mN3pR7sT9uW1yOeKjH4iFgEaDcBzAyMxLwVnUoSqPrItG",
  "role": "TEACHER",
  "__v": 0
}

Build docs developers (and LLMs) love