Skip to main content

Endpoint

POST /api/especialidades

Authentication

This endpoint requires authentication with an admin role. Include a valid JWT token in the Authorization header.
Authorization: Bearer <token>

Description

Creates a new medical specialty in the system. Specialties are used to categorize doctors and help patients find the right medical professional for their needs.

Request Body

nombre
string
required
Name of the medical specialty. Must be unique.
descripcion
string
Description of what the specialty covers or treats

Response

Returns the newly created specialty object.

Response Fields

id
integer
Unique identifier for the newly created specialty
nombre
string
Name of the specialty
descripcion
string
Description of the specialty (null if not provided)

Example Request

curl -X POST "https://api.example.com/api/especialidades" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Neurology",
    "descripcion": "Medical specialty dealing with disorders of the nervous system"
  }'

Example Response

{
  "id": 4,
  "nombre": "Neurology",
  "descripcion": "Medical specialty dealing with disorders of the nervous system"
}

Error Responses

400 Bad Request
Missing required field
{
  "message": "El nombre es obligatorio"
}
401 Unauthorized
Missing or invalid authentication token
{
  "message": "Token no proporcionado"
}
403 Forbidden
User does not have admin role
{
  "message": "Acceso denegado"
}
409 Conflict
Specialty name already exists
{
  "message": "La especialidad ya existe"
}
500 Internal Server Error
Server error while creating specialty
{
  "message": "Error al crear especialidad"
}

Notes

  • The specialty name must be unique across the system
  • The description field is optional but recommended for better user understanding
  • Once created, the specialty can be assigned to doctors

Build docs developers (and LLMs) love