{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://doc.g3nretailstack.com/common/schemas/request-context.schema.json",
  "title": "Request Context",
  "type": "object",
  "properties": {
    "orgcode": { "type": "string" },
    "org_guid": { "type": "string" },
    "logical_guid": { "type": "string" },
    "channel_code": { "type": "string" },
    "cccode": { "type": "string" },
    "actor": { "type": "string" },
    "roles": {
      "type": "array",
      "items": { "type": "string" }
    },
    "context_source": {
      "type": "string",
      "enum": ["session", "api_key", "operator", "system"]
    },
    "session_fingerprint": { "type": "string" },
    "api_key_fingerprint": { "type": "string" }
  },
  "required": ["orgcode", "actor", "context_source"],
  "allOf": [
    {
      "if": {
        "properties": { "context_source": { "const": "session" } }
      },
      "then": {
        "required": ["session_fingerprint"]
      }
    },
    {
      "if": {
        "properties": { "context_source": { "const": "api_key" } }
      },
      "then": {
        "required": ["api_key_fingerprint"]
      }
    }
  ],
  "additionalProperties": false
}
