{
  "openapi": "3.1.0",
  "info": {
    "title": "FIRMSapi",
    "description": "Look up, search and validate U.S. CBP FIRMS codes: the 4-character facility codes for piers, container\nfreight stations, bonded warehouses, foreign trade zones and exam stations.\n\nSend your key in the `x-api-key` header, or as `Authorization: Bearer <key>`. `fapi_test_` keys return\nfixture data and are never counted; `fapi_live_` keys read the latest CBP list and count against your plan.\nEvery response carries `meta.data_as_of`, `meta.source` and `meta.mode`; errors look like\n`{\"error\": {\"code\": \"quota_exceeded\", \"message\": \"...\", \"links\": {...}}}`.\n",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.firmsapi.com/v1",
      "description": "Production"
    }
  ],
  "paths": {
    "/firms/{code}": {
      "get": {
        "tags": [
          "Facilities"
        ],
        "summary": "Look up a FIRMS code",
        "description": "Returns the facility, including deleted codes and flagged placeholders, plus the other codes registered at the same address.",
        "operationId": "getFacility",
        "parameters": [
          {
            "description": "4-character FIRMS code.",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]{4}$",
              "title": "Code",
              "description": "4-character FIRMS code.",
              "examples": [
                "E430"
              ]
            },
            "name": "code",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacilityResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not found (counted: it is a lookup result).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/ports/{port}": {
      "get": {
        "tags": [
          "Ports"
        ],
        "summary": "Get a port and its facilities",
        "description": "Facilities are ordered by code and paged with `cursor`. Placeholders are left out.",
        "operationId": "getPort",
        "parameters": [
          {
            "description": "4-digit CBP port code.",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{4}$",
              "title": "Port",
              "description": "4-digit CBP port code.",
              "examples": [
                "4601"
              ]
            },
            "name": "port",
            "in": "path"
          },
          {
            "description": "Facility type codes, comma-separated (e.g. `03,04`).",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^(0[1-9]|1[01])(,(0[1-9]|1[01]))*$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Type",
              "description": "Facility type codes, comma-separated (e.g. `03,04`)."
            },
            "name": "type",
            "in": "query"
          },
          {
            "description": "Include deleted codes (ranked after active ones).",
            "required": false,
            "schema": {
              "type": "boolean",
              "title": "Include Deleted",
              "description": "Include deleted codes (ranked after active ones).",
              "default": false
            },
            "name": "include_deleted",
            "in": "query"
          },
          {
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500.0,
              "minimum": 1.0,
              "title": "Limit",
              "default": 100
            },
            "name": "limit",
            "in": "query"
          },
          {
            "description": "`next_cursor` from the last page.",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9]{4}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor",
              "description": "`next_cursor` from the last page."
            },
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not found (counted: it is a lookup result).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/watchlists/{code}": {
      "get": {
        "tags": [
          "Watchlists"
        ],
        "summary": "Get a watched code",
        "operationId": "getWatch",
        "parameters": [
          {
            "description": "4-character FIRMS code.",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]{4}$",
              "title": "Code",
              "description": "4-character FIRMS code.",
              "examples": [
                "E430"
              ]
            },
            "name": "code",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WatchEntryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Your plan does not include this endpoint (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not found (counted: it is a lookup result).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Watchlists"
        ],
        "summary": "Watch a code",
        "description": "Idempotent: watching a code twice keeps the original `created_at`. The code must be on the FIRMS list (deleted codes are fine). Does not count toward your monthly calls.",
        "operationId": "putWatch",
        "parameters": [
          {
            "description": "4-character FIRMS code.",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]{4}$",
              "title": "Code",
              "description": "4-character FIRMS code.",
              "examples": [
                "E430"
              ]
            },
            "name": "code",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WatchEntryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Your plan does not include this endpoint (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not found (counted: it is a lookup result).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Watchlists"
        ],
        "summary": "Stop watching a code",
        "description": "Idempotent: `removed` is false if you were not watching the code. Does not count toward your monthly calls.",
        "operationId": "deleteWatch",
        "parameters": [
          {
            "description": "4-character FIRMS code.",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]{4}$",
              "title": "Code",
              "description": "4-character FIRMS code.",
              "examples": [
                "E430"
              ]
            },
            "name": "code",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WatchRemovedResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Your plan does not include this endpoint (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/search": {
      "get": {
        "tags": [
          "Search"
        ],
        "summary": "Search facilities",
        "description": "Fuzzy search over facility name, street address, city and state, and over the names terminal operators and port authorities publish with their codes (`apm terminals elizabeth` finds E425, SEALAND TERMINAL in CBP's list). Typos and abbreviations (ST/STREET, INTL/INTERNATIONAL) are fine. Active codes only unless `include_deleted=true`.",
        "operationId": "search",
        "parameters": [
          {
            "description": "Name and/or address.",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200,
              "minLength": 2,
              "title": "Q",
              "description": "Name and/or address.",
              "examples": [
                "maher terminal elizabeth"
              ]
            },
            "name": "q",
            "in": "query"
          },
          {
            "description": "2-letter state, e.g. `NJ`.",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[A-Za-z]{2}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "State",
              "description": "2-letter state, e.g. `NJ`."
            },
            "name": "state",
            "in": "query"
          },
          {
            "description": "4-digit CBP port code, e.g. `4601`.",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[0-9]{4}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Port",
              "description": "4-digit CBP port code, e.g. `4601`."
            },
            "name": "port",
            "in": "query"
          },
          {
            "description": "Facility type codes, comma-separated (e.g. `03,04`).",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^(0[1-9]|1[01])(,(0[1-9]|1[01]))*$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Type",
              "description": "Facility type codes, comma-separated (e.g. `03,04`)."
            },
            "name": "type",
            "in": "query"
          },
          {
            "description": "Include deleted codes (ranked after active ones).",
            "required": false,
            "schema": {
              "type": "boolean",
              "title": "Include Deleted",
              "description": "Include deleted codes (ranked after active ones).",
              "default": false
            },
            "name": "include_deleted",
            "in": "query"
          },
          {
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 50.0,
              "minimum": 1.0,
              "title": "Limit",
              "default": 10
            },
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/autocomplete": {
      "get": {
        "tags": [
          "Search"
        ],
        "summary": "Autocomplete facility names",
        "description": "Prefix matching for type-ahead inputs. Returns compact items; fetch details with `GET /firms/{code}`. Autocomplete requests do not count toward your monthly calls.",
        "operationId": "autocomplete",
        "parameters": [
          {
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 100,
              "minLength": 1,
              "title": "Q",
              "examples": [
                "mah"
              ]
            },
            "name": "q",
            "in": "query"
          },
          {
            "description": "2-letter state, e.g. `NJ`.",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[A-Za-z]{2}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "State",
              "description": "2-letter state, e.g. `NJ`."
            },
            "name": "state",
            "in": "query"
          },
          {
            "description": "4-digit CBP port code, e.g. `4601`.",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[0-9]{4}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Port",
              "description": "4-digit CBP port code, e.g. `4601`."
            },
            "name": "port",
            "in": "query"
          },
          {
            "description": "Facility type codes, comma-separated (e.g. `03,04`).",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^(0[1-9]|1[01])(,(0[1-9]|1[01]))*$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Type",
              "description": "Facility type codes, comma-separated (e.g. `03,04`)."
            },
            "name": "type",
            "in": "query"
          },
          {
            "description": "Include deleted codes (ranked after active ones).",
            "required": false,
            "schema": {
              "type": "boolean",
              "title": "Include Deleted",
              "description": "Include deleted codes (ranked after active ones).",
              "default": false
            },
            "name": "include_deleted",
            "in": "query"
          },
          {
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 20.0,
              "minimum": 1.0,
              "title": "Limit",
              "default": 8
            },
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutocompleteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/nearby": {
      "get": {
        "tags": [
          "Search"
        ],
        "summary": "Find facilities near a point, a facility or an address",
        "description": "Pass one of: `lat` and `lon`; `code`, to search around that facility (it is left out of the results); or `address`, a US street address. An address that belongs to a FIRMS facility uses that facility's location; any other address is geocoded. `meta.origin` says which point was used. One call either way. Facilities whose own address could not be geocoded are not included.",
        "operationId": "nearby",
        "parameters": [
          {
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "number",
                  "maximum": 90.0,
                  "minimum": -90.0
                },
                {
                  "type": "null"
                }
              ],
              "title": "Lat"
            },
            "name": "lat",
            "in": "query"
          },
          {
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "number",
                  "maximum": 180.0,
                  "minimum": -180.0
                },
                {
                  "type": "null"
                }
              ],
              "title": "Lon"
            },
            "name": "lon",
            "in": "query"
          },
          {
            "description": "Search around this code.",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9]{4}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Code",
              "description": "Search around this code."
            },
            "name": "code",
            "in": "query"
          },
          {
            "description": "Search around this address, e.g. `231 Tyler St, Newark, NJ 07114`.",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200,
                  "minLength": 3
                },
                {
                  "type": "null"
                }
              ],
              "title": "Address",
              "description": "Search around this address, e.g. `231 Tyler St, Newark, NJ 07114`.",
              "examples": [
                "231 Tyler St, Newark, NJ 07114"
              ]
            },
            "name": "address",
            "in": "query"
          },
          {
            "required": false,
            "schema": {
              "type": "number",
              "maximum": 100.0,
              "exclusiveMinimum": 0.0,
              "title": "Radius Km",
              "default": 10
            },
            "name": "radius_km",
            "in": "query"
          },
          {
            "description": "Facility type codes, comma-separated (e.g. `03,04`).",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^(0[1-9]|1[01])(,(0[1-9]|1[01]))*$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Type",
              "description": "Facility type codes, comma-separated (e.g. `03,04`)."
            },
            "name": "type",
            "in": "query"
          },
          {
            "description": "Include deleted codes (ranked after active ones).",
            "required": false,
            "schema": {
              "type": "boolean",
              "title": "Include Deleted",
              "description": "Include deleted codes (ranked after active ones).",
              "default": false
            },
            "name": "include_deleted",
            "in": "query"
          },
          {
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100.0,
              "minimum": 1.0,
              "title": "Limit",
              "default": 20
            },
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NearbyResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not found (counted: it is a lookup result).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/validate": {
      "post": {
        "tags": [
          "Validation"
        ],
        "summary": "Check a FIRMS code before you file",
        "description": "Runs the pre-filing checks in order: format, exists (ACE 158), active (159), in your port (164), facility type fits the intended use, not a placeholder. A code that fails is still a `200` with `valid: false`. `checks_not_possible` lists what the FIRMS list cannot tell you; confirm those in ACE.",
        "operationId": "validate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/batch": {
      "post": {
        "tags": [
          "Batch"
        ],
        "summary": "Run up to 100 lookups, validations and searches",
        "description": "Pro and Enterprise. Each request in the batch counts as one call, and the whole batch is counted up front: if your remaining calls cannot cover it, nothing runs and you get `429`.",
        "operationId": "batch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Your plan does not include this endpoint (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/ports": {
      "get": {
        "tags": [
          "Ports"
        ],
        "summary": "List CBP ports",
        "description": "Every port that has FIRMS codes, with counts.",
        "operationId": "listPorts",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/changes": {
      "get": {
        "tags": [
          "Changes"
        ],
        "summary": "Feed of FIRMS list changes",
        "description": "Pro and Enterprise. Codes added, removed, updated or with a status change, oldest first, from `since` (default: the last 30 days). Store `next_cursor` to page through, and the last `changed_at` you saw to resume later.",
        "operationId": "listChanges",
        "parameters": [
          {
            "description": "ISO 8601 date or date-time (UTC).",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Since",
              "description": "ISO 8601 date or date-time (UTC).",
              "examples": [
                "2026-10-01"
              ]
            },
            "name": "since",
            "in": "query"
          },
          {
            "description": "Only this code.",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9]{4}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Code",
              "description": "Only this code."
            },
            "name": "code",
            "in": "query"
          },
          {
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "added",
                    "removed",
                    "updated",
                    "status_changed"
                  ]
                },
                {
                  "type": "null"
                }
              ],
              "title": "Change Type"
            },
            "name": "change_type",
            "in": "query"
          },
          {
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500.0,
              "minimum": 1.0,
              "title": "Limit",
              "default": 100
            },
            "name": "limit",
            "in": "query"
          },
          {
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 1024
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            },
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangesResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Your plan does not include this endpoint (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/watchlists": {
      "get": {
        "tags": [
          "Watchlists"
        ],
        "summary": "List watched codes",
        "description": "Enterprise. The codes you watch. Webhook notifications for watched codes are not available yet; use `GET /changes` to see what changed.",
        "operationId": "listWatchlist",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WatchlistResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Your plan does not include this endpoint (not counted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Monthly quota, call packs and overage cap used up (`quota_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Address": {
        "properties": {
          "street": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Street"
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "City"
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "State"
          },
          "zip": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Zip"
          }
        },
        "type": "object",
        "required": [
          "street",
          "city",
          "state",
          "zip"
        ],
        "title": "Address"
      },
      "AutocompleteItem": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "City"
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "State"
          },
          "port": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Port"
          },
          "type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Type",
            "description": "Facility type code."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "deleted"
            ],
            "title": "Status"
          }
        },
        "type": "object",
        "required": [
          "code",
          "name",
          "city",
          "state",
          "port",
          "type",
          "status"
        ],
        "title": "AutocompleteItem"
      },
      "AutocompleteResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/AutocompleteItem"
            },
            "type": "array",
            "title": "Data"
          },
          "meta": {
            "$ref": "#/components/schemas/PageMeta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "AutocompleteResponse"
      },
      "BatchLookup": {
        "properties": {
          "op": {
            "type": "string",
            "const": "lookup",
            "title": "Op"
          },
          "code": {
            "type": "string",
            "maxLength": 32,
            "minLength": 1,
            "title": "Code"
          }
        },
        "type": "object",
        "required": [
          "op",
          "code"
        ],
        "title": "BatchLookup"
      },
      "BatchRequest": {
        "properties": {
          "requests": {
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/BatchLookup"
                },
                {
                  "$ref": "#/components/schemas/BatchValidate"
                },
                {
                  "$ref": "#/components/schemas/BatchSearch"
                }
              ],
              "discriminator": {
                "propertyName": "op",
                "mapping": {
                  "lookup": "#/components/schemas/BatchLookup",
                  "search": "#/components/schemas/BatchSearch",
                  "validate": "#/components/schemas/BatchValidate"
                }
              }
            },
            "type": "array",
            "maxItems": 100,
            "minItems": 1,
            "title": "Requests",
            "description": "Up to 100. Each counts as one call."
          }
        },
        "type": "object",
        "required": [
          "requests"
        ],
        "title": "BatchRequest"
      },
      "BatchResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/BatchResult"
            },
            "type": "array",
            "title": "Data",
            "description": "One result per request, in order."
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "BatchResponse"
      },
      "BatchResult": {
        "properties": {
          "status": {
            "type": "integer",
            "title": "Status",
            "description": "The status the same request would get on its own endpoint."
          },
          "data": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FacilityDetail"
              },
              {
                "$ref": "#/components/schemas/ValidationResult"
              },
              {
                "items": {
                  "$ref": "#/components/schemas/SearchHit"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Data"
          },
          "error": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ErrorBody"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "status"
        ],
        "title": "BatchResult"
      },
      "BatchSearch": {
        "properties": {
          "op": {
            "type": "string",
            "const": "search",
            "title": "Op"
          },
          "q": {
            "type": "string",
            "maxLength": 200,
            "minLength": 2,
            "title": "Q"
          },
          "state": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2,
                "minLength": 2
              },
              {
                "type": "null"
              }
            ],
            "title": "State"
          },
          "port": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]{4}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Port"
          },
          "limit": {
            "type": "integer",
            "maximum": 20.0,
            "minimum": 1.0,
            "title": "Limit",
            "default": 5
          }
        },
        "type": "object",
        "required": [
          "op",
          "q"
        ],
        "title": "BatchSearch"
      },
      "BatchValidate": {
        "properties": {
          "code": {
            "type": "string",
            "maxLength": 32,
            "minLength": 1,
            "title": "Code",
            "description": "The FIRMS code to check.",
            "examples": [
              "E430"
            ]
          },
          "port": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 8
              },
              {
                "type": "null"
              }
            ],
            "title": "Port",
            "description": "4-digit CBP port of entry the filing is for.",
            "examples": [
              "4601"
            ]
          },
          "use": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "warehouse_entry",
                  "ftz_admission",
                  "exam_site",
                  "location_of_goods"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Use",
            "description": "How you will use the code, to check the facility type."
          },
          "op": {
            "type": "string",
            "const": "validate",
            "title": "Op"
          }
        },
        "type": "object",
        "required": [
          "code",
          "op"
        ],
        "title": "BatchValidate"
      },
      "Change": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code"
          },
          "change_type": {
            "type": "string",
            "enum": [
              "added",
              "removed",
              "updated",
              "status_changed"
            ],
            "title": "Change Type"
          },
          "changed_at": {
            "type": "string",
            "title": "Changed At",
            "description": "When the pipeline published the change (ISO 8601)."
          },
          "build_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Build Id"
          },
          "before": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Before"
          },
          "after": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "After"
          }
        },
        "type": "object",
        "required": [
          "code",
          "change_type",
          "changed_at",
          "build_id",
          "before",
          "after"
        ],
        "title": "Change"
      },
      "ChangesResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/Change"
            },
            "type": "array",
            "title": "Data"
          },
          "meta": {
            "$ref": "#/components/schemas/PageMeta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "ChangesResponse"
      },
      "Check": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "title": {
            "type": "string",
            "title": "Title"
          },
          "ace_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ace Code",
            "description": "ACE/ABI reject this check is meant to catch."
          },
          "message": {
            "type": "string",
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "id",
          "title",
          "message"
        ],
        "title": "Check"
      },
      "ErrorBody": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "description": "Stable, machine-readable error code.",
            "examples": [
              "quota_exceeded"
            ]
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "links": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Links",
            "description": "`docs` always; `billing`, `buy_pack`, `upgrade` when they help."
          },
          "details": {
            "title": "Details"
          }
        },
        "type": "object",
        "required": [
          "code",
          "message",
          "links"
        ],
        "title": "ErrorBody"
      },
      "ErrorResponse": {
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorBody"
          },
          "meta": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Meta"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "error"
        ],
        "title": "ErrorResponse"
      },
      "Facility": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "description": "4-character FIRMS code.",
            "examples": [
              "E430"
            ]
          },
          "name": {
            "type": "string",
            "title": "Name",
            "examples": [
              "MAHER TERMINAL"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "deleted"
            ],
            "title": "Status",
            "description": "Deleted codes stay in the data so you can tell why a filing failed."
          },
          "type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FacilityType"
              },
              {
                "type": "null"
              }
            ],
            "description": "Facility type. Null when CBP left it blank."
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "port": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PortRef"
              },
              {
                "type": "null"
              }
            ]
          },
          "region": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Region"
          },
          "location": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Location"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null when the address could not be geocoded."
          },
          "junk": {
            "type": "boolean",
            "title": "Junk",
            "description": "True for \"DO NOT USE\" placeholders and CBP test records."
          },
          "first_seen": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Seen"
          },
          "last_changed": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Changed"
          }
        },
        "type": "object",
        "required": [
          "code",
          "name",
          "status",
          "type",
          "address",
          "port",
          "region",
          "location",
          "junk",
          "first_seen",
          "last_changed"
        ],
        "title": "Facility"
      },
      "FacilityDetail": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "description": "4-character FIRMS code.",
            "examples": [
              "E430"
            ]
          },
          "name": {
            "type": "string",
            "title": "Name",
            "examples": [
              "MAHER TERMINAL"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "deleted"
            ],
            "title": "Status",
            "description": "Deleted codes stay in the data so you can tell why a filing failed."
          },
          "type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FacilityType"
              },
              {
                "type": "null"
              }
            ],
            "description": "Facility type. Null when CBP left it blank."
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "port": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PortRef"
              },
              {
                "type": "null"
              }
            ]
          },
          "region": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Region"
          },
          "location": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Location"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null when the address could not be geocoded."
          },
          "junk": {
            "type": "boolean",
            "title": "Junk",
            "description": "True for \"DO NOT USE\" placeholders and CBP test records."
          },
          "first_seen": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Seen"
          },
          "last_changed": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Changed"
          },
          "same_address": {
            "items": {
              "$ref": "#/components/schemas/FacilitySummary"
            },
            "type": "array",
            "title": "Same Address",
            "description": "Other FIRMS codes at the same physical address."
          },
          "warnings": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Warnings"
          }
        },
        "type": "object",
        "required": [
          "code",
          "name",
          "status",
          "type",
          "address",
          "port",
          "region",
          "location",
          "junk",
          "first_seen",
          "last_changed",
          "same_address",
          "warnings"
        ],
        "title": "FacilityDetail"
      },
      "FacilityResponse": {
        "properties": {
          "data": {
            "$ref": "#/components/schemas/FacilityDetail"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "FacilityResponse"
      },
      "FacilitySummary": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "deleted"
            ],
            "title": "Status"
          },
          "type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FacilityType"
              },
              {
                "type": "null"
              }
            ]
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "City"
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "State"
          },
          "port": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Port"
          }
        },
        "type": "object",
        "required": [
          "code",
          "name",
          "status",
          "type",
          "city",
          "state",
          "port"
        ],
        "title": "FacilitySummary"
      },
      "FacilityType": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "examples": [
              "03"
            ]
          },
          "label": {
            "type": "string",
            "title": "Label",
            "examples": [
              "Pier or terminal"
            ]
          }
        },
        "type": "object",
        "required": [
          "code",
          "label"
        ],
        "title": "FacilityType"
      },
      "Location": {
        "properties": {
          "lat": {
            "type": "number",
            "title": "Lat"
          },
          "lon": {
            "type": "number",
            "title": "Lon"
          },
          "quality": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Quality",
            "description": "Geocoder match quality for the facility address."
          }
        },
        "type": "object",
        "required": [
          "lat",
          "lon",
          "quality"
        ],
        "title": "Location"
      },
      "Meta": {
        "properties": {
          "data_as_of": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Data As Of",
            "description": "Date (YYYY-MM-DD) of the CBP FIRMS list this response reflects."
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source",
            "description": "Where the data comes from. Test mode says so."
          },
          "mode": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "live",
                  "test"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Mode",
            "description": "`test` for fapi_test_ keys: fixture data, not counted."
          },
          "build_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Build Id",
            "description": "Index build that served the response."
          },
          "request_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Request Id",
            "description": "Quote this when you contact support."
          }
        },
        "type": "object",
        "required": [
          "data_as_of",
          "source",
          "mode"
        ],
        "title": "Meta"
      },
      "NearbyHit": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "description": "4-character FIRMS code.",
            "examples": [
              "E430"
            ]
          },
          "name": {
            "type": "string",
            "title": "Name",
            "examples": [
              "MAHER TERMINAL"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "deleted"
            ],
            "title": "Status",
            "description": "Deleted codes stay in the data so you can tell why a filing failed."
          },
          "type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FacilityType"
              },
              {
                "type": "null"
              }
            ],
            "description": "Facility type. Null when CBP left it blank."
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "port": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PortRef"
              },
              {
                "type": "null"
              }
            ]
          },
          "region": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Region"
          },
          "location": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Location"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null when the address could not be geocoded."
          },
          "junk": {
            "type": "boolean",
            "title": "Junk",
            "description": "True for \"DO NOT USE\" placeholders and CBP test records."
          },
          "first_seen": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Seen"
          },
          "last_changed": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Changed"
          },
          "distance_km": {
            "type": "number",
            "title": "Distance Km"
          }
        },
        "type": "object",
        "required": [
          "code",
          "name",
          "status",
          "type",
          "address",
          "port",
          "region",
          "location",
          "junk",
          "first_seen",
          "last_changed",
          "distance_km"
        ],
        "title": "NearbyHit"
      },
      "NearbyMeta": {
        "properties": {
          "data_as_of": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Data As Of",
            "description": "Date (YYYY-MM-DD) of the CBP FIRMS list this response reflects."
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source",
            "description": "Where the data comes from. Test mode says so."
          },
          "mode": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "live",
                  "test"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Mode",
            "description": "`test` for fapi_test_ keys: fixture data, not counted."
          },
          "build_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Build Id",
            "description": "Index build that served the response."
          },
          "request_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Request Id",
            "description": "Quote this when you contact support."
          },
          "count": {
            "type": "integer",
            "title": "Count",
            "description": "Items in `data`."
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor",
            "description": "Pass as `cursor` to get the next page; null on the last page."
          },
          "origin": {
            "$ref": "#/components/schemas/Origin",
            "description": "The point distances are measured from, and how it was found."
          }
        },
        "type": "object",
        "required": [
          "data_as_of",
          "source",
          "mode",
          "count",
          "origin"
        ],
        "title": "NearbyMeta"
      },
      "NearbyResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/NearbyHit"
            },
            "type": "array",
            "title": "Data"
          },
          "meta": {
            "$ref": "#/components/schemas/NearbyMeta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "NearbyResponse"
      },
      "Origin": {
        "properties": {
          "lat": {
            "type": "number",
            "title": "Lat"
          },
          "lon": {
            "type": "number",
            "title": "Lon"
          },
          "source": {
            "type": "string",
            "enum": [
              "point",
              "code",
              "firms_address",
              "geocoder"
            ],
            "title": "Source",
            "description": "`point`: your lat/lon. `code`: that facility's location. `firms_address`: the address is a FIRMS facility's, so its stored location was used. `geocoder`: the address was geocoded."
          },
          "label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Label",
            "description": "The facility name, or the address the geocoder matched."
          },
          "code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Code",
            "description": "The facility used as the origin (`code` and `firms_address`)."
          },
          "relevance": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Relevance",
            "description": "Geocoder match score, 0 to 1 (`geocoder` only)."
          },
          "place_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Place Type",
            "description": "What the geocoder matched, e.g. `PointAddress`, `Street`, `Locality` (`geocoder` only)."
          }
        },
        "type": "object",
        "required": [
          "lat",
          "lon",
          "source"
        ],
        "title": "Origin"
      },
      "PageMeta": {
        "properties": {
          "data_as_of": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Data As Of",
            "description": "Date (YYYY-MM-DD) of the CBP FIRMS list this response reflects."
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source",
            "description": "Where the data comes from. Test mode says so."
          },
          "mode": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "live",
                  "test"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Mode",
            "description": "`test` for fapi_test_ keys: fixture data, not counted."
          },
          "build_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Build Id",
            "description": "Index build that served the response."
          },
          "request_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Request Id",
            "description": "Quote this when you contact support."
          },
          "count": {
            "type": "integer",
            "title": "Count",
            "description": "Items in `data`."
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor",
            "description": "Pass as `cursor` to get the next page; null on the last page."
          }
        },
        "type": "object",
        "required": [
          "data_as_of",
          "source",
          "mode",
          "count"
        ],
        "title": "PageMeta"
      },
      "PortDetail": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "examples": [
              "4601"
            ]
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "State"
          },
          "region": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Region"
          },
          "facility_count": {
            "type": "integer",
            "title": "Facility Count"
          },
          "active_count": {
            "type": "integer",
            "title": "Active Count"
          },
          "facilities": {
            "items": {
              "$ref": "#/components/schemas/Facility"
            },
            "type": "array",
            "title": "Facilities",
            "description": "One page of the port's facilities, ordered by code."
          }
        },
        "type": "object",
        "required": [
          "code",
          "name",
          "state",
          "region",
          "facility_count",
          "active_count",
          "facilities"
        ],
        "title": "PortDetail"
      },
      "PortRef": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "examples": [
              "4601"
            ]
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name",
            "examples": [
              "Newark/Elizabeth"
            ]
          }
        },
        "type": "object",
        "required": [
          "code",
          "name"
        ],
        "title": "PortRef"
      },
      "PortResponse": {
        "properties": {
          "data": {
            "$ref": "#/components/schemas/PortDetail"
          },
          "meta": {
            "$ref": "#/components/schemas/PageMeta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "PortResponse"
      },
      "PortSummary": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "examples": [
              "4601"
            ]
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "State"
          },
          "region": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Region"
          },
          "facility_count": {
            "type": "integer",
            "title": "Facility Count"
          },
          "active_count": {
            "type": "integer",
            "title": "Active Count"
          }
        },
        "type": "object",
        "required": [
          "code",
          "name",
          "state",
          "region",
          "facility_count",
          "active_count"
        ],
        "title": "PortSummary"
      },
      "PortsResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/PortSummary"
            },
            "type": "array",
            "title": "Data"
          },
          "meta": {
            "$ref": "#/components/schemas/PageMeta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "PortsResponse"
      },
      "SearchHit": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "description": "4-character FIRMS code.",
            "examples": [
              "E430"
            ]
          },
          "name": {
            "type": "string",
            "title": "Name",
            "examples": [
              "MAHER TERMINAL"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "deleted"
            ],
            "title": "Status",
            "description": "Deleted codes stay in the data so you can tell why a filing failed."
          },
          "type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FacilityType"
              },
              {
                "type": "null"
              }
            ],
            "description": "Facility type. Null when CBP left it blank."
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "port": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PortRef"
              },
              {
                "type": "null"
              }
            ]
          },
          "region": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Region"
          },
          "location": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Location"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null when the address could not be geocoded."
          },
          "junk": {
            "type": "boolean",
            "title": "Junk",
            "description": "True for \"DO NOT USE\" placeholders and CBP test records."
          },
          "first_seen": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Seen"
          },
          "last_changed": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Changed"
          },
          "score": {
            "type": "number",
            "title": "Score",
            "description": "Relevance, 0-100."
          }
        },
        "type": "object",
        "required": [
          "code",
          "name",
          "status",
          "type",
          "address",
          "port",
          "region",
          "location",
          "junk",
          "first_seen",
          "last_changed",
          "score"
        ],
        "title": "SearchHit"
      },
      "SearchResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/SearchHit"
            },
            "type": "array",
            "title": "Data"
          },
          "meta": {
            "$ref": "#/components/schemas/PageMeta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "SearchResponse"
      },
      "ValidateRequest": {
        "properties": {
          "code": {
            "type": "string",
            "maxLength": 32,
            "minLength": 1,
            "title": "Code",
            "description": "The FIRMS code to check.",
            "examples": [
              "E430"
            ]
          },
          "port": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 8
              },
              {
                "type": "null"
              }
            ],
            "title": "Port",
            "description": "4-digit CBP port of entry the filing is for.",
            "examples": [
              "4601"
            ]
          },
          "use": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "warehouse_entry",
                  "ftz_admission",
                  "exam_site",
                  "location_of_goods"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Use",
            "description": "How you will use the code, to check the facility type."
          }
        },
        "type": "object",
        "required": [
          "code"
        ],
        "title": "ValidateRequest"
      },
      "ValidateResponse": {
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ValidationResult"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "ValidateResponse"
      },
      "ValidationResult": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code"
          },
          "valid": {
            "type": "boolean",
            "title": "Valid",
            "description": "True when no check failed. Still confirm in ACE."
          },
          "checks_passed": {
            "items": {
              "$ref": "#/components/schemas/Check"
            },
            "type": "array",
            "title": "Checks Passed"
          },
          "checks_failed": {
            "items": {
              "$ref": "#/components/schemas/Check"
            },
            "type": "array",
            "title": "Checks Failed"
          },
          "checks_skipped": {
            "items": {
              "$ref": "#/components/schemas/Check"
            },
            "type": "array",
            "title": "Checks Skipped",
            "description": "Checks that need an input you did not send or a failed check."
          },
          "checks_not_possible": {
            "items": {
              "$ref": "#/components/schemas/Check"
            },
            "type": "array",
            "title": "Checks Not Possible",
            "description": "Things a filing needs that the FIRMS list cannot show."
          },
          "facility": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Facility"
              },
              {
                "type": "null"
              }
            ]
          },
          "note": {
            "type": "string",
            "title": "Note"
          }
        },
        "type": "object",
        "required": [
          "code",
          "valid",
          "checks_passed",
          "checks_failed",
          "checks_skipped",
          "checks_not_possible",
          "facility",
          "note"
        ],
        "title": "ValidationResult"
      },
      "WatchEntry": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code"
          },
          "created_at": {
            "type": "string",
            "title": "Created At"
          },
          "facility": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FacilitySummary"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null if the code is no longer in the index."
          }
        },
        "type": "object",
        "required": [
          "code",
          "created_at",
          "facility"
        ],
        "title": "WatchEntry"
      },
      "WatchEntryResponse": {
        "properties": {
          "data": {
            "$ref": "#/components/schemas/WatchEntry"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "WatchEntryResponse"
      },
      "WatchRemoved": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code"
          },
          "removed": {
            "type": "boolean",
            "title": "Removed"
          }
        },
        "type": "object",
        "required": [
          "code",
          "removed"
        ],
        "title": "WatchRemoved"
      },
      "WatchRemovedResponse": {
        "properties": {
          "data": {
            "$ref": "#/components/schemas/WatchRemoved"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "WatchRemovedResponse"
      },
      "WatchlistResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/WatchEntry"
            },
            "type": "array",
            "title": "Data"
          },
          "meta": {
            "$ref": "#/components/schemas/PageMeta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "WatchlistResponse"
      }
    },
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      },
      "bearer": {
        "type": "http",
        "description": "The same API key, for clients that can only send a bearer token.",
        "scheme": "bearer"
      }
    }
  },
  "security": [
    {
      "apiKey": []
    },
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "Facilities",
      "description": "Look up a FIRMS code."
    },
    {
      "name": "Search",
      "description": "Find codes by name, address or location."
    },
    {
      "name": "Validation",
      "description": "Check a code before you file."
    },
    {
      "name": "Batch",
      "description": "Many lookups, validations and searches in one request (Pro and Enterprise)."
    },
    {
      "name": "Ports",
      "description": "CBP ports and the facilities in them."
    },
    {
      "name": "Changes",
      "description": "What changed in the FIRMS list (Pro and Enterprise)."
    },
    {
      "name": "Watchlists",
      "description": "The codes your product depends on (Enterprise). Webhook notifications are not available yet."
    }
  ]
}
