Retrieve a list of time blocks based on user role and filters.
Authentication
Requires JWT authentication via Bearer token.
Required Header:
Authorization: Bearer <token>
Authorization
Allowed roles:
doctor - Can view their own time blocks
admin - Can view all time blocks
Query Parameters
Query parameters can be used to filter the results (implementation-specific).
Filter time blocks by doctor IDAdmin only - Admins can filter by any doctor IDDoctor role - Automatically filtered to their own ID
Filter time blocks starting from this dateFormat: ISO 8601 date stringExample: 2026-03-15T00:00:00.000Z
Filter time blocks up to this dateFormat: ISO 8601 date stringExample: 2026-03-20T23:59:59.999Z
Response
Returns an array of time block objects.
Unique identifier for the time block
ID of the doctor who owns this time block
Start time in ISO 8601 format
End time in ISO 8601 format
Record creation timestamp
Associated appointment if the time block is bookednull if the time block is available
Error Responses
401 Unauthorized
Missing or invalid authentication token:
{
"error": "Unauthorized"
}
403 Forbidden
Insufficient permissions:
Example Request
As Doctor
curl -X GET https://api.example.com/api/time-blocks \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
As Admin (with filters)
curl -X GET "https://api.example.com/api/time-blocks?doctorId=5&startDate=2026-03-15T00:00:00.000Z" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Example Response
[
{
"id": 42,
"doctorId": 5,
"startTime": "2026-03-15T09:00:00.000Z",
"endTime": "2026-03-15T10:00:00.000Z",
"date": "2026-03-03T10:30:00.000Z",
"createdAt": "2026-03-03T10:30:00.000Z",
"updatedAt": "2026-03-03T10:30:00.000Z",
"appointment": null
},
{
"id": 43,
"doctorId": 5,
"startTime": "2026-03-15T10:00:00.000Z",
"endTime": "2026-03-15T11:00:00.000Z",
"date": "2026-03-03T10:30:00.000Z",
"createdAt": "2026-03-03T10:30:00.000Z",
"updatedAt": "2026-03-03T10:30:00.000Z",
"appointment": {
"id": 15,
"patientId": 8,
"status": "CONFIRMED"
}
}
]
Notes
- Doctors automatically see only their own time blocks
- Admins can see all time blocks across all doctors
- The response may include the
appointment relationship if a time block is booked
- Empty array
[] is returned if no time blocks match the criteria