Skip to main content

Endpoint

PUT /api/users/profile

Authentication

This endpoint requires authentication. Include a valid JWT token in the Authorization header:
Authorization: Bearer <token>

Request body

All fields are optional. Only include the fields you want to update. Other profile fields (email, role, register_number, employee_id, etc.) cannot be updated through this endpoint.

Response

Success response

Returns the updated user profile data.
success
boolean
required
Indicates if the request was successful
message
string
required
Success message
data
object
required
Updated user profile data
id
string
required
User’s unique identifier
name
string
required
User’s full name
email
string
required
User’s email address
role
string
required
User’s role. One of: student, faculty, or store_employee
register_number
string
Student or faculty registration number (null if not applicable)
employee_id
string
Employee ID for store employees (null if not applicable)
phone_number
string
User’s phone number (null if not provided)
is_email_verified
boolean
required
Whether the user’s email has been verified
no_show_count
number
required
Number of times the user failed to pick up orders
trust_tier
string
required
User’s trust level based on order history. One of: good, watch, or restricted
ordering_restricted_until
string
ISO 8601 date when ordering restrictions will be lifted (null if not restricted)
last_no_show_at
string
ISO 8601 date of the last no-show incident (null if none)
created_at
string
required
ISO 8601 date when the account was created
updated_at
string
required
ISO 8601 date when the profile was last updated
store
object
Store information (only present if user role is store_employee and owns a store)

Error responses

success
boolean
required
Always false for errors
message
string
required
Error description

Validation rules

  • name: Must be a non-empty string if provided. Whitespace is automatically trimmed.
  • phoneNumber: Can be any string value, empty string, or null.
  • Fields not in the allowed list (name, phoneNumber) are ignored.
  • The email, role, register_number, employee_id, and other system fields cannot be modified through this endpoint.

Examples

curl -X PUT https://api.campusbite.com/api/users/profile \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jane Smith",
    "phoneNumber": "+1987654321"
  }'

Success response example

{
  "success": true,
  "message": "Profile updated successfully.",
  "data": {
    "id": "507f1f77bcf86cd799439011",
    "name": "Jane Smith",
    "email": "[email protected]",
    "role": "student",
    "register_number": "2021CS001",
    "employee_id": null,
    "phone_number": "+1987654321",
    "is_email_verified": true,
    "no_show_count": 0,
    "trust_tier": "good",
    "ordering_restricted_until": null,
    "last_no_show_at": null,
    "created_at": "2024-01-15T10:30:00.000Z",
    "updated_at": "2024-01-20T14:45:00.000Z",
    "store": null
  }
}

Update only name example

{
  "name": "Jane Smith"
}

Remove phone number example

{
  "phoneNumber": null
}

Error response example

{
  "success": false,
  "message": "User not found."
}
The updated_at timestamp is automatically updated whenever the profile is modified.

Build docs developers (and LLMs) love