{
  "$id": "https://betterstood.com/developers/v31/schemas/mcp/campaign_prepare_publish.output.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "additionalProperties": false,
      "properties": {
        "operation": {
          "additionalProperties": false,
          "properties": {
            "approvalRequired": {
              "type": "boolean"
            },
            "approvalUrl": {
              "anyOf": [
                {
                  "maxLength": 2048,
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "approvedAt": {
              "anyOf": [
                {
                  "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"
                },
                {
                  "type": "null"
                }
              ]
            },
            "cancellable": {
              "type": "boolean"
            },
            "completedAt": {
              "anyOf": [
                {
                  "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"
                },
                {
                  "type": "null"
                }
              ]
            },
            "error": {
              "anyOf": [
                {
                  "enum": [
                    "AUTHORIZATION_CHANGED",
                    "APPROVAL_EXPIRED",
                    "REVISION_CONFLICT",
                    "PREVIEW_CHANGED",
                    "CONDITIONS_CHANGED",
                    "INVALID_APPROVAL",
                    "EXECUTION_FAILED",
                    "RECOVERY_REQUIRED",
                    "CONFIGURATION_CHANGED_AFTER_EXECUTION"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "expiresAt": {
              "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"
            },
            "operationId": {
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
              "type": "string"
            },
            "preview": {
              "anyOf": [
                {
                  "additionalProperties": false,
                  "properties": {
                    "campaignKey": {
                      "maxLength": 128,
                      "minLength": 1,
                      "type": "string"
                    },
                    "campaignName": {
                      "maxLength": 256,
                      "type": "string"
                    },
                    "campaignRevision": {
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991,
                      "type": "integer"
                    },
                    "changes": {
                      "items": {
                        "additionalProperties": false,
                        "properties": {
                          "after": {
                            "maxLength": 32,
                            "type": "string"
                          },
                          "before": {
                            "maxLength": 32,
                            "type": "string"
                          },
                          "field": {
                            "enum": [
                              "status",
                              "accessMode"
                            ],
                            "type": "string"
                          }
                        },
                        "required": [
                          "field",
                          "before",
                          "after"
                        ],
                        "type": "object"
                      },
                      "maxItems": 2,
                      "minItems": 1,
                      "type": "array"
                    },
                    "cost": {
                      "additionalProperties": false,
                      "properties": {
                        "billingMode": {
                          "const": "included",
                          "type": "string"
                        },
                        "collectionBilledSeparately": {
                          "const": true,
                          "type": "boolean"
                        },
                        "estimated": {
                          "const": 0,
                          "type": "number"
                        },
                        "maximum": {
                          "const": 0,
                          "type": "number"
                        },
                        "unit": {
                          "const": "credits",
                          "type": "string"
                        }
                      },
                      "required": [
                        "unit",
                        "estimated",
                        "maximum",
                        "billingMode",
                        "collectionBilledSeparately"
                      ],
                      "type": "object"
                    },
                    "effects": {
                      "items": {
                        "enum": [
                          "activate_campaign",
                          "stop_new_collection",
                          "cancel_scheduled_callbacks",
                          "allow_public_collection_when_active",
                          "require_password_setup",
                          "revoke_existing_access_sessions_and_invites"
                        ],
                        "type": "string"
                      },
                      "maxItems": 4,
                      "type": "array"
                    },
                    "kind": {
                      "enum": [
                        "campaign_publish",
                        "campaign_unpublish",
                        "campaign_access"
                      ],
                      "type": "string"
                    },
                    "scenarioId": {
                      "maxLength": 128,
                      "minLength": 1,
                      "type": "string"
                    },
                    "scenarioRevision": {
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991,
                      "type": "integer"
                    },
                    "scheduledCallbackCount": {
                      "maximum": 9007199254740991,
                      "minimum": 0,
                      "type": "integer"
                    }
                  },
                  "required": [
                    "kind",
                    "campaignKey",
                    "campaignName",
                    "campaignRevision",
                    "scenarioId",
                    "scenarioRevision",
                    "changes",
                    "effects",
                    "cost"
                  ],
                  "type": "object"
                },
                {
                  "additionalProperties": false,
                  "properties": {
                    "cost": {
                      "additionalProperties": false,
                      "properties": {
                        "billingMode": {
                          "const": "included",
                          "type": "string"
                        },
                        "collectionBilledSeparately": {
                          "const": false,
                          "type": "boolean"
                        },
                        "estimated": {
                          "const": 0,
                          "type": "number"
                        },
                        "maximum": {
                          "const": 0,
                          "type": "number"
                        },
                        "unit": {
                          "const": "credits",
                          "type": "string"
                        }
                      },
                      "required": [
                        "unit",
                        "estimated",
                        "maximum",
                        "billingMode",
                        "collectionBilledSeparately"
                      ],
                      "type": "object"
                    },
                    "effects": {
                      "items": {
                        "enum": [
                          "store_private_source",
                          "fetch_public_https_url"
                        ],
                        "type": "string"
                      },
                      "maxItems": 2,
                      "minItems": 1,
                      "type": "array"
                    },
                    "kind": {
                      "const": "knowledge_stage",
                      "type": "string"
                    },
                    "scenarioId": {
                      "maxLength": 128,
                      "minLength": 1,
                      "type": "string"
                    },
                    "scenarioName": {
                      "maxLength": 256,
                      "type": "string"
                    },
                    "scenarioRevision": {
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991,
                      "type": "integer"
                    },
                    "source": {
                      "additionalProperties": false,
                      "properties": {
                        "kind": {
                          "enum": [
                            "file",
                            "url"
                          ],
                          "type": "string"
                        },
                        "label": {
                          "maxLength": 2048,
                          "type": "string"
                        },
                        "sha256": {
                          "anyOf": [
                            {
                              "pattern": "^[a-f0-9]{64}$",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "sizeBytes": {
                          "anyOf": [
                            {
                              "maximum": 131072,
                              "minimum": 1,
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "kind",
                        "label",
                        "sizeBytes",
                        "sha256"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "kind",
                    "scenarioId",
                    "scenarioName",
                    "scenarioRevision",
                    "source",
                    "effects",
                    "cost"
                  ],
                  "type": "object"
                },
                {
                  "additionalProperties": false,
                  "properties": {
                    "cost": {
                      "additionalProperties": false,
                      "properties": {
                        "billingMode": {
                          "enum": [
                            "included",
                            "shadow",
                            "enforce"
                          ],
                          "type": "string"
                        },
                        "collectionBilledSeparately": {
                          "const": false,
                          "type": "boolean"
                        },
                        "estimated": {
                          "maximum": 200,
                          "minimum": 0,
                          "type": "integer"
                        },
                        "maximum": {
                          "maximum": 200,
                          "minimum": 0,
                          "type": "integer"
                        },
                        "unit": {
                          "const": "credits",
                          "type": "string"
                        }
                      },
                      "required": [
                        "unit",
                        "estimated",
                        "maximum",
                        "billingMode",
                        "collectionBilledSeparately"
                      ],
                      "type": "object"
                    },
                    "effects": {
                      "items": {
                        "enum": [
                          "publish_private_knowledge",
                          "remove_private_source",
                          "disable_private_knowledge",
                          "validate_private_retrieval"
                        ],
                        "type": "string"
                      },
                      "maxItems": 2,
                      "minItems": 1,
                      "type": "array"
                    },
                    "kind": {
                      "enum": [
                        "knowledge_publish",
                        "knowledge_remove",
                        "knowledge_validate"
                      ],
                      "type": "string"
                    },
                    "knowledgeBaseRevisionId": {
                      "maxLength": 128,
                      "minLength": 1,
                      "type": "string"
                    },
                    "manifestHash": {
                      "maxLength": 128,
                      "minLength": 1,
                      "type": "string"
                    },
                    "query": {
                      "anyOf": [
                        {
                          "maxLength": 2000,
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scenarioId": {
                      "maxLength": 128,
                      "minLength": 1,
                      "type": "string"
                    },
                    "scenarioName": {
                      "maxLength": 256,
                      "type": "string"
                    },
                    "scenarioRevision": {
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991,
                      "type": "integer"
                    },
                    "sourceLabel": {
                      "anyOf": [
                        {
                          "maxLength": 2048,
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "kind",
                    "scenarioId",
                    "scenarioName",
                    "scenarioRevision",
                    "knowledgeBaseRevisionId",
                    "manifestHash",
                    "sourceLabel",
                    "query",
                    "effects",
                    "cost"
                  ],
                  "type": "object"
                }
              ]
            },
            "result": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "properties": {
                        "configurationUpdated": {
                          "type": "boolean"
                        },
                        "knowledgeBaseRevisionId": {
                          "maxLength": 128,
                          "minLength": 1,
                          "type": "string"
                        },
                        "publicationStatus": {
                          "enum": [
                            "published",
                            "partial",
                            "failed",
                            "empty"
                          ],
                          "type": "string"
                        },
                        "revision": {
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991,
                          "type": "integer"
                        },
                        "scenarioId": {
                          "maxLength": 128,
                          "minLength": 1,
                          "type": "string"
                        },
                        "validation": {
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "properties": {
                                "query": {
                                  "maxLength": 2000,
                                  "type": "string"
                                },
                                "resultCount": {
                                  "maximum": 10,
                                  "minimum": 0,
                                  "type": "integer"
                                },
                                "validatedAt": {
                                  "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"
                                }
                              },
                              "required": [
                                "query",
                                "resultCount",
                                "validatedAt"
                              ],
                              "type": "object"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "scenarioId",
                        "revision",
                        "knowledgeBaseRevisionId",
                        "publicationStatus",
                        "configurationUpdated",
                        "validation"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": false,
                      "properties": {
                        "accessMode": {
                          "enum": [
                            "PUBLIC_WEB",
                            "PASSWORD",
                            "INVITE_LINK"
                          ],
                          "type": "string"
                        },
                        "campaignKey": {
                          "maxLength": 128,
                          "minLength": 1,
                          "type": "string"
                        },
                        "revision": {
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "DRAFT",
                            "ACTIVE",
                            "PAUSED",
                            "ARCHIVED"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "campaignKey",
                        "revision",
                        "status",
                        "accessMode"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": false,
                      "properties": {
                        "knowledgeBaseRevisionId": {
                          "maxLength": 128,
                          "minLength": 1,
                          "type": "string"
                        },
                        "publicationStatus": {
                          "const": "draft",
                          "type": "string"
                        },
                        "revision": {
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991,
                          "type": "integer"
                        },
                        "scenarioId": {
                          "maxLength": 128,
                          "minLength": 1,
                          "type": "string"
                        }
                      },
                      "required": [
                        "scenarioId",
                        "revision",
                        "knowledgeBaseRevisionId",
                        "publicationStatus"
                      ],
                      "type": "object"
                    }
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "retainedUntil": {
              "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"
            },
            "state": {
              "enum": [
                "awaiting_approval",
                "queued",
                "running",
                "succeeded",
                "failed",
                "cancelled",
                "expired"
              ],
              "type": "string"
            },
            "statusUrl": {
              "maxLength": 2048,
              "type": "string"
            }
          },
          "required": [
            "operationId",
            "state",
            "preview",
            "approvalRequired",
            "approvalUrl",
            "statusUrl",
            "expiresAt",
            "retainedUntil",
            "approvedAt",
            "completedAt",
            "cancellable",
            "result",
            "error"
          ],
          "type": "object"
        },
        "replayed": {
          "type": "boolean"
        }
      },
      "required": [
        "operation",
        "replayed"
      ],
      "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": "campaign_prepare_publish output",
  "type": "object"
}
