{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sweetvaluelab-com/json-schema/sweetvaluelab-com-envelope-schema.json",
  "title": "Envelope",
  "description": "Every endpoint on every service returns this shape. `ok` says which half is filled: on success `data` holds the payload and `error` is null; on failure `data` is null and `error` says why.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sweetvaluelab-com-openapi.json#/components/schemas/Envelope",
  "type": "object",
  "required": [
    "ok",
    "schema_version",
    "as_of",
    "code_version",
    "data",
    "error"
  ],
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "schema_version": {
      "type": "string",
      "description": "Envelope contract version, currently \"1\". It changes only on a breaking change to this shape."
    },
    "as_of": {
      "type": "string",
      "format": "date",
      "description": "The day the payload speaks for."
    },
    "code_version": {
      "type": "string",
      "description": "The build that produced the payload. With as_of it is what makes a figure reproducible."
    },
    "data": {
      "description": "The payload, or null on failure.",
      "type": [
        "object",
        "array",
        "null"
      ]
    },
    "error": {
      "oneOf": [
        {
          "$ref": "#/$defs/ErrorDetail"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "$defs": {
    "ErrorDetail": {
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "Stable machine-readable code, e.g. not_found, bad_request."
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "object",
          "additionalProperties": true
        }
      }
    }
  }
}