Skip to main content
GET
/
api
/
time-blocks
/
:id
Get Time Block
curl --request GET \
  --url https://api.example.com/api/time-blocks/:id
{
  "id": 123,
  "doctorId": 123,
  "startTime": "<string>",
  "endTime": "<string>",
  "date": "<string>",
  "createdAt": "<string>",
  "updatedAt": "<string>",
  "doctor": {},
  "appointment": {}
}
Retrieve a specific time block by its ID.

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 any time block

Path Parameters

id
integer
required
The unique identifier of the time block to retrieveExample: 42

Response

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
doctor
object
Doctor information (if included in response)
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 (doctor accessing another doctor’s time block):
{
  "error": "Forbidden"
}

404 Not Found

Time block with specified ID does not exist:
{
  "error": "TimeBlock not found"
}

Example Request

curl -X GET https://api.example.com/api/time-blocks/42 \
  -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
}

Example Response (Booked Time Block)

{
  "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": {
    "id": 15,
    "patientId": 8,
    "doctorId": 5,
    "status": "CONFIRMED",
    "reason": "Annual checkup",
    "notes": "Patient has been fasting"
  }
}

Notes

  • Doctors can only retrieve their own time blocks
  • Admins can retrieve any time block
  • The response may include related data such as appointment details
  • A time block with appointment: null indicates it’s available for booking

Build docs developers (and LLMs) love