Patients Endpoints

Create and manage patient records through the external API

Overview

The Patients API allows you to create new patient records and retrieve patient data for your hospital. All requests require proper authentication and the appropriate permissions.

API Endpoints

POSThttps://server.nyraai.io/api/external/patients

Create a new patient record and optionally schedule an appointment

Permission: patients:create

Headers

x-api-keyrequired

API key

x-api-secretrequired

API secret

Authorizationrequired

Bearer hospital token

Content-Typerequired

application/json

Request Body

{
  "phone": "9876543210",
  "name": "Ravi Kumar",
  "age": 35,
  "gender": "MALE",
  "date_of_birth": "1990-01-01",
  "email": "ravi@example.com",
  "address": "Kukatpally",
  "appointment_time": "2026-04-15T09:30:00Z",
  "doctor_id": "<doctor-uuid>",
  "branch_id": "<branch-uuid>"
}

Response

{
  "success": true,
  "message": "Patient created successfully",
  "data": {
    "patient_id": "patient-uuid",
    "appointment_id": "appointment-uuid-or-null"
  }
}
GEThttps://server.nyraai.io/api/external/patients

Fetch hospital-scoped patient list with pagination and search

Permission: patients:read

Headers

x-api-keyrequired

API key

x-api-secretrequired

API secret

Authorizationrequired

Bearer hospital token

Query Parameters

page(integer)

Page number (default: 1)

limit(integer)

Records per page (default: 20, max: 100)

q(string)

Search on name, phone, email

status(string)

Filter by status (e.g., ACTIVE)

branch_id(string)

Filter by branch (ignored if key has branch lock)

doctor_id(string)

Filter by assigned doctor

Response

{
  "success": true,
  "data": {
    "total": 123,
    "results": [
      {
        "id": "patient-uuid",
        "name": "Ravi Kumar",
        "phone": "9876543210",
        "age": 35,
        "gender": "MALE",
        "date_of_birth": "1990-01-01",
        "email": "ravi@example.com",
        "address": "Kukatpally",
        "status": "ACTIVE",
        "branch_id": "branch-uuid",
        "doctor_id": "doctor-uuid",
        "created_at": "2026-04-01T10:00:00.000Z",
        "updated_at": "2026-04-03T09:00:00.000Z"
      }
    ],
    "page": 1,
    "limit": 20,
    "total_pages": 7
  }
}

Usage Examples

Create a New Patient

curl -X POST "https://server.nyraai.io/api/external/patients" \
  -H "x-api-key: nyra_..." \
  -H "x-api-secret: secret..." \
  -H "Authorization: Bearer token..." \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "9876543210",
    "name": "Ravi Kumar",
    "age": 35,
    "gender": "MALE",
    "date_of_birth": "1990-01-01"
  }'

Fetch Patients with Search

curl -X GET "https://server.nyraai.io/api/external/patients?page=1&limit=20&q=ravi" \
  -H "x-api-key: nyra_..." \
  -H "x-api-secret: secret..." \
  -H "Authorization: Bearer token..."

JavaScript/Node.js Example

const createPatient = async (patientData) => {
  const response = await fetch(
    'https://server.nyraai.io/api/external/patients',
    {
      method: 'POST',
      headers: {
        'x-api-key': process.env.API_KEY,
        'x-api-secret': process.env.API_SECRET,
        'Authorization': `Bearer ${process.env.API_TOKEN}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(patientData)
    }
  );

  if (!response.ok) {
    throw new Error(`Failed to create patient: ${response.status}`);
  }

  const data = await response.json();
  return data.data.patient_id;
};

Patient Fields Reference

FieldTypeRequiredDescription
phonestringPhone number, 10+ digits
namestringFull name
ageintegerAge in years
genderstringMALE, FEMALE, OTHER
date_of_birthdateYYYY-MM-DD format
emailstringEmail address
addressstringStreet address
doctor_iduuidAssigned doctor UUID
branch_iduuidHospital branch UUID

Scroll sideways to see all columns

Error Handling

400 Bad Request

Invalid or missing required fields

{
  "success": false,
  "error": "Validation Error",
  "message": "Phone number is required"
}