{
  "openapi": "3.1.0",
  "info": {
    "title": "Thenleaf",
    "version": "0.1.0",
    "description": "The status of an FDA guidance on any date since 2019: draft, final or removed, from dated copies of FDA's own table."
  },
  "servers": [],
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/v1/tools/guidance_on_date": {
      "post": {
        "operationId": "guidance_on_date",
        "summary": "Status of one FDA guidance on a date",
        "description": "Returns what FDA's guidance table showed for one guidance on a date: status_on_date (draft, final, withdrawn, not_yet_listed, removed or unknown), the row as listed then (title, status, issue date, comment close date, docket, center, PDF links), the dated copy it was read from and the next copy, today's status, every change since (finalized, issue date changed, retitled, removed), the draft that preceded a final, and the matching Federal Register notices. Call it when a document cites a guidance and you need to know whether it was draft or final when the document was written, or whether it still exists. Give the title, the FDA page URL or the docket, and the date (default: today). Basis 'snapshot' is read from a dated copy; dates before 3 September 2019 are inferred from the issue date or the Federal Register and labelled so. It does not return guidance text and cannot date a change more precisely than the two copies around it. An ambiguous title returns an 'ambiguous' error with candidate ids.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "guidance"
                ],
                "properties": {
                  "guidance": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 400,
                    "description": "The guidance as cited: its title (or most of it), the FDA page URL, a docket number such as FDA-2023-D-1955 (add the title when the docket is shared), or a Thenleaf id from find_guidance."
                  },
                  "date": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "ISO date YYYY-MM-DD, for example 2024-03-01: the day a study was designed, a protocol signed or a submission filed. 'today' means the latest copy."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/check_citations": {
      "post": {
        "operationId": "check_citations",
        "summary": "Check every FDA guidance cited in a document, for its date",
        "description": "Checks a list of up to 50 FDA guidance citations (titles, FDA URLs or dockets, as written in a reference list) against the document's date in one call. For each: the guidance it resolved to with the match confidence, its status on the date and today, and flags: draft_on_date, not_yet_listed, removed_on_date, removed_since, finalized_since, issue_date_changed_since, retitled_since, withdrawn, before_coverage, ambiguous, not_found. Use it for a protocol, briefing document, submission module or SOP before it goes out, or to audit an old one. Unresolved citations come back with candidates instead of a guess. It does not read the document itself: pass the citations as strings.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "citations"
                ],
                "properties": {
                  "citations": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "items": {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 400
                    },
                    "description": "Guidance citations as written: titles, FDA page URLs or docket numbers, one per item."
                  },
                  "date": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "ISO date YYYY-MM-DD, for example 2024-03-01: the day a study was designed, a protocol signed or a submission filed. 'today' means the latest copy."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/find_guidance": {
      "post": {
        "operationId": "find_guidance",
        "summary": "Find FDA guidances by title words, docket or URL",
        "description": "Searches every guidance FDA's table has listed since 3 September 2019, including rows FDA has since removed, by words of the title (any version of it), docket number or FDA page URL. Filters: center (cder, cber, cdrh, cvm, ctp, hfp, oii and others), status now (draft, final or removed) and document type. Returns ids, current titles, status now, issue date, docket and FDA page, ten at a time with next_offset. Call it to get the id for guidance_on_date or guidance_history when a title is vague; skip it when you already have an exact title, URL or docket.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 300,
                    "description": "Words of the title, a docket number or an FDA guidance page URL."
                  },
                  "center": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "FDA center or office, as a code (cder, cber, cdrh, cvm, ctp, cfsan, hfp, ora, oii, oc, oce) or a name such as Center for Devices and Radiological Health."
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "draft",
                      "final",
                      "removed"
                    ],
                    "description": "Status in today's table; removed means no longer listed."
                  },
                  "type": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Document type, for example Guidance Document, Compliance Policy Guide or Small Entity Compliance Guide."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 25,
                    "description": "Results per page, default 10."
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 5000,
                    "description": "Skip this many results, from next_offset."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/guidance_history": {
      "post": {
        "operationId": "guidance_history",
        "summary": "Full dated history of one FDA guidance",
        "description": "Returns every version of one guidance as FDA's table listed it, each with the dates of the first and last copy that showed it (status, issue date, comment close date, docket, center, type, PDF links), the events between versions (listed, finalized, issue date changed, retitled, file replaced, removed), a likely successor when a removed row was replaced by a new page, and every matching Federal Register notice of availability, comment period or withdrawal. Use it to recover a draft date FDA's table no longer shows, to see when a guidance was revised, or to document a citation trail. For a single date, guidance_on_date is smaller.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "guidance"
                ],
                "properties": {
                  "guidance": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 400,
                    "description": "The guidance as cited: its title (or most of it), the FDA page URL, a docket number such as FDA-2023-D-1955 (add the title when the docket is shared), or a Thenleaf id from find_guidance."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/changes_between": {
      "post": {
        "operationId": "changes_between",
        "summary": "What changed in FDA's guidance table between two dates",
        "description": "Lists the changes FDA made to its guidance table between two dates: new guidances listed, drafts finalized, issue dates changed, retitles, rows removed without notice (with a likely successor when one exists) and relisted rows, each dated by the two copies it fell between. Filter by center and by kinds (listed, removed, finalized, status_changed, issue_date_changed, retitled, comment_close_changed, docket_changed, center_changed, type_changed, file_replaced, relisted); center, file and comment-date changes are left out unless asked for. Returns counts per kind and 25 changes at a time with next_offset. Use it for a weekly regulatory watch, or to find what moved since a submission was filed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "from"
                ],
                "properties": {
                  "from": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "Start date, ISO YYYY-MM-DD (changes first seen after it)."
                  },
                  "to": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "End date, ISO YYYY-MM-DD, default today."
                  },
                  "center": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "FDA center or office, as a code (cder, cber, cdrh, cvm, ctp, cfsan, hfp, ora, oii, oc, oce) or a name such as Center for Devices and Radiological Health."
                  },
                  "kinds": {
                    "type": "array",
                    "maxItems": 12,
                    "items": {
                      "type": "string",
                      "enum": [
                        "listed",
                        "removed",
                        "finalized",
                        "status_changed",
                        "issue_date_changed",
                        "retitled",
                        "comment_close_changed",
                        "docket_changed",
                        "center_changed",
                        "type_changed",
                        "file_replaced",
                        "relisted"
                      ]
                    },
                    "description": "Kinds of change to include."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "description": "Changes per page, default 25."
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000,
                    "description": "Skip this many changes, from next_offset."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/ema_guideline": {
      "post": {
        "operationId": "ema_guideline",
        "summary": "EMA scientific guideline: dates and document status",
        "description": "Finds an EMA scientific guideline by title words, reference number or EMA page URL and returns its first published and last updated dates from EMA's guideline report and, where Thenleaf has read the guideline's page, each document with its status (adopted, draft with consultation dates), reference number and legal effective date. With a date, says whether a version was adopted and in effect, adopted but not yet effective, or only a draft by then. EMA pages are read slowly within EMA's rate limit, so many pages are not read yet; the answer says so instead of guessing. Not for FDA guidance (use guidance_on_date). Source: European Medicines Agency.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 300,
                    "description": "Words of the EMA guideline title, its reference number (for example CPMP/EWP/QWP/1401/98) or its EMA page URL."
                  },
                  "date": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "ISO date YYYY-MM-DD, for example 2024-03-01: the day a study was designed, a protocol signed or a submission filed. 'today' means the latest copy."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/source_status": {
      "post": {
        "operationId": "source_status",
        "summary": "Data version, dated copies, sources and limits",
        "description": "Returns the data version, how many dated copies of FDA's guidance table Thenleaf holds (first, latest, longest gap), how many guidances were ever listed and how many were removed, the Federal Register and EMA coverage, every source with its licence, and the list of things Thenleaf cannot know. Call it once to cite the data version or when an answer looks out of date. It takes no input.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    }
  }
}
