{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/dataquoll-io/json-schema/dataquoll-io-postcode-declaration-result-schema.json",
  "title": "PostcodeDeclarationResult",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dataquoll-io-declarations-api-openapi.yml#/components/schemas/PostcodeDeclarationResult",
  "type": "object",
  "properties": {
    "postcode": {
      "type": "string"
    },
    "matchStatus": {
      "type": "string",
      "enum": [
        "declared",
        "partial",
        "not_declared",
        "uncertain",
        "activation_only",
        "unknown_postcode"
      ]
    },
    "matchStatusReason": {
      "type": "string",
      "description": "Present when matchStatus is uncertain or activation_only"
    },
    "matchedLgas": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MatchedLga"
      }
    },
    "narrowing": {
      "$ref": "#/$defs/SuburbNarrowing"
    },
    "asAt": {
      "type": "string",
      "format": "date",
      "description": "Date the status was evaluated against; the requested as_at value or today (AEST) when omitted"
    },
    "dataLastUpdated": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "stale": {
      "type": "boolean"
    },
    "disclaimer": {
      "type": "string"
    },
    "meta": {
      "type": "object",
      "properties": {
        "generatedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "attribution": {
      "type": "string"
    }
  },
  "$defs": {
    "DeclarationRecord": {
      "type": "object",
      "properties": {
        "agrn": {
          "type": [
            "string",
            "null"
          ]
        },
        "title": {
          "type": "string"
        },
        "instrumentType": {
          "type": "string",
          "enum": [
            "state_natural_disaster_declaration",
            "drfa_activation_agrn",
            "state_of_disaster_emergency_powers"
          ]
        },
        "jurisdiction": {
          "type": "string"
        },
        "disasterTypes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "startDate": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "endDate": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "status": {
          "type": "string",
          "enum": [
            "active",
            "expired",
            "unknown"
          ]
        },
        "source": {
          "type": "string",
          "description": "Display name of the highest-precedence reporting source"
        },
        "sources": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Every government source reporting this AGRN+instrument for this LGA. Multiple entries = multiple sources corroborate it."
        },
        "sourceUrl": {
          "type": "string"
        },
        "sourcePublishedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "scope": {
          "type": "string",
          "enum": [
            "part_not_stated"
          ],
          "description": "Present only when we hold this record against a whole ABS catch-all area (for example Unincorporated SA) because the source's name for the area matches no part we can place. It still counts toward the status, except that a declaration held this way reads uncertain, never declared."
        },
        "publishedFor": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "With scope only: the sources' own names for the area, verbatim (for example \"Unincorporated South Australia (Gawler Ranges)\"), leaving out any that is just the ABS name. Omitted when none remain."
        }
      }
    },
    "MatchedLga": {
      "type": "object",
      "properties": {
        "lgaCode": {
          "type": "string"
        },
        "lgaName": {
          "type": "string"
        },
        "area": {
          "type": "object",
          "description": "Present only when the location is inside an ABS catch-all code whose parts we hold boundaries for (NSW and Victoria): the part it is in. lgaCode stays the ABS code, and records the sources place in a different part are left out.",
          "properties": {
            "code": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          }
        },
        "populationShare": {
          "type": [
            "number",
            "null"
          ],
          "description": "Share of the postcode's population in this LGA (ABS correspondence). Always the postcode-level share, even when the response is narrowed by suburb (never renormalised). null for point lookups, where population share is not a meaningful concept."
        },
        "declarationStatus": {
          "type": "string",
          "enum": [
            "declared",
            "uncertain",
            "activation_only",
            "not_declared"
          ]
        },
        "declarations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PostcodeDeclarationRecord"
          }
        }
      }
    },
    "PostcodeDeclarationRecord": {
      "allOf": [
        {
          "$ref": "#/$defs/DeclarationRecord"
        },
        {
          "type": "object",
          "properties": {
            "currencyConfidence": {
              "type": [
                "string",
                "null"
              ],
              "enum": [
                "strong",
                "moderate",
                "weak",
                null
              ],
              "description": "TCDE currency-confidence band for an in-force record (null when not in force). Transparent evidence, never a numeric 'chance you can bill' score."
            },
            "basis": {
              "type": "string",
              "description": "Short human-readable basis for this record's verdict (the evidence behind its status)."
            }
          }
        }
      ]
    },
    "SuburbNarrowing": {
      "type": "object",
      "description": "Present on postcode responses only when the suburb parameter was supplied.",
      "properties": {
        "requested": {
          "type": "string",
          "description": "The trimmed caller input (up to 100 characters)"
        },
        "applied": {
          "type": "boolean"
        },
        "method": {
          "type": "string",
          "enum": [
            "spatial_derivation",
            "abs_sal_lga_correspondence"
          ],
          "description": "How suburb-to-LGA membership was derived. spatial_derivation = area-weighted intersection of ABS SAL 2021 and LGA 2022 boundary polygons (the current source; ABS publishes no SAL 2021 to LGA 2022 correspondence); abs_sal_lga_correspondence = a published ABS population-weighted correspondence, if one is adopted later."
        },
        "matchedSuburbs": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "salCode": {
                "type": "string"
              },
              "salName": {
                "type": "string"
              }
            }
          },
          "description": "The ABS SAL suburb(s) the input matched within this postcode. More than one entry means the bare name denotes multiple suburbs (their LGA sets are unioned)."
        },
        "reason": {
          "type": "string",
          "enum": [
            "suburb_not_found_in_postcode",
            "suburb_lgas_outside_postcode",
            "unknown_postcode"
          ],
          "description": "Present only when applied is false"
        },
        "knownSuburbs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Present only when applied is false and the postcode is known: the postcode's suburb names, for typo recovery"
        }
      }
    }
  }
}