Doctor Slots & Availability
External API for doctor weekly schedules, overrides, and generated appointment slots
Overview
For frontend and integration teams
Use these endpoints to read and update a doctor's availability configuration and to fetch generated slots for a given date. All routes live under /api/external.
Base URL
Use your backend host with the /api prefix, then /external/... for these routes
All calls use the same three auth headers as other external APIs. Paths below use the production host; swap the base for local development.
URL reference
Bases and paths used in this guide
API base
- Production
- https://server.nyraai.io/api
- Local
- http://127.0.0.1:5000/api
Doctor slots endpoints
- GET
https://server.nyraai.io/api/external/doctors/:doctor_id/availability
Weekly schedule, overrides, slot length, fee
- PUT
https://server.nyraai.io/api/external/doctors/:doctor_id/availability
Create or update availability (JSON body)
- GET
https://server.nyraai.io/api/external/doctors/:doctor_id/slots
Query ?date=YYYY-MM-DD (optional; defaults to tomorrow)
Authentication
Required on every request
Send all three credentials together. If any one is missing or invalid, the API returns 401 Unauthorized.
x-api-key— external API keyx-api-secret— paired secretAuthorization: Bearer <hospital_token>— hospital token from key issuance (REST; not the WebSocket JWT)
Permissions
Scopes required on the API key
doctor_slots:read
GET availability and GET generated slots
doctor_slots:write
PUT availability (create or update schedule)
Existing keys with legacy scopes may still pass checks because the middleware supports permission aliases. New integrations should request doctor_slots:read and doctor_slots:write explicitly.
API endpoints
https://server.nyraai.io/api/external/doctors/:doctor_id/availabilityFetch weekly schedule, slot duration, date overrides, consultation fee, and metadata for a doctor.
Permission: doctor_slots:read
Headers
x-api-keyrequiredAPI key
x-api-secretrequiredAPI secret
AuthorizationrequiredBearer hospital token
Response
{
"success": true,
"data": {
"doctor_id": "8f42f1a3-7d11-4ee0-8f54-7d7be7bdf2d6",
"schedule": {
"Monday": { "is_available": true, "slots": [{ "start": "09:00", "end": "13:00" }] },
"Tuesday": { "is_available": true, "slots": [{ "start": "09:00", "end": "13:00" }] },
"Wednesday": { "is_available": false, "slots": [] },
"Thursday": { "is_available": true, "slots": [{ "start": "14:00", "end": "18:00" }] },
"Friday": { "is_available": true, "slots": [{ "start": "10:00", "end": "16:00" }] },
"Saturday": { "is_available": false, "slots": [] },
"Sunday": { "is_available": false, "slots": [] }
},
"slot_duration_minutes": 30,
"consultation_fee": 500,
"currency": "INR",
"overrides": {
"2026-04-25": {
"is_available": true,
"slots": [{ "start": "11:00", "end": "15:00" }]
}
},
"has_schedule": true,
"updated_at": "2026-04-21T06:12:10.000Z"
}
}https://server.nyraai.io/api/external/doctors/:doctor_id/availabilityCreate or replace the doctor availability schedule used for slot generation. Supports full replace or partial updates when a schedule already exists.
Permission: doctor_slots:write
Headers
x-api-keyrequiredAPI key
x-api-secretrequiredAPI secret
AuthorizationrequiredBearer hospital token
Content-Typerequiredapplication/json
Request Body
{
"schedule": {
"Monday": { "is_available": true, "slots": [{ "start": "09:00", "end": "13:00" }, { "start": "14:00", "end": "18:00" }] },
"Tuesday": { "is_available": true, "slots": [{ "start": "09:00", "end": "17:00" }] },
"Wednesday": { "is_available": true, "slots": [{ "start": "09:00", "end": "17:00" }] },
"Thursday": { "is_available": true, "slots": [{ "start": "09:00", "end": "17:00" }] },
"Friday": { "is_available": true, "slots": [{ "start": "09:00", "end": "17:00" }] },
"Saturday": { "is_available": false, "slots": [] },
"Sunday": { "is_available": false, "slots": [] }
},
"slot_duration_minutes": 30,
"consultation_fee": 650,
"overrides": {
"2026-04-30": { "is_available": false, "slots": [] },
"2026-05-02": { "is_available": true, "slots": [{ "start": "12:00", "end": "16:00" }] }
}
}Response
{
"success": true,
"message": "Doctor availability updated successfully",
"data": {
"doctor_id": "8f42f1a3-7d11-4ee0-8f54-7d7be7bdf2d6",
"schedule": {
"Monday": { "is_available": true, "slots": [{ "start": "09:00", "end": "13:00" }] },
"Tuesday": { "is_available": true, "slots": [{ "start": "09:00", "end": "13:00" }] },
"Wednesday": { "is_available": true, "slots": [{ "start": "09:00", "end": "13:00" }] },
"Thursday": { "is_available": true, "slots": [{ "start": "09:00", "end": "13:00" }] },
"Friday": { "is_available": true, "slots": [{ "start": "09:00", "end": "13:00" }] },
"Saturday": { "is_available": false, "slots": [] },
"Sunday": { "is_available": false, "slots": [] }
},
"slot_duration_minutes": 30,
"overrides": {},
"consultation_fee": 650,
"currency": "INR",
"updated_at": "2026-04-21T06:20:00.000Z"
}
}https://server.nyraai.io/api/external/doctors/:doctor_id/slotsReturn generated appointment slots for a doctor on a date, with booked / free / locked counts. If date is omitted, the API defaults to tomorrow.
Permission: doctor_slots:read
Headers
x-api-keyrequiredAPI key
x-api-secretrequiredAPI secret
AuthorizationrequiredBearer hospital token
Query Parameters
date(date)Target date YYYY-MM-DD (optional; defaults to tomorrow)
Response
{
"success": true,
"data": {
"doctor_id": "8f42f1a3-7d11-4ee0-8f54-7d7be7bdf2d6",
"date": "2026-04-22",
"is_on_leave": false,
"leave_reason": null,
"total_slots": 6,
"booked": 1,
"free": 4,
"locked": 1,
"slots": [
{
"start": "2026-04-22T03:30:00.000Z",
"end": "2026-04-22T04:00:00.000Z",
"display_time": "09:00 AM",
"status": "AVAILABLE",
"available": true
},
{
"start": "2026-04-22T04:00:00.000Z",
"end": "2026-04-22T04:30:00.000Z",
"display_time": "09:30 AM",
"status": "BOOKED",
"available": false
}
],
"consultation_fee": 650,
"currency": "INR"
}
}Update modes (PUT availability)
Full vs partial body
1. Full update
Send a complete schedule for all seven days to create or replace the schedule. You may include slot_duration_minutes, consultation_fee, and overrides in the same request.
2. Partial update
When a schedule already exists, you may send only the fields you want to change (for example only consultation_fee, only overrides, or only slot_duration_minutes). If the doctor has no schedule yet, partial updates are rejected — send a full schedule first.
Partial body examples
Fee only:
{
"consultation_fee": 700
}Overrides only:
{
"overrides": {
"2026-05-12": {
"is_available": true,
"slots": [{ "start": "10:00", "end": "14:00" }]
}
}
}Slot duration only:
{
"slot_duration_minutes": 15
}Validation rules (PUT availability)
doctor_idmust be a UUID.- At least one of:
schedule,slot_duration_minutes,overrides,consultation_fee. slot_duration_minutesmust be one of: 15, 20, 30, 45, 60.- Day slot times use 24-hour
HH:MM. - For each slot,
endmust be greater than start. - Slots must not overlap within the same day.
- A full
schedulemust include all seven weekdays. overrideskeys must be dates inYYYY-MM-DD.
Common errors
400 — invalid doctor_id, invalid date, or validation error (see message and optional details).
404 — doctor not found within the API key scope (hospital / branch).
401 — missing or mismatched credentials.
Integration notes
- Branch-scoped API keys can only access doctors in that branch.
- Slot generation uses schedule, overrides, leave, existing bookings, and lock windows.
- Each slot includes
available(derived fromstatus === "AVAILABLE") for simple UI binding. - Validate
HH:MMand non-overlapping ranges client-side before calling PUT to reduce round trips.
Fetch examples (JavaScript)
Uses https://server.nyraai.io/api — swap host for local dev
Shared helper + three calls
const API_BASE = "https://server.nyraai.io/api";
function externalHeaders({ apiKey, apiSecret, hospitalToken }) {
return {
"Content-Type": "application/json",
"x-api-key": apiKey,
"x-api-secret": apiSecret,
Authorization: `Bearer ${hospitalToken}`,
};
}
async function getDoctorAvailability(doctorId, auth) {
const res = await fetch(
`${API_BASE}/external/doctors/${doctorId}/availability`,
{ method: "GET", headers: externalHeaders(auth) }
);
if (!res.ok) throw await res.json();
return res.json();
}
async function updateDoctorAvailability(doctorId, payload, auth) {
const res = await fetch(
`${API_BASE}/external/doctors/${doctorId}/availability`,
{
method: "PUT",
headers: externalHeaders(auth),
body: JSON.stringify(payload),
}
);
if (!res.ok) throw await res.json();
return res.json();
}
async function getDoctorSlots(doctorId, date, auth) {
const query = date ? `?date=${encodeURIComponent(date)}` : "";
const res = await fetch(
`${API_BASE}/external/doctors/${doctorId}/slots${query}`,
{ method: "GET", headers: externalHeaders(auth) }
);
if (!res.ok) throw await res.json();
return res.json();
}cURL quick checks
# Get availability
curl -s "https://server.nyraai.io/api/external/doctors/DOCTOR_UUID/availability" \
-H "x-api-key: nyra_..." \
-H "x-api-secret: ..." \
-H "Authorization: Bearer <hospital_token>"
# Get slots for a date
curl -s "https://server.nyraai.io/api/external/doctors/DOCTOR_UUID/slots?date=2026-04-22" \
-H "x-api-key: nyra_..." \
-H "x-api-secret: ..." \
-H "Authorization: Bearer <hospital_token>"