{
  "openapi": "3.1.0",
  "info": {
    "title": "citas-bot: API de integración",
    "description": "API para que el sistema de cada clínica (HIS, ERP, CRM, call center) consulte la agenda y opere citas en citas-bot. Autenticación con la clave de API de la clínica, JSON en snake_case y fechas en la hora local de la clínica. Guía completa: https://valdratech.app/desarrolladores",
    "contact": {
      "name": "Valdra Tech",
      "url": "https://valdratech.app/desarrolladores",
      "email": "contacto@valdratech.app"
    },
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://citas-bot.valdratech.app",
      "description": "Producción"
    }
  ],
  "security": [
    {
      "claveApi": []
    }
  ],
  "tags": [
    {
      "name": "Catálogo",
      "description": "La clínica de la clave, sus especialidades, profesionales y consultorios, y los horarios libres."
    },
    {
      "name": "Citas",
      "description": "Consultar, agendar, reprogramar, cancelar, confirmar y marcar asistencia, con las reglas de recepción."
    },
    {
      "name": "Lista de espera",
      "description": "Pacientes que esperan un cupo: cuándo se libera un horario, citas-bot se lo ofrece por WhatsApp."
    }
  ],
  "paths": {
    "/api/integracion/v1/lista-espera": {
      "get": {
        "tags": [
          "Lista de espera"
        ],
        "summary": "Inscritos",
        "description": "Inscripciones vigentes. Alcance `lista_espera:leer`.",
        "operationId": "ver",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListaEspera"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Lista de espera"
        ],
        "summary": "Anotar",
        "description": "Anota a una persona para una especialidad, con franja y periodo opcionales. Cada persona (nombre o documento) del mismo teléfono tiene su propia inscripcion. Alcance `lista_espera:escribir`.",
        "operationId": "anotar",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Opcional. Un valor único por operación (p. ej. un UUID): si reintenta con la misma llave y el mismo cuerpo recibe la respuesta original (header `Idempotent-Replayed: true`) y la operación no se repite. Vale 24 horas.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "6f1c8a2e-3b7d-4e0a-9c11-2a5f6d7e8b90"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NuevaInscripcion"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Anotado; `vence_en` dice hasta cuándo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Inscrito"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "409": {
            "description": "`HORARIO_TOMADO`, `IDEMPOTENCIA_EN_CONFLICTO` o `IDEMPOTENCIA_EN_PROCESO`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/lista-espera/{id}/retirar": {
      "post": {
        "tags": [
          "Lista de espera"
        ],
        "summary": "Retirar",
        "description": "Alcance `lista_espera:escribir`.",
        "operationId": "retirar",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Opcional. Un valor único por operación (p. ej. un UUID): si reintenta con la misma llave y el mismo cuerpo recibe la respuesta original (header `Idempotent-Replayed: true`) y la operación no se repite. Vale 24 horas.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "6f1c8a2e-3b7d-4e0a-9c11-2a5f6d7e8b90"
          }
        ],
        "responses": {
          "204": {
            "description": "Retirado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "404": {
            "description": "No existe en su clínica (`CITA_NO_ENCONTRADA`, `INSCRIPCION_NO_ENCONTRADA`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "409": {
            "description": "`HORARIO_TOMADO`, `IDEMPOTENCIA_EN_CONFLICTO` o `IDEMPOTENCIA_EN_PROCESO`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/citas": {
      "get": {
        "tags": [
          "Citas"
        ],
        "summary": "Citas de un rango",
        "description": "Citas entre `desde` y `hasta` (días completos, máximo 31), en cualquier estado salvo que se filtre. Alcance `citas:leer`.",
        "operationId": "citas",
        "parameters": [
          {
            "name": "desde",
            "in": "query",
            "description": "Primer día",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-20"
          },
          {
            "name": "hasta",
            "in": "query",
            "description": "Último día (incluido); máximo 31 días",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-24"
          },
          {
            "name": "profesional_id",
            "in": "query",
            "description": "Solo este profesional",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "estado",
            "in": "query",
            "description": "pendiente, confirmada, atendida, no_asistio, cancelada o reprogramada",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Citas"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Citas"
        ],
        "summary": "Agendar",
        "description": "Agenda en un horario libre (`slot_id` de `GET /disponibilidad`). **Exige `Idempotency-Key`**: un reintento con la misma llave no agenda dos veces. Si el horario se tomó un instante antes responde 409 `HORARIO_TOMADO`. El paciente recibe el aviso por WhatsApp y sale el webhook `cita.creada` con `origen: integracion`. Alcance `citas:escribir`.",
        "operationId": "crear",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Obligatoria. Un valor único por operación (p. ej. un UUID): si reintenta con la misma llave y el mismo cuerpo recibe la respuesta original (header `Idempotent-Replayed: true`) y la operación no se repite. Vale 24 horas.",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "6f1c8a2e-3b7d-4e0a-9c11-2a5f6d7e8b90"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NuevaCita"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "La cita creada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Cita"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "409": {
            "description": "`HORARIO_TOMADO`, `IDEMPOTENCIA_EN_CONFLICTO` o `IDEMPOTENCIA_EN_PROCESO`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/citas/{id}/reprogramar": {
      "post": {
        "tags": [
          "Citas"
        ],
        "summary": "Reprogramar",
        "description": "La cita queda `reprogramada` y se crea otra en el nuevo horario: la respuesta es la cita NUEVA, con otro `id`. `motivo` es obligatorio. Alcance `citas:escribir`.",
        "operationId": "reprogramar",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Opcional. Un valor único por operación (p. ej. un UUID): si reintenta con la misma llave y el mismo cuerpo recibe la respuesta original (header `Idempotent-Replayed: true`) y la operación no se repite. Vale 24 horas.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "6f1c8a2e-3b7d-4e0a-9c11-2a5f6d7e8b90"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Reprogramacion"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "La cita nueva",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Cita"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "404": {
            "description": "No existe en su clínica (`CITA_NO_ENCONTRADA`, `INSCRIPCION_NO_ENCONTRADA`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "409": {
            "description": "`HORARIO_TOMADO`, `IDEMPOTENCIA_EN_CONFLICTO` o `IDEMPOTENCIA_EN_PROCESO`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/citas/{id}/confirmar": {
      "post": {
        "tags": [
          "Citas"
        ],
        "summary": "Confirmar asistencia",
        "description": "Solo citas `pendiente` (por ejemplo, el call center llamó al paciente). Alcance `asistencia:escribir`.",
        "operationId": "confirmar",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Opcional. Un valor único por operación (p. ej. un UUID): si reintenta con la misma llave y el mismo cuerpo recibe la respuesta original (header `Idempotent-Replayed: true`) y la operación no se repite. Vale 24 horas.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "6f1c8a2e-3b7d-4e0a-9c11-2a5f6d7e8b90"
          }
        ],
        "responses": {
          "204": {
            "description": "Confirmada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "404": {
            "description": "No existe en su clínica (`CITA_NO_ENCONTRADA`, `INSCRIPCION_NO_ENCONTRADA`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "409": {
            "description": "`HORARIO_TOMADO`, `IDEMPOTENCIA_EN_CONFLICTO` o `IDEMPOTENCIA_EN_PROCESO`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/citas/{id}/cancelar": {
      "post": {
        "tags": [
          "Citas"
        ],
        "summary": "Cancelar",
        "description": "`motivo` es obligatorio. No se puede después de la hora de inicio. El horario vuelve a quedar libre y se ofrece a la lista de espera. Alcance `citas:escribir`.",
        "operationId": "cancelar",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Opcional. Un valor único por operación (p. ej. un UUID): si reintenta con la misma llave y el mismo cuerpo recibe la respuesta original (header `Idempotent-Replayed: true`) y la operación no se repite. Vale 24 horas.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "6f1c8a2e-3b7d-4e0a-9c11-2a5f6d7e8b90"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Cancelacion"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Cancelada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "404": {
            "description": "No existe en su clínica (`CITA_NO_ENCONTRADA`, `INSCRIPCION_NO_ENCONTRADA`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "409": {
            "description": "`HORARIO_TOMADO`, `IDEMPOTENCIA_EN_CONFLICTO` o `IDEMPOTENCIA_EN_PROCESO`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/citas/{id}/asistencia": {
      "post": {
        "tags": [
          "Citas"
        ],
        "summary": "Marcar asistencia",
        "description": "`atendida` o `no_asistio`, desde la hora de inicio de la cita. Alcance `asistencia:escribir`.",
        "operationId": "asistencia",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Opcional. Un valor único por operación (p. ej. un UUID): si reintenta con la misma llave y el mismo cuerpo recibe la respuesta original (header `Idempotent-Replayed: true`) y la operación no se repite. Vale 24 horas.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "6f1c8a2e-3b7d-4e0a-9c11-2a5f6d7e8b90"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Asistencia"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Registrada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "404": {
            "description": "No existe en su clínica (`CITA_NO_ENCONTRADA`, `INSCRIPCION_NO_ENCONTRADA`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "409": {
            "description": "`HORARIO_TOMADO`, `IDEMPOTENCIA_EN_CONFLICTO` o `IDEMPOTENCIA_EN_PROCESO`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/profesionales": {
      "get": {
        "tags": [
          "Catálogo"
        ],
        "summary": "Profesionales",
        "description": "Activos e inactivos, con la duración de sus citas y hasta qué día tienen agenda abierta (`disponible_hasta`). Alcance `catalogo:leer`.",
        "operationId": "profesionales",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Profesional"
                  }
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/pacientes/citas": {
      "get": {
        "tags": [
          "Citas"
        ],
        "summary": "Citas de un paciente",
        "description": "Por su teléfono de WhatsApp, o por `tipo_documento` y `numero_documento` con que se agendaron. Las más recientes primero, máximo 100. Alcance `pacientes:leer`.",
        "operationId": "citasDePaciente",
        "parameters": [
          {
            "name": "telefono",
            "in": "query",
            "description": "WhatsApp del paciente",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": 3001112233
          },
          {
            "name": "tipo_documento",
            "in": "query",
            "description": "CC, TI, CE, PA... (ver `GET /clinica`)",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "CC"
          },
          {
            "name": "numero_documento",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": 1020304050
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CitasDePaciente"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/especialidades": {
      "get": {
        "tags": [
          "Catálogo"
        ],
        "summary": "Especialidades",
        "description": "Las que se pueden agendar: las que tienen al menos un profesional activo. Alcance `catalogo:leer`.",
        "operationId": "especialidades",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Especialidad"
                  }
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/disponibilidad": {
      "get": {
        "tags": [
          "Catálogo"
        ],
        "summary": "Horarios libres",
        "description": "Horarios libres de profesionales activos entre `desde` y `hasta` (días completos, máximo 31) que todavía no empiezan, ordenados por hora. El `slot_id` es el que se usa para agendar o reprogramar. Alcance `disponibilidad:leer`.",
        "operationId": "disponibilidad",
        "parameters": [
          {
            "name": "desde",
            "in": "query",
            "description": "Primer día, en la fecha local de la clínica",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-20"
          },
          {
            "name": "hasta",
            "in": "query",
            "description": "Último día (incluido); máximo 31 días desde `desde`",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-24"
          },
          {
            "name": "especialidad",
            "in": "query",
            "description": "Solo esta especialidad (sin importar mayúsculas)",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "psicologia"
          },
          {
            "name": "profesional_id",
            "in": "query",
            "description": "Solo este profesional",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Disponibilidad"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/consultorios": {
      "get": {
        "tags": [
          "Catálogo"
        ],
        "summary": "Consultorios",
        "description": "Alcance `catalogo:leer`.",
        "operationId": "consultorios",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Consultorio"
                  }
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/clinica": {
      "get": {
        "tags": [
          "Catálogo"
        ],
        "summary": "Datos de la clínica",
        "description": "Nombre, zona horaria, si exige documento al agendar, tipos de documento aceptados y los alcances de la clave. Sirve para comprobar que la clave funciona. Cualquier alcance.",
        "operationId": "clinica",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Clinica"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    },
    "/api/integracion/v1/citas/{id}": {
      "get": {
        "tags": [
          "Citas"
        ],
        "summary": "Una cita",
        "description": "Alcance `citas:leer`. 404 `CITA_NO_ENCONTRADA` si no es de su clínica.",
        "operationId": "cita",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Cita"
                }
              }
            }
          },
          "401": {
            "description": "`CLAVE_INVALIDA`: falta la clave, no existe, venció o fue revocada",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "403": {
            "description": "`ALCANCE_INSUFICIENTE` o `IP_NO_PERMITIDA`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "404": {
            "description": "No existe en su clínica (`CITA_NO_ENCONTRADA`, `INSCRIPCION_NO_ENCONTRADA`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "422": {
            "description": "La regla de negocio no lo permite (`DATOS_INVALIDOS`, `MOTIVO_REQUERIDO`, `FUERA_DE_VENTANA`, `RANGO_INVALIDO`...)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          },
          "429": {
            "description": "`LIMITE_DE_PETICIONES`: espere los segundos de `Retry-After`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problema"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "NuevaInscripcion": {
        "type": "object",
        "properties": {
          "telefono": {
            "type": "string",
            "description": "WhatsApp al que se ofrecen los cupos",
            "example": "3001112233"
          },
          "nombre": {
            "type": [
              "string",
              "null"
            ],
            "description": "Quién espera: cada persona del mismo teléfono tiene su inscripcion",
            "example": "Ana Torres"
          },
          "especialidad": {
            "type": "string",
            "example": "psicologia"
          },
          "franja": {
            "type": [
              "string",
              "null"
            ],
            "description": "Por defecto cualquiera",
            "enum": [
              "manana",
              "tarde",
              "cualquiera"
            ]
          },
          "desde": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Solo cupos desde este día",
            "example": "2026-10-20"
          },
          "hasta": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Solo cupos hasta este día",
            "example": "2026-10-31"
          },
          "consentimiento_obtenido": {
            "type": "boolean",
            "description": "Su sistema declara que la persona autorizó el tratamiento de sus datos",
            "example": true
          },
          "tipo_documento": {
            "type": [
              "string",
              "null"
            ],
            "example": "CC"
          },
          "numero_documento": {
            "type": [
              "string",
              "null"
            ],
            "example": "1020304050"
          }
        }
      },
      "Inscrito": {
        "type": "object",
        "properties": {
          "vence_en": {
            "type": "string",
            "format": "date-time",
            "description": "Hasta cuándo sigue anotado"
          }
        }
      },
      "NuevaCita": {
        "type": "object",
        "properties": {
          "slot_id": {
            "type": "string",
            "description": "El `slot_id` de `GET /disponibilidad`",
            "example": "348"
          },
          "paciente": {
            "$ref": "#/components/schemas/PacienteNuevo"
          },
          "consentimiento_obtenido": {
            "type": "boolean",
            "description": "Su sistema declara que el paciente autorizó el tratamiento de sus datos (Ley 1581). Sin consentimiento previo y sin esto en true: 422 `CONSENTIMIENTO_REQUERIDO_PERSONAL`",
            "example": true
          }
        }
      },
      "PacienteNuevo": {
        "type": "object",
        "properties": {
          "telefono": {
            "type": "string",
            "description": "WhatsApp del paciente: 10 digitos de Colombia o 57 + el número; otro pais con + e indicativo. Le llegan los avisos y recordatorios",
            "example": "3001112233"
          },
          "nombre": {
            "type": "string",
            "example": "Ana Torres"
          },
          "tipo_documento": {
            "type": [
              "string",
              "null"
            ],
            "description": "Obligatorio si `documento_obligatorio` (ver `GET /clinica`)",
            "example": "CC"
          },
          "numero_documento": {
            "type": [
              "string",
              "null"
            ],
            "example": "1020304050"
          }
        }
      },
      "Cita": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "example": 17
          },
          "estado": {
            "type": "string",
            "description": "pendiente, confirmada, atendida, no_asistio, cancelada o reprogramada",
            "example": "confirmada"
          },
          "inicio": {
            "type": "string",
            "format": "date-time",
            "description": "Hora local de la clínica",
            "example": "2026-10-20T08:00:00"
          },
          "fin": {
            "type": "string",
            "format": "date-time",
            "example": "2026-10-20T08:30:00"
          },
          "profesional_id": {
            "type": "integer",
            "format": "int64"
          },
          "profesional": {
            "type": [
              "string",
              "null"
            ],
            "example": "Dra. Paula Mendez"
          },
          "especialidad": {
            "type": [
              "string",
              "null"
            ],
            "example": "psicologia"
          },
          "consultorio_id": {
            "type": "integer",
            "format": "int64"
          },
          "paciente": {
            "$ref": "#/components/schemas/PacienteDeCita"
          },
          "canal": {
            "type": "string",
            "description": "Por dónde entró: panel (también esta API), flujo (menú del bot) o ia (asistente)",
            "example": "panel"
          }
        }
      },
      "PacienteDeCita": {
        "type": "object",
        "properties": {
          "nombre": {
            "type": "string",
            "example": "Ana Torres"
          },
          "telefono": {
            "type": [
              "string",
              "null"
            ],
            "example": "573001112233"
          },
          "documento_tipo": {
            "type": [
              "string",
              "null"
            ],
            "example": "CC"
          },
          "documento_numero": {
            "type": [
              "string",
              "null"
            ],
            "example": "1020304050"
          }
        }
      },
      "Reprogramacion": {
        "type": "object",
        "properties": {
          "nuevo_slot_id": {
            "type": "string",
            "description": "El `slot_id` del nuevo horario",
            "example": "352"
          },
          "motivo": {
            "type": "string",
            "description": "Obligatorio",
            "example": "El paciente pidio otra hora"
          }
        }
      },
      "Cancelacion": {
        "type": "object",
        "properties": {
          "motivo": {
            "type": "string",
            "description": "Obligatorio",
            "example": "El paciente no puede asistir"
          }
        }
      },
      "Asistencia": {
        "type": "object",
        "properties": {
          "estado": {
            "type": "string",
            "enum": [
              "atendida",
              "no_asistio"
            ],
            "example": "atendida"
          }
        }
      },
      "Profesional": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "nombre": {
            "type": "string",
            "example": "Dra. Paula Mendez"
          },
          "especialidad": {
            "type": "string",
            "example": "psicologia"
          },
          "consultorio_id": {
            "type": "integer",
            "format": "int64"
          },
          "duracion_minutos": {
            "type": "integer",
            "format": "int32",
            "description": "Duración de cada cita",
            "example": 30
          },
          "activo": {
            "type": "boolean"
          },
          "disponible_hasta": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Último día con agenda abierta; null si no tiene"
          }
        }
      },
      "CitasDePaciente": {
        "type": "object",
        "properties": {
          "zona_horaria": {
            "type": "string",
            "example": "America/Bogota"
          },
          "paciente": {
            "description": "null si no hay un paciente con ese teléfono, o si se busco por documento",
            "oneOf": [
              {
                "$ref": "#/components/schemas/Paciente"
              },
              {
                "type": "null"
              }
            ]
          },
          "citas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Cita"
            }
          }
        }
      },
      "Paciente": {
        "type": "object",
        "properties": {
          "telefono": {
            "type": "string",
            "example": "573001112233"
          },
          "nombre": {
            "type": [
              "string",
              "null"
            ],
            "example": "Ana Torres"
          },
          "tiene_consentimiento": {
            "type": "boolean",
            "description": "Ya autorizó el tratamiento de sus datos"
          }
        }
      },
      "Inscripcion": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "telefono": {
            "type": "string",
            "example": "573001112233"
          },
          "paciente": {
            "type": [
              "string",
              "null"
            ],
            "description": "Quién espera",
            "example": "Ana Torres"
          },
          "especialidad": {
            "type": "string",
            "example": "psicologia"
          },
          "franja": {
            "type": "string",
            "enum": [
              "manana",
              "tarde",
              "cualquiera"
            ]
          },
          "desde": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "hasta": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "anotado_en": {
            "type": "string",
            "format": "date-time"
          },
          "vence_en": {
            "type": "string",
            "format": "date-time"
          },
          "ya_tiene_cita": {
            "type": "boolean",
            "description": "Ya tiene una cita futura de esa especialidad: no se le ofrecen cupos"
          }
        }
      },
      "ListaEspera": {
        "type": "object",
        "properties": {
          "zona_horaria": {
            "type": "string",
            "example": "America/Bogota"
          },
          "inscritos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Inscripcion"
            }
          }
        }
      },
      "Especialidad": {
        "type": "object",
        "properties": {
          "nombre": {
            "type": "string",
            "example": "psicologia"
          },
          "profesionales_activos": {
            "type": "integer",
            "format": "int64",
            "example": 2
          }
        }
      },
      "Disponibilidad": {
        "type": "object",
        "properties": {
          "zona_horaria": {
            "type": "string",
            "example": "America/Bogota"
          },
          "horarios": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Horario"
            }
          }
        }
      },
      "Horario": {
        "type": "object",
        "properties": {
          "slot_id": {
            "type": "integer",
            "format": "int64",
            "description": "Se envía como `slot_id` (texto) al agendar o reprogramar",
            "example": 348
          },
          "profesional_id": {
            "type": "integer",
            "format": "int64"
          },
          "profesional": {
            "type": "string",
            "example": "Dra. Paula Mendez"
          },
          "especialidad": {
            "type": "string",
            "example": "psicologia"
          },
          "consultorio_id": {
            "type": "integer",
            "format": "int64"
          },
          "inicio": {
            "type": "string",
            "format": "date-time",
            "description": "Hora local de la clínica, sin desfase",
            "example": "2026-10-20T08:00:00"
          },
          "fin": {
            "type": "string",
            "format": "date-time",
            "example": "2026-10-20T08:30:00"
          }
        }
      },
      "Consultorio": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "nombre": {
            "type": "string",
            "example": "Consultorio 1"
          }
        }
      },
      "Clinica": {
        "type": "object",
        "properties": {
          "nombre": {
            "type": "string",
            "example": "Clinica Demo"
          },
          "zona_horaria": {
            "type": "string",
            "description": "Zona IANA en que se expresan todas las fechas y horas",
            "example": "America/Bogota"
          },
          "documento_obligatorio": {
            "type": "boolean",
            "description": "true: al agendar hay que enviar tipo y número de documento"
          },
          "tipos_documento": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TipoDocumento"
            }
          },
          "alcances": {
            "type": "array",
            "description": "Permisos de la clave que hizo la petición",
            "example": [
              "catalogo:leer",
              "citas:escribir"
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "TipoDocumento": {
        "type": "object",
        "description": "Un tipo de documento que acepta la clínica",
        "properties": {
          "codigo": {
            "type": "string",
            "example": "CC"
          },
          "descripcion": {
            "type": "string",
            "example": "Cedula de ciudadania"
          }
        }
      },
      "Citas": {
        "type": "object",
        "properties": {
          "zona_horaria": {
            "type": "string",
            "example": "America/Bogota"
          },
          "citas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Cita"
            }
          }
        }
      },
      "Problema": {
        "type": "object",
        "description": "Error (RFC 9457). Decida por `codigo`, nunca por el texto de `detail`.",
        "properties": {
          "type": {
            "type": "string",
            "example": "about:blank"
          },
          "title": {
            "type": "string",
            "example": "Unprocessable Content"
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "example": 422
          },
          "detail": {
            "type": "string",
            "example": "Ese horario acaba de ser tomado. Ofrece otras opciones."
          },
          "codigo": {
            "type": "string",
            "example": "HORARIO_TOMADO"
          }
        },
        "required": [
          "codigo",
          "status"
        ]
      }
    },
    "securitySchemes": {
      "claveApi": {
        "type": "http",
        "description": "Clave de API de la clinica (Configuracion -> Integraciones -> Claves de API)",
        "scheme": "bearer",
        "bearerFormat": "cbk_..."
      }
    }
  }
}
