Download OpenAPI specification:
Contrato publico de la API de facturacion electronica NinfaDTE (dteapi.ninfasolutions.com).
Es la fuente unica de verdad: de aqui se generan el cliente TypeScript del panel, las tools del servidor MCP y la referencia de API del sitio publico.
La API real es Rust stdlib artesanal; este spec se mantiene a mano y un test de contrato
(npm run validate) valida los ejemplos contra sus schemas para detectar drift.
/v1./v1/tenants/{tenant_id}.X-DTE-Environment: certification | production | sandbox
en las mutaciones que lo requieren. sandbox nunca contacta al SII y no emite documentos legales.Authorization: Bearer <api_key> en todas las rutas /v1/tenants/{tenant_id}/....
La key se guarda como SHA-256 y queda asociada a un tenant.YYYY-MM-DD. Timestamps: ISO 8601 UTC.{ "error": "codigo" }; algunos agregan reason y/o preflight.Cada documento expone su estado REAL ante el SII: firmado -> enviado (trackid) ->
aceptado / rechazado / con reparos, con la glosa oficial como evidencia
(GET /v1/tenants/{tenant_id}/documents/{document_id}/sii-status).
{- "document_types": [
- {
- "code": 33,
- "name": "Factura Electronica"
}, - {
- "code": 34,
- "name": "Factura Exenta Electronica"
}, - {
- "code": 56,
- "name": "Nota de Debito Electronica"
}, - {
- "code": 61,
- "name": "Nota de Credito Electronica"
}
]
}Consulta publica del registro del SII (ee_empresa_rut), sin certificado ni token.
No expone datos de ningun tenant. Requiere DTE_SII_ENABLE_REAL_HTTP=1 en el servidor.
| rut required | string Example: rut=78427717-8 |
| environment | string Default: "certification" Enum: "certification" "production" |
{- "authorized": true,
- "environment": "certification",
- "rut": "78427717-8",
- "legal_name": "TENGO CITA SPA",
- "resolution": {
- "number": "0",
- "date": "2026-07-04"
}, - "documents": [
- {
- "code": 33,
- "name": "Factura Electronica",
- "authorized_at": "2026-07-04",
- "deauthorized_at": null
}
]
}| tenant_id required | integer <int64> Example: 1 |
{- "tenant_id": 1,
- "counts": {
- "taxpayers": 1,
- "drafts": 1,
- "issued_documents": 1,
- "pending_deliveries": 1
}, - "drafts_by_status": {
- "draft": 1
}, - "documents_by_status": {
- "issued_local": 1
}
}| tenant_id required | integer <int64> Example: 1 |
| rut required | string |
| legal_name required | string |
| activity_code | string |
| address | string |
{- "rut": "76192083-9",
- "legal_name": "Demo SpA",
- "activity_code": "620200",
- "address": "Direccion 123"
}{- "id": 1,
- "rut": "76192083-9",
- "legal_name": "Demo SpA",
- "status": "active"
}| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: 1 |
{- "id": 1,
- "rut": "76192083-9",
- "legal_name": "Demo SpA",
- "status": "active",
- "activity_code": "620200",
- "address": "Direccion 123"
}| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: taxpayer_id=1 |
{- "certificates": [
- {
- "id": 1,
- "taxpayer_id": 1,
- "subject_rut": "76192083-9",
- "valid_from": "2026-01-01T00:00:00Z",
- "valid_to": "2027-01-01T00:00:00Z",
- "pkcs12_sha256": "hex...",
- "status": "active"
}
]
}Valida que el PKCS#12 cargue con la password antes de guardar. La respuesta nunca incluye P12 ni password.
| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> |
| subject_rut | string |
| valid_from | string <date> |
| valid_to | string <date> |
| pkcs12_base64 required | string P12 en base64. Nunca se devuelve. |
| pkcs12_password required | string Password del P12. Nunca se devuelve ni loguea. |
{- "taxpayer_id": 1,
- "subject_rut": "76192083-9",
- "valid_from": "2026-01-01",
- "valid_to": "2027-01-01",
- "pkcs12_base64": "base64-del-p12",
- "pkcs12_password": "password-del-p12"
}{- "id": 1,
- "taxpayer_id": 1,
- "subject_rut": "76192083-9",
- "valid_from": "2026-01-01",
- "valid_to": "2027-01-01",
- "pkcs12_sha256": "hex...",
- "status": "active"
}Genera server-side un P12 de desarrollo (CA local) y lo registra como certificado activo. Solo demo; nunca contacta al SII.
| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> |
| rut | string |
| legal_name | string |
{- "taxpayer_id": 1,
- "rut": "76.192.083-9",
- "legal_name": "Demo SpA"
}{- "id": 0,
- "taxpayer_id": 0,
- "subject_rut": "string",
- "valid_from": "string",
- "valid_to": "string",
- "pkcs12_sha256": "string",
- "status": "active"
}| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: taxpayer_id=1 |
{- "authorizations": [
- {
- "id": 1,
- "taxpayer_id": 1,
- "environment": "certification",
- "resolution_number": "0",
- "resolution_date": "2020-01-01"
}
]
}No consulta SII. sandbox no usa autorizacion y se rechaza aqui.
| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> |
| environment required | string (Environment) Enum: "certification" "production" "sandbox" |
| resolution_number required | string |
| resolution_date required | string <date> |
{- "taxpayer_id": 1,
- "environment": "certification",
- "resolution_number": "0",
- "resolution_date": "2020-01-01"
}{- "id": 1,
- "taxpayer_id": 1,
- "environment": "certification",
- "resolution_number": "0",
- "resolution_date": "2020-01-01"
}| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: taxpayer_id=1 |
{- "caf_files": [
- {
- "id": 1,
- "taxpayer_id": 1,
- "environment": "certification",
- "doc_type": 33,
- "folio_from": 1,
- "folio_to": 50,
- "authorized_at": "2026-01-01",
- "expires_at": null,
- "caf_sha256": "hex...",
- "status": "active"
}
]
}Guarda el CAF cifrado e inicializa el contador de folios. sandbox se rechaza. La respuesta nunca incluye el XML crudo.
| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> |
| environment required | string (Environment) Enum: "certification" "production" "sandbox" |
| authorized_at | string <date> |
| caf_xml_base64 required | string CAF (contiene RSASK = secreto). Nunca se devuelve. |
{- "taxpayer_id": 1,
- "environment": "certification",
- "authorized_at": "2026-01-01",
- "caf_xml_base64": "base64-del-caf"
}{- "id": 1,
- "taxpayer_id": 1,
- "environment": "certification",
- "doc_type": 33,
- "folio_from": 1,
- "folio_to": 50,
- "caf_sha256": "hex..."
}| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: taxpayer_id=1 |
| environment required | string (Environment) Enum: "certification" "production" "sandbox" |
| doc_type required | integer Example: doc_type=33 |
{- "taxpayer_id": 1,
- "environment": "certification",
- "doc_type": 33,
- "next_folio": 1,
- "available_until": 50,
- "remaining": 50,
- "active_caf_files": [
- {
- "id": 1,
- "folio_from": 1,
- "folio_to": 50,
- "authorized_at": "2026-01-01",
- "expires_at": null,
- "status": "active"
}
]
}| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: 1 |
| environment required | string (Environment) Enum: "certification" "production" "sandbox" |
| doc_type required | integer Example: doc_type=33 |
{- "taxpayer_id": 1,
- "environment": "certification",
- "doc_type": 33,
- "status": "ready_for_issue",
- "checks": {
- "taxpayer_data": true,
- "certificate": true,
- "sii_authorization": true,
- "caf": true
}
}| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: taxpayer_id=1 |
{- "drafts": [
- {
- "id": 1,
- "status": "draft",
- "taxpayer_id": 1,
- "doc_type": 33,
- "recipient_tax_id": "60803000-K",
- "created_at": "2026-06-25T12:01:00Z",
- "updated_at": "2026-06-25T12:01:00Z"
}
]
}| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> |
| doc_type required | integer |
| issue_date | string <date> |
required | object (DraftRecipient) |
required | Array of objects (DraftItem) |
Array of objects (DraftReference) | |
object |
{- "taxpayer_id": 1,
- "doc_type": 33,
- "issue_date": "2026-06-25",
- "recipient": {
- "tax_id": "11111111-1",
- "legal_name": "Cliente SpA",
- "activity": "Servicios",
- "address": "Direccion 123",
- "city": "Santiago"
}, - "items": [
- {
- "name": "Servicio mensual",
- "quantity": 1,
- "unit_price": 10000,
- "tax_exempt": false
}
]
}{- "id": 1,
- "status": "draft",
- "taxpayer_id": 1,
- "doc_type": 33,
- "totals": {
- "net": 10000,
- "vat": 1900,
- "exempt": 0,
- "total": 11900
}, - "created_at": "2026-06-25T12:00:00Z"
}| tenant_id required | integer <int64> Example: 1 |
| draft_id required | integer <int64> Example: 1 |
{- "id": 0,
- "status": "draft",
- "taxpayer_id": 0,
- "doc_type": 0,
- "totals": {
- "net": 0,
- "vat": 0,
- "exempt": 0,
- "total": 0
}, - "created_at": "2019-08-24T14:15:22Z"
}En certification/production responde 501 (emision legal aun no habilitada por API),
con preflight no destructivo si hay Idempotency-Key y DB. En sandbox crea un documento
de laboratorio sin valor legal. Idempotency-Key obligatorio en sandbox.
| tenant_id required | integer <int64> Example: 1 |
| draft_id required | integer <int64> Example: 1 |
| X-DTE-Environment | string (Environment) Enum: "certification" "production" "sandbox" |
| Idempotency-Key | string Example: issue-2026-07-15-0001 Obligatorio en sandbox y en emision legal. Un retry con la misma key nunca duplica un envio. |
| send_to_sii | boolean |
{- "send_to_sii": true
}{- "id": 123,
- "draft_id": 2,
- "status": "sandbox_issued",
- "taxpayer_id": 1,
- "environment": "sandbox",
- "doc_type": 33,
- "folio": 2,
- "sii_track_id": null,
- "xml_sha256": "hex...",
- "totals": {
- "net": 10000,
- "vat": 1900,
- "exempt": 0,
- "total": 11900
}, - "legal_value": false,
- "signature": "SandboxSignature RSA-SHA256, not XMLDSig",
- "created_at": "2026-06-26T12:01:00Z"
}| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: taxpayer_id=1 |
{- "documents": [
- {
- "id": 123,
- "status": "issued_local",
- "taxpayer_id": 1,
- "environment": "certification",
- "doc_type": 33,
- "folio": 456,
- "recipient_tax_id": "11111111-1",
- "sii_track_id": null,
- "totals": {
- "total": 11900
}, - "created_at": "2026-06-25T12:01:00Z"
}
]
}| tenant_id required | integer <int64> Example: 1 |
| document_id required | integer <int64> Example: 123 |
{- "id": 123,
- "status": "submitted",
- "taxpayer_id": 1,
- "environment": "certification",
- "doc_type": 33,
- "folio": 456,
- "recipient_tax_id": "11111111-1",
- "sii_track_id": "123456789",
- "totals": {
- "net": 10000,
- "vat": 1900,
- "exempt": 0,
- "total": 11900
}, - "created_at": "2026-06-25T12:01:00Z"
}Implementado para documentos sandbox_issued. Para certification/production responde 501 hasta el renderer legal.
| tenant_id required | integer <int64> Example: 1 |
| document_id required | integer <int64> Example: 123 |
{- "error": "unauthorized"
}Sonda QueryEstUp con el RUT de la EMPRESA para distinguir "mi certificado sirve"
de "puedo emitir por la empresa". Solo certification. Requiere token SII activo.
| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: 1 |
| X-DTE-Environment | string (Environment) Enum: "certification" "production" "sandbox" |
{- "authorized_signer": true,
- "environment": "certification",
- "taxpayer_rut": "78427717-8",
- "signer_rut": "12345678-9",
- "sii_state": "001",
- "sii_glosa": "SEMILLA VALIDA"
}Por defecto responde 501 con un preflight no destructivo. Con
DTE_SII_ENABLE_REAL_HTTP=1 y preflight ready_for_auth, en certification
pide semilla, firma XMLDSig con el P12 del certificado activo, pide token y lo cachea cifrado.
| tenant_id required | integer <int64> Example: 1 |
| taxpayer_id required | integer <int64> Example: 1 |
| X-DTE-Environment | string (Environment) Enum: "certification" "production" "sandbox" |
{ }{ }Lee envios/eventos ya guardados; no consulta SII. No devuelve el XML de respuesta.
| tenant_id required | integer <int64> Example: 1 |
| document_id required | integer <int64> Example: 123 |
{- "document_id": 123,
- "current_status": "submitted",
- "submissions": [
- {
- "id": 1,
- "attempt": 1,
- "track_id": "123456789",
- "status": "received",
- "error_code": null,
- "error_detail": null,
- "created_at": "2026-06-25T12:01:00Z"
}
], - "events": [
- {
- "id": 1,
- "track_id": "123456789",
- "raw_state": "EPR",
- "normalized_state": "pending",
- "detail": { },
- "source": "sii",
- "created_at": "2026-06-25T12:02:00Z"
}
]
}Por defecto responde 501 con preflight no destructivo (no expone signed_xml ni contacta SII).
Con DTE_SII_ENABLE_REAL_HTTP=1, token activo y documento ready_for_upload, se habilita solo
en certification: arma multipart, hace POST a maullin, parsea RECEPCIONDTE y persiste el recibo.
| tenant_id required | integer <int64> Example: 1 |
| document_id required | integer <int64> Example: 123 |
{ }{ }Por defecto responde 501 (con preflight en certification si hay DB). Con transporte real
habilitado y preflight ready_for_refresh, consulta QueryEstUp en maullin y persiste el evento.
Para documentos sandbox_issued devuelve el estado local sin consultar SII.
| tenant_id required | integer <int64> Example: 1 |
| document_id required | integer <int64> Example: 123 |
{ }{- "id": 123,
- "status": "accepted",
- "sii_track_id": "123456789",
- "sii": {
- "raw_state": "EPR",
- "raw_detail": "Aceptado"
}, - "checked_at": "2026-06-25T12:10:00Z"
}Encola la entrega y declara el adjunto XML. El PDF se agregara cuando el renderer legal exista.
| tenant_id required | integer <int64> Example: 1 |
| document_id required | integer <int64> Example: 123 |
| to required | Array of strings <email> [ items <email > ] |
| cc | Array of strings <email> [ items <email > ] |
| bcc | Array of strings <email> [ items <email > ] |
| subject | string |
| message | string |
{- "cc": [ ],
- "bcc": [ ],
- "subject": "DTE 33 folio 456",
- "message": "Adjuntamos XML."
}{- "delivery_id": 1,
- "document_id": 123,
- "status": "pending",
- "attachments": [
- "xml"
]
}| tenant_id required | integer <int64> Example: 1 |
| document_id required | integer <int64> Example: 123 |
{- "document_id": 123,
- "deliveries": [
- {
- "id": 1,
- "channel": "email",
- "status": "pending",
- "error_detail": null,
- "created_at": "2026-06-25T12:01:00Z"
}
]
}