{
  "openapi": "3.1.0",
  "info": {
    "title": "Twigmark",
    "version": "0.1.0",
    "description": "EU and GB plant import rules by plant, origin and date, cited to the annex point and version."
  },
  "servers": [
    {
      "url": "https://twigmark.bulkhead.solutions"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/v1/tools/import_requirements": {
      "post": {
        "operationId": "import_requirements",
        "summary": "Plant import requirements by plant, origin and date",
        "description": "What the EU or GB plant health annexes require for one plant from one origin country on a date: Annex VI prohibitions (with any EU derogation act in force), the Annex VII special requirement entries that apply (ref, why it matched, origin match, an excerpt; paginated with limit and offset), and whether Annex XI requires a phytosanitary certificate, plus amendments already adopted but not yet applying. Each entry says how it matched: named (the genus or species is named), family (the plant's family is named, per the GBIF backbone), general (no plant named; applies by commodity) or other_species. Call it first, for any 'can we import X from Y' or 'what does the certificate need to say' question. Give commodity: without it, rows that name no plant are left out and counted in skipped. Do not call it for movements inside the EU. It cannot see emergency measures in separate acts, the EU high-risk plants list, protected zones, GB licences or a border post's decision, and it is not advice.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "market",
                  "plant",
                  "origin"
                ],
                "properties": {
                  "market": {
                    "type": "string",
                    "enum": [
                      "EU",
                      "GB"
                    ],
                    "description": "EU (the Union) or GB (England, Scotland and Wales)."
                  },
                  "plant": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 80,
                    "description": "Latin genus or species, for example Citrus, Citrus sinensis, Petunia x hybrida or Prunus laurocerasus. Common names are not understood."
                  },
                  "origin": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 60,
                    "description": "Country of origin: a 2-letter ISO code (UG, ZA, TR, KE, CN) or an English name (Uganda, South Africa, Türkiye)."
                  },
                  "commodity": {
                    "type": "string",
                    "enum": [
                      "plants_for_planting",
                      "fruit",
                      "cut_flowers",
                      "foliage",
                      "seeds",
                      "tubers_bulbs",
                      "wood",
                      "bark",
                      "grain",
                      "pollen",
                      "growing_medium",
                      "machinery"
                    ],
                    "description": "What is shipped. plants_for_planting includes cuttings, young plants and rooted material; foliage is cut branches and leaves. Strongly recommended: rows that name no plant apply by commodity and are only returned when you give it."
                  },
                  "cn_code": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "maxLength": 20,
                    "description": "Optional CN code, 4 to 10 digits, spaces allowed (0602 10 90). EU only: narrows to rows whose CN codes fit. The GB annexes carry no CN codes in Annex 7."
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date the goods enter, YYYY-MM-DD. Defaults to today. Texts are kept from 2025-01-26."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50,
                    "description": "Special requirement entries per page, default 10."
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000,
                    "description": "Entries to skip, for 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/requirement_text": {
      "post": {
        "operationId": "requirement_text",
        "summary": "Full text of one annex entry",
        "description": "The verbatim wording of one entry of Annex VI, VII or XI as it stood on a date, with its description, origin, CN codes (EU), the act that last amended it, EU derogations in force, the dates on which it changed within the stored versions, and amendments adopted but not yet applying. Call it before quoting a requirement or drafting the additional declaration for a phytosanitary certificate. Pass point as the id from import_requirements (VII:21.1 for the EU; VII:A:30B for GB), or annex plus point. It returns one entry; to find entries, use import_requirements.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "market",
                  "point"
                ],
                "properties": {
                  "market": {
                    "type": "string",
                    "enum": [
                      "EU",
                      "GB"
                    ],
                    "description": "EU (the Union) or GB (England, Scotland and Wales)."
                  },
                  "point": {
                    "type": [
                      "string",
                      "number"
                    ],
                    "maxLength": 20,
                    "description": "Entry id from import_requirements (VII:21.1, VI:18, VII:A:30B, XI:A:7) or a point number with annex given (21.1)."
                  },
                  "annex": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "maxLength": 4,
                    "description": "VI, VII or XI (or 6, 7, 11) when point is a bare number."
                  },
                  "part": {
                    "type": "string",
                    "maxLength": 1,
                    "description": "Part letter when the annex has parts (GB Annex 7: A or B; Annex XI: A, B or C)."
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date the goods enter, YYYY-MM-DD. Defaults to today. Texts are kept from 2025-01-26."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/compare_eu_gb": {
      "post": {
        "operationId": "compare_eu_gb",
        "summary": "Compare EU and GB rules for one plant and origin",
        "description": "Puts the EU and GB answers for the same plant, origin, commodity and date side by side and lists the differences: prohibited in one and not the other, an EU derogation with no GB counterpart in this service, certificate need, number of special requirement entries, and the organisms named only in one side's requirement text. Call it when the same goods are sold into both markets, or when a supplier asks why GB treats them differently. Entries are numbered differently in the two texts, so it compares content, not point numbers. Organism names are pattern-read from the text; read both entries before relying on a difference.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "plant",
                  "origin"
                ],
                "properties": {
                  "plant": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 80,
                    "description": "Latin genus or species, for example Citrus, Citrus sinensis, Petunia x hybrida or Prunus laurocerasus. Common names are not understood."
                  },
                  "origin": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 60,
                    "description": "Country of origin: a 2-letter ISO code (UG, ZA, TR, KE, CN) or an English name (Uganda, South Africa, Türkiye)."
                  },
                  "commodity": {
                    "type": "string",
                    "enum": [
                      "plants_for_planting",
                      "fruit",
                      "cut_flowers",
                      "foliage",
                      "seeds",
                      "tubers_bulbs",
                      "wood",
                      "bark",
                      "grain",
                      "pollen",
                      "growing_medium",
                      "machinery"
                    ],
                    "description": "What is shipped. plants_for_planting includes cuttings, young plants and rooted material; foliage is cut branches and leaves. Strongly recommended: rows that name no plant apply by commodity and are only returned when you give it."
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date the goods enter, YYYY-MM-DD. Defaults to today. Texts are kept from 2025-01-26."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/derogations": {
      "post": {
        "operationId": "derogations",
        "summary": "EU derogation acts from 2019/2072",
        "description": "Lists the standalone Commission acts that EUR-Lex records as derogating from Implementing Regulation (EU) 2019/2072, including temporary measures such as those on citrus black spot (for example allowing unrooted Calibrachoa and Petunia cuttings from Uganda despite the Annex VI ban), with the annex points they derogate from, their validity dates, and whether the title names your plant and origin. These acts sit outside the consolidated text, so a reading of the annexes alone misses them. Call it when import_requirements shows a prohibition, or to see what is in force on a date. Filter by plant, origin and active_on. EU only.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "plant": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 80,
                    "description": "Latin genus or species, for example Citrus, Citrus sinensis, Petunia x hybrida or Prunus laurocerasus. Common names are not understood."
                  },
                  "origin": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 60,
                    "description": "Country of origin: a 2-letter ISO code (UG, ZA, TR, KE, CN) or an English name (Uganda, South Africa, Türkiye)."
                  },
                  "active_on": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Only acts in force on this date, YYYY-MM-DD."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50,
                    "description": "Acts per page, default 10."
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000,
                    "description": "Acts to skip."
                  }
                }
              }
            }
          }
        },
        "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_since": {
      "post": {
        "operationId": "changes_since",
        "summary": "Amendments and derogations since a date",
        "description": "What changed in the EU and GB plant import annexes after a date: amending acts and the point each touches (EUR-Lex index), derogation acts starting or ending, GB amendment notes, and entry-level text changes found by comparing stored versions, oldest first. Future dates are amendments already adopted and scheduled. Call it once a day or week to re-check open product lines, with the next_cursor from the last page while has_more is true. Filter by market and annex.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "since"
                ],
                "properties": {
                  "since": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Return changes dated after this day, YYYY-MM-DD."
                  },
                  "market": {
                    "type": "string",
                    "enum": [
                      "EU",
                      "GB"
                    ],
                    "description": "EU (the Union) or GB (England, Scotland and Wales)."
                  },
                  "annex": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "maxLength": 4,
                    "description": "Only VI, VII or XI (6, 7, 11)."
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "next_cursor from the previous page."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200,
                    "description": "Events per page, default 50."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    }
  }
}
