{
  "openapi": "3.1.0",
  "info": {
    "title": "SaaS RENTRI — ricerca e importazione autorizzata FIR esterni",
    "version": "1.1.0",
    "description": "Ricerca/importazione in sola lettura DEMO e PROD. PROD richiede opt-in dedicato, identità deployment, letture abilitate e certificato approvato. Nessun elenco universale né assegnazione implicita di visibilità."
  },
  "x-upstream-source": "https://demoapi.rentri.gov.it/docs/formulari/v1.0",
  "x-upstream-source-sha256": "fb3acc7fb339ccd56d790689f6b24bfcd788253f9fe288907b8a4609037b6c9b",
  "x-upstream-version": "1.0.20261020-1178",
  "x-native-environments": [
    "demo",
    "prod"
  ],
  "x-creates-or-mutates-rentri-fir": false,
  "x-local-post-max-bytes": 65536,
  "x-remote-budget": {
    "client-per-minute": 10,
    "instance-per-minute": 20,
    "reserved-reads-per-item": 2,
    "shared-with-fir-sync": true,
    "shared-upstream-cooldown": true
  },
  "x-admission-per-minute": {
    "client": 20,
    "instance": 100
  },
  "x-active-queue-max-items": {
    "client": 100,
    "instance": 1000
  },
  "paths": {
    "/api/v1/fir/ricerca-rentri": {
      "post": {
        "operationId": "searchExternalFir",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "fir:read"
        ],
        "description": "Una pagina GET nativa limitata alla sede risolta dal contesto. Nessun parametro soggetto/sito arbitrario. Cursore cifrato valido 15 minuti, legato a client, istanza, contesto, metadati, filtri e limite. Massimo 100 pagine, dati non congelati. Non importa nulla.",
        "responses": {
          "401": {
            "description": "API key non valida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, contesto o visibilità RENTRI non autorizzati",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Risorsa non del client corrente o non esistente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Idempotenza o contesto cambiato",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Corpo oltre 64 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Input o token non valido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Budget/coda pieni o attesa RENTRI: rispettare Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Secondi prima del prossimo tentativo."
              }
            }
          },
          "502": {
            "description": "Risposta RENTRI non verificabile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacità non abilitata o prerequisiti non disponibili",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Pagina remota verificata; selezione valida 15 minuti.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "maxItems": 50,
                      "items": {
                        "type": "object",
                        "required": [
                          "numero_fir"
                        ],
                        "properties": {
                          "numero_fir": {
                            "type": "string"
                          },
                          "versione_remota": {
                            "type": [
                              "integer",
                              "null"
                            ],
                            "minimum": 1
                          },
                          "stato": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "codice_eer": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "data_emissione": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "data_creazione": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          }
                        }
                      }
                    },
                    "meta": {
                      "type": "object",
                      "required": [
                        "limit",
                        "pagina",
                        "next_cursor",
                        "selezione",
                        "selezione_scade_in_secondi",
                        "limite_pagine_raggiunto"
                      ],
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "pagina": {
                          "type": "integer"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "selezione": {
                          "type": "string"
                        },
                        "selezione_scade_in_secondi": {
                          "const": 900
                        },
                        "limite_pagine_raggiunto": {
                          "type": "boolean"
                        },
                        "origine": {
                          "const": "rentri"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "contesto"
                ],
                "properties": {
                  "contesto": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "operator_id",
                      "local_unit_id",
                      "ruolo"
                    ],
                    "properties": {
                      "operator_id": {
                        "type": "string",
                        "pattern": "^op_[a-f0-9]{32}$"
                      },
                      "local_unit_id": {
                        "type": "string",
                        "pattern": "^ul_[a-f0-9]{32}$"
                      },
                      "ruolo": {
                        "enum": [
                          "producer",
                          "transporter"
                        ]
                      }
                    }
                  },
                  "filtri": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "numero_fir": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "codice_eer": {
                        "type": "string",
                        "pattern": "^[0-9]{6}\\*?$"
                      },
                      "data_creazione_da": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "data_creazione_a": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "data_emissione_da": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "data_emissione_a": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50,
                    "default": 25
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 16384
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fir/importazioni": {
      "post": {
        "operationId": "enqueueExternalFirImport",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "fir:read",
          "fir:import"
        ],
        "description": "Nessuna lettura RENTRI nel POST. Crea una coda locale di 1–10 numeri selezionati. Chiavi dello stesso client condividono idempotenza e quote. Replay stessa richiesta indipendente dalla scadenza della selezione; una richiesta diversa con stessa chiave riceve 409. Il worker usa la chiave originaria, ricontrolla visibilità della sede e ruolo nel dettaglio. Scadenza lavoro 24 ore.",
        "responses": {
          "401": {
            "description": "API key non valida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, contesto o visibilità RENTRI non autorizzati",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Risorsa non del client corrente o non esistente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Idempotenza o contesto cambiato",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Corpo oltre 64 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Input o token non valido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Budget/coda pieni o attesa RENTRI: rispettare Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Secondi prima del prossimo tentativo."
              }
            }
          },
          "502": {
            "description": "Risposta RENTRI non verificabile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacità non abilitata o prerequisiti non disponibili",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "202": {
            "description": "Lavoro in attesa, Location alla risorsa e Retry-After: 5",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "data"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ImportJob"
                    }
                  }
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "const": 5
                }
              }
            }
          },
          "200": {
            "description": "Replay di lavoro concluso, senza Location",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "data"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ImportJob"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "contesto",
                  "numeri_fir",
                  "selezione"
                ],
                "properties": {
                  "contesto": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "operator_id",
                      "local_unit_id",
                      "ruolo"
                    ],
                    "properties": {
                      "operator_id": {
                        "type": "string",
                        "pattern": "^op_[a-f0-9]{32}$"
                      },
                      "local_unit_id": {
                        "type": "string",
                        "pattern": "^ul_[a-f0-9]{32}$"
                      },
                      "ruolo": {
                        "enum": [
                          "producer",
                          "transporter"
                        ]
                      }
                    }
                  },
                  "numeri_fir": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 10,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "maxLength": 100
                    }
                  },
                  "selezione": {
                    "type": "string",
                    "maxLength": 16384
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:-]{1,128}$"
            }
          }
        ]
      }
    },
    "/api/v1/fir/importazioni/{import_id}": {
      "get": {
        "operationId": "getExternalFirImport",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "fir:read"
        ],
        "description": "Solo stato locale, sempre senza Location e senza I/O remoto. cancelled riguarda il lavoro di importazione, mai l’annullamento di un FIR. Restituisce esiti per elemento; already_managed non copia né concede accessi alla pratica locale.",
        "responses": {
          "401": {
            "description": "API key non valida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, contesto o visibilità RENTRI non autorizzati",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Risorsa non del client corrente o non esistente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Idempotenza o contesto cambiato",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Corpo oltre 64 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Input o token non valido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Budget/coda pieni o attesa RENTRI: rispettare Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Secondi prima del prossimo tentativo."
              }
            }
          },
          "502": {
            "description": "Risposta RENTRI non verificabile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacità non abilitata o prerequisiti non disponibili",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Stato locale",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "data"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ImportJob"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "import_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^imp_[a-f0-9]{32}$"
            }
          }
        ]
      }
    },
    "/api/v1/fir/esterni": {
      "get": {
        "operationId": "listImportedFir",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "fir:read"
        ],
        "description": "Archivio locale distinto da GET /api/v1/fir. Nessuna lettura RENTRI. Un record per client/operatore/sede/ruolo/numero normalizzato. Ordinamento ID crescente, cursore legato ai filtri e al limite per 24 ore. Filtri temporali inclusivi RFC3339; date mancanti non corrispondono a filtri di intervallo.",
        "responses": {
          "401": {
            "description": "API key non valida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, contesto o visibilità RENTRI non autorizzati",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Risorsa non del client corrente o non esistente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Idempotenza o contesto cambiato",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Corpo oltre 64 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Input o token non valido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Budget/coda pieni o attesa RENTRI: rispettare Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Secondi prima del prossimo tentativo."
              }
            }
          },
          "502": {
            "description": "Risposta RENTRI non verificabile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacità non abilitata o prerequisiti non disponibili",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Pagina locale",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "maxItems": 50,
                      "items": {
                        "$ref": "#/components/schemas/ExternalFir"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "origine": {
                          "const": "archivio_importati"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "operator_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^op_[a-f0-9]{32}$"
            }
          },
          {
            "name": "local_unit_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^ul_[a-f0-9]{32}$"
            }
          },
          {
            "name": "ruolo",
            "in": "query",
            "required": true,
            "schema": {
              "enum": [
                "producer",
                "transporter"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 16384
            }
          },
          {
            "name": "emissione_da",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "emissione_a",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "creazione_da",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "creazione_a",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "lettura_da",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "lettura_a",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ]
      }
    },
    "/api/v1/fir/esterni/{external_id}": {
      "get": {
        "operationId": "getImportedFir",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "fir:read"
        ],
        "description": "Fotografia RENTRI minimizzata, numero e versione reali. Nessuna versione locale confermata inventata. Azioni modifica, annullamento, firma, download e sincronizzazione periodica false. Una nuova importazione esplicita può aggiornare la fotografia, senza regredire la versione né sovrascrivere documenti locali. Disponibile anche con flag di importazione disabilitato.",
        "responses": {
          "401": {
            "description": "API key non valida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, contesto o visibilità RENTRI non autorizzati",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Risorsa non del client corrente o non esistente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Idempotenza o contesto cambiato",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Corpo oltre 64 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Input o token non valido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Budget/coda pieni o attesa RENTRI: rispettare Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Secondi prima del prossimo tentativo."
              }
            }
          },
          "502": {
            "description": "Risposta RENTRI non verificabile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Capacità non abilitata o prerequisiti non disponibili",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Archivio in sola lettura",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "data"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ExternalFir"
                        },
                        {
                          "type": "object",
                          "required": [
                            "contesto",
                            "fotografia_rentri",
                            "provenienza",
                            "azioni"
                          ],
                          "properties": {
                            "contesto": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "operator_id",
                                "local_unit_id",
                                "ruolo"
                              ],
                              "properties": {
                                "operator_id": {
                                  "type": "string",
                                  "pattern": "^op_[a-f0-9]{32}$"
                                },
                                "local_unit_id": {
                                  "type": "string",
                                  "pattern": "^ul_[a-f0-9]{32}$"
                                },
                                "ruolo": {
                                  "enum": [
                                    "producer",
                                    "transporter"
                                  ]
                                }
                              }
                            },
                            "fotografia_rentri": {
                              "type": "object",
                              "description": "Proiezione tipizzata dei dati RENTRI già usata dal sincronizzatore; firme minimizzate a presenza/data. Nessun P12, JWT, signer identity o blob non previsto."
                            },
                            "provenienza": {
                              "type": "object",
                              "properties": {
                                "tipo": {
                                  "const": "rentri_import"
                                },
                                "profilo_contratto": {
                                  "type": "string"
                                },
                                "prima_importazione": {
                                  "type": "string"
                                },
                                "ultima_lettura": {
                                  "type": "string"
                                }
                              }
                            },
                            "azioni": {
                              "type": "object",
                              "properties": {
                                "modifica": {
                                  "const": false
                                },
                                "annullamento": {
                                  "const": false
                                },
                                "firma": {
                                  "const": false
                                },
                                "download": {
                                  "const": false
                                },
                                "sincronizzazione_periodica": {
                                  "const": false
                                }
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "external_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^ext_[a-f0-9]{32}$"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "request_id",
          "error"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "ImportItem": {
        "type": "object",
        "required": [
          "numero_fir",
          "status",
          "tentativi",
          "errore",
          "external_id"
        ],
        "properties": {
          "numero_fir": {
            "type": "string"
          },
          "status": {
            "enum": [
              "queued",
              "running",
              "imported",
              "updated",
              "unchanged",
              "already_managed",
              "failed",
              "cancelled"
            ]
          },
          "tentativi": {
            "type": "integer",
            "minimum": 0
          },
          "errore": {
            "type": [
              "string",
              "null"
            ]
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^ext_[a-f0-9]{32}$"
          },
          "prossimo_tentativo": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ImportJob": {
        "type": "object",
        "required": [
          "import_id",
          "status",
          "funzione_attiva",
          "scadenza",
          "elementi"
        ],
        "properties": {
          "import_id": {
            "type": "string",
            "pattern": "^imp_[a-f0-9]{32}$"
          },
          "status": {
            "enum": [
              "pending",
              "completed",
              "completed_with_errors"
            ]
          },
          "funzione_attiva": {
            "type": "boolean"
          },
          "scadenza": {
            "type": "string"
          },
          "elementi": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/ImportItem"
            }
          },
          "replayed": {
            "type": "boolean"
          }
        }
      },
      "ExternalFir": {
        "type": "object",
        "required": [
          "external_id",
          "numero_fir",
          "versione_remota",
          "revisione_archivio",
          "origine",
          "sola_lettura"
        ],
        "properties": {
          "external_id": {
            "type": "string",
            "pattern": "^ext_[a-f0-9]{32}$"
          },
          "numero_fir": {
            "type": "string"
          },
          "versione_remota": {
            "type": "integer",
            "minimum": 1
          },
          "revisione_archivio": {
            "type": "integer",
            "minimum": 1
          },
          "stato": {
            "type": "string"
          },
          "origine": {
            "const": "rentri_import"
          },
          "sola_lettura": {
            "const": true
          },
          "data_emissione": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "data_creazione": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "importato_il": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "ultima_lettura": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      }
    }
  }
}
