Skip to main content
GET
/
api
/
users
/
:id
/
appointments
Get User Appointments
curl --request GET \
  --url https://api.example.com/api/users/:id/appointments
{
  "appointments": [
    {
      "id": 123,
      "date": "<string>",
      "timeBlockId": 123,
      "patientId": 123,
      "doctorId": 123,
      "status": "<string>",
      "notes": "<string>",
      "reason": "<string>",
      "createdAt": "<string>",
      "updatedAt": "<string>"
    }
  ],
  "error": "<string>"
}

Authentication

Requires a valid JWT token in the Authorization header.
Authorization: Bearer <token>

Authorization

Any authenticated user can access this endpoint. The authorization logic depends on the user’s role:
  • Patients can view their own appointments
  • Doctors can view appointments where they are the assigned doctor
  • Admins can view any user’s appointments

Path Parameters

id
integer
required
The ID of the user whose appointments to retrieve.

Response

Returns an array of appointment objects.
appointments
array
Array of appointment objects

Error Responses

error
string
Error message describing what went wrong

Common Errors

Status CodeError MessageDescription
401Access Denied, no token providedNo JWT token was provided
403Invalid tokenThe JWT token is invalid or expired
500Error al obtener las citas del usuarioInternal server error while fetching appointments

Example Request

curl -X GET https://api.example.com/api/users/42/appointments \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

[
  {
    "id": 101,
    "date": "2024-03-15T10:00:00.000Z",
    "timeBlockId": 501,
    "patientId": 42,
    "doctorId": 7,
    "status": "CONFIRMED",
    "notes": "Follow-up appointment",
    "reason": "Annual checkup",
    "createdAt": "2024-03-01T09:30:00.000Z",
    "updatedAt": "2024-03-02T11:15:00.000Z"
  },
  {
    "id": 102,
    "date": "2024-03-22T14:30:00.000Z",
    "timeBlockId": 502,
    "patientId": 42,
    "doctorId": 7,
    "status": "PENDING",
    "notes": null,
    "reason": "Consultation",
    "createdAt": "2024-03-03T10:00:00.000Z",
    "updatedAt": "2024-03-03T10:00:00.000Z"
  }
]

Build docs developers (and LLMs) love