Skip to main content
GET
/
api
/
time-blocks
List Time Blocks
curl --request GET \
  --url https://api.example.com/api/time-blocks
{
  "id": 123,
  "doctorId": 123,
  "startTime": "<string>",
  "endTime": "<string>",
  "date": "<string>",
  "createdAt": "<string>",
  "updatedAt": "<string>",
  "appointment": {}
}
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).
doctorId
integer
Filter time blocks by doctor IDAdmin only - Admins can filter by any doctor IDDoctor role - Automatically filtered to their own ID
startDate
string
Filter time blocks starting from this dateFormat: ISO 8601 date stringExample: 2026-03-15T00:00:00.000Z
endDate
string
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.
id
integer
Unique identifier for the time block
doctorId
integer
ID of the doctor who owns this time block
startTime
string
Start time in ISO 8601 format
endTime
string
End time in ISO 8601 format
date
string
Creation date/timestamp
createdAt
string
Record creation timestamp
updatedAt
string
Last update timestamp
appointment
object
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:
{
  "error": "Forbidden"
}

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

Build docs developers (and LLMs) love