{
  "openapi": "3.1.0",
  "info": {
    "title": "Tullage",
    "version": "0.1.0",
    "description": "EU tariff quota balances, history and run-out forecasts for every live quota, from signed daily TARIC files."
  },
  "servers": [
    {
      "url": "https://tullage.bulkhead.solutions"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/v1/tools/quota_status": {
      "post": {
        "operationId": "quota_status",
        "summary": "Quota balance and status",
        "description": "Current balance, status (open, exhausted, blocked, suspended, not_yet_open, closed) and critical flag of one EU tariff quota order number, with its period (labelled 2026-Q4 style where it is a calendar quarter), volume, origins, CN codes and in-quota duty. A blocked or suspended quota carries its blocking or suspension period, and one already scheduled later in the period is listed as blocking_periods_ahead. initial_volume is the volume first opened, as in the regulation; volume is the current volume after any raise, such as a carry-over, and the balance is measured against it, so it can exceed initial_volume. Pass as_of to get the state on a past date or time instead; today, or any day since the data date, is answered from the newest data and says so. Call it when you know the order number and need the balance now or on a past date. Do not call it to predict a future date (use forecast_runout) or to find which quota covers a product (use quotas_for). Balances come from Swedish Customs' signed copy of TARIC and can lag the Commission by up to a day; a positive balance is not a promise of allocation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "order"
                ],
                "properties": {
                  "order": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "EU tariff quota order number, 6 digits, for example 099702 (also accepted as 09.9702)."
                  },
                  "as_of": {
                    "type": "string",
                    "maxLength": 40,
                    "description": "Optional past date (YYYY-MM-DD, end of that day) or date-time (YYYY-MM-DDTHH:MM:SS, read on the same clock as Tullverket's allocation timestamps, which carry no time zone), from 2019-01-01 on. Defaults to the newest data."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/quotas_for": {
      "post": {
        "operationId": "quotas_for",
        "summary": "Quotas for a CN code and origin",
        "description": "Finds the EU tariff quotas that cover a CN code from a given origin on a date, with each quota's order number, in-quota duty, status, balance, volume and initial_volume, and the blocking or suspension period of any quota that is blocked, plus the duties that apply outside the quota (third-country duty, tariff preference, additional duties such as the 50 % steel out-of-quota duty, trade defence). Call it when you know the goods and origin but not the order number, or to answer what duty applies if the quota is exhausted. A 2, 4 or 6 digit code also lists quotas on codes beneath it, marked part_of_code; at most 40 quotas are listed, so pass origin or a longer code for a short answer. It covers first-come, first-served quotas, the ones TARIC keeps balances for, not quotas managed by import licences. It cannot judge origin, end-use or which producer's anti-dumping rate applies, and it is not a binding tariff ruling.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "cn_code"
                ],
                "properties": {
                  "cn_code": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "maxLength": 20,
                    "description": "CN or TARIC code, 2 to 10 digits, spaces and dots allowed, for example 7208100000 or 7208 10."
                  },
                  "origin": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Country of origin as a 2-letter code (ID, CN, TR, GB, US), a TARIC area code, or a country name (Indonesia, Viet Nam). Strongly recommended: without it all areas are listed."
                  },
                  "date": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "Date the goods are declared, YYYY-MM-DD, from 2026-01-01 (about a year back from the data date) on. Defaults to the newest data date."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/depletion_history": {
      "post": {
        "operationId": "depletion_history",
        "summary": "Depletion history of a quota period",
        "description": "Every allocation in one period of an EU tariff quota: timestamp, balance after, change, and the request date it covered, with a summary (first allocation share, critical date, run-out date) and the run-out dates of up to 8 other periods. Call it to show how fast a quota was drawn down, or to explain a forecast. Pass quarter as 2026-Q4 or any date inside the period; omit it for the current period. History in this service starts in 2019. Do not use it for the live balance alone (use quota_status).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "order"
                ],
                "properties": {
                  "order": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "EU tariff quota order number, 6 digits, for example 099702 (also accepted as 09.9702)."
                  },
                  "quarter": {
                    "type": "string",
                    "maxLength": 10,
                    "description": "Period to show: a quarter (2026-Q4 or Q4 2026), a month (2026-11), a year (2026), or a date inside the period (YYYY-MM-DD). Matched by overlap, so 2026 finds an annual period; when it covers several periods, the open one is shown and the others are listed. Defaults to the current period."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/forecast_runout": {
      "post": {
        "operationId": "forecast_runout",
        "summary": "Forecast whether a quota is open on a shipment date",
        "description": "Forecasts whether an EU tariff quota will still be open on the date your goods are declared, with a probability, a run-out date range, the projected balance and, if you give the quantity, whether it is likely to fit. It reports what TARIC already records for that date (a blocking period, for example) and the status now, with any current or scheduled blocking period, and ends with summary, one sentence to quote. kg is in the quota's own unit, kilograms for steel, so 500 tonnes is 500000. It states its method, the past periods it rests on, and its out-of-sample backtest at that horizon; with no comparable history it returns unknown rather than guessing. Give cn_code and origin to also get the duty that applies if the quota is gone. Call it before booking or routing a shipment that will arrive on a future date. It cannot know demand that has not been filed yet, policy changes, or new volumes, and it is a probability, not a guarantee.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "order",
                  "shipment_date"
                ],
                "properties": {
                  "order": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "EU tariff quota order number, 6 digits, for example 099702 (also accepted as 09.9702)."
                  },
                  "shipment_date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date the goods will be declared for release for free circulation, YYYY-MM-DD, on or after the data date."
                  },
                  "kg": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Optional quantity to check, in the quota's own unit, which is kilograms for most quotas; the answer states the unit."
                  },
                  "cn_code": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "maxLength": 20,
                    "description": "Optional CN code of the goods, to return the duty outside the quota."
                  },
                  "origin": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Optional country of origin, a 2-letter code or a country name, used with cn_code for preferences and country measures."
                  }
                }
              }
            }
          }
        },
        "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": "Quota changes since a cursor",
        "description": "Lists what changed in EU tariff quotas since your last call: allocations, balances raised by returns or carry-over, quotas becoming critical, exhausted or reopened. Pass the next_cursor from your previous call, or a date (YYYY-MM-DD) to get everything published after that day, so 2026-11-04 starts on 5 November; with no cursor you get the newest day. Filter with orders and kinds. Page with next_cursor while has_more is true. Use it instead of a webhook: poll once a day. Changes are kept for 35 days; an older cursor returns cursor_expired.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "cursor": {
                    "type": "string",
                    "maxLength": 500,
                    "description": "next_cursor from the previous call, or a date YYYY-MM-DD meaning everything published after that day."
                  },
                  "orders": {
                    "type": [
                      "array",
                      "string"
                    ],
                    "maxItems": 200,
                    "maxLength": 2000,
                    "items": {
                      "type": "string",
                      "maxLength": 12
                    },
                    "description": "Only these order numbers, as a list or one comma-separated string, for example [\"099702\", \"09.9807\"]. An unknown number is an error, not an empty feed."
                  },
                  "kinds": {
                    "type": [
                      "array",
                      "string"
                    ],
                    "maxItems": 20,
                    "maxLength": 200,
                    "items": {
                      "type": "string",
                      "enum": [
                        "allocation",
                        "balance_raised",
                        "became_critical",
                        "no_longer_critical",
                        "exhausted",
                        "reopened",
                        "unblocked",
                        "unsuspended"
                      ]
                    },
                    "description": "Only these kinds of change, as a list or one comma-separated string: allocation, balance_raised, became_critical, no_longer_critical, exhausted, reopened, unblocked, unsuspended."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500,
                    "description": "Maximum changes to return, default 100."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    }
  }
}
