Skip to main content
GET
/
api
/
users
/
:id
/
reservations
Get User Reservations
curl --request GET \
  --url https://api.example.com/api/users/:id/reservations
{
  "id": 123,
  "doctorId": 123,
  "patientId": 123,
  "timeBlockId": 123,
  "reason": "<string>",
  "notes": "<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 reservations
  • Doctors can view reservations for their time blocks
  • Admins can view any user’s reservations

Path Parameters

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

Response

id
integer
The reservation’s unique identifier
doctorId
integer
The ID of the doctor for this reservation
patientId
integer
The ID of the patient who made the reservation
timeBlockId
integer
The ID of the time block reserved
reason
string
Reason for the reservation (optional)
notes
string
Additional notes about the reservation (optional)
createdAt
string
ISO 8601 timestamp of when the reservation was created
updatedAt
string
ISO 8601 timestamp of when the reservation was last updated

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
404Reserva no encontradaThe reservation was not found
500Internal server errorAn unexpected error occurred while fetching reservations

Example Request

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

Example Response

{
  "id": 201,
  "doctorId": 7,
  "patientId": 42,
  "timeBlockId": 503,
  "reason": "Annual checkup",
  "notes": "Patient prefers morning appointments",
  "createdAt": "2024-03-01T09:30:00.000Z",
  "updatedAt": "2024-03-01T09:30:00.000Z"
}
The reservations endpoint returns a single reservation object, not an array. This appears to be based on the user ID parameter which acts as a filter.

Build docs developers (and LLMs) love