{
  "openapi": "3.1.1",
  "info": {
    "title": "API de integración SIFE",
    "version": "1.0.0",
    "description": "API E31 con alta asistida por empresa. Certificado cargado previamente en SIFE; JSON -> XML -> firma -> procesamiento. Requiere credencial, preparación técnica e identificación de la empresa. Sin sandbox público ni webhooks en esta versión.",
    "contact": {
      "name": "SIFE",
      "url": "https://digisign.do/contact.php"
    }
  },
  "servers": [
    {
      "url": "https://facturacion.digisign.do/api/v1/integrations",
      "description": "Producción. Requiere activación explícita por empresa antes de emitir."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/capabilities": {
      "get": {
        "operationId": "getCapabilities",
        "summary": "Consultar capacidades del contrato; no autoriza emisión.",
        "x-required-scope": "documents:validate",
        "responses": {
          "200": {
            "description": "Capacidades declaradas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Capabilities"
                }
              }
            }
          },
          "401": {
            "description": "Credencial inválida, vencida o revocada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Empresa o usuario sin acceso.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de peticiones o cola lleno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Segundos antes de intentar de nuevo."
              }
            }
          },
          "503": {
            "description": "API cerrada o servicio no disponible. Recuperar por referencia antes de reintentar una emisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents/validate": {
      "post": {
        "operationId": "validateDocument",
        "summary": "Validar JSON y cálculo sin reserva o emisión.",
        "x-required-scope": "documents:validate",
        "requestBody": {
          "required": true,
          "description": "JSON UTF-8, máximo 262144 bytes; sin compresión, claves duplicadas ni campos desconocidos.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Invoice"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validación satisfactoria.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Validation"
                }
              }
            }
          },
          "400": {
            "description": "JSON inválido o claves duplicadas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credencial inválida, vencida o revocada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Empresa o usuario sin acceso.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Cuerpo mayor que 256 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type no soportado o cuerpo comprimido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Campo o cálculo inválido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de peticiones o cola lleno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Segundos antes de intentar de nuevo."
              }
            }
          },
          "503": {
            "description": "API cerrada o servicio no disponible. Recuperar por referencia antes de reintentar una emisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents": {
      "post": {
        "operationId": "createDocument",
        "summary": "Admitir una solicitud E31 de forma durable.",
        "x-required-scope": "documents:write",
        "description": "202 sólo acredita persistencia local. Emisor, ambiente, certificado y e-NCF son resueltos por SIFE. Un replay no reabre operaciones ni envía otra factura.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{7,127}$"
            },
            "description": "Guardar y reutilizar exactamente la misma clave y JSON ante timeout."
          }
        ],
        "requestBody": {
          "required": true,
          "description": "JSON UTF-8, máximo 262144 bytes; sin compresión, claves duplicadas ni campos desconocidos.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Invoice"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Misma operación previamente admitida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Admission"
                }
              }
            }
          },
          "202": {
            "description": "Nueva solicitud guardada; sin aceptación DGII implícita.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Admission"
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "const": "5"
                }
              }
            }
          },
          "400": {
            "description": "JSON inválido o claves duplicadas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credencial inválida, vencida o revocada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Empresa o usuario sin acceso.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "La clave o referencia ya pertenece a otra solicitud.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Cuerpo mayor que 256 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type no soportado o cuerpo comprimido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Campo o cálculo inválido.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de peticiones o cola lleno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Segundos antes de intentar de nuevo."
              }
            }
          },
          "503": {
            "description": "API cerrada o servicio no disponible. Recuperar por referencia antes de reintentar una emisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/operations": {
      "get": {
        "operationId": "findOperation",
        "summary": "Recuperar por external_id de la misma integración.",
        "x-required-scope": "documents:read",
        "parameters": [
          {
            "name": "external_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estado de la operación.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Operation"
                }
              }
            }
          },
          "401": {
            "description": "Credencial inválida, vencida o revocada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Empresa o usuario sin acceso.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Operación no encontrada en esta integración.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "La integridad de la operación requiere revisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Referencia inválida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de peticiones o cola lleno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Segundos antes de intentar de nuevo."
              }
            }
          },
          "503": {
            "description": "API cerrada o servicio no disponible. Recuperar por referencia antes de reintentar una emisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/operations/{operation_id}": {
      "get": {
        "operationId": "getOperation",
        "summary": "Consultar procesamiento y resultados separados.",
        "x-required-scope": "documents:read",
        "parameters": [
          {
            "name": "operation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estado de la operación.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Operation"
                }
              }
            }
          },
          "401": {
            "description": "Credencial inválida, vencida o revocada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Empresa o usuario sin acceso.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Operación no encontrada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Integridad requiere revisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de peticiones o cola lleno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Segundos antes de intentar de nuevo."
              }
            }
          },
          "503": {
            "description": "API cerrada o servicio no disponible. Recuperar por referencia antes de reintentar una emisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/operations/{operation_id}/xml": {
      "get": {
        "operationId": "downloadXML",
        "summary": "Descargar XML firmado original.",
        "x-required-scope": "artifacts:read",
        "parameters": [
          {
            "name": "operation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Artefacto autorizado.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Credencial inválida, vencida o revocada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Empresa o usuario sin acceso.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Operación no encontrada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Artefacto no listo o integridad requiere revisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de peticiones o cola lleno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Segundos antes de intentar de nuevo."
              }
            }
          },
          "503": {
            "description": "API cerrada o servicio no disponible. Recuperar por referencia antes de reintentar una emisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/operations/{operation_id}/pdf": {
      "get": {
        "operationId": "downloadPDF",
        "summary": "Descargar PDF definitivo de factura aceptada.",
        "x-required-scope": "artifacts:read",
        "parameters": [
          {
            "name": "operation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Artefacto autorizado.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Credencial inválida, vencida o revocada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Empresa o usuario sin acceso.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Operación no encontrada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Artefacto no listo o integridad requiere revisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de peticiones o cola lleno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Segundos antes de intentar de nuevo."
              }
            }
          },
          "503": {
            "description": "API cerrada o servicio no disponible. Recuperar por referencia antes de reintentar una emisión.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Opaque integration token"
      }
    },
    "schemas": {
      "Invoice": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version",
          "external_id",
          "document_type",
          "issue_date",
          "currency",
          "income_type",
          "buyer",
          "payment",
          "items"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "const": 1
          },
          "external_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,99}$"
          },
          "document_type": {
            "const": "E31"
          },
          "issue_date": {
            "type": "string",
            "format": "date",
            "description": "No futura en America/Santo_Domingo; preparación y período contable se verifican al reservar."
          },
          "currency": {
            "enum": [
              "DOP",
              "USD",
              "EUR"
            ]
          },
          "income_type": {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06"
            ]
          },
          "buyer": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "tax_id",
              "legal_name"
            ],
            "properties": {
              "tax_id": {
                "type": "string",
                "pattern": "^([0-9]{9}|[0-9]{11})$"
              },
              "legal_name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 150,
                "pattern": "^[^\\u0000-\\u001F\\u007F]+$"
              }
            }
          },
          "payment": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "enum": [
                  "cash",
                  "credit"
                ]
              },
              "due_date": {
                "type": "string",
                "format": "date"
              },
              "terms": {
                "type": "string",
                "minLength": 1,
                "maxLength": 15,
                "pattern": "^[^\\u0000-\\u001F\\u007F]+$",
                "description": "Opcional para crédito."
              }
            },
            "allOf": [
              {
                "if": {
                  "properties": {
                    "type": {
                      "const": "credit"
                    }
                  }
                },
                "then": {
                  "required": [
                    "due_date"
                  ]
                },
                "else": {
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "due_date"
                        ]
                      },
                      {
                        "required": [
                          "terms"
                        ]
                      }
                    ]
                  }
                }
              }
            ]
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "description",
                "kind",
                "quantity",
                "unit_price",
                "tax_treatment"
              ],
              "properties": {
                "description": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80,
                  "pattern": "^[^\\u0000-\\u001F\\u007F]+$"
                },
                "kind": {
                  "enum": [
                    "goods",
                    "service"
                  ]
                },
                "quantity": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]{0,11})(\\.[0-9]{1,2})?$",
                  "description": "Mayor que cero."
                },
                "unit_price": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]{0,11})(\\.[0-9]{1,4})?$"
                },
                "tax_treatment": {
                  "enum": [
                    "itbis_18",
                    "zero_rated",
                    "exempt"
                  ]
                },
                "discount": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "method",
                    "value"
                  ],
                  "properties": {
                    "method": {
                      "enum": [
                        "percentage",
                        "fixed"
                      ]
                    },
                    "value": {
                      "type": "string",
                      "pattern": "^(0|[1-9][0-9]{0,11})(\\.[0-9]{1,2})?$",
                      "description": "Porcentaje hasta 100 o monto fijo que no supere la base."
                    }
                  }
                }
              }
            }
          },
          "exchange_rate_to_dop": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,2})(\\.[0-9]{1,4})?$",
            "description": "Obligatoria y positiva en USD/EUR; omitir para DOP."
          },
          "amounts_include_itbis": {
            "type": "boolean",
            "default": false,
            "description": "Omitir cuando todas las líneas sean exentas."
          },
          "expected_total": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,11})(\\.[0-9]{1,2})?$",
            "description": "Debe coincidir exactamente con el cálculo de SIFE."
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "currency": {
                  "const": "DOP"
                }
              }
            },
            "then": {
              "not": {
                "required": [
                  "exchange_rate_to_dop"
                ]
              }
            },
            "else": {
              "required": [
                "exchange_rate_to_dop"
              ]
            }
          },
          {
            "if": {
              "properties": {
                "items": {
                  "items": {
                    "properties": {
                      "tax_treatment": {
                        "const": "exempt"
                      }
                    }
                  }
                }
              }
            },
            "then": {
              "not": {
                "required": [
                  "amounts_include_itbis"
                ]
              }
            }
          }
        ],
        "examples": [
          {
            "version": 1,
            "external_id": "ERP-2026-000123",
            "document_type": "E31",
            "issue_date": "2026-10-01",
            "currency": "DOP",
            "income_type": "01",
            "buyer": {
              "tax_id": "131000002",
              "legal_name": "Cliente Sintetico SRL"
            },
            "payment": {
              "type": "cash"
            },
            "items": [
              {
                "description": "Servicio de ejemplo",
                "kind": "service",
                "quantity": "1",
                "unit_price": "100.00",
                "tax_treatment": "itbis_18"
              }
            ],
            "expected_total": "118.00"
          }
        ]
      },
      "Admission": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "external_id",
          "status",
          "idempotent_replay",
          "links"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
          },
          "external_id": {
            "type": "string"
          },
          "status": {
            "enum": [
              "queued",
              "reserved",
              "attention"
            ]
          },
          "idempotent_replay": {
            "type": "boolean"
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "self"
            ],
            "properties": {
              "self": {
                "type": "string"
              }
            }
          }
        }
      },
      "Validation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "valid",
          "emission_authorized",
          "currency",
          "total",
          "tax_total"
        ],
        "properties": {
          "valid": {
            "const": true
          },
          "emission_authorized": {
            "const": false
          },
          "currency": {
            "enum": [
              "DOP",
              "USD",
              "EUR"
            ]
          },
          "total": {
            "type": "string"
          },
          "tax_total": {
            "type": "string"
          }
        }
      },
      "Operation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "external_id",
          "environment",
          "document_type",
          "processing",
          "error",
          "e_ncf",
          "created_at",
          "dgii",
          "buyer_delivery",
          "commercial_approval",
          "links"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
          },
          "external_id": {
            "type": "string"
          },
          "environment": {
            "const": "production"
          },
          "document_type": {
            "const": "E31"
          },
          "processing": {
            "enum": [
              "queued",
              "attention",
              "reserved",
              "remote_unknown",
              "polling",
              "reported_used",
              "reported_reusable",
              "accepted",
              "accepted_conditional",
              "rejected_attention",
              "identity_conflict",
              "expired_unadmitted"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "e_ncf": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "state_version": {
            "type": "integer",
            "minimum": 1
          },
          "dgii": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "status",
              "track_id",
              "reported_code",
              "sequence_used"
            ],
            "properties": {
              "status": {
                "type": "string",
                "description": "not_submitted, pending_submission, processing o resultado terminal del motor."
              },
              "track_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "reported_code": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "sequence_used": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            }
          },
          "buyer_delivery": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "status",
              "acknowledgement"
            ],
            "properties": {
              "status": {
                "type": "string"
              },
              "acknowledgement": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "commercial_approval": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "status"
            ],
            "properties": {
              "status": {
                "const": "not_available"
              }
            }
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "self",
              "xml",
              "pdf"
            ],
            "properties": {
              "self": {
                "type": "string"
              },
              "xml": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "pdf": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "request_id"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "field": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "request_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "Identificador opaco correlacionado con la telemetría del servidor."
              }
            }
          }
        }
      },
      "Capabilities": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "api_version",
          "environment",
          "document_types",
          "max_body_bytes",
          "max_items",
          "requests_per_minute",
          "feedback",
          "webhooks",
          "numbering_authority",
          "commercial_mode",
          "automatic_overage_authorization",
          "tax_treatments",
          "currencies",
          "scope"
        ],
        "properties": {
          "api_version": {
            "const": 1
          },
          "environment": {
            "const": "production"
          },
          "document_types": {
            "type": "array",
            "items": {
              "const": "E31"
            }
          },
          "max_body_bytes": {
            "const": 262144
          },
          "max_items": {
            "const": 200
          },
          "requests_per_minute": {
            "const": 60
          },
          "feedback": {
            "const": "polling"
          },
          "webhooks": {
            "const": false
          },
          "numbering_authority": {
            "const": "SIFE"
          },
          "commercial_mode": {
            "const": "integrated"
          },
          "automatic_overage_authorization": {
            "const": false
          },
          "tax_treatments": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "currencies": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scope": {
            "type": "string"
          }
        }
      }
    }
  },
  "externalDocs": {
    "url": "https://sife.com.do/api/",
    "description": "Guía de integración SIFE"
  }
}
