Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/bentlyy/Clinica/llms.txt

Use this file to discover all available pages before exploring further.

Create a new doctor record and optionally link it to an existing user account. Only admins can call this endpoint. The linked user must already exist and must have the doctor role.

Request

Method: POST
Path: /api/doctors
Auth required: Yes — admin role

Headers

Authorization
string
required
Bearer <token> — a JWT obtained from POST /api/auth/login with an account that has the admin role.

Body

name
string
required
The doctor’s full name.
specialty
string
required
The doctor’s medical specialty (e.g., "Cardiología", "Pediatría").
email
string
required
The doctor’s contact email. Must be unique across the doctors table.
user_id
integer
required
The ID of the existing user account to link to this doctor profile. The referenced user must have the doctor role. This field is required by the current implementation.

Response

201 — Created

Returns the full doctor record that was inserted.
id
integer
required
Unique ID of the new doctor record.
name
string
required
The doctor’s full name.
specialty
string
required
The doctor’s medical specialty.
email
string
required
The doctor’s contact email.
user_id
integer
The ID of the linked user account.

Error responses

StatusConditionError message
400Any required field is missing"Missing required fields"
400user_id does not match any user"User not found"
400The referenced user does not have the doctor role"User must have role doctor"
400A doctor profile already exists for this user_id or email"Doctor already exists for this user or email"
401No token provided or token is invalid
403Token is valid but the user does not have the admin role
Error responses use the shape { "error": "<message>" }.

Example

cURL
curl --request POST \
  --url http://localhost:3000/api/doctors \
  --header 'Authorization: Bearer <admin_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Dr. Carlos López",
    "specialty": "Neurología",
    "email": "c.lopez@clinica.com",
    "user_id": 7
  }'
Response
{
  "id": 3,
  "name": "Dr. Carlos López",
  "specialty": "Neurología",
  "email": "c.lopez@clinica.com",
  "user_id": 7
}
Before calling this endpoint, ensure the target user account exists and has been assigned the doctor role. A user with any other role (including patient or admin) will be rejected.

Build docs developers (and LLMs) love