{
  "openapi": "3.1.0",
  "info": {
    "title": "Fichestone",
    "version": "0.1.0",
    "description": "Which version of a French CEE standardised operation fiche applies on a date, its kWh cumac and what changed, from the official PDFs."
  },
  "servers": [],
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/v1/tools/find_fiche": {
      "post": {
        "operationId": "find_fiche",
        "summary": "Find a CEE fiche by name or reference",
        "description": "Searches the French CEE standardised operation fiches by reference (BAR-TH-171) or by words from the official French name, with common English words translated (heat pump, attic insulation, boiler, greenhouse). Returns up to 10 fiches per page with reference, French title, sector, the version in force today and whether its kWh cumac can be computed here. Call it when you know the works but not the fiche reference. Do not call it when you already have the reference: go straight to fiche_in_force. It matches words, not meaning, so try the French term if an English one finds nothing; it cannot tell you which fiche an operation legally falls under.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "A reference such as BAR-TH-171, or words from the name, for example pompe à chaleur air/eau or heat pump air to water."
                  },
                  "sector": {
                    "type": "string",
                    "enum": [
                      "AGRI",
                      "BAR",
                      "BAT",
                      "IND",
                      "RES",
                      "TRA",
                      "agri",
                      "bar",
                      "bat",
                      "ind",
                      "res",
                      "tra"
                    ],
                    "description": "Optional sector prefix: AGRI agriculture, BAR residential buildings, BAT tertiary buildings, IND industry, RES networks, TRA transport."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 25,
                    "description": "Results per page, default 10."
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "next_cursor from the previous answer, to get the next page."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/fiche_in_force": {
      "post": {
        "operationId": "fiche_in_force",
        "summary": "Version of a CEE fiche in force on a date",
        "description": "For one CEE standardised operation fiche and an engagement date, returns the version that applies (for example A82-5 from 2026-09-01), when it started and when the next one starts, the arrêté that created it where the ministry catalogue shows it, the conventional life in years, the window of operations it covers (engagées jusqu'au, avant le, abrogée), the annex documents in force that day (Annexe 1 Partie A of the attestation sur l'honneur, Annexe 2) with their PDFs, whether the kWh cumac can be computed, and a one-sentence summary to quote. Status is in_force, ended, earlier_version_not_served (an older version applied but its text is not served; you get the original ministry URL), or unknown_before_ledger. Call it first for any question about a fiche on a date. Do not use it for the amount (compute_cumac) or the full conditions text (fiche_text). It cannot know versions the ministry has not yet published.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "fiche"
                ],
                "properties": {
                  "fiche": {
                    "type": "string",
                    "maxLength": 20,
                    "description": "Standardised operation reference, for example BAR-TH-171 (also accepted: bar th 171). Sectors: AGRI, BAR (residential), BAT (tertiary), IND, RES (networks), TRA."
                  },
                  "date": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "Engagement date of the operation (date d'engagement, for example the date the quote was accepted), YYYY-MM-DD. Defaults to today."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/compute_cumac": {
      "post": {
        "operationId": "compute_cumac",
        "summary": "kWh cumac of a CEE operation",
        "description": "Computes the kWh cumac of one operation from the forfait tables of the fiche version in force on the engagement date: forfait times each correction factor times any quantity (surface S, number N, power P), with every step, the band chosen and the formula. Send what you know in inputs, for example { \"S\": 80, \"Etas\": 145, \"case\": \"maison\" } with department 67 or zone H1; if anything is missing it answers status needs_input with the names and options to send, so one first call without inputs is fine. Answers status not_computed, with the French text of the amount section, when the fiche states its amount as a formula or a table this service cannot read safely (about half the fiches); it never guesses. Call it to price a quote or check a dossier amount. It does not check eligibility conditions, and it does not apply bonifications or coup de pouce offers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "fiche"
                ],
                "properties": {
                  "fiche": {
                    "type": "string",
                    "maxLength": 20,
                    "description": "Standardised operation reference, for example BAR-TH-171 (also accepted: bar th 171). Sectors: AGRI, BAR (residential), BAT (tertiary), IND, RES (networks), TRA."
                  },
                  "date": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "Engagement date of the operation (date d'engagement, for example the date the quote was accepted), YYYY-MM-DD. Defaults to today."
                  },
                  "inputs": {
                    "type": "object",
                    "description": "Values by the names compute_cumac asks for: a band variable as a number (Etas 145, S 80), a quantity (S, N, P), zone (H1, H2, H3), case (label or number), or another option as printed in the fiche."
                  },
                  "department": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "maxLength": 3,
                    "description": "Optional French department number (75, 2A, 974 is not covered) to set the climate zone from the ministry's table."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/fiche_text": {
      "post": {
        "operationId": "fiche_text",
        "summary": "Verbatim French text of a fiche section",
        "description": "Returns the verbatim French text of one section of a fiche version: sector, definitions, denomination, conditions, life, amount, partie_a, annexe_2 (partie_a is Annexe 1, the content of the attestation sur l'honneur; annexe_2 where the fiche has one). Pick the version by engagement date or by version number. Long sections are paged: up to 3,000 characters per call, continue with next_offset. Call it to quote a condition exactly or to read an amount the fiche gives as a formula. Do not call it to find which version applies (fiche_in_force). Tables are flattened to lines, so read numbers from compute_cumac where it can compute them.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "fiche",
                  "section"
                ],
                "properties": {
                  "fiche": {
                    "type": "string",
                    "maxLength": 20,
                    "description": "Standardised operation reference, for example BAR-TH-171 (also accepted: bar th 171). Sectors: AGRI, BAR (residential), BAT (tertiary), IND, RES (networks), TRA."
                  },
                  "section": {
                    "type": "string",
                    "enum": [
                      "sector",
                      "definitions",
                      "denomination",
                      "conditions",
                      "life",
                      "amount",
                      "partie_a",
                      "annexe_2"
                    ],
                    "description": "Which part to return."
                  },
                  "date": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "Engagement date of the operation (date d'engagement, for example the date the quote was accepted), YYYY-MM-DD. Defaults to today."
                  },
                  "version": {
                    "type": "string",
                    "maxLength": 12,
                    "description": "Optional version instead of a date, for example A82-5 or vA78.4."
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 200000,
                    "description": "Character offset to start from, from next_offset."
                  },
                  "max_chars": {
                    "type": "integer",
                    "minimum": 200,
                    "maximum": 3000,
                    "description": "Characters to return, default 3,000."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/diff_versions": {
      "post": {
        "operationId": "diff_versions",
        "summary": "What changed between two versions",
        "description": "Lists what changed between two versions of a fiche: title, conventional life, application window, every kWh cumac table row that changed, and the paragraphs of the sector, dénomination and conditions sections that were added, removed or reworded (before and after, clipped). With document partie_a or annexe_2 it compares the two latest annex documents instead, which is where the 1 July 2026 attestation changes sit. Defaults to the two latest versions held; pass from_version and to_version to choose. Pages of 20 changes with next_cursor. Call it when a version switches or to explain why an amount moved. Layout and hyphenation are ignored; it cannot explain why the ministry made a change.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "fiche"
                ],
                "properties": {
                  "fiche": {
                    "type": "string",
                    "maxLength": 20,
                    "description": "Standardised operation reference, for example BAR-TH-171 (also accepted: bar th 171). Sectors: AGRI, BAR (residential), BAT (tertiary), IND, RES (networks), TRA."
                  },
                  "document": {
                    "type": "string",
                    "enum": [
                      "fiche",
                      "partie_a",
                      "annexe_2"
                    ],
                    "description": "fiche (default), partie_a (Annexe 1) or annexe_2."
                  },
                  "from_version": {
                    "type": "string",
                    "maxLength": 12,
                    "description": "Older version, for example A78-4."
                  },
                  "to_version": {
                    "type": "string",
                    "maxLength": 12,
                    "description": "Newer version, for example A82-5."
                  },
                  "version": {
                    "type": "string",
                    "maxLength": 12,
                    "description": "With partie_a or annexe_2: compare the annexes of this fiche version only."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50,
                    "description": "Changes per page, default 20."
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "next_cursor from the previous answer, to get the next page."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/upcoming_changes": {
      "post": {
        "operationId": "upcoming_changes",
        "summary": "Dated changes to CEE fiches",
        "description": "Lists the dated changes across all fiches between two dates, oldest first: new_version, annex_change, fiche_ends (a new fiche version starts, an annex such as Partie A or Annexe 2 starts, a fiche stops applying to newly engaged operations). Defaults to the next 12 months from today; pass a past from to see recent switches. Filter by sector and kinds; pages of 25 with next_cursor. Call it to plan quotes around a switch date or to poll weekly for what is coming. It only knows changes the ministry has already published.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "from": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "First date, YYYY-MM-DD. Defaults to today."
                  },
                  "to": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "Last date, YYYY-MM-DD. Defaults to a year after from."
                  },
                  "sector": {
                    "type": "string",
                    "enum": [
                      "AGRI",
                      "BAR",
                      "BAT",
                      "IND",
                      "RES",
                      "TRA",
                      "agri",
                      "bar",
                      "bat",
                      "ind",
                      "res",
                      "tra"
                    ],
                    "description": "Optional sector prefix: AGRI agriculture, BAR residential buildings, BAT tertiary buildings, IND industry, RES networks, TRA transport."
                  },
                  "kinds": {
                    "type": [
                      "array",
                      "string"
                    ],
                    "maxItems": 3,
                    "maxLength": 60,
                    "items": {
                      "type": "string",
                      "enum": [
                        "new_version",
                        "annex_change",
                        "fiche_ends"
                      ]
                    },
                    "description": "Only these kinds, as a list or a comma-separated string: new_version, annex_change, fiche_ends."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "description": "Changes per page, default 25."
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "next_cursor from the previous answer, to get the next page."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    }
  }
}
