{
  "openapi": "3.1.0",
  "info": {
    "title": "API de Marimpex Global Trade",
    "version": "1.0.0",
    "description": "API de solo lectura para consultar despachos y facturación de tu empresa. Autenticación con clave Bearer por empresa. Se habilita a pedido (api@marimpex.com.ar); después el titular de la empresa crea las claves en el portal (Mi Organización → API). Manual: https://mgt.marimpex.com.ar/integraciones",
    "contact": {
      "name": "Marimpex Global Trade",
      "email": "api@marimpex.com.ar"
    }
  },
  "servers": [
    {
      "url": "https://mgt.marimpex.com.ar/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "General"
    },
    {
      "name": "Despachos"
    },
    {
      "name": "Facturación"
    }
  ],
  "paths": {
    "/ping": {
      "get": {
        "tags": [
          "General"
        ],
        "operationId": "ping",
        "summary": "Prueba de clave",
        "description": "Sirve con cualquier clave válida.",
        "responses": {
          "200": {
            "description": "Clave válida.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ping"
                }
              }
            }
          },
          "401": {
            "description": "Clave ausente, inválida, vencida o anulada (code unauthorized). Genérico a propósito.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de uso superado (code rate_limited).",
            "headers": {
              "Retry-After": {
                "description": "Segundos a esperar.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (code internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/despachos": {
      "get": {
        "tags": [
          "Despachos"
        ],
        "operationId": "listDespachos",
        "summary": "Listar despachos",
        "description": "Permiso customs:read. Ordenado por updatedAt ascendente.",
        "parameters": [
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Solo lo modificado desde esa fecha, inclusive (ISO 8601)."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "description": "Elementos por página."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "nextCursor de la página anterior (opaco)."
          }
        ],
        "responses": {
          "200": {
            "description": "Página de despachos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DespachoList"
                }
              }
            }
          },
          "400": {
            "description": "Parámetro inválido (code invalid_parameter).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Clave ausente, inválida, vencida o anulada (code unauthorized). Genérico a propósito.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso del recurso (code forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de uso superado (code rate_limited).",
            "headers": {
              "Retry-After": {
                "description": "Segundos a esperar.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (code internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/despachos/{despacho}": {
      "get": {
        "tags": [
          "Despachos"
        ],
        "operationId": "getDespacho",
        "summary": "Detalle de un despacho",
        "description": "Permiso customs:read.",
        "parameters": [
          {
            "name": "despacho",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]{8,24}$"
            },
            "description": "Número de destinación."
          }
        ],
        "responses": {
          "200": {
            "description": "Despacho completo.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Despacho"
                }
              }
            }
          },
          "400": {
            "description": "Parámetro inválido (code invalid_parameter).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Clave ausente, inválida, vencida o anulada (code unauthorized). Genérico a propósito.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso del recurso (code forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe o no es de tu empresa (code not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Existe pero todavía no tiene .RET (code ret_not_available).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de uso superado (code rate_limited).",
            "headers": {
              "Retry-After": {
                "description": "Segundos a esperar.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (code internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/facturas": {
      "get": {
        "tags": [
          "Facturación"
        ],
        "operationId": "listFacturas",
        "summary": "Listar facturas y notas de crédito",
        "description": "Permiso billing:read. Solo comprobantes con CAE. limit cuenta documentos de origen: una página puede traer más, menos o cero elementos y tener nextCursor.",
        "parameters": [
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Solo lo modificado desde esa fecha, inclusive (ISO 8601)."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 25
            },
            "description": "Documentos de origen por página."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "nextCursor de la página anterior (opaco)."
          },
          {
            "name": "origen",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "aduana",
                "flete"
              ]
            },
            "description": "Filtra por origen."
          }
        ],
        "responses": {
          "200": {
            "description": "Página de comprobantes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacturaList"
                }
              }
            }
          },
          "400": {
            "description": "Parámetro inválido (code invalid_parameter).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Clave ausente, inválida, vencida o anulada (code unauthorized). Genérico a propósito.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso del recurso (code forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de uso superado (code rate_limited).",
            "headers": {
              "Retry-After": {
                "description": "Segundos a esperar.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (code internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/facturas/{id}": {
      "get": {
        "tags": [
          "Facturación"
        ],
        "operationId": "getFactura",
        "summary": "Detalle de un comprobante",
        "description": "Permiso billing:read.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Id opaco obtenido del listado."
          }
        ],
        "responses": {
          "200": {
            "description": "Comprobante.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Factura"
                }
              }
            }
          },
          "401": {
            "description": "Clave ausente, inválida, vencida o anulada (code unauthorized). Genérico a propósito.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso del recurso (code forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe, no es de tu empresa o no está emitido (code not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de uso superado (code rate_limited).",
            "headers": {
              "Retry-After": {
                "description": "Segundos a esperar.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (code internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/facturas/{id}/pdf": {
      "get": {
        "tags": [
          "Facturación"
        ],
        "operationId": "getFacturaPdf",
        "summary": "Enlace al PDF de un comprobante",
        "description": "Permiso billing:read. Los enlaces firmados duran 10 minutos.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Id opaco obtenido del listado."
          }
        ],
        "responses": {
          "200": {
            "description": "Enlace de descarga.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacturaPdf"
                }
              }
            }
          },
          "401": {
            "description": "Clave ausente, inválida, vencida o anulada (code unauthorized). Genérico a propósito.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso del recurso (code forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No existe (not_found) o no tiene PDF (pdf_not_available).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Límite de uso superado (code rate_limited).",
            "headers": {
              "Retry-After": {
                "description": "Segundos a esperar.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (code internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Clave mgt_live_<id8>_<secret32>. La crea el titular de la empresa en el portal (Mi Organización → API); el servicio se habilita a pedido en api@marimpex.com.ar."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "invalid_parameter",
                  "unauthorized",
                  "forbidden",
                  "api_not_enabled",
                  "account_inactive",
                  "not_found",
                  "pdf_not_available",
                  "ret_not_available",
                  "rate_limited",
                  "internal_error"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "Ping": {
        "type": "object",
        "required": [
          "ok",
          "tenantId",
          "scopes",
          "clientLabel"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "tenantId": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "customs:read",
                "billing:read"
              ]
            }
          },
          "clientLabel": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "DespachoListItem": {
        "type": "object",
        "required": [
          "despacho",
          "estado",
          "canal",
          "fechaOficializacion",
          "interno",
          "updatedAt",
          "tieneRet"
        ],
        "properties": {
          "despacho": {
            "type": "string"
          },
          "estado": {
            "type": [
              "string",
              "null"
            ],
            "description": "Último estado informado."
          },
          "canal": {
            "type": [
              "string",
              "null"
            ],
            "description": "Canal de selectividad."
          },
          "fechaOficializacion": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "interno": {
            "type": [
              "string",
              "null"
            ],
            "description": "Número interno de Marimpex."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "tieneRet": {
            "type": "boolean"
          }
        }
      },
      "DespachoList": {
        "type": "object",
        "required": [
          "data",
          "nextCursor"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DespachoListItem"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "DespachoLiquidacion": {
        "type": "object",
        "required": [
          "concepto",
          "nombre",
          "alicuota",
          "monto",
          "moneda"
        ],
        "properties": {
          "concepto": {
            "type": "string"
          },
          "nombre": {
            "type": "string"
          },
          "alicuota": {
            "type": [
              "number",
              "null"
            ],
            "description": "Porcentaje."
          },
          "monto": {
            "type": [
              "number",
              "null"
            ],
            "description": "Monto del tributo, en la moneda indicada (alícuota x base imponible en dólares)."
          },
          "moneda": {
            "type": "string",
            "const": "USD",
            "description": "Moneda de monto."
          }
        }
      },
      "DespachoItem": {
        "type": "object",
        "required": [
          "nro",
          "posicionSim",
          "descripcion",
          "paisOrigen",
          "cantidad",
          "fobDolar",
          "valorEnAduanaCif",
          "liquidacion",
          "fobDivisa",
          "fobDivisaCodigo",
          "moneda"
        ],
        "properties": {
          "nro": {
            "type": "string"
          },
          "posicionSim": {
            "type": "string"
          },
          "descripcion": {
            "type": [
              "string",
              "null"
            ]
          },
          "paisOrigen": {
            "type": [
              "string",
              "null"
            ]
          },
          "cantidad": {
            "type": [
              "number",
              "null"
            ],
            "description": "Cantidad declarada."
          },
          "fobDolar": {
            "type": [
              "number",
              "null"
            ],
            "description": "FOB del ítem en dólares. Null si el .RET no trae el dato en dólares."
          },
          "valorEnAduanaCif": {
            "type": [
              "number",
              "null"
            ],
            "description": "CIF del ítem en dólares. Null si el .RET no trae el dato en dólares."
          },
          "liquidacion": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DespachoLiquidacion"
            }
          },
          "fobDivisa": {
            "type": [
              "number",
              "null"
            ],
            "description": "FOB del ítem en la divisa de la operación."
          },
          "fobDivisaCodigo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Divisa de fobDivisa."
          },
          "moneda": {
            "type": "string",
            "const": "USD",
            "description": "Moneda de fobDolar, valorEnAduanaCif y los montos de liquidacion."
          }
        }
      },
      "Despacho": {
        "type": "object",
        "required": [
          "despacho",
          "subregimen",
          "tipo",
          "estado",
          "canal",
          "aduana",
          "fechaOficializacion",
          "interno",
          "importador",
          "despachante",
          "proveedor",
          "transporte",
          "valores",
          "items",
          "totales"
        ],
        "properties": {
          "despacho": {
            "type": "string"
          },
          "subregimen": {
            "type": [
              "string",
              "null"
            ]
          },
          "tipo": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "importacion",
              "exportacion",
              null
            ]
          },
          "estado": {
            "type": [
              "string",
              "null"
            ]
          },
          "canal": {
            "type": [
              "string",
              "null"
            ]
          },
          "aduana": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "required": [
                  "codigo",
                  "nombre"
                ],
                "properties": {
                  "codigo": {
                    "type": "string"
                  },
                  "nombre": {
                    "type": "string"
                  }
                }
              }
            ]
          },
          "fechaOficializacion": {
            "type": [
              "string",
              "null"
            ]
          },
          "interno": {
            "type": [
              "string",
              "null"
            ]
          },
          "importador": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "required": [
                  "razonSocial",
                  "cuit",
                  "ivaInscripto"
                ],
                "properties": {
                  "razonSocial": {
                    "type": "string"
                  },
                  "cuit": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "ivaInscripto": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  }
                }
              }
            ]
          },
          "despachante": {
            "type": "object",
            "required": [
              "razonSocial",
              "cuit"
            ],
            "properties": {
              "razonSocial": {
                "type": "string"
              },
              "cuit": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "proveedor": {
            "type": [
              "string",
              "null"
            ]
          },
          "transporte": {
            "type": "object",
            "required": [
              "medio",
              "buque",
              "bandera",
              "documentoTransporte",
              "fechaArribo",
              "deposito",
              "pesoBrutoKg",
              "bultos"
            ],
            "properties": {
              "medio": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "buque": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "bandera": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "documentoTransporte": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "fechaArribo": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "deposito": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "pesoBrutoKg": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Kilos."
              },
              "bultos": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Cantidad."
              }
            }
          },
          "valores": {
            "type": "object",
            "required": [
              "incoterm",
              "divisa",
              "fob",
              "flete",
              "seguro",
              "valorEnAduanaCif",
              "cotizacion",
              "divisaFlete",
              "divisaSeguro",
              "monedaValorEnAduanaCif"
            ],
            "properties": {
              "incoterm": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "divisa": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Divisa de fob."
              },
              "fob": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "FOB, en divisa."
              },
              "flete": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Flete, en divisaFlete."
              },
              "seguro": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Seguro, en divisaSeguro."
              },
              "valorEnAduanaCif": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Valor en aduana (CIF) en dólares. Null si el .RET no trae el dato en dólares."
              },
              "cotizacion": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Pesos por dólar."
              },
              "divisaFlete": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Divisa de flete."
              },
              "divisaSeguro": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Divisa de seguro."
              },
              "monedaValorEnAduanaCif": {
                "type": "string",
                "const": "USD",
                "description": "Moneda de valorEnAduanaCif."
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DespachoItem"
            }
          },
          "totales": {
            "type": "object",
            "required": [
              "totalPagado",
              "totalGarantizado",
              "moneda"
            ],
            "properties": {
              "totalPagado": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Total a pagar, en la moneda indicada (dólares)."
              },
              "totalGarantizado": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Total garantizado, en la moneda indicada."
              },
              "moneda": {
                "type": "string",
                "const": "USD",
                "description": "Moneda de totalPagado y totalGarantizado."
              }
            }
          }
        }
      },
      "FacturaLinea": {
        "type": "object",
        "required": [
          "descripcion",
          "netoUsd",
          "ivaPorcentaje",
          "ivaUsd",
          "totalUsd"
        ],
        "properties": {
          "descripcion": {
            "type": "string"
          },
          "cantidad": {
            "type": "number",
            "description": "Solo flete."
          },
          "precioUnitarioUsd": {
            "type": "number",
            "description": "Solo flete."
          },
          "netoUsd": {
            "type": "number"
          },
          "ivaPorcentaje": {
            "type": "number"
          },
          "ivaUsd": {
            "type": "number"
          },
          "totalUsd": {
            "type": "number"
          }
        }
      },
      "Factura": {
        "type": "object",
        "required": [
          "id",
          "origen",
          "tipo",
          "comprobante",
          "despacho",
          "booking",
          "moneda",
          "tipoDeCambio",
          "lineas",
          "lineasOrigen",
          "totales",
          "comprobanteAsociado",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Id opaco y estable."
          },
          "origen": {
            "type": "string",
            "enum": [
              "aduana",
              "flete"
            ]
          },
          "tipo": {
            "type": "string",
            "enum": [
              "factura",
              "nota_credito"
            ]
          },
          "comprobante": {
            "type": "object",
            "required": [
              "tipo",
              "puntoVenta",
              "numero",
              "cae",
              "caeVencimiento",
              "fechaEmision"
            ],
            "properties": {
              "tipo": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "FCA, FCB, NCA o NCB."
              },
              "puntoVenta": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "numero": {
                "type": "string"
              },
              "cae": {
                "type": "string"
              },
              "caeVencimiento": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "fechaEmision": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "despacho": {
            "type": [
              "string",
              "null"
            ]
          },
          "booking": {
            "type": [
              "string",
              "null"
            ]
          },
          "moneda": {
            "type": "string",
            "enum": [
              "USD",
              "ARS"
            ],
            "description": "Moneda fiscal. Los importes de lineas y totales están siempre en USD."
          },
          "tipoDeCambio": {
            "type": [
              "number",
              "null"
            ],
            "description": "Solo si moneda es ARS."
          },
          "lineas": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/FacturaLinea"
                }
              }
            ],
            "description": "Null en facturas de aduana anteriores al 2026-10-19."
          },
          "lineasOrigen": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "emitidas",
              "reconstruidas",
              null
            ],
            "description": "Origen del detalle: 'emitidas' = líneas guardadas al emitir el comprobante; 'reconstruidas' = rearmadas desde el import del comprobante en Contabilium; null = el comprobante no tiene detalle por línea disponible (lineas y totales vienen null)."
          },
          "totales": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "required": [
                  "netoUsd",
                  "ivaUsd",
                  "totalUsd"
                ],
                "properties": {
                  "netoUsd": {
                    "type": "number"
                  },
                  "ivaUsd": {
                    "type": "number"
                  },
                  "totalUsd": {
                    "type": "number"
                  }
                }
              }
            ]
          },
          "comprobanteAsociado": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "required": [
                  "id",
                  "tipo",
                  "numero",
                  "cae",
                  "fechaEmision"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "tipo": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "numero": {
                    "type": "string"
                  },
                  "cae": {
                    "type": "string"
                  },
                  "fechaEmision": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            ],
            "description": "Solo notas de crédito."
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "FacturaList": {
        "type": "object",
        "required": [
          "data",
          "nextCursor"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Factura"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "FacturaPdf": {
        "type": "object",
        "required": [
          "url",
          "expiraEn",
          "tipo"
        ],
        "properties": {
          "url": {
            "type": "string"
          },
          "expiraEn": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Null en enlace_publico."
          },
          "tipo": {
            "type": "string",
            "enum": [
              "firmada",
              "enlace_publico"
            ]
          }
        }
      }
    }
  }
}
