{"openapi":"3.1.0","info":{"title":"Nodda API","version":"1.0.0","description":"Capa de conexión, sincronización y normalización de datos externos. Autenticación por API key (Bearer). Consume datos ya sincronizados; los syncs son asíncronos."},"servers":[{"url":"https://app.nodda.cl/api"}],"security":[{"ApiKeyAuth":[]},{"OAuthToken":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"nodda_sk_…","description":"API key creada en el dashboard. La organización se resuelve desde la key."},"OAuthToken":{"type":"http","scheme":"bearer","bearerFormat":"nodda_at_…","description":"Token de acceso OAuth 2.1 (MCP), formato Bearer nodda_at_…. La organización se resuelve desde el token; alcanza los mismos endpoints de lectura que una API key."},"SessionCookieAuth":{"type":"apiKey","in":"cookie","name":"sb-access-token","description":"Sesión del dashboard (Supabase). Sólo para operaciones de gestión; API keys y tokens MCP reciben 403."}},"schemas":{"Pagination":{"type":"object","required":["total","limit","offset","has_more"],"properties":{"total":{"type":"integer","description":"Total de registros"},"limit":{"type":"integer"},"offset":{"type":"integer"},"has_more":{"type":"boolean"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}}}}},"ScopeDescriptor":{"type":"object","required":["name","label","data_url","filters","sync_metadata"],"properties":{"name":{"type":"string"},"label":{"type":"string"},"data_url":{"type":["string","null"],"description":"URL relativa al recurso de datos de este scope"},"filters":{"type":["object","null"],"description":"JSON Schema de los query-params aceptados por data_url"},"sync_metadata":{"type":"object","description":"JSON Schema del campo metadata del body de sync"}}},"ExtSourceScope":{"type":"object","required":["name","label","sync_metadata","data_path_template","filters"],"properties":{"name":{"type":"string"},"label":{"type":"string"},"sync_metadata":{"type":"object"},"data_path_template":{"type":["string","null"],"description":"Template de path; reemplaza {connection_id}"},"filters":{"type":["object","null"]}}},"Connection":{"type":"object","required":["id","organization_id","external_source_code","external_source_name","name","status","enabled_scopes","scopes","metadata","sync_schedule_enabled","sync_frequency_minutes","next_scheduled_sync_at"],"properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"external_source_code":{"type":"string"},"external_source_name":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","enum":["pending","active","error","disabled"]},"enabled_scopes":{"type":"array","items":{"type":"string"}},"scopes":{"type":"array","items":{"$ref":"#/components/schemas/ScopeDescriptor"}},"metadata":{"type":"object"},"sync_schedule_enabled":{"type":"boolean"},"sync_frequency_minutes":{"type":["integer","null"]},"next_scheduled_sync_at":{"type":["string","null"],"format":"date-time"},"last_successful_sync_at":{"type":["string","null"],"format":"date-time"},"last_sync_status":{"type":["string","null"]}}},"ExternalSource":{"type":"object","required":["code","name","type","country","is_active","supported_scopes","scopes","metadata"],"properties":{"code":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"country":{"type":"string"},"is_active":{"type":"boolean"},"supported_scopes":{"type":"array","items":{"type":"string"}},"scopes":{"type":"array","items":{"$ref":"#/components/schemas/ExtSourceScope"}},"metadata":{"type":"object"}}},"ScopeNotice":{"type":"object","required":["code","message"],"properties":{"code":{"type":["string","null"],"description":"Machine-readable notice code, e.g. sii.guias.out_of_window"},"message":{"type":["string","null"]}}},"ScopeOutcome":{"type":"object","required":["scope","status"],"properties":{"scope":{"type":["string","null"]},"status":{"type":["string","null"]},"records_found":{"type":["integer","null"]},"duration_ms":{"type":["integer","null"],"description":"Wall-clock milliseconds this scope took during the sync run."},"period":{"type":["string","null"],"pattern":"^\\d{4}-\\d{2}$"},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"notices":{"type":"array","items":{"$ref":"#/components/schemas/ScopeNotice"},"description":"Informational, expected, non-failure conditions for this scope. Do NOT degrade the run status."}}},"SyncRun":{"type":"object","required":["id","connection_id","scopes","scope_outcomes","status"],"properties":{"id":{"type":"string","format":"uuid"},"connection_id":{"type":"string","format":"uuid"},"scopes":{"type":"array","items":{"type":"string"}},"scope_outcomes":{"type":"array","items":{"$ref":"#/components/schemas/ScopeOutcome"}},"trigger":{"type":["string","null"]},"status":{"type":["string","null"]},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"records_found":{"type":["integer","null"]},"records_created":{"type":["integer","null"]},"records_updated":{"type":["integer","null"]},"progress":{"type":["object","null"],"properties":{"stage":{"type":"string"},"message":{"type":["string","null"]},"updated_at":{"type":["string","null"]}}},"created_at":{"type":["string","null"],"format":"date-time"}}},"RcvListRow":{"type":"object","required":["id","period","direction","document_type","folio"],"properties":{"id":{"type":"string","format":"uuid"},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"direction":{"type":"string","enum":["received","issued"]},"document_type":{"type":"string"},"folio":{"type":["string","null"]},"issuer_rut":{"type":["string","null"]},"issuer_name":{"type":["string","null"]},"receiver_rut":{"type":["string","null"]},"receiver_name":{"type":["string","null"]},"issued_at":{"type":["string","null"]},"received_at":{"type":["string","null"]},"net_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"exempt_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"vat_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"total_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"currency":{"type":["string","null"]},"status":{"type":["string","null"]},"estado":{"type":"string"},"referenced_document_type":{"type":["string","null"]},"referenced_folio":{"type":["string","null"]},"acknowledged_at":{"type":["string","null"]},"claimed_at":{"type":["string","null"]},"transaction_type":{"type":["string","null"]},"created_at":{"type":["string","null"],"format":"date-time"}}},"BoletaListRow":{"type":"object","required":["id","period","document_type","day","total_amount"],"description":"Resumen diario de boletas electrónicas de venta (agregado por día y tipo).","properties":{"id":{"type":"string","format":"uuid"},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"document_type":{"type":"string","enum":["39","41"],"description":"39 = boleta electrónica afecta, 41 = exenta"},"day":{"type":"integer","minimum":1,"maximum":31},"date":{"type":["string","null"],"format":"date-time"},"total_documentos":{"type":["integer","null"],"description":"Cantidad de boletas de venta registradas ese día"},"net_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"exempt_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"vat_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"total_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"channel":{"type":["string","null"],"description":"Canal de transacción reportado por el SII"},"updated_at":{"type":["string","null"],"format":"date-time","description":"Última vez que esta fila diaria fue refrescada por una sincronización"}}},"RcvDocument":{"type":"object","required":["id","connection_id","period","direction","document_type","folio"],"properties":{"id":{"type":"string","format":"uuid"},"connection_id":{"type":"string","format":"uuid"},"sync_run_id":{"type":["string","null"],"format":"uuid"},"raw_payload_id":{"type":["string","null"],"format":"uuid"},"source_document_id":{"type":["string","null"]},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"direction":{"type":"string","enum":["received","issued"]},"document_type":{"type":"string"},"folio":{"type":["string","null"]},"issuer_rut":{"type":["string","null"]},"issuer_name":{"type":["string","null"]},"receiver_rut":{"type":["string","null"]},"receiver_name":{"type":["string","null"]},"issued_at":{"type":["string","null"]},"received_at":{"type":["string","null"]},"net_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"exempt_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"vat_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"total_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"currency":{"type":["string","null"]},"status":{"type":["string","null"]},"estado":{"type":"string"},"referenced_document_type":{"type":["string","null"]},"referenced_folio":{"type":["string","null"]},"acknowledged_at":{"type":["string","null"]},"claimed_at":{"type":["string","null"]},"transaction_type":{"type":["string","null"]},"raw_row":{"type":["object","null"],"description":"Payload bruto del SII normalizado"},"created_at":{"type":["string","null"],"format":"date-time"}}},"GuideListRow":{"type":"object","required":["id","period","direction","folio","issued_at"],"properties":{"id":{"type":"string","format":"uuid"},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"direction":{"type":"string","enum":["received","issued"]},"folio":{"type":["string","null"]},"counterparty_rut":{"type":["string","null"]},"counterparty_name":{"type":["string","null"]},"issued_at":{"type":["string","null"]},"total_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"vat_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"status":{"type":["string","null"]}}},"Guide":{"type":"object","required":["id","connection_id","period","direction"],"properties":{"id":{"type":"string","format":"uuid"},"connection_id":{"type":"string","format":"uuid"},"sync_run_id":{"type":["string","null"],"format":"uuid"},"raw_payload_id":{"type":["string","null"],"format":"uuid"},"source_guide_id":{"type":["string","null"]},"direction":{"type":"string","enum":["received","issued"]},"document_type":{"type":["string","null"]},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"folio":{"type":["string","null"]},"counterparty_rut":{"type":["string","null"]},"counterparty_name":{"type":["string","null"]},"net_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"exempt_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"vat_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"total_amount":{"type":["string","null"],"description":"Decimal serializado como string"},"vat_rate":{"type":["string","null"],"description":"Decimal serializado como string"},"issued_at":{"type":["string","null"]},"received_at":{"type":["string","null"]},"event_order":{"type":["string","null"]},"event_description":{"type":["string","null"]},"dhdr_codigo":{"type":["string","null"]},"raw_row":{"type":["object","null"]},"created_at":{"type":["string","null"],"format":"date-time"}}},"TransferRow":{"type":"object","required":["id","period","direction","transferred_at","amount"],"properties":{"id":{"type":"string","format":"uuid"},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"direction":{"type":"string","enum":["received","issued"]},"numero_transaccion":{"type":["string","null"]},"transferred_at":{"type":["string","null"]},"amount":{"type":["string","null"],"description":"Decimal serializado como string"},"currency":{"type":["string","null"]},"subject":{"type":["string","null"]},"counterparty_rut":{"type":["string","null"]},"counterparty_name":{"type":["string","null"]},"counterparty_bank":{"type":["string","null"]}}},"BalanceRow":{"type":"object","required":["id","numero_cuenta","currency","observed_at"],"properties":{"id":{"type":"string","format":"uuid"},"numero_cuenta":{"type":"string"},"currency":{"type":"string","description":"ISO currency (CLP, USD)"},"saldo_contable":{"type":["string","null"],"description":"Decimal serializado como string"},"saldo_disponible":{"type":["string","null"],"description":"Decimal serializado como string"},"saldo_provisorio":{"type":["string","null"],"description":"Decimal serializado como string"},"observed_at":{"type":"string","description":"Momento en que se observó el saldo (ISO 8601)"}}},"NominaRow":{"type":"object","required":["id","period","numero_nomina"],"properties":{"id":{"type":"string","format":"uuid"},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"numero_nomina":{"type":["string","null"]},"nomina_date":{"type":["string","null"],"description":"Fecha de la nómina (YYYY-MM-DD)"},"tipo":{"type":["string","null"]},"cuenta_cargo":{"type":["string","null"]},"estado":{"type":["string","null"]},"num_registros":{"type":["integer","null"]},"monto":{"type":["string","null"],"description":"Decimal serializado como string"},"currency":{"type":["string","null"]}}},"PagoRow":{"type":"object","required":["id"],"properties":{"id":{"type":"string","format":"uuid"},"linea":{"type":["integer","null"]},"rut":{"type":["string","null"]},"nombre":{"type":["string","null"]},"tipo_cuenta":{"type":["string","null"]},"numero_cuenta":{"type":["string","null"]},"banco":{"type":["string","null"]},"monto":{"type":["string","null"],"description":"Decimal serializado como string"},"currency":{"type":["string","null"]},"estado":{"type":["string","null"]},"mail":{"type":["string","null"]},"glosa":{"type":["string","null"]},"motivo_rechazo":{"type":["string","null"]}}},"ApiKey":{"type":"object","required":["id","name","display_prefix","status","last_used_at","expires_at","revoked_at","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"display_prefix":{"type":"string"},"status":{"type":"string","enum":["active","revoked","expired"]},"last_used_at":{"type":["string","null"],"format":"date-time"},"expires_at":{"type":["string","null"],"format":"date-time"},"revoked_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"BciMovementRow":{"type":"object","required":["id","numero_cuenta","period"],"properties":{"id":{"type":"string","format":"uuid"},"numero_cuenta":{"type":"string"},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"fecha_movimiento":{"type":["string","null"],"description":"Fecha del movimiento (YYYY-MM-DD)"},"fecha_contable":{"type":["string","null"],"description":"Fecha contable (YYYY-MM-DD)"},"descripcion":{"type":["string","null"]},"amount":{"type":["string","null"],"description":"Decimal serializado como string"},"saldo_contable":{"type":["string","null"],"description":"Saldo contable tras el movimiento, decimal como string"},"tipo":{"type":["string","null"],"description":"Tipo de movimiento (cargo/abono)"},"mnemonico":{"type":["string","null"],"description":"Código mnemonico del movimiento"},"direction":{"type":["string","null"],"description":"received (abono/entrada) o issued (cargo/salida)"},"category":{"type":["string","null"],"description":"Categoría del banco (Transferencias, Pagos, …)"},"counterparty_name":{"type":["string","null"],"description":"Nombre de la contraparte"},"counterparty_rut":{"type":["string","null"],"description":"RUT de la contraparte"},"counterparty_bank":{"type":["string","null"],"description":"Banco de la contraparte"},"counterparty_account":{"type":["string","null"],"description":"Cuenta de la contraparte"}}},"SecurityMovementRow":{"type":"object","required":["id","numero_cuenta","period"],"properties":{"id":{"type":"string","format":"uuid"},"numero_cuenta":{"type":"string"},"currency":{"type":["string","null"],"description":"ISO currency (CLP, USD). Limitación: la cartola histórica (meses cerrados) no expone moneda por cuenta y se reporta como CLP; sólo el mes en curso refleja la moneda real (p. ej. USD)."},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"fecha_movimiento":{"type":["string","null"],"description":"Fecha del movimiento (YYYY-MM-DD)"},"descripcion":{"type":["string","null"]},"documento":{"type":["string","null"],"description":"Código de documento del movimiento"},"amount":{"type":["string","null"],"description":"Decimal serializado como string"},"saldo_contable":{"type":["string","null"],"description":"Saldo contable tras el movimiento, decimal como string"},"tipo":{"type":["string","null"],"description":"Tipo de movimiento: C (cargo) o A (abono)"},"direction":{"type":["string","null"],"description":"received (abono/entrada) o issued (cargo/salida)"}}},"BiceMovementRow":{"type":"object","required":["id","numero_cuenta","period"],"properties":{"id":{"type":"string","format":"uuid"},"numero_cuenta":{"type":"string"},"currency":{"type":["string","null"],"description":"ISO currency (CLP, USD)"},"period":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"fecha_movimiento":{"type":["string","null"],"description":"Fecha del movimiento (YYYY-MM-DD)"},"descripcion":{"type":["string","null"]},"documento":{"type":["string","null"],"description":"Nº de documento del movimiento"},"amount":{"type":["string","null"],"description":"Decimal serializado como string, con signo (cargo negativo, abono positivo)"},"saldo_contable":{"type":["string","null"],"description":"Saldo contable tras el movimiento, decimal como string"},"tipo":{"type":["string","null"],"description":"C (cargo) o A (abono)"},"direction":{"type":["string","null"],"description":"received (abono) o issued (cargo)"}}},"BiceBalanceRow":{"type":"object","required":["id","numero_cuenta","currency","observed_at"],"properties":{"id":{"type":"string","format":"uuid"},"numero_cuenta":{"type":"string"},"currency":{"type":"string","description":"ISO currency (CLP, USD)"},"saldo_contable":{"type":["string","null"],"description":"Decimal serializado como string"},"saldo_disponible":{"type":["string","null"],"description":"Decimal serializado como string"},"observed_at":{"type":"string","description":"Momento en que se observó el saldo (ISO 8601)"}}},"WebhookEventType":{"type":"string","enum":["sync.succeeded","sync.partial","sync.failed"],"description":"Event types emitted by Nodda syncs."},"WebhookEndpoint":{"type":"object","required":["id","url","event_types","enabled","disabled_at","last_success_at","created_at"],"description":"A registered webhook endpoint. The signing secret is NOT included in any list/get response — it is returned only on create (POST /webhooks) and roll-secret (POST /webhooks/{id}/roll-secret).","properties":{"id":{"type":"string","format":"uuid"},"url":{"type":"string","format":"uri","description":"HTTPS URL that Nodda delivers events to."},"event_types":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEventType"},"description":"Event types this endpoint is subscribed to."},"enabled":{"type":"boolean"},"disabled_at":{"type":["string","null"],"format":"date-time"},"last_success_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"WebhookDelivery":{"type":"object","required":["id","event_type","status","attempts","response_status","error","last_attempt_at","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"event_type":{"$ref":"#/components/schemas/WebhookEventType"},"status":{"type":"string","enum":["pending","delivering","delivered","failed"],"description":"Current delivery status. `delivering` = attempt in flight. `delivered` = received a 2xx response. `failed` = all retries exhausted without a 2xx."},"attempts":{"type":"integer","description":"Number of delivery attempts made so far."},"response_status":{"type":["integer","null"],"description":"HTTP status code of the last attempt, if any."},"error":{"type":["string","null"],"description":"Last error message, if delivery failed."},"last_attempt_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"BciBalanceRow":{"type":"object","required":["id","numero_cuenta","currency","observed_at"],"properties":{"id":{"type":"string","format":"uuid"},"numero_cuenta":{"type":"string"},"currency":{"type":"string","description":"ISO currency (CLP, USD)"},"saldo_contable":{"type":["string","null"],"description":"Decimal serializado como string"},"saldo_disponible":{"type":["string","null"],"description":"Decimal serializado como string"},"saldo_contable_9am":{"type":["string","null"],"description":"Saldo contable a las 9am, decimal como string"},"retencion":{"type":["string","null"],"description":"Retención, decimal como string"},"observed_at":{"type":"string","description":"Momento en que se observó el saldo (ISO 8601)"}}},"MpLicitacionRow":{"type":"object","required":["id","codigo"],"properties":{"id":{"type":"string","format":"uuid"},"codigo":{"type":"string"},"nombre":{"type":["string","null"]},"descripcion":{"type":["string","null"]},"estado":{"type":["string","null"]},"tipo_licitacion":{"type":["string","null"]},"tipo_convocatoria":{"type":["string","null"]},"moneda":{"type":["string","null"]},"monto_estimado":{"type":["string","null"]},"organismo_razon_social":{"type":["string","null"]},"organismo_rut":{"type":["string","null"]},"unidad_compra":{"type":["string","null"]},"region":{"type":["string","null"]},"comuna":{"type":["string","null"]},"direccion":{"type":["string","null"]},"fecha_publicacion":{"type":["string","null"],"format":"date-time"},"fecha_inicio_preguntas":{"type":["string","null"],"format":"date-time"},"fecha_fin_preguntas":{"type":["string","null"],"format":"date-time"},"fecha_publicacion_respuestas":{"type":["string","null"],"format":"date-time"},"fecha_cierre":{"type":["string","null"],"format":"date-time"},"fecha_apertura_tecnica":{"type":["string","null"],"format":"date-time"},"fecha_apertura_economica":{"type":["string","null"],"format":"date-time"},"fecha_adjudicacion":{"type":["string","null"],"format":"date-time"},"observed_at":{"type":"string","format":"date-time"},"raw_ficha":{"type":"object"}}},"MpDocumentoRow":{"type":"object","required":["id","codigo","documento_id","origen"],"properties":{"id":{"type":"string","format":"uuid"},"codigo":{"type":"string"},"documento_id":{"type":"string"},"origen":{"type":"string","description":"Fuente del documento (e.g. Bases, Anexo)"},"nombre":{"type":["string","null"]},"tipo":{"type":["string","null"]},"descripcion":{"type":["string","null"]},"tamano":{"type":["string","null"],"description":"Tamaño del archivo en bytes (como string)"},"fecha_adjunto":{"type":["string","null"],"format":"date-time"},"locator":{"type":"object","description":"Metadatos opacos de descarga (URL, etc.)"}}},"MpPreguntaRow":{"type":"object","required":["id","codigo","pregunta_id"],"properties":{"id":{"type":"string","format":"uuid"},"codigo":{"type":"string"},"pregunta_id":{"type":"string"},"numero":{"type":["string","null"]},"tema":{"type":["string","null"]},"pregunta":{"type":["string","null"]},"respuesta":{"type":["string","null"]},"fecha_pregunta":{"type":["string","null"],"format":"date-time"},"fecha_respuesta":{"type":["string","null"],"format":"date-time"}}},"MpOfertaDocumentoRow":{"type":"object","required":["id","codigo","oferente_rut","documento_id","origen","locator"],"properties":{"id":{"type":"string","format":"uuid"},"codigo":{"type":"string"},"oferente_rut":{"type":"string"},"documento_id":{"type":"string"},"origen":{"type":"string","description":"Fuente del documento (e.g. Oferta, Anexo)"},"nombre":{"type":["string","null"]},"locator":{"type":"object","description":"Metadatos opacos de descarga (URL, etc.)"}}},"MpOfertaRow":{"type":"object","required":["id","codigo","oferente_rut","documentos"],"properties":{"id":{"type":"string","format":"uuid"},"codigo":{"type":"string"},"oferente_rut":{"type":"string"},"proveedor_razon_social":{"type":["string","null"]},"nombre_oferta":{"type":["string","null"]},"estado":{"type":["string","null"]},"total_oferta":{"type":["string","null"],"description":"Monto total de la oferta, decimal como string"},"habil_chileproveedores":{"type":["boolean","null"]},"documentos":{"type":"array","items":{"$ref":"#/components/schemas/MpOfertaDocumentoRow"}}}}}},"paths":{"/connections":{"get":{"summary":"Listar conexiones","operationId":"listConnections","responses":{"200":{"description":"Lista de conexiones de la organización","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Connection"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Crear conexión (requiere sesión del dashboard)","operationId":"createConnection","security":[{"SessionCookieAuth":[]}],"description":"API keys reciben 403; requiere sesión del dashboard.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["external_source_code","name","enabled_scopes","credentials","metadata"],"properties":{"external_source_code":{"type":"string"},"name":{"type":"string"},"enabled_scopes":{"type":"array","items":{"type":"string"}},"credentials":{"type":"object"},"metadata":{"type":"object"}}}}}},"responses":{"201":{"description":"Conexión creada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Connection"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Requiere sesión del dashboard; API keys no autorizadas","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Datos inválidos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Obtener conexión","operationId":"getConnection","responses":{"200":{"description":"Conexión","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Connection"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Eliminar conexión (requiere sesión del dashboard)","operationId":"deleteConnection","security":[{"SessionCookieAuth":[]}],"description":"API keys reciben 403; requiere sesión del dashboard.","responses":{"200":{"description":"Conexión eliminada","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","required":["id","deleted"],"properties":{"id":{"type":"string","format":"uuid"},"deleted":{"type":"boolean","enum":[true]}}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Requiere sesión del dashboard; API keys no autorizadas","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"connection_sync_in_progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/schedule":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"put":{"summary":"Configurar agenda de sync automático","operationId":"setConnectionSchedule","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["enabled"],"properties":{"enabled":{"type":"boolean"},"frequency_minutes":{"type":["integer","null"],"enum":[60,360,720,1440,null],"description":"Requerido cuando enabled=true. Debe ser 60, 360, 720 o 1440."}}}}}},"responses":{"200":{"description":"Agenda actualizada","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","required":["enabled","frequency_minutes","next_scheduled_sync_at"],"properties":{"enabled":{"type":"boolean"},"frequency_minutes":{"type":["integer","null"]},"next_scheduled_sync_at":{"type":["string","null"],"format":"date-time"}}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"OAuth access tokens cannot perform this action","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"schedule_invalid_frequency — frecuencia no permitida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sync":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"post":{"summary":"Iniciar sync","operationId":"triggerSync","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"scopes":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object"}}}}}},"responses":{"202":{"description":"Sync encolado (respuesta sin envoltorio data:)","content":{"application/json":{"schema":{"type":"object","required":["sync_id","connection_id","scopes","status"],"properties":{"sync_id":{"type":"string","format":"uuid"},"connection_id":{"type":"string","format":"uuid"},"scopes":{"type":"array","items":{"type":"string"}},"status":{"type":"string","enum":["queued"]}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"OAuth access tokens cannot perform this action","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Scopes inválidos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sync-runs":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Listar sync runs (últimos 10)","operationId":"listSyncRuns","responses":{"200":{"description":"Lista de sync runs","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SyncRun"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sync-runs/{runId}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"runId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Obtener sync run","operationId":"getSyncRun","responses":{"200":{"description":"Sync run con input_metadata","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"allOf":[{"$ref":"#/components/schemas/SyncRun"},{"type":"object","properties":{"input_metadata":{"type":"object"}}}]}}}}}},"400":{"description":"runId no es UUID válido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"sync_run_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sii-rcv-documents":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},{"name":"direction","in":"query","schema":{"type":"string","enum":["received","issued"]}},{"name":"estado","in":"query","schema":{"type":"string","enum":["registro","pendiente","no_incluir","reclamado"]}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar documentos RCV SII","operationId":"listRcvDocuments","responses":{"200":{"description":"Documentos RCV paginados","content":{"application/json":{"schema":{"type":"object","required":["data","pagination"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/RcvListRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sii-rcv-documents/{documentId}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"documentId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Obtener documento RCV SII","operationId":"getRcvDocument","responses":{"200":{"description":"Documento RCV completo con raw_row","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/RcvDocument"}}}}}},"400":{"description":"documentId no es UUID válido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"rcv_document_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sii-rcv-documents/periods":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Listar períodos RCV disponibles","operationId":"listRcvPeriods","responses":{"200":{"description":"Períodos YYYY-MM en orden descendente","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sii-boletas":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},{"name":"document_type","in":"query","schema":{"type":"string","enum":["39","41"]}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar boletas electrónicas diarias SII","description":"Resumen diario de boletas electrónicas de venta (tipo 39 afecta, 41 exenta). Una fila por día y tipo; se actualiza en cada sincronización (last-write-wins).","operationId":"listSiiBoletas","responses":{"200":{"description":"Boletas diarias paginadas","content":{"application/json":{"schema":{"type":"object","required":["data","pagination"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BoletaListRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sii-boletas/periods":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Listar períodos de boletas disponibles","operationId":"listSiiBoletasPeriods","responses":{"200":{"description":"Períodos YYYY-MM en orden descendente","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sii-dispatch-guides":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},{"name":"direction","in":"query","schema":{"type":"string","enum":["received","issued"]}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"q","in":"query","schema":{"type":"string"},"description":"Búsqueda por nombre, RUT o folio"},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar guías de despacho SII","operationId":"listDispatchGuides","responses":{"200":{"description":"Guías de despacho paginadas","content":{"application/json":{"schema":{"type":"object","required":["data","pagination"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/GuideListRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sii-dispatch-guides/{guideId}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"guideId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Obtener guía de despacho SII","operationId":"getDispatchGuide","responses":{"200":{"description":"Guía de despacho completa","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Guide"}}}}}},"400":{"description":"guideId no es UUID válido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"dispatch_guide_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/sii-dispatch-guides/periods":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Listar períodos de guías de despacho disponibles","operationId":"listDispatchGuidePeriods","responses":{"200":{"description":"Períodos YYYY-MM en orden descendente","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/security-transfers":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},{"name":"direction","in":"query","schema":{"type":"string","enum":["received","issued"]}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar transferencias Banco Security","operationId":"listSecurityTransfers","responses":{"200":{"description":"Transferencias paginadas","content":{"application/json":{"schema":{"type":"object","required":["data","pagination"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/TransferRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/security-balances":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"latest","in":"query","description":"Si es 'true', devuelve el saldo más reciente por cuenta/moneda","schema":{"type":"string","enum":["true"]}},{"name":"currency","in":"query","schema":{"type":"string","example":"CLP"}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar saldos de cuenta Banco Security (historial de saldos observados)","operationId":"listSecurityBalances","responses":{"200":{"description":"Saldos observados, del más reciente al más antiguo (sin paginación cuando latest=true)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BalanceRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"400":{"description":"validation_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/security-movements":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},{"name":"direction","in":"query","schema":{"type":"string","enum":["received","issued"]}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar movimientos Banco Security","description":"Cartola completa de la cuenta corriente, normalizada. amount es con signo (cargo negativo, abono positivo); direction se deriva del tipo (cargo→issued, abono→received). La cartola no entrega contraparte estructurada: counterparty_* y category no se exponen para este scope (usa los scopes directas/masivas). Ver la limitación de moneda en SecurityMovementRow.currency.","operationId":"listSecurityMovements","responses":{"200":{"description":"Movimientos paginados","content":{"application/json":{"schema":{"type":"object","required":["data","pagination"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SecurityMovementRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"400":{"description":"validation_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/security-movements/periods":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Listar períodos de movimientos Banco Security disponibles","operationId":"listSecurityMovementPeriods","responses":{"200":{"description":"Períodos YYYY-MM en orden descendente","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/security-transfers/periods":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Listar períodos de transferencias disponibles","operationId":"listSecurityTransferPeriods","responses":{"200":{"description":"Períodos YYYY-MM en orden descendente","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/security-nominas":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar nóminas masivas Banco Security","operationId":"listSecurityNominas","responses":{"200":{"description":"Nóminas paginadas","content":{"application/json":{"schema":{"type":"object","required":["data","pagination"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/NominaRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/security-nominas/{nominaId}/pagos":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"nominaId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar pagos de una nómina masiva","operationId":"listNominaPagos","responses":{"200":{"description":"Pagos paginados","content":{"application/json":{"schema":{"type":"object","required":["data","pagination"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PagoRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found o nómina no encontrada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/security-nominas/periods":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Listar períodos de nóminas disponibles","operationId":"listSecurityNominaPeriods","responses":{"200":{"description":"Períodos YYYY-MM en orden descendente","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/external-sources":{"get":{"summary":"Listar fuentes externas disponibles","operationId":"listExternalSources","security":[],"parameters":[{"name":"country","in":"query","schema":{"type":"string"}},{"name":"type","in":"query","schema":{"type":"string"}},{"name":"is_active","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Fuentes externas (sin autenticación)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ExternalSource"}}}}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api-keys":{"get":{"summary":"Listar API keys (requiere sesión del dashboard)","operationId":"listApiKeys","security":[{"SessionCookieAuth":[]}],"description":"API keys reciben 403; requiere sesión del dashboard.","responses":{"200":{"description":"Lista de API keys de la organización","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ApiKey"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Requiere sesión del dashboard; API keys no autorizadas","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Crear API key (requiere sesión del dashboard)","operationId":"createApiKey","security":[{"SessionCookieAuth":[]}],"description":"API keys reciben 403; requiere sesión del dashboard. La key en texto plano sólo se devuelve en esta respuesta.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"expires_at":{"type":"string","format":"date-time"}}}}}},"responses":{"201":{"description":"API key creada (incluye key en texto plano — guardar ahora)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"allOf":[{"$ref":"#/components/schemas/ApiKey"},{"type":"object","required":["key"],"properties":{"key":{"type":"string","description":"Token completo (sólo visible aquí)"}}}]}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Requiere sesión del dashboard; API keys no autorizadas","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Datos inválidos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/bci-movements":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},{"name":"direction","in":"query","schema":{"type":"string","enum":["received","issued"]}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar movimientos BCI PyME","operationId":"listBciMovements","responses":{"200":{"description":"Movimientos paginados","content":{"application/json":{"schema":{"type":"object","required":["data","pagination"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BciMovementRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/bci-movements/periods":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Listar períodos de movimientos BCI PyME disponibles","operationId":"listBciMovementPeriods","responses":{"200":{"description":"Períodos YYYY-MM en orden descendente","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/bci-balances":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"latest","in":"query","description":"Si es 'true', devuelve el saldo más reciente por cuenta/moneda","schema":{"type":"string","enum":["true"]}},{"name":"currency","in":"query","schema":{"type":"string","example":"CLP"}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar saldos de cuenta BCI PyME (historial de saldos observados)","operationId":"listBciBalances","responses":{"200":{"description":"Saldos observados, del más reciente al más antiguo (sin paginación cuando latest=true)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BciBalanceRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"400":{"description":"validation_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/bice-movements":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"period","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},{"name":"direction","in":"query","schema":{"type":"string","enum":["received","issued"]}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar movimientos BICE Empresas","description":"Cartola de la cuenta corriente, normalizada. amount con signo (cargo negativo, abono positivo); direction derivado de los legs credit/debit. BICE no entrega contraparte estructurada: counterparty_*/category no se exponen.","operationId":"listBiceMovements","responses":{"200":{"description":"Movimientos paginados","content":{"application/json":{"schema":{"type":"object","required":["data","pagination"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BiceMovementRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"400":{"description":"validation_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/connections/{id}/bice-balances":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"latest","in":"query","description":"Si es 'true', devuelve el saldo más reciente por cuenta/moneda","schema":{"type":"string","enum":["true"]}},{"name":"currency","in":"query","schema":{"type":"string","example":"CLP"}},{"name":"from","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"get":{"summary":"Listar saldos de cuenta BICE Empresas (historial de saldos observados)","operationId":"listBiceBalances","responses":{"200":{"description":"Saldos observados, del más reciente al más antiguo (sin paginación cuando latest=true)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BiceBalanceRow"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"400":{"description":"validation_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"connection_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks":{"get":{"summary":"Listar webhook endpoints","operationId":"listWebhookEndpoints","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"responses":{"200":{"description":"Lista de endpoints de webhook de la organización","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEndpoint"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Crear webhook endpoint","operationId":"createWebhookEndpoint","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"description":"Registra un nuevo endpoint de webhook. La respuesta incluye el campo `secret` en texto plano — **guárdalo ahora**, no se vuelve a exponer. Para rotar el secreto usa `POST /webhooks/{id}/roll-secret`.\n\n## Firma de entregas (Standard Webhooks)\n\nCada entrega incluye las cabeceras:\n- `webhook-id` — identificador único de la entrega (UUID v4). Usar para idempotencia.\n- `webhook-timestamp` — Unix timestamp en segundos del momento de envío.\n- `webhook-signature` — firma HMAC-SHA256 con el formato `v1,<base64>`. La cadena firmada es `{webhook-id}.{webhook-timestamp}.{body}` (body = bytes del request). Rotar el secreto via `roll-secret` reemplaza el secreto de firma en forma inmediata — no hay ventana de firma dual.\n\n## Reintentos\n\nEn caso de fallo (no-2xx o timeout), Nodda reintenta con backoff exponencial: hasta 4 intentos distribuidos a lo largo de ≈2,5 horas (inmediato → +1m → +30m → +2h). Usa `webhook-id` para deduplicar entregas en tu endpoint.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url","event_types"],"properties":{"url":{"type":"string","format":"uri","description":"URL HTTPS de destino."},"event_types":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEventType"},"minItems":1}}}}}},"responses":{"201":{"description":"Endpoint creado (incluye secret en texto plano — guardar ahora)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"allOf":[{"$ref":"#/components/schemas/WebhookEndpoint"},{"type":"object","required":["secret"],"properties":{"secret":{"type":"string","description":"Secreto de firma (sólo visible aquí y en roll-secret)."}}}]}}}}}},"400":{"description":"Datos inválidos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Obtener webhook endpoint","operationId":"getWebhookEndpoint","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"responses":{"200":{"description":"Endpoint de webhook","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/WebhookEndpoint"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"webhook_endpoint_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"summary":"Actualizar webhook endpoint","operationId":"patchWebhookEndpoint","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"event_types":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEventType"},"minItems":1},"enabled":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Endpoint actualizado","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/WebhookEndpoint"}}}}}},"400":{"description":"Datos inválidos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"webhook_endpoint_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Eliminar webhook endpoint","operationId":"deleteWebhookEndpoint","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"responses":{"200":{"description":"Endpoint eliminado","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","required":["deleted"],"properties":{"deleted":{"type":"boolean","enum":[true]}}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"webhook_endpoint_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks/{id}/roll-secret":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"post":{"summary":"Rotar secreto de webhook","operationId":"rollWebhookSecret","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"description":"Genera un nuevo secreto de firma para el endpoint. El secreto anterior deja de ser válido inmediatamente. El nuevo secreto se devuelve en texto plano una sola vez — guárdalo ahora.","responses":{"200":{"description":"Nuevo secreto generado (texto plano — guardar ahora)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","required":["secret"],"properties":{"secret":{"type":"string","description":"Nuevo secreto de firma (sólo visible aquí)."}}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"webhook_endpoint_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks/{id}/deliveries":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"get":{"summary":"Listar entregas de un endpoint","operationId":"listWebhookDeliveries","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"responses":{"200":{"description":"Entregas del endpoint (más recientes primero)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookDelivery"}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"webhook_endpoint_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks/{id}/deliveries/{deliveryId}/resend":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"deliveryId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"post":{"summary":"Reenviar una entrega","operationId":"resendWebhookDelivery","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]}],"description":"Encola un reintento inmediato de la entrega, independientemente de su estado actual.","responses":{"200":{"description":"Reenvío encolado","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","required":["resent"],"properties":{"resent":{"type":"boolean","enum":[true]}}}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"webhook_endpoint_not_found o entrega no encontrada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api-keys/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"delete":{"summary":"Revocar API key (requiere sesión del dashboard)","operationId":"revokeApiKey","security":[{"SessionCookieAuth":[]}],"description":"API keys reciben 403; requiere sesión del dashboard.","responses":{"200":{"description":"API key revocada","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/ApiKey"}}}}}},"401":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Requiere sesión del dashboard; API keys no autorizadas","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"api_key_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mercado-publico/documentos/{documentoId}/download":{"get":{"summary":"Descargar documento de Mercado Público","operationId":"downloadMercadoPublicoDocumento","description":"Descarga el archivo de un documento de licitación u oferta por su ID interno. Devuelve los bytes del archivo directamente (no JSON). Requiere autenticación (API key o sesión del dashboard). Esta operación no forma parte del catálogo MCP/agente — devuelve bytes, no datos estructurados.","security":[{"ApiKeyAuth":[]},{"SessionCookieAuth":[]},{"OAuthToken":[]}],"parameters":[{"name":"documentoId","in":"path","required":true,"schema":{"type":"string"},"description":"ID interno del documento (UUID)."}],"responses":{"200":{"description":"Bytes del archivo adjunto","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Parámetro inválido o error de autenticación","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"document_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"mercado_publico.download_failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mercado-publico/licitaciones/{codigo}/documentos":{"get":{"summary":"Documentos adjuntos de una licitación de Mercado Público","operationId":"listMercadoPublicoDocumentos","description":"Devuelve los documentos adjuntos de una licitación por su código (e.g. `2216-39-LE99`). Si los datos están en caché y son frescos (<24 h) se sirven directamente. Con `?refresh=true` fuerza una nueva consulta al portal. Requiere autenticación (API key o token OAuth).","parameters":[{"name":"codigo","in":"path","required":true,"schema":{"type":"string","pattern":"^\\d+-\\d+-[A-Za-z0-9]+$","example":"2216-39-LE99"},"description":"Código de la licitación (formato: dígitos-dígitos-alfanum)."},{"name":"refresh","in":"query","required":false,"schema":{"type":"boolean"},"description":"Si `true`, ignora el caché y re-consulta el portal."}],"responses":{"200":{"description":"Lista de documentos adjuntos de la licitación","content":{"application/json":{"schema":{"type":"object","required":["data","fetched_at","stale"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/MpDocumentoRow"}},"fetched_at":{"type":"string","format":"date-time"},"stale":{"type":"boolean"}}}}}},"400":{"description":"Código inválido o error de autenticación","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Error al consultar el portal de Mercado Público","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mercado-publico/licitaciones/{codigo}/ofertas":{"get":{"summary":"Ofertas de una licitación de Mercado Público","operationId":"listMercadoPublicoOfertas","description":"Devuelve las ofertas presentadas en una licitación por su código (e.g. `2216-39-LE99`). Cada oferta incluye sus documentos adjuntos en el campo `documentos`. Si los datos están en caché y son frescos (<24 h) se sirven directamente. Con `?refresh=true` fuerza una nueva consulta al portal. Requiere autenticación (API key o token OAuth).","parameters":[{"name":"codigo","in":"path","required":true,"schema":{"type":"string","pattern":"^\\d+-\\d+-[A-Za-z0-9]+$","example":"2216-39-LE99"},"description":"Código de la licitación (formato: dígitos-dígitos-alfanum)."},{"name":"refresh","in":"query","required":false,"schema":{"type":"boolean"},"description":"Si `true`, ignora el caché y re-consulta el portal."}],"responses":{"200":{"description":"Lista de ofertas de la licitación con sus documentos adjuntos","content":{"application/json":{"schema":{"type":"object","required":["data","fetched_at","stale"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/MpOfertaRow"}},"fetched_at":{"type":"string","format":"date-time"},"stale":{"type":"boolean"}}}}}},"400":{"description":"Código inválido o error de autenticación","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Error al consultar el portal de Mercado Público","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mercado-publico/licitaciones/{codigo}/preguntas":{"get":{"summary":"Preguntas y respuestas de una licitación de Mercado Público","operationId":"listMercadoPublicoPreguntas","description":"Devuelve las preguntas y respuestas de una licitación por su código (e.g. `2216-39-LE99`). Si los datos están en caché y son frescos (<24 h) se sirven directamente. Con `?refresh=true` fuerza una nueva consulta al portal. Requiere autenticación (API key o token OAuth).","parameters":[{"name":"codigo","in":"path","required":true,"schema":{"type":"string","pattern":"^\\d+-\\d+-[A-Za-z0-9]+$","example":"2216-39-LE99"},"description":"Código de la licitación (formato: dígitos-dígitos-alfanum)."},{"name":"refresh","in":"query","required":false,"schema":{"type":"boolean"},"description":"Si `true`, ignora el caché y re-consulta el portal."}],"responses":{"200":{"description":"Lista de preguntas y respuestas de la licitación","content":{"application/json":{"schema":{"type":"object","required":["data","fetched_at","stale"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/MpPreguntaRow"}},"fetched_at":{"type":"string","format":"date-time"},"stale":{"type":"boolean"}}}}}},"400":{"description":"Código inválido o error de autenticación","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Error al consultar el portal de Mercado Público","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mercado-publico/licitaciones/{codigo}":{"get":{"summary":"Ficha de licitación de Mercado Público","operationId":"getMercadoPublicoLicitacion","description":"Devuelve la ficha de una licitación por su código (e.g. `2216-39-LE99`). Si los datos están en caché y son frescos (<24 h) se sirven directamente. Con `?refresh=true` fuerza una nueva consulta al portal. Requiere autenticación (API key o token OAuth).","parameters":[{"name":"codigo","in":"path","required":true,"schema":{"type":"string","pattern":"^\\d+-\\d+-[A-Za-z0-9]+$","example":"2216-39-LE99"},"description":"Código de la licitación (formato: dígitos-dígitos-alfanum)."},{"name":"refresh","in":"query","required":false,"schema":{"type":"boolean"},"description":"Si `true`, ignora el caché y re-consulta el portal."}],"responses":{"200":{"description":"Ficha de la licitación","content":{"application/json":{"schema":{"type":"object","required":["data","fetched_at","stale"],"properties":{"data":{"$ref":"#/components/schemas/MpLicitacionRow"},"fetched_at":{"type":"string","format":"date-time"},"stale":{"type":"boolean"}}}}}},"400":{"description":"Código inválido o error de autenticación","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Error interno","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Error al consultar el portal de Mercado Público","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}