Skip to main content
PUT
/
api
/
updateuserdata
Update User Data
curl --request PUT \
  --url https://api.example.com/api/updateuserdata \
  --header 'Content-Type: application/json' \
  --data '
{
  "barExamTestDate": "<string>",
  "currentScore": 123,
  "targetScore": 123,
  "examResultFinal": "<string>"
}
'
{
  "barExamTestDate": "<string>",
  "currentScore": 123,
  "targetScore": 123,
  "updatedAt": "<string>",
  "examResultFinal": {
    "passed": {}
  },
  "error": "<string>"
}

Overview

Updates user exam information including test dates, scores, and exam results. This endpoint validates score ranges and ensures data integrity before persisting changes to Firestore.

Query Parameters

uuid
string
required
The unique identifier for the user

Request Body

barExamTestDate
string
required
The scheduled bar exam test date
currentScore
number
required
Current practice score. Must be between 260 and 400.
targetScore
number
required
Target score for the bar exam. Must be between 260 and 400, and greater than or equal to currentScore.
examResultFinal
string
Final exam result status. Accepted values:
  • "pass": User passed the exam
  • "fail": User failed the exam
  • "prefer-not": User prefers not to disclose

Request

cURL
curl -X PUT "https://api.example.com/api/updateuserdata?uuid=user123" \
  -H "Content-Type: application/json" \
  -d '{
    "barExamTestDate": "2026-07-28",
    "currentScore": 310,
    "targetScore": 350,
    "examResultFinal": "pass"
  }'

Validation Rules

  1. Score Range: Both currentScore and targetScore must be between 260 and 400
  2. Score Relationship: targetScore must be greater than or equal to currentScore
  3. User Existence: User document must exist in Firestore
  4. Valid JSON: Request body must be valid JSON format

Response

Returns the complete updated user document with all fields.
barExamTestDate
string
The updated exam test date
currentScore
number
The updated current score
targetScore
number
The updated target score
updatedAt
string
ISO 8601 timestamp of when the update occurred
examResultFinal
object
Final exam result (only present if provided in request)

Response Example

{
  "barExamTestDate": "2026-07-28",
  "currentScore": 310,
  "targetScore": 350,
  "updatedAt": "2026-03-03T10:30:00.000Z",
  "examResultFinal": {
    "passed": true
  },
  "weeklyHours": 20,
  "onboarded": true,
  "progress": {
    "constitutionalLaw": 45,
    "contracts": 38,
    "criminalLaw": 52,
    "totalTimeSpent": 1200,
    "testAttempts": 5,
    "lastUpdated": "2026-03-02T18:45:00.000Z"
  },
  "StudyStreak": 7,
  "PracticeQuestions": 234,
  "questionDataKey": "decent"
}

Error Responses

error
string
Error message describing what went wrong

400 Bad Request - Missing UUID

Returned when UUID is not provided in query parameters.
{
  "error": "UUID is required"
}

400 Bad Request - Invalid JSON

Returned when the request body is not valid JSON.
{
  "error": "Invalid JSON format"
}

400 Bad Request - Missing Required Fields

Returned when required fields are missing from the request body.
{
  "error": "Missing required fields"
}
Required fields:
  • barExamTestDate
  • currentScore
  • targetScore

400 Bad Request - Invalid Score Range

Returned when scores are outside the valid range (260-400).
{
  "error": "Scores must be between 260 and 400"
}

400 Bad Request - Invalid Score Relationship

Returned when target score is less than current score.
{
  "error": "Target score must be greater than or equal to current score"
}

404 Not Found

Returned when the user document does not exist.
{
  "error": "User not found"
}

500 Internal Server Error - Update Failed

Returned when Firestore update operation fails.
{
  "error": "Failed to update user data"
}

500 Internal Server Error - General Error

Returned for unexpected server errors.
{
  "error": "Internal server error"
}

Notes

  • The endpoint uses merge strategy when updating, preserving existing fields not included in the request
  • The updatedAt timestamp is automatically set to the current time
  • The examResultFinal field is only added if explicitly provided in the request
  • All score values are validated as integers within the specified range

Build docs developers (and LLMs) love