{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/stackdata-io/json-schema/stackdata-io-data-response-schema.json",
  "title": "DataResponse",
  "description": "Status-tagged answer. `status` names the outcome — success (`ok`, `ok_correlation`,\n`ok_coverage`) or an honest non-answer (`empty`, `no_candidates`, `dsd_unavailable`,\n`multi_concept_unparsed`, `language_unsupported`, `tariff_redirect`, `unit_mismatch`,\n…). `billing.charged` says whether an\nuncached fetch was paid for. `interpreted_as` appears when an LLM rewrote the prompt.\nWhen `status` is `empty`, `reason` may begin `pin_unavailable:` — the source's serve set\npins a statistic that this request cannot hold, and no other member is substituted.\n",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/stackdata-io-openapi.json#/components/schemas/DataResponse",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    },
    "pin_unavailable": {
      "type": "array",
      "description": "Present on a non-ok answer when one or more candidate datasets were skipped because their serve-set pin could not hold. It accompanies the answer's own `reason` and never replaces it.",
      "items": {
        "type": "object",
        "properties": {
          "dataset": {
            "type": "string"
          },
          "dimension": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "why": {
            "type": "string"
          }
        }
      }
    },
    "pinned": {
      "type": "array",
      "description": "Present when the answer was served under a serve-set pin (the source declares one member per dimension for this dataset). Each cell also carries `pinned_by` and `pins`.",
      "items": {
        "type": "object",
        "properties": {
          "dimension": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "rule": {
            "type": "string",
            "enum": [
              "serve.pin"
            ]
          }
        }
      }
    },
    "billing": {
      "type": "object",
      "properties": {
        "charged": {
          "type": "boolean"
        }
      }
    },
    "scope_note": {
      "type": [
        "string",
        "null"
      ],
      "description": "Present when the country on the series did not come from a code in the data. Either a named region is the publisher's own aggregate (not a sum of members), or the source publishes exactly one country and this dataflow carries no geography dimension, so every value is that country's by the publisher's declared scope (cells then carry `country_binding: source_scope`)."
    },
    "fallback": {
      "type": [
        "object",
        "null"
      ],
      "description": "Present when the top-ranked candidate refused by its own declared structure (for example a PxWeb table declared out of scope, or one whose time axis cannot be read) and a lower candidate answered. `skipped` is the refused dataset id and `why` its refusal. When no lower candidate answers, the response is the top candidate's own `dsd_unavailable`, with `fallback_tried` listing the ids tried.",
      "properties": {
        "skipped": {
          "type": "string"
        },
        "why": {
          "type": "string"
        },
        "note": {
          "type": "string"
        }
      }
    },
    "fallback_tried": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      }
    },
    "coverage": {
      "type": "object",
      "additionalProperties": true
    },
    "withheld": {
      "type": [
        "object",
        "null"
      ],
      "description": "Present and non-null only when the publisher HOLDS observations in this window\nand states they may not be shown as numbers — today, Statistics Canada cells\nsuppressed under the Statistics Act (`securityLevelCode` 1) or flagged too\nunreliable to be published (`statusCode` 8). Those points are absent from\n`series`, and absent is not zero, so the count, the publisher's own stated\nreasons and the affected periods are reported rather than left as a gap.\n`null` for every source that flags nothing. It also appears on `status:\n\"empty\"`, where it is the difference between \"the source holds nothing\" and\n\"the source holds it and may not show it\" — and the `reason` then says so.\n",
      "properties": {
        "count": {
          "$ref": "#/$defs/TypedCount"
        },
        "note": {
          "type": [
            "string",
            "null"
          ]
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The publisher's own wording, never paraphrased."
        },
        "periods": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    },
    "interpreted_as": {
      "type": "object",
      "additionalProperties": true
    },
    "payment": {
      "type": "object",
      "description": "Present only on the x402 path — settlement outcome for the answer.",
      "additionalProperties": true
    },
    "meta": {
      "$ref": "#/$defs/Meta"
    }
  },
  "additionalProperties": true,
  "$defs": {
    "Meta": {
      "type": "object",
      "description": "Attached to every JSON response. `harvest` maps each source id to its last successful harvest timestamp.",
      "properties": {
        "harvest": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "api_version": {
          "type": "string"
        }
      }
    },
    "TypedCount": {
      "type": "object",
      "description": "A count that states whether it is exact — never a bare integer.",
      "required": [
        "value",
        "exact"
      ],
      "properties": {
        "value": {
          "type": "integer"
        },
        "exact": {
          "type": "boolean"
        }
      }
    }
  }
}