{"openapi":"3.1.0","info":{"title":"Fisnodo API","version":"0.1.0","description":"API v1 para documentos SIFEN y autoimpresor, configuracion multi-tenant, webhooks y consola operativa."},"servers":[{"url":"https://api.fisnodo.sun.com.py","description":"Produccion"},{"url":"http://localhost:6020","description":"Desarrollo local"}],"tags":[{"name":"Health"},{"name":"Auth"},{"name":"Tenants"},{"name":"Configuration"},{"name":"Documents"},{"name":"Sandbox"},{"name":"Webhooks"}],"security":[{"bearerAuth":[]}],"paths":{"/health":{"get":{"tags":["Health"],"security":[],"summary":"Health check del proceso HTTP","responses":{"200":{"description":"Proceso disponible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"examples":{"ok":{"value":{"status":"ok","version":"0.1.0"}}}}}}}}},"/ready":{"get":{"tags":["Health"],"security":[],"summary":"Readiness con verificacion de base de datos","responses":{"200":{"description":"Dependencias listas","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}},"503":{"$ref":"#/components/responses/ApiError"}}}},"/metrics":{"get":{"tags":["Health"],"security":[{"metricsBearer":[]}],"summary":"Metricas Prometheus de API, jobs, webhooks y certificados","responses":{"200":{"description":"Exposicion Prometheus text/plain","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/v1/auth/login":{"post":{"tags":["Auth"],"security":[],"summary":"Crea una sesion de consola","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"},"examples":{"login":{"value":{"email":"admin@example.com","password":"secret"}}}}}},"responses":{"200":{"description":"Sesion creada","headers":{"Set-Cookie":{"schema":{"type":"string"},"description":"Cookie de sesion HTTP-only"}}},"401":{"$ref":"#/components/responses/ApiError"}}}},"/v1/auth/logout":{"post":{"tags":["Auth"],"summary":"Revoca la sesion actual","responses":{"200":{"description":"Sesion revocada"},"401":{"$ref":"#/components/responses/ApiError"}}}},"/v1/tenants":{"post":{"tags":["Tenants"],"security":[],"summary":"Crea un tenant","requestBody":{"$ref":"#/components/requestBodies/TenantCreate"},"responses":{"201":{"description":"Tenant creado"},"409":{"$ref":"#/components/responses/ApiError"}}}},"/v1/tenants/{id}":{"get":{"tags":["Tenants"],"summary":"Obtiene un tenant accesible","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Tenant"},"404":{"$ref":"#/components/responses/ApiError"}}}},"/v1/users":{"post":{"tags":["Configuration"],"security":[],"summary":"Crea un usuario","responses":{"201":{"description":"Usuario creado"},"400":{"$ref":"#/components/responses/ApiError"}}}},"/v1/memberships":{"post":{"tags":["Configuration"],"summary":"Asigna un usuario a un tenant","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"responses":{"201":{"description":"Membership creado"},"403":{"$ref":"#/components/responses/ApiError"}}}},"/v1/companies":{"get":{"tags":["Configuration"],"summary":"Lista empresas del tenant","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"responses":{"200":{"description":"Empresas"}}},"post":{"tags":["Configuration"],"summary":"Crea una empresa","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"responses":{"201":{"description":"Empresa creada"},"409":{"$ref":"#/components/responses/ApiError"}}}},"/v1/companies/{id}":{"patch":{"tags":["Configuration"],"summary":"Actualiza una empresa","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Empresa actualizada"},"404":{"$ref":"#/components/responses/ApiError"}}}},"/v1/branches":{"get":{"tags":["Configuration"],"summary":"Lista sucursales","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"name":"company_id","in":"query","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Sucursales"}}},"post":{"tags":["Configuration"],"summary":"Crea una sucursal","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"responses":{"201":{"description":"Sucursal creada"}}}},"/v1/issuance-points":{"post":{"tags":["Configuration"],"summary":"Crea un punto de expedicion","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"responses":{"201":{"description":"Punto creado"}}}},"/v1/certificates":{"get":{"tags":["Configuration"],"summary":"Lista certificados sin material sensible","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"responses":{"200":{"description":"Certificados"}}},"post":{"tags":["Configuration"],"summary":"Carga un certificado PFX cifrado en reposo","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"responses":{"201":{"description":"Certificado cargado"}}}},"/v1/certificates/{id}/validate":{"post":{"tags":["Configuration"],"summary":"Valida metadata y vigencia del certificado","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Resultado de validacion"}}}},"/v1/emission-channels":{"post":{"tags":["Configuration"],"summary":"Configura canal SIFEN o autoimpresor","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmissionChannelRequest"},"examples":{"sifen":{"$ref":"#/components/examples/SifenChannel"},"autoimpresor":{"$ref":"#/components/examples/AutoimpresorChannel"}}}}},"responses":{"201":{"description":"Canal configurado"}}}},"/v1/emission-channels/readiness":{"get":{"tags":["Configuration"],"summary":"Lista readiness separado por canal","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"name":"company_id","in":"query","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Readiness por canal"}}}},"/v1/api-keys":{"post":{"tags":["Configuration"],"summary":"Crea API key y devuelve el valor plano una sola vez","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"responses":{"201":{"description":"API key creada"}}}},"/v1/api-keys/current":{"get":{"tags":["Configuration"],"summary":"Describe la API key autenticada","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"responses":{"200":{"description":"API key actual"}}}},"/v1/documents":{"get":{"tags":["Documents"],"summary":"Lista documentos con filtros operativos","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"name":"company_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/DocumentStatus"}},{"name":"channel","in":"query","schema":{"$ref":"#/components/schemas/EmissionChannel"}},{"name":"external_id","in":"query","schema":{"type":"string"}},{"name":"cdc","in":"query","schema":{"type":"string","pattern":"^\\d{44}$"}},{"name":"ruc","in":"query","schema":{"type":"string"}},{"name":"date_from","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"date_to","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"responses":{"200":{"description":"Documentos"}}},"post":{"tags":["Documents"],"summary":"Ingiere un documento canonico","description":"Idempotente por 24h usando el header Idempotency-Key. Si no se informa canal, sucursal o punto, se usan defaults configurados cuando son inequívocos.","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdempotencyKeyHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CanonicalDocumentV1"},"examples":{"sifen":{"$ref":"#/components/examples/SifenDocument"},"autoimpresor":{"$ref":"#/components/examples/AutoimpresorDocument"}}}}},"responses":{"201":{"description":"Documento recibido"},"400":{"$ref":"#/components/responses/ApiError"},"409":{"$ref":"#/components/responses/ApiError"},"413":{"$ref":"#/components/responses/ApiError"}}}},"/v1/documents/validate":{"post":{"tags":["Documents"],"summary":"Dry-run de validacion canonica","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CanonicalDocumentV1"}}}},"responses":{"200":{"description":"Resultado de validacion","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentValidationResponse"}}}},"413":{"$ref":"#/components/responses/ApiError"}}}},"/v1/documents/{id}":{"get":{"tags":["Documents"],"summary":"Detalle diagnostico del documento","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Detalle con resumen, artefactos y timeline"}}}},"/v1/documents/{id}/status":{"get":{"tags":["Documents"],"summary":"Estado materializado del documento","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Estado"}}}},"/v1/documents/{id}/timeline":{"get":{"tags":["Documents"],"summary":"Timeline inmutable del documento","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Eventos"}}}},"/v1/documents/{id}/artifacts":{"get":{"tags":["Documents"],"summary":"Artefactos con URLs presignadas de 15 minutos","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Artefactos descargables"}}}},"/v1/documents/{id}/artifacts/{artifactId}/download":{"get":{"tags":["Documents"],"security":[],"summary":"Descarga un artefacto con URL firmada","parameters":[{"$ref":"#/components/parameters/IdPath"},{"name":"artifactId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"expires","in":"query","required":true,"schema":{"type":"integer"}},{"name":"signature","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Artefacto"},"403":{"$ref":"#/components/responses/ApiError"}}}},"/v1/documents/{id}/retry":{"post":{"tags":["Documents"],"summary":"Reenvia manualmente un documento en retrying","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"202":{"description":"Job encolado"},"409":{"$ref":"#/components/responses/ApiError"}}}},"/v1/documents/{id}/regenerate-pdf":{"post":{"tags":["Documents"],"summary":"Encola la generacion del PDF imprimible autoimpresor","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"202":{"description":"Job encolado"},"409":{"$ref":"#/components/responses/ApiError"}}}},"/v1/print-settings":{"get":{"tags":["Configuration"],"summary":"Lee configuracion de impresion autoimpresor por empresa","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"name":"company_id","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Configuracion de impresion","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrintSettings"}}}}}},"put":{"tags":["Configuration"],"summary":"Guarda configuracion de impresion autoimpresor por empresa","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrintSettingsRequest"}}}},"responses":{"200":{"description":"Configuracion guardada"},"400":{"$ref":"#/components/responses/ApiError"}}}},"/v1/documents/{id}/cancel":{"post":{"tags":["Documents"],"summary":"Cancela un documento con motivo obligatorio","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"requestBody":{"$ref":"#/components/requestBodies/FiscalReason"},"responses":{"200":{"description":"Documento cancelado"},"409":{"$ref":"#/components/responses/ApiError"}}}},"/v1/documents/{id}/inutilize":{"post":{"tags":["Documents"],"summary":"Inutiliza un documento aceptado con motivo obligatorio","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"requestBody":{"$ref":"#/components/requestBodies/FiscalReason"},"responses":{"200":{"description":"Documento inutilizado"},"409":{"$ref":"#/components/responses/ApiError"}}}},"/v1/sandbox/preview":{"post":{"tags":["Sandbox"],"security":[],"summary":"Genera una vista previa interactiva sin impacto fiscal","description":"Soporta modos demo_simulated, sifen_dev y autoimpresor_test. Es una vista previa: no persiste documentos, no reserva numeracion y no remite a DNIT/SIFEN.","requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SandboxPreviewRequest"},"examples":{"sifenDev":{"value":{"mode":"sifen_dev","channel":"sifen","external_id":"dev-001"}},"autoimpresorTest":{"value":{"mode":"autoimpresor_test"}}}}}},"responses":{"200":{"description":"Artefactos de prueba visibles segun canal","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SandboxPreviewResponse"}}}},"400":{"$ref":"#/components/responses/ApiError"}}}},"/v1/webhooks":{"get":{"tags":["Webhooks"],"summary":"Lista endpoints webhook","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"name":"company_id","in":"query","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Webhooks"}}},"post":{"tags":["Webhooks"],"summary":"Crea endpoint webhook con secreto devuelto una sola vez","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookRequest"},"examples":{"accepted":{"value":{"url":"https://example.com/fisnodo/webhook","events":["document.accepted","document.rejected"]}}}}}},"responses":{"201":{"description":"Webhook creado"}}}},"/v1/webhooks/{id}":{"patch":{"tags":["Webhooks"],"summary":"Actualiza endpoint webhook","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Webhook actualizado"}}},"delete":{"tags":["Webhooks"],"summary":"Elimina endpoint webhook de forma logica","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Webhook eliminado"}}}},"/v1/webhooks/{id}/test":{"post":{"tags":["Webhooks"],"summary":"Envia webhook.test firmado","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Webhook de prueba enviado"}}}},"/v1/webhooks/{id}/replay":{"post":{"tags":["Webhooks"],"summary":"Reencola una entrega webhook almacenada","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["delivery_id"],"properties":{"delivery_id":{"type":"string","format":"uuid"}}}}}},"responses":{"202":{"description":"Entrega reencolada"}}}},"/v1/webhooks/{id}/deliveries":{"get":{"tags":["Webhooks"],"summary":"Lista entregas recientes de un endpoint webhook","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"},{"name":"status","in":"query","schema":{"type":"string","enum":["pending","delivering","delivered","retrying","failed"]}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}}],"responses":{"200":{"description":"Entregas webhook recientes"}}}},"/v1/webhooks/{id}/deactivate":{"post":{"tags":["Webhooks"],"summary":"Desactiva endpoint webhook","parameters":[{"$ref":"#/components/parameters/TenantIdHeader"},{"$ref":"#/components/parameters/IdPath"}],"responses":{"200":{"description":"Webhook desactivado"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"API key como Authorization: Bearer <key>. Las sesiones de consola usan cookie HTTP-only."},"metricsBearer":{"type":"http","scheme":"bearer","description":"Token operacional de METRICS_BEARER_TOKEN para scrapers Prometheus."}},"parameters":{"TenantIdHeader":{"name":"X-Tenant-Id","in":"header","required":true,"schema":{"type":"string","format":"uuid"},"description":"Tenant activo. Debe coincidir con la API key o sesion."},"IdempotencyKeyHeader":{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":1},"description":"Clave obligatoria para POST /v1/documents. Reenvios identicos por 24h devuelven el documento original."},"IdPath":{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}},"requestBodies":{"TenantCreate":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["slug","name"],"properties":{"slug":{"type":"string"},"name":{"type":"string"},"environment":{"type":"string","enum":["demo","production"]}}}}}},"FiscalReason":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["reason"],"properties":{"reason":{"type":"string","minLength":1}}},"examples":{"cancel":{"value":{"reason":"Cliente solicito anulacion"}}}}}}},"responses":{"ApiError":{"description":"Error normalizado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"examples":{"validation":{"value":{"code":"validation_error","message":"La validacion del documento fallo.","request_id":"req_123","details":{"errors":[{"field":"currency","code":"unsupported_currency","message":"La moneda del documento debe ser PYG."}]}}},"idempotency":{"value":{"code":"validation_error","message":"La clave de idempotencia ya fue usada con otro cuerpo de solicitud.","request_id":"req_456"}},"rateLimit":{"value":{"code":"rate_limit_error","message":"Se supero el limite de solicitudes.","request_id":"req_rate_limit","details":{"bucket":"requests_minute","limit":600,"reset_at":"2026-04-25T12:00:00.000Z"}}}}}}}},"examples":{"SifenChannel":{"value":{"company_id":"00000000-0000-0000-0000-000000000001","channel":"sifen","is_default":true,"credentials":{"endpoint":"https://sifen.dev/submit","client_id":"client","client_secret":"secret"}}},"AutoimpresorChannel":{"value":{"company_id":"00000000-0000-0000-0000-000000000001","channel":"autoimpresor","credentials":{"endpoint":"https://autoimpresor.test/submit","api_key":"secret"},"autoimpresor":{"authorization":"AUTH-001","declared_software":"Fisnodo","timbrado":"12345678","valid_from":"2026-01-01","valid_to":"2026-12-31","branch_id":"00000000-0000-0000-0000-000000000010","issuance_point_id":"00000000-0000-0000-0000-000000000011","range_start":1,"range_end":1000,"next_number":1}}},"SifenDocument":{"value":{"company_id":"00000000-0000-0000-0000-000000000001","channel":"sifen","external_id":"sifen-invoice-001","type":"invoice","issue_datetime":"2026-04-24T12:00:00.000Z","currency":"PYG","seller":{"ruc":"80012345-6","legal_name":"Fisnodo Demo SA"},"buyer":{"ruc":"1234567-8","legal_name":"Cliente Demo","email":"cliente@example.com"},"items":[{"description":"Servicio de prueba","quantity":1,"unit_price":100000,"tax_rate":10,"tax_amount":10000,"total_amount":110000}],"totals":{"subtotal":100000,"tax_total":10000,"grand_total":110000},"payment_terms":{"condition":"cash","method":"cash"},"delivery":{"customer":{"mode":"manual"}}}},"AutoimpresorDocument":{"value":{"company_id":"00000000-0000-0000-0000-000000000001","channel":"autoimpresor","external_id":"autoimpresor-invoice-001","type":"invoice","issue_datetime":"2026-04-24T12:00:00.000Z","currency":"PYG","seller":{"ruc":"80012345-6","legal_name":"Fisnodo Demo SA"},"buyer":{"ruc":"1234567-8","legal_name":"Cliente Demo","email":"cliente@example.com"},"items":[{"description":"Servicio de prueba","quantity":1,"unit_price":100000,"tax_rate":10,"tax_amount":10000,"total_amount":110000}],"totals":{"subtotal":100000,"tax_total":10000,"grand_total":110000},"payment_terms":{"condition":"cash","method":"cash"},"delivery":{"customer":{"mode":"manual"}}}}},"schemas":{"HealthResponse":{"type":"object","required":["status","version"],"properties":{"status":{"type":"string"},"version":{"type":"string"}}},"ApiError":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","enum":["validation_error","not_found","readiness_check_failed","configuration_error","certificate_error","upstream_error","rate_limit_error","internal_error"]},"message":{"type":"string"},"request_id":{"type":"string"},"details":{}}},"ValidationIssue":{"type":"object","required":["field","code","message"],"properties":{"field":{"type":"string"},"code":{"type":"string"},"message":{"type":"string"}}},"DocumentValidationResponse":{"type":"object","required":["valid","errors","warnings","routing"],"properties":{"valid":{"type":"boolean"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/ValidationIssue"}},"warnings":{"type":"array","items":{"$ref":"#/components/schemas/ValidationIssue"}},"routing":{"oneOf":[{"type":"null"},{"type":"object","required":["company_id","channel"],"properties":{"company_id":{"type":"string","format":"uuid"},"branch_id":{"type":["string","null"],"format":"uuid"},"issuance_point_id":{"type":["string","null"],"format":"uuid"},"channel":{"$ref":"#/components/schemas/EmissionChannel"}}}]}}},"LoginRequest":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email"},"password":{"type":"string","format":"password"}}},"EmissionChannel":{"type":"string","enum":["sifen","autoimpresor"]},"DocumentStatus":{"type":"string","enum":["received","validation_failed","validated","queued","transforming","signing","submitting","accepted","rejected","retrying","rendering","cancelled","invalidated","failed_terminal"]},"SandboxMode":{"type":"string","enum":["demo_simulated","sifen_dev","autoimpresor_test"]},"EmissionChannelRequest":{"type":"object","required":["company_id","channel","credentials"],"properties":{"company_id":{"type":"string","format":"uuid"},"channel":{"$ref":"#/components/schemas/EmissionChannel"},"is_default":{"type":"boolean"},"credentials":{"type":"object"},"autoimpresor":{"type":"object"}}},"PrintSettingsRequest":{"type":"object","required":["company_id","logo_text","business_activity","footer_note","copy_label","show_logo","show_item_tax","show_payment_terms","show_copy_label"],"properties":{"company_id":{"type":"string","format":"uuid"},"logo_text":{"type":"string"},"logo_image_data_url":{"type":["string","null"],"description":"JPEG data URL normalized by the SVG editor."},"logo_image_name":{"type":["string","null"]},"business_activity":{"type":"string"},"footer_note":{"type":"string"},"copy_label":{"type":"string","enum":["ORIGINAL","COPIA"]},"show_logo":{"type":"boolean"},"show_item_tax":{"type":"boolean"},"show_payment_terms":{"type":"boolean"},"show_copy_label":{"type":"boolean"},"page_width":{"type":"number"},"page_height":{"type":"number"},"template_elements":{"type":"array","items":{"type":"object"}}}},"PrintSettings":{"allOf":[{"$ref":"#/components/schemas/PrintSettingsRequest"},{"type":"object","properties":{"id":{"type":["string","null"],"format":"uuid"},"tenant_id":{"type":"string","format":"uuid"},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"}}}]},"WebhookRequest":{"type":"object","required":["url","events"],"properties":{"company_id":{"type":"string","format":"uuid"},"url":{"type":"string","format":"uri"},"description":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"active":{"type":"boolean"}}},"CanonicalDocumentV1":{"type":"object","required":["external_id","type","issue_datetime","currency","seller","items","totals","payment_terms"],"properties":{"company_id":{"type":"string","format":"uuid","description":"Opcional si la API key esta scoping a una empresa."},"branch_id":{"type":"string","format":"uuid","description":"Opcional; se resuelve desde defaults cuando aplica."},"issuance_point_id":{"type":"string","format":"uuid","description":"Opcional; se resuelve desde defaults cuando aplica."},"channel":{"$ref":"#/components/schemas/EmissionChannel"},"external_id":{"type":"string"},"type":{"type":"string","enum":["invoice","credit_note","debit_note","remision","receipt","autofactura"]},"issue_datetime":{"type":"string","format":"date-time"},"currency":{"type":"string","enum":["PYG"]},"seller":{"$ref":"#/components/schemas/Party"},"buyer":{"$ref":"#/components/schemas/Party"},"items":{"type":"array","items":{"$ref":"#/components/schemas/DocumentItem"}},"totals":{"$ref":"#/components/schemas/DocumentTotals"},"payment_terms":{"$ref":"#/components/schemas/PaymentTerms"},"delivery":{"$ref":"#/components/schemas/DocumentDelivery"},"metadata":{"type":"object"}}},"DocumentDelivery":{"type":"object","properties":{"customer":{"$ref":"#/components/schemas/CustomerDocumentDelivery"},"issuer":{"$ref":"#/components/schemas/IssuerDocumentDelivery"}}},"CustomerDocumentDelivery":{"type":"object","required":["mode"],"properties":{"mode":{"type":"string","enum":["manual","automatic"],"description":"manual: el emisor entrega desde la UI; automatic: Fisnodo debe intentar entregar por los canales configurados."},"channels":{"type":"array","items":{"$ref":"#/components/schemas/CustomerDeliveryChannel"}},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"telegram_chat_id":{"type":"string"}}},"IssuerDocumentDelivery":{"type":"object","properties":{"mode":{"type":"string","enum":["manual","automatic"]},"channels":{"type":"array","items":{"type":"string","enum":["email","whatsapp","telegram","webhook"]}},"emails":{"type":"array","items":{"type":"string","format":"email"}},"webhook":{"type":"boolean"}}},"CustomerDeliveryChannel":{"type":"string","enum":["email","whatsapp","telegram"]},"SandboxPreviewRequest":{"allOf":[{"$ref":"#/components/schemas/CanonicalDocumentV1"},{"type":"object","properties":{"mode":{"$ref":"#/components/schemas/SandboxMode"}}}]},"SandboxPreviewResponse":{"type":"object","required":["mode","channel","fiscal_impact","persistence","routing","document","artifacts","response"],"properties":{"mode":{"$ref":"#/components/schemas/SandboxMode"},"channel":{"$ref":"#/components/schemas/EmissionChannel"},"fiscal_impact":{"type":"boolean","const":false},"persistence":{"type":"string","enum":["none"]},"routing":{"type":"object"},"document":{"$ref":"#/components/schemas/CanonicalDocumentV1"},"artifacts":{"type":"array","items":{"type":"object","required":["type","content_type"],"properties":{"type":{"type":"string"},"content_type":{"type":"string"},"body":{"type":"string"},"body_base64":{"type":"string"}}}},"response":{"type":"object"}}},"Party":{"type":"object","properties":{"ruc":{"type":"string"},"legal_name":{"type":"string"},"trade_name":{"type":"string"},"email":{"type":"string","format":"email"},"operation_type":{"type":"string","enum":["b2b","b2c","foreign","anonymous"]},"document_type":{"type":"string","enum":["ruc","ci","passport","foreign_id","diplomatic_card","innominado","other"]},"document_number":{"type":"string"}}},"DocumentItem":{"type":"object","required":["description","quantity","unit_price","tax_rate","tax_amount","total_amount"],"properties":{"description":{"type":"string"},"quantity":{"type":"number"},"unit_price":{"type":"number"},"tax_rate":{"type":"number","enum":[0,5,10]},"tax_amount":{"type":"number"},"total_amount":{"type":"number"}}},"DocumentTotals":{"type":"object","required":["subtotal","tax_total","grand_total"],"properties":{"subtotal":{"type":"number"},"tax_total":{"type":"number"},"grand_total":{"type":"number"}}},"PaymentTerms":{"type":"object","required":["condition"],"properties":{"condition":{"type":"string","enum":["cash","credit"],"description":"cash = contado, credit = credito."},"method":{"type":"string","enum":["cash","card","bank_transfer","check","other"]},"due_date":{"type":"string","format":"date"},"installments":{"type":"array","items":{"type":"object","required":["due_date","amount"],"properties":{"due_date":{"type":"string","format":"date"},"amount":{"type":"number"}}}}}}}}}