{
  "$id": "https://betterstood.com/developers/v31/schemas/mcp/intelligence_query.output.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "citations": {
              "items": {
                "additionalProperties": false,
                "properties": {
                  "citationId": {
                    "maxLength": 128,
                    "minLength": 1,
                    "type": "string"
                  },
                  "kind": {
                    "const": "AGGREGATE",
                    "type": "string"
                  },
                  "queryDigest": {
                    "pattern": "^[0-9a-f]{64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "citationId",
                  "kind",
                  "queryDigest"
                ],
                "type": "object"
              },
              "maxItems": 1,
              "type": "array"
            },
            "coverage": {
              "additionalProperties": false,
              "properties": {
                "asOf": {
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                  "type": "string"
                },
                "eligibleCalls": {
                  "maximum": 9007199254740991,
                  "minimum": 0,
                  "type": "integer"
                },
                "exact": {
                  "const": true,
                  "type": "boolean"
                },
                "scenarioRevisions": {
                  "items": {
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991,
                    "type": "integer"
                  },
                  "maxItems": 10000,
                  "type": "array"
                },
                "selectionMethod": {
                  "const": "FULL_EXACT",
                  "type": "string"
                },
                "truncated": {
                  "const": false,
                  "type": "boolean"
                }
              },
              "required": [
                "eligibleCalls",
                "exact",
                "truncated",
                "selectionMethod",
                "asOf",
                "scenarioRevisions"
              ],
              "type": "object"
            },
            "operation": {
              "const": "journey_count",
              "type": "string"
            },
            "pagination": {
              "type": "null"
            },
            "scope": {
              "additionalProperties": false,
              "properties": {
                "campaignKey": {
                  "anyOf": [
                    {
                      "maxLength": 128,
                      "minLength": 1,
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "campaignRevision": {
                  "anyOf": [
                    {
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991,
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "scenarioId": {
                  "maxLength": 128,
                  "minLength": 1,
                  "type": "string"
                },
                "scenarioRevision": {
                  "exclusiveMinimum": 0,
                  "maximum": 9007199254740991,
                  "type": "integer"
                }
              },
              "required": [
                "scenarioId",
                "scenarioRevision",
                "campaignKey",
                "campaignRevision"
              ],
              "type": "object"
            },
            "value": {
              "maximum": 9007199254740991,
              "minimum": 0,
              "type": "integer"
            }
          },
          "required": [
            "scope",
            "operation",
            "value",
            "coverage",
            "citations",
            "pagination"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "citations": {
              "items": {
                "additionalProperties": false,
                "properties": {
                  "citationId": {
                    "maxLength": 128,
                    "minLength": 1,
                    "type": "string"
                  },
                  "kind": {
                    "const": "AGGREGATE",
                    "type": "string"
                  },
                  "queryDigest": {
                    "pattern": "^[0-9a-f]{64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "citationId",
                  "kind",
                  "queryDigest"
                ],
                "type": "object"
              },
              "maxItems": 1,
              "type": "array"
            },
            "coverage": {
              "additionalProperties": false,
              "properties": {
                "asOf": {
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                  "type": "string"
                },
                "eligibleCalls": {
                  "maximum": 9007199254740991,
                  "minimum": 0,
                  "type": "integer"
                },
                "exact": {
                  "const": true,
                  "type": "boolean"
                },
                "scenarioRevisions": {
                  "items": {
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991,
                    "type": "integer"
                  },
                  "maxItems": 10000,
                  "type": "array"
                },
                "selectionMethod": {
                  "const": "FULL_EXACT",
                  "type": "string"
                },
                "truncated": {
                  "const": false,
                  "type": "boolean"
                }
              },
              "required": [
                "eligibleCalls",
                "exact",
                "truncated",
                "selectionMethod",
                "asOf",
                "scenarioRevisions"
              ],
              "type": "object"
            },
            "operation": {
              "const": "answer_distribution",
              "type": "string"
            },
            "pagination": {
              "additionalProperties": false,
              "properties": {
                "nextPage": {
                  "anyOf": [
                    {
                      "maximum": 9007199254740991,
                      "minimum": 0,
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "page": {
                  "maximum": 9007199254740991,
                  "minimum": 0,
                  "type": "integer"
                },
                "pageSize": {
                  "maximum": 9007199254740991,
                  "minimum": 0,
                  "type": "integer"
                },
                "total": {
                  "maximum": 9007199254740991,
                  "minimum": 0,
                  "type": "integer"
                },
                "truncated": {
                  "type": "boolean"
                }
              },
              "required": [
                "page",
                "pageSize",
                "total",
                "nextPage",
                "truncated"
              ],
              "type": "object"
            },
            "scope": {
              "additionalProperties": false,
              "properties": {
                "campaignKey": {
                  "anyOf": [
                    {
                      "maxLength": 128,
                      "minLength": 1,
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "campaignRevision": {
                  "anyOf": [
                    {
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991,
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "scenarioId": {
                  "maxLength": 128,
                  "minLength": 1,
                  "type": "string"
                },
                "scenarioRevision": {
                  "exclusiveMinimum": 0,
                  "maximum": 9007199254740991,
                  "type": "integer"
                }
              },
              "required": [
                "scenarioId",
                "scenarioRevision",
                "campaignKey",
                "campaignRevision"
              ],
              "type": "object"
            },
            "value": {
              "additionalProperties": false,
              "properties": {
                "answered": {
                  "maximum": 9007199254740991,
                  "minimum": 0,
                  "type": "integer"
                },
                "definitionDiscontinuity": {
                  "type": "boolean"
                },
                "eligible": {
                  "maximum": 9007199254740991,
                  "minimum": 0,
                  "type": "integer"
                },
                "fieldDefinitionHash": {
                  "maxLength": 128,
                  "minLength": 1,
                  "type": "string"
                },
                "fieldLabel": {
                  "maxLength": 1500,
                  "type": "string"
                },
                "values": {
                  "items": {
                    "additionalProperties": false,
                    "properties": {
                      "count": {
                        "maximum": 9007199254740991,
                        "minimum": 0,
                        "type": "integer"
                      },
                      "label": {
                        "maxLength": 1500,
                        "type": "string"
                      },
                      "value": {
                        "maxLength": 1500,
                        "type": "string"
                      }
                    },
                    "required": [
                      "value",
                      "label",
                      "count"
                    ],
                    "type": "object"
                  },
                  "maxItems": 50,
                  "type": "array"
                }
              },
              "required": [
                "fieldLabel",
                "fieldDefinitionHash",
                "definitionDiscontinuity",
                "eligible",
                "answered",
                "values"
              ],
              "type": "object"
            }
          },
          "required": [
            "scope",
            "operation",
            "value",
            "coverage",
            "citations",
            "pagination"
          ],
          "type": "object"
        }
      ]
    },
    {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "NOT_FOUND",
            "REVISION_CONFLICT",
            "RESOURCE_LOCKED",
            "SCENARIO_LOCKED",
            "CAMPAIGN_LOCKED",
            "VALIDATION_FAILED",
            "QUOTA_EXCEEDED",
            "TOOL_NOT_AVAILABLE",
            "IDEMPOTENCY_KEY_REUSED",
            "REMOVAL_ACKNOWLEDGEMENT_REQUIRED",
            "UNAUTHORIZED",
            "FORBIDDEN",
            "RATE_LIMITED",
            "SERVICE_UNAVAILABLE"
          ],
          "type": "string"
        },
        "currentRevision": {
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991,
          "type": "integer"
        },
        "docsUrl": {
          "maxLength": 2048,
          "type": "string"
        },
        "editorUrl": {
          "maxLength": 2048,
          "type": "string"
        },
        "expectedRevision": {
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991,
          "type": "integer"
        },
        "field": {
          "maxLength": 256,
          "type": "string"
        },
        "issues": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "maxLength": 128,
                "type": "string"
              },
              "message": {
                "maxLength": 1024,
                "type": "string"
              },
              "path": {
                "maxLength": 512,
                "type": "string"
              }
            },
            "required": [
              "path",
              "code",
              "message"
            ],
            "type": "object"
          },
          "maxItems": 100,
          "type": "array"
        },
        "message": {
          "maxLength": 1024,
          "minLength": 1,
          "type": "string"
        },
        "retryable": {
          "type": "boolean"
        },
        "studioUrl": {
          "maxLength": 2048,
          "type": "string"
        }
      },
      "required": [
        "code",
        "message",
        "retryable"
      ],
      "type": "object"
    }
  ],
  "title": "intelligence_query output",
  "type": "object"
}
