{
  "openapi": "3.1.0",
  "info": {
    "title": "SplitTesty REST API",
    "version": "1.0.0",
    "description": "Manage campaigns, variations and metrics and read report data from your own systems.\n\nAuthentication: send a personal API token (Settings → API tokens) as \"Authorization: Bearer <token>\". A token belongs to one workspace; every request is confined to that workspace. Scopes are hierarchical (publish ⊃ edit ⊃ browse) and a token never exceeds the current role of the user who created it.\n\nRate limit: 120 requests per minute and token. Every response carries X-RateLimit-* headers; a 429 response also carries Retry-After.\n\nPagination: list endpoints return { data, next_cursor, has_more }. Pass next_cursor unchanged as ?cursor= to read the next page.\n\nErrors: { \"error\": { \"code\", \"message\", \"details\"? } } with a matching HTTP status. The API is intended for server-to-server use: CORS is not enabled and responses are never cached."
  },
  "servers": [
    {
      "url": "/api/v1",
      "description": "This dashboard"
    }
  ],
  "tags": [
    {
      "name": "Workspaces",
      "description": "The workspace a token belongs to."
    },
    {
      "name": "Campaigns",
      "description": "Experiments, rollouts and personalizations."
    },
    {
      "name": "Variations",
      "description": "The arms of a campaign."
    },
    {
      "name": "Metrics",
      "description": "Reusable goals."
    },
    {
      "name": "Reports",
      "description": "Collected data per metric and variation."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/workspaces": {
      "get": {
        "operationId": "workspaces_list",
        "summary": "Get the token's workspace",
        "tags": [
          "Workspaces"
        ],
        "security": [
          {
            "bearerAuth": [
              "browse"
            ]
          }
        ],
        "x-required-scope": "browse",
        "description": "Returns a list with exactly one entry: the workspace the token is bound to.",
        "responses": {
          "200": {
            "description": "The workspace.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Workspace"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as ?cursor= to fetch the next page; null on the last page."
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/campaigns": {
      "get": {
        "operationId": "campaigns_list",
        "summary": "List campaigns",
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerAuth": [
              "browse"
            ]
          }
        ],
        "x-required-scope": "browse",
        "description": "Newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Page size (1–100).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "next_cursor of the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Only campaigns in this status.",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "qa",
                "scheduled",
                "running",
                "paused",
                "archived"
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Only campaigns of this type.",
            "schema": {
              "type": "string",
              "enum": [
                "ab",
                "multipage",
                "split",
                "mvt",
                "rollout",
                "personalization"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of campaigns.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Campaign"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as ?cursor= to fetch the next page; null on the last page."
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": 42,
                      "name": "Pricing page headline",
                      "type": "ab",
                      "status": "draft",
                      "url": "https://www.example.com/pricing",
                      "notes": null,
                      "traffic": 100,
                      "traffic_split": "equal",
                      "created_at": "2026-03-02T09:15:00.000Z",
                      "updated_at": "2026-03-02T09:15:00.000Z",
                      "started_at": null,
                      "stopped_at": null,
                      "result": null
                    }
                  ],
                  "next_cursor": null,
                  "has_more": false
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "campaigns_create",
        "summary": "Create a campaign",
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerAuth": [
              "edit"
            ]
          }
        ],
        "x-required-scope": "edit",
        "description": "Creates a draft. Tests start with a control and one variation; when a URL is given it becomes the first page rule.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CampaignCreate"
              },
              "example": {
                "name": "Pricing page headline",
                "type": "ab",
                "url": "https://www.example.com/pricing"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created campaign.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CampaignDetail"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/campaigns/{id}": {
      "get": {
        "operationId": "campaigns_get",
        "summary": "Get a campaign",
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerAuth": [
              "browse"
            ]
          }
        ],
        "x-required-scope": "browse",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric campaign id as shown in the dashboard.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The campaign with its pages, variations and metrics.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CampaignDetail"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "campaigns_update",
        "summary": "Update a campaign",
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerAuth": [
              "edit"
            ]
          }
        ],
        "x-required-scope": "edit",
        "description": "Partial update. name, notes and stats can always be changed; everything else on a running campaign needs confirm_running: true (409 confirm_running otherwise). Archived campaigns are read-only.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric campaign id as shown in the dashboard.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CampaignUpdate"
              },
              "example": {
                "name": "Pricing headline v2",
                "traffic": 50
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated campaign.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CampaignDetail"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "campaigns_delete",
        "summary": "Delete a campaign",
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerAuth": [
              "edit"
            ]
          }
        ],
        "x-required-scope": "edit",
        "description": "Permanently deletes the campaign and its data. As in the dashboard this is an admin action: besides the edit scope, the token's owner must currently be an admin or owner. Running campaigns must be paused first.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric campaign id as shown in the dashboard.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/campaigns/{id}/status": {
      "post": {
        "operationId": "campaigns_status",
        "summary": "Start, pause or archive a campaign",
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerAuth": [
              "publish"
            ]
          }
        ],
        "x-required-scope": "publish",
        "description": "start → running (runs the launch checks; 422 not_ready lists what is missing), pause → paused, archive → archived. Emits the campaign.status_changed webhook.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric campaign id as shown in the dashboard.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CampaignStatusChange"
              },
              "example": {
                "action": "start"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The campaign in its new status.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/NotReady"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/campaigns/{id}/variations": {
      "get": {
        "operationId": "variations_list",
        "summary": "List variations",
        "tags": [
          "Variations"
        ],
        "security": [
          {
            "bearerAuth": [
              "browse"
            ]
          }
        ],
        "x-required-scope": "browse",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric campaign id as shown in the dashboard.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "All variations of the campaign (never paginated; at most 20).",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Variation"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as ?cursor= to fetch the next page; null on the last page."
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "key": "v1",
                      "name": "Variation 1",
                      "is_control": false,
                      "weight": 50,
                      "disabled": false,
                      "redirect_url": null,
                      "changes": [
                        {
                          "page": null,
                          "ops": [],
                          "js": null,
                          "css": null
                        }
                      ]
                    }
                  ],
                  "next_cursor": null,
                  "has_more": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "variations_create",
        "summary": "Add a variation",
        "tags": [
          "Variations"
        ],
        "security": [
          {
            "bearerAuth": [
              "edit"
            ]
          }
        ],
        "x-required-scope": "edit",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric campaign id as shown in the dashboard.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VariationCreate"
              },
              "example": {
                "name": "Shorter headline"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created variation.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Variation"
                },
                "example": {
                  "key": "v1",
                  "name": "Variation 1",
                  "is_control": false,
                  "weight": 50,
                  "disabled": false,
                  "redirect_url": null,
                  "changes": [
                    {
                      "page": null,
                      "ops": [],
                      "js": null,
                      "css": null
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/campaigns/{id}/variations/{key}": {
      "patch": {
        "operationId": "variations_update",
        "summary": "Update a variation",
        "tags": [
          "Variations"
        ],
        "security": [
          {
            "bearerAuth": [
              "edit"
            ]
          }
        ],
        "x-required-scope": "edit",
        "description": "Renaming is always allowed; other changes on a running campaign need confirm_running: true.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric campaign id as shown in the dashboard.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "Stable key of the variation, e.g. v1.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VariationUpdate"
              },
              "example": {
                "weight": 30,
                "changes": [
                  {
                    "ops": [
                      {
                        "id": "op1",
                        "type": "setText",
                        "selector": "h1",
                        "payload": {
                          "text": "Grow faster"
                        }
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated variation.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Variation"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "variations_delete",
        "summary": "Delete a variation",
        "tags": [
          "Variations"
        ],
        "security": [
          {
            "bearerAuth": [
              "edit"
            ]
          }
        ],
        "x-required-scope": "edit",
        "description": "Only possible before the campaign has collected data; afterwards disable the variation instead. The control cannot be deleted.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric campaign id as shown in the dashboard.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "Stable key of the variation, e.g. v1.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "confirm_running",
            "in": "query",
            "description": "Set to true to confirm the change on a running campaign.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/metrics": {
      "get": {
        "operationId": "metrics_list",
        "summary": "List metrics",
        "tags": [
          "Metrics"
        ],
        "security": [
          {
            "bearerAuth": [
              "browse"
            ]
          }
        ],
        "x-required-scope": "browse",
        "description": "Newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Page size (1–100).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "next_cursor of the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_archived",
            "in": "query",
            "description": "Include archived metrics.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "false"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of metrics.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Metric"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as ?cursor= to fetch the next page; null on the last page."
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "metrics_create",
        "summary": "Create a metric",
        "tags": [
          "Metrics"
        ],
        "security": [
          {
            "bearerAuth": [
              "edit"
            ]
          }
        ],
        "x-required-scope": "edit",
        "description": "The required fields depend on the type: click / formSubmit / elementVisible need selector; pageView / linkClick need url; custom needs event; timeOnPage / scrollDepth need threshold; sum and average need a revenue or custom event.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MetricCreate"
              },
              "example": {
                "name": "Signup click",
                "type": "click",
                "selector": "#signup",
                "category": "conversion"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created metric.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metric"
                },
                "example": {
                  "key": "m_3f9a1c20be",
                  "name": "Signup click",
                  "description": null,
                  "type": "click",
                  "aggregation": "uniqueVisitors",
                  "direction": "increase",
                  "category": "conversion",
                  "selector": "#signup",
                  "url": null,
                  "event": null,
                  "property": null,
                  "threshold": null,
                  "archived": false,
                  "created_at": "2026-03-02T09:15:00.000Z",
                  "used_in": 0
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/metrics/{key}": {
      "get": {
        "operationId": "metrics_get",
        "summary": "Get a metric",
        "tags": [
          "Metrics"
        ],
        "security": [
          {
            "bearerAuth": [
              "browse"
            ]
          }
        ],
        "x-required-scope": "browse",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "Stable key of the metric, e.g. m_revenue.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The metric.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metric"
                },
                "example": {
                  "key": "m_3f9a1c20be",
                  "name": "Signup click",
                  "description": null,
                  "type": "click",
                  "aggregation": "uniqueVisitors",
                  "direction": "increase",
                  "category": "conversion",
                  "selector": "#signup",
                  "url": null,
                  "event": null,
                  "property": null,
                  "threshold": null,
                  "archived": false,
                  "created_at": "2026-03-02T09:15:00.000Z",
                  "used_in": 0
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/campaigns/{id}/report": {
      "get": {
        "operationId": "reports_get",
        "summary": "Get report data",
        "tags": [
          "Reports"
        ],
        "security": [
          {
            "bearerAuth": [
              "browse"
            ]
          }
        ],
        "x-required-scope": "browse",
        "description": "Totals per metric and variation. stats holds the statistics computed by the dashboard report for the same date range when they have been computed already, otherwise null.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric campaign id as shown in the dashboard.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "First day (UTC), inclusive.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day (UTC), inclusive.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report.",
            "headers": {
              "X-RateLimit-Limit": {
                "description": "Requests allowed per minute for this token.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Unix time (seconds) at which the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "spt_pat_…",
        "description": "Personal API token created under Settings → API tokens."
      }
    },
    "responses": {
      "Unauthenticated": {
        "description": "Missing, invalid, expired or revoked token.",
        "headers": {
          "X-RateLimit-Limit": {
            "description": "Requests allowed per minute for this token.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Requests left in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "Unix time (seconds) at which the window resets.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "unauthenticated",
                "message": "Invalid API token."
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "The token lacks the required scope, or its owner's role no longer allows the action.",
        "headers": {
          "X-RateLimit-Limit": {
            "description": "Requests allowed per minute for this token.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Requests left in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "Unix time (seconds) at which the window resets.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "forbidden",
                "message": "This API token lacks the \"edit\" scope."
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "The resource does not exist in the token's workspace.",
        "headers": {
          "X-RateLimit-Limit": {
            "description": "Requests allowed per minute for this token.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Requests left in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "Unix time (seconds) at which the window resets.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "not_found",
                "message": "Campaign not found."
              }
            }
          }
        }
      },
      "Invalid": {
        "description": "The request is malformed or fails validation.",
        "headers": {
          "X-RateLimit-Limit": {
            "description": "Requests allowed per minute for this token.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Requests left in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "Unix time (seconds) at which the window resets.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "invalid_request",
                "message": "Invalid body: name is required.",
                "details": {
                  "issues": [
                    {
                      "path": "name",
                      "message": "is required"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "Conflict": {
        "description": "The current state does not allow the change (code conflict), or a running campaign needs confirm_running (code confirm_running).",
        "headers": {
          "X-RateLimit-Limit": {
            "description": "Requests allowed per minute for this token.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Requests left in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "Unix time (seconds) at which the window resets.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "confirm_running",
                "message": "This campaign is running. …"
              }
            }
          }
        }
      },
      "NotReady": {
        "description": "The campaign fails the launch checks.",
        "headers": {
          "X-RateLimit-Limit": {
            "description": "Requests allowed per minute for this token.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Requests left in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "Unix time (seconds) at which the window resets.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "not_ready",
                "message": "This campaign is not ready: Choose a primary metric (Metrics step).",
                "details": {
                  "problems": [
                    "Choose a primary metric (Metrics step)."
                  ]
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded.",
        "headers": {
          "X-RateLimit-Limit": {
            "description": "Requests allowed per minute for this token.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Requests left in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "Unix time (seconds) at which the window resets.",
            "schema": {
              "type": "integer"
            }
          },
          "Retry-After": {
            "description": "Seconds to wait before retrying.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "rate_limited",
                "message": "Rate limit exceeded. Retry in 17 seconds."
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Machine-readable code.",
                "enum": [
                  "unauthenticated",
                  "forbidden",
                  "not_found",
                  "invalid_request",
                  "conflict",
                  "confirm_running",
                  "not_ready",
                  "rate_limited",
                  "internal"
                ]
              },
              "message": {
                "type": "string",
                "description": "Human-readable explanation."
              },
              "details": {
                "type": "object",
                "description": "Optional extra information, e.g. validation issues or launch problems.",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "Workspace": {
        "type": "object",
        "required": [
          "account_id",
          "name"
        ],
        "properties": {
          "account_id": {
            "type": "integer",
            "description": "Public account id used in the install snippet."
          },
          "name": {
            "type": "string"
          },
          "organization": {
            "type": [
              "string",
              "null"
            ]
          },
          "timezone": {
            "type": "string"
          },
          "data_region": {
            "type": [
              "string",
              "null"
            ]
          },
          "require_consent": {
            "type": "boolean",
            "description": "Whether tracking waits for visitor consent."
          },
          "retention_days": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "token": {
            "type": "object",
            "description": "The token used for this request.",
            "properties": {
              "name": {
                "type": "string"
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "browse",
                    "edit",
                    "publish"
                  ]
                }
              },
              "owner_role": {
                "type": "string",
                "description": "Current role of the user who created the token."
              },
              "expires_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        }
      },
      "Campaign": {
        "type": "object",
        "required": [
          "id",
          "name",
          "type",
          "status"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "description": "Numeric id, unique within the workspace."
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "ab",
              "multipage",
              "split",
              "mvt",
              "rollout",
              "personalization"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "qa",
              "scheduled",
              "running",
              "paused",
              "archived"
            ]
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Primary URL of the campaign."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "traffic": {
            "type": "number",
            "description": "Share of visitors included in the campaign, 0–100.",
            "minimum": 0,
            "maximum": 100
          },
          "traffic_split": {
            "type": "string",
            "enum": [
              "equal",
              "custom"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "stopped_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "result": {
            "type": [
              "object",
              "null"
            ],
            "description": "Latest result summary, once a report has been computed.",
            "properties": {
              "decision": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "improvement": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "winner": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "visitors": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "CampaignDetail": {
        "type": "object",
        "description": "A Campaign plus its configuration.",
        "required": [
          "id",
          "name",
          "type",
          "status",
          "pages",
          "variations",
          "metrics"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "ab",
              "multipage",
              "split",
              "mvt",
              "rollout",
              "personalization"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "qa",
              "scheduled",
              "running",
              "paused",
              "archived"
            ]
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "traffic": {
            "type": "number"
          },
          "traffic_split": {
            "type": "string",
            "enum": [
              "equal",
              "custom"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "stopped_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "result": {
            "type": [
              "object",
              "null"
            ]
          },
          "segment": {
            "type": [
              "object",
              "null"
            ],
            "description": "Audience condition tree; null targets all visitors.",
            "additionalProperties": true
          },
          "trigger": {
            "type": [
              "object",
              "null"
            ],
            "description": "When the campaign activates, e.g. { \"type\": \"pageView\" }.",
            "additionalProperties": true
          },
          "stats": {
            "$ref": "#/components/schemas/StatsConfig"
          },
          "pages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "include": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UrlRule"
                  }
                },
                "exclude": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UrlRule"
                  }
                }
              }
            }
          },
          "variations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Variation"
            }
          },
          "metrics": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "primary",
                    "secondary",
                    "guardrail"
                  ]
                }
              }
            }
          }
        }
      },
      "CampaignCreate": {
        "type": "object",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "type": {
            "type": "string",
            "enum": [
              "ab",
              "multipage",
              "split",
              "mvt",
              "rollout",
              "personalization"
            ],
            "default": "ab"
          },
          "url": {
            "type": "string",
            "description": "http(s) URL of the page under test."
          }
        }
      },
      "CampaignUpdate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "notes": {
            "type": "string",
            "maxLength": 10000
          },
          "url": {
            "type": "string",
            "description": "http(s) URL; an empty string clears it."
          },
          "traffic": {
            "type": "number",
            "minimum": 0,
            "maximum": 100
          },
          "segment": {
            "type": [
              "object",
              "null"
            ],
            "description": "Condition tree, or null for all visitors.",
            "additionalProperties": true
          },
          "trigger": {
            "type": "object",
            "additionalProperties": true
          },
          "stats": {
            "$ref": "#/components/schemas/StatsConfig"
          },
          "confirm_running": {
            "type": "boolean",
            "description": "Required (true) when the change affects a RUNNING campaign. Changing a live test can mix data collected under different settings — consider cloning instead."
          }
        }
      },
      "CampaignStatusChange": {
        "type": "object",
        "required": [
          "action"
        ],
        "additionalProperties": false,
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "start",
              "pause",
              "archive"
            ]
          }
        }
      },
      "StatsConfig": {
        "type": "object",
        "required": [
          "approach",
          "correction",
          "winnerThreshold",
          "mde",
          "rope",
          "power"
        ],
        "properties": {
          "approach": {
            "type": "string",
            "enum": [
              "sequential",
              "fixed"
            ]
          },
          "correction": {
            "type": "string",
            "enum": [
              "none",
              "bonferroni",
              "sidak"
            ]
          },
          "winnerThreshold": {
            "type": "number",
            "description": "Probability needed to call a winner, e.g. 0.95."
          },
          "mde": {
            "type": "number",
            "description": "Minimum detectable effect (relative), e.g. 0.05."
          },
          "rope": {
            "type": "number",
            "description": "Region of practical equivalence (relative half-width)."
          },
          "power": {
            "type": "number"
          }
        }
      },
      "UrlRule": {
        "type": "object",
        "required": [
          "type",
          "value"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "wildcard",
              "exact",
              "contains",
              "startsWith",
              "endsWith",
              "regex"
            ]
          },
          "value": {
            "type": "string"
          }
        }
      },
      "Variation": {
        "type": "object",
        "required": [
          "key",
          "name",
          "is_control",
          "weight",
          "disabled"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Stable key used in events and reports (\"v0\" is the control)."
          },
          "name": {
            "type": "string"
          },
          "is_control": {
            "type": "boolean"
          },
          "weight": {
            "type": "number",
            "description": "Traffic share in percent (used with a custom split)."
          },
          "disabled": {
            "type": "boolean"
          },
          "redirect_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Split URL destination."
          },
          "changes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChangeSet"
            }
          }
        }
      },
      "ChangeSet": {
        "type": "object",
        "properties": {
          "page": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Index of the page group (multi-page tests); null applies everywhere."
          },
          "ops": {
            "type": "array",
            "description": "Visual editor operations: { id, type, selector, payload }.",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "js": {
            "type": [
              "string",
              "null"
            ]
          },
          "css": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "VariationCreate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "confirm_running": {
            "type": "boolean",
            "description": "Required (true) when the change affects a RUNNING campaign. Changing a live test can mix data collected under different settings — consider cloning instead."
          }
        }
      },
      "VariationUpdate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "weight": {
            "type": "number",
            "minimum": 0,
            "maximum": 100
          },
          "disabled": {
            "type": "boolean",
            "description": "The control cannot be disabled."
          },
          "redirect_url": {
            "type": "string",
            "description": "Split URL destination; an empty string clears it."
          },
          "changes": {
            "type": "array",
            "description": "Replaces all change sets of the variation.",
            "items": {
              "$ref": "#/components/schemas/ChangeSet"
            }
          },
          "confirm_running": {
            "type": "boolean",
            "description": "Required (true) when the change affects a RUNNING campaign. Changing a live test can mix data collected under different settings — consider cloning instead."
          }
        }
      },
      "Metric": {
        "type": "object",
        "required": [
          "key",
          "name",
          "type",
          "aggregation",
          "direction"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Stable key used in events and reports."
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "pageView",
              "click",
              "formSubmit",
              "linkClick",
              "custom",
              "revenue",
              "timeOnPage",
              "scrollDepth",
              "elementVisible"
            ]
          },
          "aggregation": {
            "type": "string",
            "enum": [
              "uniqueVisitors",
              "totalConversions",
              "sum",
              "average"
            ]
          },
          "direction": {
            "type": "string",
            "description": "Whether a higher value is better.",
            "enum": [
              "increase",
              "decrease"
            ]
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "selector": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UrlRule"
              },
              {
                "type": "null"
              }
            ]
          },
          "event": {
            "type": [
              "string",
              "null"
            ]
          },
          "property": {
            "type": [
              "string",
              "null"
            ]
          },
          "threshold": {
            "type": [
              "number",
              "null"
            ]
          },
          "archived": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "used_in": {
            "type": "integer",
            "description": "Number of campaigns using the metric (single-metric responses only)."
          }
        }
      },
      "MetricCreate": {
        "type": "object",
        "required": [
          "name",
          "type"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 500
          },
          "type": {
            "type": "string",
            "enum": [
              "pageView",
              "click",
              "formSubmit",
              "linkClick",
              "custom",
              "revenue",
              "timeOnPage",
              "scrollDepth",
              "elementVisible"
            ]
          },
          "aggregation": {
            "type": "string",
            "enum": [
              "uniqueVisitors",
              "totalConversions",
              "sum",
              "average"
            ],
            "default": "uniqueVisitors"
          },
          "direction": {
            "type": "string",
            "enum": [
              "increase",
              "decrease"
            ],
            "default": "increase"
          },
          "category": {
            "type": "string"
          },
          "selector": {
            "type": "string",
            "description": "CSS selector (click, formSubmit, elementVisible)."
          },
          "url": {
            "$ref": "#/components/schemas/UrlRule"
          },
          "event": {
            "type": "string",
            "description": "Event name passed to track() (custom, revenue)."
          },
          "property": {
            "type": "string",
            "description": "Numeric property summed / averaged."
          },
          "threshold": {
            "type": "number",
            "description": "Seconds (timeOnPage) or percent (scrollDepth)."
          }
        }
      },
      "Report": {
        "type": "object",
        "required": [
          "campaign",
          "variations",
          "metrics"
        ],
        "properties": {
          "campaign": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "started_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "stopped_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "to": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "variations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "is_control": {
                  "type": "boolean"
                },
                "visitors": {
                  "type": "integer"
                }
              }
            }
          },
          "metrics": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "primary",
                    "secondary",
                    "guardrail"
                  ]
                },
                "aggregation": {
                  "type": "string"
                },
                "direction": {
                  "type": "string"
                },
                "variations": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string"
                      },
                      "visitors": {
                        "type": "integer",
                        "description": "Unique visitors bucketed into the variation."
                      },
                      "conversions": {
                        "type": "integer",
                        "description": "Unique converting visitors."
                      },
                      "events": {
                        "type": "integer",
                        "description": "Total conversion events."
                      },
                      "sum": {
                        "type": "number",
                        "description": "Sum of the numeric value (e.g. revenue)."
                      },
                      "sum_of_squares": {
                        "type": "number",
                        "description": "Sum of squared values (for variance)."
                      },
                      "value": {
                        "type": [
                          "number",
                          "null"
                        ],
                        "description": "Headline value: conversion rate, events or sum per visitor, or the average — depending on the aggregation."
                      }
                    }
                  }
                }
              }
            }
          },
          "stats": {
            "type": [
              "object",
              "null"
            ],
            "description": "Statistics from the dashboard report (probabilities, intervals, decision) when cached for the same range.",
            "properties": {
              "computed_at": {
                "type": "string",
                "format": "date-time"
              },
              "result": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      }
    }
  }
}