{
  "openapi": "3.0.3",
  "info": {
    "title": "Chokh",
    "version": "0.1.0",
    "description": "The HTTP API of a Chokh install, generated from the server's route table and schemas."
  },
  "servers": [
    {
      "url": "https://analytics.example.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "session": {
        "type": "apiKey",
        "in": "cookie",
        "name": "chokh_session"
      },
      "key": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Failure": {
        "type": "object",
        "required": [
          "success",
          "error"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {}
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "session": []
    },
    {
      "key": []
    }
  ],
  "paths": {
    "/api/collect": {
      "post": {
        "summary": "What the tracker sends: a batch of pageviews and events from one page, read as JSON whatever its content type says.",
        "tags": [
          "Collecting"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "sentAt": {
                    "type": "integer"
                  },
                  "hostname": {
                    "type": "string",
                    "maxLength": 253
                  },
                  "lang": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "screen": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "viewport": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "visitorId": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "userId": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "sig": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "pageview",
                            "event",
                            "heartbeat",
                            "leave",
                            "identify",
                            "vital",
                            "error"
                          ]
                        },
                        "ts": {
                          "type": "integer"
                        },
                        "path": {
                          "type": "string",
                          "maxLength": 1024
                        },
                        "title": {
                          "type": "string",
                          "maxLength": 512
                        },
                        "referrer": {
                          "type": "string",
                          "maxLength": 2048
                        },
                        "utm": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 500
                          }
                        },
                        "name": {
                          "type": "string",
                          "maxLength": 200
                        },
                        "status": {
                          "type": "string",
                          "pattern": "^[1-5][0-9]{2}$"
                        },
                        "props": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 500
                          }
                        },
                        "userId": {
                          "type": "string",
                          "maxLength": 200
                        },
                        "traits": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 500
                          }
                        },
                        "duration": {
                          "type": "number",
                          "minimum": 0
                        },
                        "scrollDepth": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "value": {
                          "type": "number"
                        },
                        "rating": {
                          "type": "string",
                          "maxLength": 40
                        },
                        "frame": {
                          "type": "string",
                          "maxLength": 2000
                        },
                        "stack": {
                          "type": "string",
                          "maxLength": 8000
                        }
                      },
                      "required": [
                        "type",
                        "ts"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 50
                  }
                },
                "required": [
                  "siteId",
                  "sentAt",
                  "hostname",
                  "events"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody."
      }
    },
    "/api/sites/{siteId}/events": {
      "post": {
        "summary": "Events and identifies from your own server, with a key carrying write:events.",
        "tags": [
          "Collecting"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "visitorId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "event",
                            "identify"
                          ]
                        },
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 120
                        },
                        "ts": {
                          "type": "integer"
                        },
                        "path": {
                          "type": "string",
                          "maxLength": 1024
                        },
                        "props": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 512
                          }
                        },
                        "traits": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 512
                          }
                        },
                        "value": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 50
                  }
                },
                "required": [
                  "userId",
                  "events"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `write:events` on the site."
      }
    },
    "/health": {
      "get": {
        "summary": "Whether the process is up, for a load balancer or a container check.",
        "tags": [
          "Collecting"
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody."
      }
    },
    "/api/auth/register": {
      "post": {
        "summary": "The first account of an install registers itself and owns it; after that, an owner creates accounts.",
        "tags": [
          "Signing in"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 320
                  },
                  "password": {
                    "type": "string",
                    "minLength": 12,
                    "maxLength": 200
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "required": [
                  "email",
                  "password"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody, for the first account of an install; after that, a person who owns a team."
      }
    },
    "/api/auth/login": {
      "post": {
        "summary": "Signs in with an address and a password and sets the session cookie.",
        "tags": [
          "Signing in"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 320
                  },
                  "password": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "email",
                  "password"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody."
      }
    },
    "/api/auth/logout": {
      "post": {
        "summary": "Ends the session this request carries.",
        "tags": [
          "Signing in"
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody signed in, or any key."
      }
    },
    "/api/sso": {
      "post": {
        "summary": "Exchanges a token another application signed for a session, for that application's server.",
        "tags": [
          "Signing in"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4096
                  }
                },
                "required": [
                  "token"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody."
      },
      "get": {
        "summary": "The same exchange for a person following a link: sets the cookie and redirects to `next`.",
        "tags": [
          "Signing in"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            }
          },
          {
            "name": "next",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 512,
              "pattern": "^\\/(?!\\/)[\\w\\-./?=&%#+*]*$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody."
      }
    },
    "/api/me": {
      "get": {
        "summary": "Who is asking: the account or the key, and every site it can read with its role and scopes.",
        "tags": [
          "Signing in"
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "actor": {
                      "kind": "session",
                      "id": "u_example1"
                    },
                    "user": {
                      "id": "u_example1",
                      "email": "mira@quillmoor.example",
                      "name": "Mira Okafor"
                    },
                    "sites": [
                      {
                        "id": "s_demo",
                        "name": "Quillmoor Coffee",
                        "domains": [
                          "quillmoor.example"
                        ],
                        "teamId": "default",
                        "settings": {
                          "ipMode": "anonymized",
                          "visitorIdMode": "cookieless",
                          "botFilter": true,
                          "retentionDays": 180,
                          "timezone": "UTC",
                          "allowUnsignedIdentify": true,
                          "excludeIps": [],
                          "excludePaths": [],
                          "excludeQueryParams": [],
                          "routeGroups": [],
                          "errorCapture": false,
                          "errorStacks": false
                        },
                        "share": {
                          "token": "share_example1",
                          "protected": false,
                          "createdAt": 1790856000000
                        },
                        "scopes": [
                          "admin",
                          "read:identity",
                          "read:stats",
                          "write:events"
                        ],
                        "role": "owner"
                      }
                    ],
                    "teams": [
                      {
                        "id": "default",
                        "name": "Default",
                        "role": "owner"
                      }
                    ]
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody signed in, or any key."
      }
    },
    "/api/license": {
      "get": {
        "summary": "What this install may run: the licence's holder, its features and its expiry, or that there is none.",
        "tags": [
          "Signing in"
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "licensed": false,
                    "plan": null,
                    "licensee": null,
                    "expiresAt": null,
                    "features": []
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody signed in, or any key."
      }
    },
    "/api/sites": {
      "get": {
        "summary": "The sites the caller can read.",
        "tags": [
          "Sites"
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "sites": [
                      {
                        "id": "s_demo",
                        "name": "Quillmoor Coffee",
                        "domains": [
                          "quillmoor.example"
                        ],
                        "teamId": "default",
                        "settings": {
                          "ipMode": "anonymized",
                          "visitorIdMode": "cookieless",
                          "botFilter": true,
                          "retentionDays": 180,
                          "timezone": "UTC",
                          "allowUnsignedIdentify": true,
                          "excludeIps": [],
                          "excludePaths": [],
                          "excludeQueryParams": [],
                          "routeGroups": [],
                          "errorCapture": false,
                          "errorStacks": false
                        },
                        "share": {
                          "token": "share_example1",
                          "protected": false,
                          "createdAt": 1790856000000
                        },
                        "scopes": [
                          "admin",
                          "read:identity",
                          "read:stats",
                          "write:events"
                        ],
                        "role": "owner"
                      }
                    ]
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody signed in, or any key."
      },
      "post": {
        "summary": "Creates a site, with its id, name, domains and settings. Its identify secret is in the answer, once.",
        "tags": [
          "Sites"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 64,
                    "pattern": "^[a-z0-9][a-z0-9_-]*$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "domains": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 253
                    },
                    "minItems": 1,
                    "maxItems": 50
                  },
                  "teamId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  "settings": {
                    "type": "object",
                    "properties": {
                      "ipMode": {
                        "type": "string",
                        "enum": [
                          "full",
                          "anonymized",
                          "none"
                        ]
                      },
                      "visitorIdMode": {
                        "type": "string",
                        "enum": [
                          "cookieless",
                          "persistent"
                        ]
                      },
                      "botFilter": {
                        "type": "boolean"
                      },
                      "retentionDays": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 3650
                      },
                      "timezone": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "allowUnsignedIdentify": {
                        "type": "boolean"
                      },
                      "errorCapture": {
                        "type": "boolean"
                      },
                      "errorStacks": {
                        "type": "boolean"
                      },
                      "excludeIps": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64
                        },
                        "maxItems": 200
                      },
                      "excludePaths": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 512
                        },
                        "maxItems": 200
                      },
                      "excludeQueryParams": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64
                        },
                        "maxItems": 200
                      },
                      "routeGroups": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 256
                        },
                        "maxItems": 100
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "required": [
                  "name",
                  "domains"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key."
      }
    },
    "/api/sites/{siteId}": {
      "get": {
        "summary": "One site and its settings.",
        "tags": [
          "Sites"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "site": {
                      "id": "s_demo",
                      "name": "Quillmoor Coffee",
                      "domains": [
                        "quillmoor.example"
                      ],
                      "teamId": "default",
                      "settings": {
                        "ipMode": "anonymized",
                        "visitorIdMode": "cookieless",
                        "botFilter": true,
                        "retentionDays": 180,
                        "timezone": "UTC",
                        "allowUnsignedIdentify": true,
                        "excludeIps": [],
                        "excludePaths": [],
                        "excludeQueryParams": [],
                        "routeGroups": [],
                        "errorCapture": false,
                        "errorStacks": false
                      },
                      "share": {
                        "token": "share_example1",
                        "protected": false,
                        "createdAt": 1790856000000
                      }
                    },
                    "scopes": [
                      "admin",
                      "read:identity",
                      "read:stats",
                      "write:events"
                    ],
                    "role": "owner"
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      },
      "patch": {
        "summary": "Changes a site's name, domains or settings.",
        "tags": [
          "Sites"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "domains": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 253
                    },
                    "minItems": 1,
                    "maxItems": 50
                  },
                  "settings": {
                    "type": "object",
                    "properties": {
                      "ipMode": {
                        "type": "string",
                        "enum": [
                          "full",
                          "anonymized",
                          "none"
                        ]
                      },
                      "visitorIdMode": {
                        "type": "string",
                        "enum": [
                          "cookieless",
                          "persistent"
                        ]
                      },
                      "botFilter": {
                        "type": "boolean"
                      },
                      "retentionDays": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 3650
                      },
                      "timezone": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "allowUnsignedIdentify": {
                        "type": "boolean"
                      },
                      "errorCapture": {
                        "type": "boolean"
                      },
                      "errorStacks": {
                        "type": "boolean"
                      },
                      "excludeIps": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64
                        },
                        "maxItems": 200
                      },
                      "excludePaths": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 512
                        },
                        "maxItems": 200
                      },
                      "excludeQueryParams": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64
                        },
                        "maxItems": 200
                      },
                      "routeGroups": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 256
                        },
                        "maxItems": 100
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/identify-secret/rotate": {
      "post": {
        "summary": "Replaces the site's identify secret; the new one is in the answer, once.",
        "tags": [
          "Sites"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/keys": {
      "get": {
        "summary": "The site's keys, without their tokens.",
        "tags": [
          "Keys"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "keys": [
                      {
                        "id": "k_example1",
                        "siteId": "s_demo",
                        "name": "Checkout server",
                        "scopes": [
                          "write:events"
                        ],
                        "createdAt": 1790856000000,
                        "createdBy": "u_example1"
                      }
                    ]
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      },
      "post": {
        "summary": "Creates a key with the scopes named; its token is in the answer, once.",
        "tags": [
          "Keys"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "read:stats",
                        "read:identity",
                        "write:events",
                        "admin"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 4
                  }
                },
                "required": [
                  "name",
                  "scopes"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/keys/{keyId}": {
      "delete": {
        "summary": "Revokes a key.",
        "tags": [
          "Keys"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/stats/aggregate": {
      "get": {
        "summary": "The headline numbers for a range: visitors, visits, pageviews, bounce rate, visit duration, with a comparison when asked.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "range": {
                      "from": 1790251200000,
                      "to": 1790856000000
                    },
                    "previousRange": null,
                    "metrics": {
                      "visitors": 6,
                      "pageviews": 13,
                      "visits": 6,
                      "bounces": 1,
                      "bounceRate": 0.16666666666666666,
                      "avgDurationMs": 60000
                    },
                    "previous": null
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/timeseries": {
      "get": {
        "summary": "The same numbers by minute, hour, day, week or month.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "interval": "day",
                    "points": [
                      {
                        "start": 1790208000000,
                        "end": 1790294400000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790294400000,
                        "end": 1790380800000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790380800000,
                        "end": 1790467200000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790467200000,
                        "end": 1790553600000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790553600000,
                        "end": 1790640000000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790640000000,
                        "end": 1790726400000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790726400000,
                        "end": 1790812800000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790812800000,
                        "end": 1790856000000,
                        "metrics": {
                          "visitors": 6,
                          "pageviews": 13,
                          "visits": 6,
                          "bounces": 1,
                          "bounceRate": 0.16666666666666666,
                          "avgDurationMs": 60000
                        }
                      }
                    ],
                    "previous": null
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/breakdown": {
      "get": {
        "summary": "One dimension's rows (pages, sources, countries, devices and the rest), with their numbers.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "dim": "page",
                    "rows": [
                      {
                        "key": "/",
                        "metrics": {
                          "visitors": 4,
                          "pageviews": 4,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "key": "/menu",
                        "metrics": {
                          "visitors": 3,
                          "pageviews": 3,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "key": "/shop/beans",
                        "metrics": {
                          "visitors": 3,
                          "pageviews": 3,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "key": "/shop/checkout",
                        "metrics": {
                          "visitors": 2,
                          "pageviews": 2,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "key": "/about",
                        "metrics": {
                          "visitors": 1,
                          "pageviews": 1,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      }
                    ]
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/engagement": {
      "get": {
        "summary": "Time on page and scroll depth by page.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "dim": "page",
                    "rows": [],
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/export.csv": {
      "get": {
        "summary": "Any report as a CSV file.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "text/csv": {
                "example": "key,visitors,pageviews,visits,bounces,bounce_rate,avg_duration_ms\r\n/,4,4,0,0,,\r\n/menu,3,3,0,0,,\r\n/shop/beans,3,3,0,0,,\r\n/shop/checkout,2,2,0,0,,\r\n/about,1,1,0,0,,\r\n"
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/events": {
      "get": {
        "summary": "Custom events and how often each happened.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "visitors": 6,
                    "rows": [
                      {
                        "key": "order_paid",
                        "visitors": 2,
                        "events": 2,
                        "rate": 0.3333333333333333
                      }
                    ],
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "rawOnly": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/properties": {
      "get": {
        "summary": "One event's properties and their values.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "event",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "property",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "event": "order_paid",
                    "properties": [
                      {
                        "key": "size",
                        "events": 2
                      }
                    ],
                    "property": "size",
                    "visitors": 6,
                    "rows": [
                      {
                        "key": "250g",
                        "visitors": 2,
                        "events": 2,
                        "rate": 0.3333333333333333
                      }
                    ],
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "rawOnly": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/goals": {
      "get": {
        "summary": "Each goal's conversions and conversion rate.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "visitors": 6,
                    "rows": [
                      {
                        "goal": {
                          "siteId": "s_demo",
                          "id": "g_example1",
                          "name": "Order paid",
                          "kind": "event",
                          "match": "order_paid",
                          "createdBy": "u_example1",
                          "createdAt": 1790856000000
                        },
                        "conversion": {
                          "visitors": 2,
                          "completions": 2,
                          "rate": 0.3333333333333333,
                          "value": null
                        }
                      },
                      {
                        "goal": {
                          "siteId": "s_demo",
                          "id": "g_example2",
                          "name": "Saw the menu",
                          "kind": "page",
                          "match": "/menu",
                          "createdBy": "u_example1",
                          "createdAt": 1790856000000
                        },
                        "conversion": {
                          "visitors": 3,
                          "completions": 3,
                          "rate": 0.5,
                          "value": null
                        }
                      }
                    ],
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "rawOnly": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/funnel": {
      "get": {
        "summary": "A saved funnel: how many reached each step, and where they dropped off.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "funnel",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "funnel": {
                      "siteId": "s_demo",
                      "id": "f_example1",
                      "name": "Home to checkout",
                      "steps": [
                        {
                          "kind": "page",
                          "match": "/",
                          "name": "/"
                        },
                        {
                          "kind": "page",
                          "match": "/shop/beans",
                          "name": "/shop/beans"
                        },
                        {
                          "kind": "page",
                          "match": "/shop/checkout",
                          "name": "/shop/checkout"
                        }
                      ],
                      "window": "visit",
                      "createdBy": "u_example1",
                      "createdAt": 1790856000000
                    },
                    "visitors": 6,
                    "steps": [
                      {
                        "visitors": 4,
                        "dropOff": 0,
                        "rate": 1,
                        "stepRate": null
                      },
                      {
                        "visitors": 2,
                        "dropOff": 2,
                        "rate": 0.5,
                        "stepRate": 0.5
                      },
                      {
                        "visitors": 1,
                        "dropOff": 1,
                        "rate": 0.25,
                        "stepRate": 0.5
                      }
                    ],
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "rawOnly": true,
                    "funnel": "f_example1"
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/journeys": {
      "get": {
        "summary": "The paths visits took from the page they came in on.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "branches",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "visits": 6,
                    "columns": [
                      [
                        {
                          "key": "/",
                          "visits": 4,
                          "exits": 0,
                          "onward": 0
                        },
                        {
                          "key": "/menu",
                          "visits": 1,
                          "exits": 1,
                          "onward": 0
                        },
                        {
                          "key": "/shop/beans",
                          "visits": 1,
                          "exits": 0,
                          "onward": 0
                        }
                      ],
                      [
                        {
                          "key": "/menu",
                          "visits": 2,
                          "exits": 1,
                          "onward": 0
                        },
                        {
                          "key": "/about",
                          "visits": 1,
                          "exits": 1,
                          "onward": 0
                        },
                        {
                          "key": "/shop/beans",
                          "visits": 1,
                          "exits": 0,
                          "onward": 0
                        },
                        {
                          "key": "/shop/checkout",
                          "visits": 1,
                          "exits": 1,
                          "onward": 0
                        }
                      ],
                      [
                        {
                          "key": "/shop/beans",
                          "visits": 1,
                          "exits": 1,
                          "onward": 0
                        },
                        {
                          "key": "/shop/checkout",
                          "visits": 1,
                          "exits": 1,
                          "onward": 0
                        }
                      ],
                      []
                    ],
                    "links": [
                      {
                        "column": 0,
                        "from": "/",
                        "to": "/menu",
                        "visits": 2
                      },
                      {
                        "column": 0,
                        "from": "/",
                        "to": "/about",
                        "visits": 1
                      },
                      {
                        "column": 0,
                        "from": "/",
                        "to": "/shop/beans",
                        "visits": 1
                      },
                      {
                        "column": 0,
                        "from": "/shop/beans",
                        "to": "/shop/checkout",
                        "visits": 1
                      },
                      {
                        "column": 1,
                        "from": "/menu",
                        "to": "/shop/beans",
                        "visits": 1
                      },
                      {
                        "column": 1,
                        "from": "/shop/beans",
                        "to": "/shop/checkout",
                        "visits": 1
                      }
                    ],
                    "branches": 5,
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "rawOnly": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/cohorts": {
      "get": {
        "summary": "Retention cohorts: of the visitors first seen in a week or month, how many came back in each one after.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "week",
                "month"
              ],
              "default": "week"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "interval": "week",
                    "cohorts": [
                      {
                        "start": 1789948800000,
                        "end": 1790553600000,
                        "visitors": 0,
                        "periods": [
                          {
                            "start": 1789948800000,
                            "end": 1790553600000,
                            "visitors": 0,
                            "rate": null,
                            "complete": true
                          },
                          {
                            "start": 1790553600000,
                            "end": 1791158400000,
                            "visitors": 0,
                            "rate": null,
                            "complete": false
                          }
                        ]
                      },
                      {
                        "start": 1790553600000,
                        "end": 1791158400000,
                        "visitors": 6,
                        "periods": [
                          {
                            "start": 1790553600000,
                            "end": 1791158400000,
                            "visitors": 6,
                            "rate": 1,
                            "complete": false
                          }
                        ]
                      }
                    ],
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "visitorIdMode": "cookieless",
                    "rawOnly": true,
                    "interval": "week"
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/activity": {
      "get": {
        "summary": "Daily, weekly and monthly active visitors, and stickiness.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "days": [
                      {
                        "start": 1790208000000,
                        "end": 1790294400000,
                        "dau": 0,
                        "wau": 0,
                        "mau": 0,
                        "complete": true
                      },
                      {
                        "start": 1790294400000,
                        "end": 1790380800000,
                        "dau": 0,
                        "wau": 0,
                        "mau": 0,
                        "complete": true
                      },
                      {
                        "start": 1790380800000,
                        "end": 1790467200000,
                        "dau": 0,
                        "wau": 0,
                        "mau": 0,
                        "complete": true
                      },
                      {
                        "start": 1790467200000,
                        "end": 1790553600000,
                        "dau": 0,
                        "wau": 0,
                        "mau": 0,
                        "complete": true
                      },
                      {
                        "start": 1790553600000,
                        "end": 1790640000000,
                        "dau": 0,
                        "wau": 0,
                        "mau": 0,
                        "complete": true
                      },
                      {
                        "start": 1790640000000,
                        "end": 1790726400000,
                        "dau": 0,
                        "wau": 0,
                        "mau": 0,
                        "complete": true
                      },
                      {
                        "start": 1790726400000,
                        "end": 1790812800000,
                        "dau": 0,
                        "wau": 0,
                        "mau": 0,
                        "complete": true
                      },
                      {
                        "start": 1790812800000,
                        "end": 1790899200000,
                        "dau": 6,
                        "wau": 6,
                        "mau": 6,
                        "complete": false
                      }
                    ],
                    "dau": 0,
                    "wau": 0,
                    "mau": 0,
                    "stickiness": null,
                    "visitors": 6,
                    "returning": 0,
                    "returningRate": 0,
                    "curve": [
                      6,
                      0,
                      0,
                      0,
                      0,
                      0,
                      0,
                      0
                    ],
                    "powerMinDays": 3,
                    "powerUsers": 0,
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "visitorIdMode": "cookieless",
                    "rawOnly": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/attribution": {
      "get": {
        "summary": "First touch against last touch for one goal: what first brought each converting visitor, and what brought the visit they converted in.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "channel",
                "referrer",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "entry"
              ],
              "default": "channel"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "dim": "channel",
                    "visitors": 2,
                    "completions": 2,
                    "value": null,
                    "rows": [
                      {
                        "key": "direct",
                        "first": {
                          "visitors": 1,
                          "completions": 1
                        },
                        "last": {
                          "visitors": 1,
                          "completions": 1
                        }
                      },
                      {
                        "key": "organic",
                        "first": {
                          "visitors": 1,
                          "completions": 1
                        },
                        "last": {
                          "visitors": 1,
                          "completions": 1
                        }
                      }
                    ],
                    "other": {
                      "first": {
                        "visitors": 0,
                        "completions": 0
                      },
                      "last": {
                        "visitors": 0,
                        "completions": 0
                      }
                    },
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "visitorIdMode": "cookieless",
                    "rawOnly": true,
                    "goal": "g_example1",
                    "dim": "channel"
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/power-users": {
      "get": {
        "summary": "The most active people of the range, as rows of the people directory; their names only for a caller with read:identity.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "minDays",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 90
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "people": [],
                    "days": 8,
                    "minDays": 3,
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "visitorIdMode": "cookieless",
                    "rawOnly": true,
                    "identity": true,
                    "limit": 20
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/vitals": {
      "get": {
        "summary": "Core Web Vitals by page, at the 75th percentile.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "device",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "desktop",
                "mobile",
                "tablet"
              ]
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "LCP",
                "INP",
                "CLS",
                "FCP",
                "TTFB"
              ],
              "default": "LCP"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "minSamples": 20,
                    "sort": "LCP",
                    "metrics": [
                      {
                        "metric": "LCP",
                        "p75": null,
                        "samples": 0,
                        "rating": null,
                        "shares": null,
                        "devices": []
                      },
                      {
                        "metric": "INP",
                        "p75": null,
                        "samples": 0,
                        "rating": null,
                        "shares": null,
                        "devices": []
                      },
                      {
                        "metric": "CLS",
                        "p75": null,
                        "samples": 0,
                        "rating": null,
                        "shares": null,
                        "devices": []
                      },
                      {
                        "metric": "FCP",
                        "p75": null,
                        "samples": 0,
                        "rating": null,
                        "shares": null,
                        "devices": []
                      },
                      {
                        "metric": "TTFB",
                        "p75": null,
                        "samples": 0,
                        "rating": null,
                        "shares": null,
                        "devices": []
                      }
                    ],
                    "pages": [],
                    "pagesTotal": 0,
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "visitorIdMode": "cookieless",
                    "rawOnly": true,
                    "sort": "LCP",
                    "device": null
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/errors": {
      "get": {
        "summary": "JavaScript errors, grouped by message and place.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "total": 0,
                    "visitors": 0,
                    "groups": [],
                    "groupsTotal": 0,
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "visitorIdMode": "cookieless",
                    "rawOnly": true,
                    "limit": 50,
                    "errorCapture": false,
                    "errorStacks": false
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/stats/coverage": {
      "get": {
        "summary": "Of the people the site's server named, the share no browser row carries: an estimate of how many block or decline the tracker.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "state": "no_server_events",
                    "people": 0,
                    "seenInBrowser": 0,
                    "serverOnly": 0,
                    "share": null,
                    "browserIdentified": 0,
                    "minPeople": 20,
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "visitorIdMode": "cookieless",
                    "rawOnly": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/realtime": {
      "get": {
        "summary": "Who is on the site now, and on which page.",
        "tags": [
          "Realtime"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "online": 0,
                    "signedIn": 0,
                    "anonymous": 0,
                    "byPage": [],
                    "byCountry": [],
                    "byCity": [],
                    "visitors": [],
                    "recent": [
                      {
                        "visitorId": "v_example1",
                        "since": 1790855880000,
                        "lastSeenAt": 1790855880000,
                        "path": "/menu",
                        "browser": "Mobile Safari",
                        "os": "iOS",
                        "device": "mobile",
                        "ip": "203.0.113.0"
                      }
                    ]
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "identity": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/realtime/stream": {
      "get": {
        "summary": "The same, pushed as server-sent events when it changes.",
        "tags": [
          "Realtime"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/people": {
      "get": {
        "summary": "Everybody the site has seen, with search and an identified-only switch.",
        "tags": [
          "People"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          {
            "name": "identifiedOnly",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "people": [
                      {
                        "visitorId": "u:cust_1042",
                        "firstSeenAt": 1790856000000,
                        "lastSeenAt": 1790856000000,
                        "sessions": 1,
                        "pageviews": 0,
                        "devices": [],
                        "ips": [],
                        "userId": "cust_1042",
                        "traits": {
                          "plan": "subscriber"
                        }
                      },
                      {
                        "visitorId": "v_example1",
                        "firstSeenAt": 1790855880000,
                        "lastSeenAt": 1790855880000,
                        "sessions": 1,
                        "pageviews": 1,
                        "devices": [
                          "Mobile Safari on iOS"
                        ],
                        "ips": [
                          "203.0.113.0"
                        ],
                        "homeGeo": {}
                      },
                      {
                        "visitorId": "v_example2",
                        "firstSeenAt": 1790834400000,
                        "lastSeenAt": 1790834520000,
                        "sessions": 1,
                        "pageviews": 3,
                        "devices": [
                          "Chrome on Windows"
                        ],
                        "ips": [
                          "203.0.113.0"
                        ],
                        "homeGeo": {}
                      },
                      {
                        "visitorId": "v_example3",
                        "firstSeenAt": 1790827200000,
                        "lastSeenAt": 1790827240000,
                        "sessions": 1,
                        "pageviews": 2,
                        "devices": [
                          "Mobile Safari on iOS"
                        ],
                        "ips": [
                          "203.0.113.0"
                        ],
                        "homeGeo": {}
                      },
                      {
                        "visitorId": "v_example4",
                        "firstSeenAt": 1790820000000,
                        "lastSeenAt": 1790820040000,
                        "sessions": 1,
                        "pageviews": 2,
                        "devices": [
                          "Mobile Safari on iOS"
                        ],
                        "ips": [
                          "198.51.100.0"
                        ],
                        "homeGeo": {}
                      },
                      {
                        "visitorId": "v_example5",
                        "firstSeenAt": 1790816400000,
                        "lastSeenAt": 1790816480000,
                        "sessions": 1,
                        "pageviews": 3,
                        "devices": [
                          "Chrome on Windows"
                        ],
                        "ips": [
                          "198.51.100.0"
                        ],
                        "homeGeo": {}
                      },
                      {
                        "visitorId": "v_example6",
                        "firstSeenAt": 1790812800000,
                        "lastSeenAt": 1790812880000,
                        "sessions": 1,
                        "pageviews": 2,
                        "devices": [
                          "Chrome on Windows"
                        ],
                        "ips": [
                          "198.51.100.0"
                        ],
                        "homeGeo": {}
                      }
                    ],
                    "next": null
                  },
                  "meta": {
                    "identity": true,
                    "limit": 50
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/visitors/{visitorId}": {
      "get": {
        "summary": "One visitor's visits and events.",
        "tags": [
          "People"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "visitorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "siteId": "s_demo",
                    "visitorId": "u:cust_1042",
                    "firstSeenAt": 1790856000000,
                    "lastSeenAt": 1790856000000,
                    "pageviews": 0,
                    "events": 1,
                    "sessions": 1,
                    "devices": [],
                    "ips": [],
                    "timeline": [
                      {
                        "ts": 1790856000000,
                        "type": "event",
                        "name": "order_paid",
                        "sessionId": "dlfwz9ud86gZn5JcGWM6_8"
                      },
                      {
                        "ts": 1790856000000,
                        "type": "identify",
                        "sessionId": "dlfwz9ud86gZn5JcGWM6_8"
                      }
                    ],
                    "userId": "cust_1042",
                    "traits": {
                      "plan": "subscriber"
                    },
                    "firstTouch": {
                      "at": 1790856000000,
                      "channel": "direct"
                    },
                    "lastTouch": {
                      "at": 1790856000000,
                      "channel": "direct"
                    }
                  },
                  "meta": {
                    "identity": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      }
    },
    "/api/sites/{siteId}/users/{userId}": {
      "get": {
        "summary": "One identified person's visits, events and traits.",
        "tags": [
          "People"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "siteId": "s_demo",
                    "visitorIds": [
                      "u:cust_1042"
                    ],
                    "firstSeenAt": 1790856000000,
                    "lastSeenAt": 1790856000000,
                    "pageviews": 0,
                    "events": 1,
                    "sessions": 1,
                    "devices": [],
                    "ips": [],
                    "timeline": [
                      {
                        "ts": 1790856000000,
                        "type": "event",
                        "name": "order_paid",
                        "sessionId": "dlfwz9ud86gZn5JcGWM6_8"
                      },
                      {
                        "ts": 1790856000000,
                        "type": "identify",
                        "sessionId": "dlfwz9ud86gZn5JcGWM6_8"
                      }
                    ],
                    "userId": "cust_1042",
                    "traits": {
                      "plan": "subscriber"
                    },
                    "firstTouch": {
                      "at": 1790856000000,
                      "channel": "direct"
                    },
                    "lastTouch": {
                      "at": 1790856000000,
                      "channel": "direct"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:identity` on the site."
      }
    },
    "/api/sites/{siteId}/users/{userId}/presence": {
      "get": {
        "summary": "Whether that person is on the site now.",
        "tags": [
          "People"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "online": false,
                    "lastSeenAt": 1790856000000
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:identity` on the site."
      }
    },
    "/api/sites/{siteId}/goals": {
      "get": {
        "summary": "The site's goals.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "goals": [
                      {
                        "siteId": "s_demo",
                        "id": "g_example1",
                        "name": "Order paid",
                        "kind": "event",
                        "match": "order_paid",
                        "createdBy": "u_example1",
                        "createdAt": 1790856000000
                      },
                      {
                        "siteId": "s_demo",
                        "id": "g_example2",
                        "name": "Saw the menu",
                        "kind": "page",
                        "match": "/menu",
                        "createdBy": "u_example1",
                        "createdAt": 1790856000000
                      }
                    ]
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "max": 50
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      },
      "post": {
        "summary": "Creates a goal: a page or an event.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "page"
                        ]
                      },
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "match": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 1024
                      },
                      "value": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1000000000
                      }
                    },
                    "required": [
                      "kind",
                      "name",
                      "match"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "event"
                        ]
                      },
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "match": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "value": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1000000000
                      }
                    },
                    "required": [
                      "kind",
                      "name",
                      "match"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/goals/{goalId}": {
      "delete": {
        "summary": "Deletes a goal.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "goalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/funnels": {
      "get": {
        "summary": "The site's funnels.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "funnels": [
                      {
                        "siteId": "s_demo",
                        "id": "f_example1",
                        "name": "Home to checkout",
                        "steps": [
                          {
                            "kind": "page",
                            "match": "/",
                            "name": "/"
                          },
                          {
                            "kind": "page",
                            "match": "/shop/beans",
                            "name": "/shop/beans"
                          },
                          {
                            "kind": "page",
                            "match": "/shop/checkout",
                            "name": "/shop/checkout"
                          }
                        ],
                        "window": "visit",
                        "createdBy": "u_example1",
                        "createdAt": 1790856000000
                      }
                    ]
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "max": 50,
                    "maxSteps": 8,
                    "windows": [
                      "visit",
                      "1h",
                      "1d",
                      "7d",
                      "30d"
                    ],
                    "defaultWindow": "visit"
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      },
      "post": {
        "summary": "Creates a funnel from its steps.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "window": {
                    "type": "string",
                    "enum": [
                      "visit",
                      "1h",
                      "1d",
                      "7d",
                      "30d"
                    ]
                  },
                  "steps": {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "goalId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64
                            },
                            "name": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100
                            }
                          },
                          "required": [
                            "goalId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "page": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 1024
                            },
                            "name": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100
                            }
                          },
                          "required": [
                            "page"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "minItems": 2,
                    "maxItems": 8
                  }
                },
                "required": [
                  "name",
                  "steps"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/funnels/{funnelId}": {
      "delete": {
        "summary": "Deletes a funnel.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "funnelId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/segments": {
      "get": {
        "summary": "The site's saved segments.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "segments": [
                      {
                        "siteId": "s_demo",
                        "id": "sg_example1",
                        "name": "From Google",
                        "filters": [
                          {
                            "dim": "referrer",
                            "op": "contains",
                            "value": "google"
                          }
                        ],
                        "createdBy": "u_example1",
                        "createdAt": 1790856000000
                      }
                    ]
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "max": 50
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      },
      "post": {
        "summary": "Saves a list of filters under a name.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "filters": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "dim": {
                          "type": "string",
                          "enum": [
                            "page",
                            "route",
                            "entry",
                            "exit",
                            "referrer",
                            "channel",
                            "utm_source",
                            "utm_medium",
                            "utm_campaign",
                            "utm_term",
                            "utm_content",
                            "country",
                            "region",
                            "city",
                            "browser",
                            "os",
                            "device",
                            "screen",
                            "lang",
                            "event",
                            "status",
                            "bot"
                          ]
                        },
                        "op": {
                          "type": "string",
                          "enum": [
                            "is",
                            "is_not",
                            "contains"
                          ]
                        },
                        "value": {
                          "type": "string",
                          "maxLength": 1024
                        }
                      },
                      "required": [
                        "dim",
                        "op",
                        "value"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 10
                  }
                },
                "required": [
                  "name",
                  "filters"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/segments/{segmentId}": {
      "delete": {
        "summary": "Deletes a segment.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "segmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/annotations": {
      "get": {
        "summary": "The marks drawn on the chart in a range.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "annotations": [
                      {
                        "siteId": "s_demo",
                        "id": "an_example1",
                        "at": 1790510400000,
                        "kind": "campaign",
                        "text": "Autumn blend launched",
                        "createdBy": "u_example1",
                        "createdAt": 1790856000000
                      }
                    ]
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "max": 1000
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site."
      },
      "post": {
        "summary": "Adds a mark: a deploy, a campaign, an outage or a note.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "at": {
                    "type": "integer",
                    "minimum": 946684800000,
                    "maximum": 4102444800000
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "deploy",
                      "campaign",
                      "downtime",
                      "note"
                    ]
                  },
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "url": {
                    "type": "string",
                    "maxLength": 2048
                  }
                },
                "required": [
                  "at",
                  "kind",
                  "text"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `write:events` on the site."
      }
    },
    "/api/sites/{siteId}/annotations/{annotationId}": {
      "delete": {
        "summary": "Deletes a mark.",
        "tags": [
          "Goals, funnels, segments and annotations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "annotationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `write:events` on the site."
      }
    },
    "/api/sites/{siteId}/share": {
      "put": {
        "summary": "Turns on the public share link, with an optional password, or changes it.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "regenerate": {
                    "type": "boolean"
                  },
                  "password": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 200,
                    "nullable": true
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      },
      "delete": {
        "summary": "Turns the share link off.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/share/{token}": {
      "get": {
        "summary": "What a share link shows: the site's name and whether a password is asked for.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "site": {
                      "name": "Quillmoor Coffee",
                      "timezone": "UTC"
                    },
                    "protected": false,
                    "unlocked": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody."
      }
    },
    "/api/share/{token}/unlock": {
      "post": {
        "summary": "Opens a share that has a password.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "password": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "password"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody."
      }
    },
    "/api/share/{token}/stats/aggregate": {
      "get": {
        "summary": "The headline numbers, through a share link.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "range": {
                      "from": 1790251200000,
                      "to": 1790856000000
                    },
                    "previousRange": null,
                    "metrics": {
                      "visitors": 6,
                      "pageviews": 13,
                      "visits": 6,
                      "bounces": 1,
                      "bounceRate": 0.16666666666666666,
                      "avgDurationMs": 60000
                    },
                    "previous": null
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Whoever holds the share link, and its password when it has one."
      }
    },
    "/api/share/{token}/stats/timeseries": {
      "get": {
        "summary": "The chart, through a share link.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "interval": "day",
                    "points": [
                      {
                        "start": 1790208000000,
                        "end": 1790294400000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790294400000,
                        "end": 1790380800000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790380800000,
                        "end": 1790467200000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790467200000,
                        "end": 1790553600000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790553600000,
                        "end": 1790640000000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790640000000,
                        "end": 1790726400000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790726400000,
                        "end": 1790812800000,
                        "metrics": {
                          "visitors": 0,
                          "pageviews": 0,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "start": 1790812800000,
                        "end": 1790856000000,
                        "metrics": {
                          "visitors": 6,
                          "pageviews": 13,
                          "visits": 6,
                          "bounces": 1,
                          "bounceRate": 0.16666666666666666,
                          "avgDurationMs": 60000
                        }
                      }
                    ],
                    "previous": null
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Whoever holds the share link, and its password when it has one."
      }
    },
    "/api/share/{token}/stats/breakdown": {
      "get": {
        "summary": "One dimension's rows, through a share link.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "dim": "page",
                    "rows": [
                      {
                        "key": "/",
                        "metrics": {
                          "visitors": 4,
                          "pageviews": 4,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "key": "/menu",
                        "metrics": {
                          "visitors": 3,
                          "pageviews": 3,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "key": "/shop/beans",
                        "metrics": {
                          "visitors": 3,
                          "pageviews": 3,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "key": "/shop/checkout",
                        "metrics": {
                          "visitors": 2,
                          "pageviews": 2,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      },
                      {
                        "key": "/about",
                        "metrics": {
                          "visitors": 1,
                          "pageviews": 1,
                          "visits": 0,
                          "bounces": 0,
                          "bounceRate": null,
                          "avgDurationMs": null
                        }
                      }
                    ]
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Whoever holds the share link, and its password when it has one."
      }
    },
    "/api/share/{token}/stats/goals": {
      "get": {
        "summary": "The goals, through a share link.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "compare",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "previous_period",
                "previous_year"
              ]
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          },
          {
            "name": "dim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "route",
                "entry",
                "exit",
                "referrer",
                "channel",
                "utm_source",
                "utm_medium",
                "utm_campaign",
                "utm_term",
                "utm_content",
                "country",
                "region",
                "city",
                "browser",
                "os",
                "device",
                "screen",
                "lang",
                "event",
                "status",
                "bot"
              ]
            }
          },
          {
            "name": "metrics",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": true,
              "minimum": 0,
              "maximum": 1000
            }
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "visitors": 6,
                    "rows": [
                      {
                        "goal": {
                          "siteId": "s_demo",
                          "id": "g_example1",
                          "name": "Order paid",
                          "kind": "event",
                          "match": "order_paid",
                          "createdBy": "u_example1",
                          "createdAt": 1790856000000
                        },
                        "conversion": {
                          "visitors": 2,
                          "completions": 2,
                          "rate": 0.3333333333333333,
                          "value": null
                        }
                      },
                      {
                        "goal": {
                          "siteId": "s_demo",
                          "id": "g_example2",
                          "name": "Saw the menu",
                          "kind": "page",
                          "match": "/menu",
                          "createdBy": "u_example1",
                          "createdAt": 1790856000000
                        },
                        "conversion": {
                          "visitors": 3,
                          "completions": 3,
                          "rate": 0.5,
                          "value": null
                        }
                      }
                    ],
                    "rawOnly": true
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "timezone": "UTC",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "retentionDays": 180,
                    "rawOnly": true
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Whoever holds the share link, and its password when it has one."
      }
    },
    "/api/share/{token}/annotations": {
      "get": {
        "summary": "The chart's marks, through a share link.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "annotations": [
                      {
                        "siteId": "s_demo",
                        "id": "an_example1",
                        "at": 1790510400000,
                        "kind": "campaign",
                        "text": "Autumn blend launched",
                        "createdBy": "u_example1",
                        "createdAt": 1790856000000
                      }
                    ]
                  },
                  "meta": {
                    "siteId": "s_demo",
                    "from": 1790251200000,
                    "to": 1790856000000,
                    "max": 1000
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Whoever holds the share link, and its password when it has one."
      }
    },
    "/api/share/{token}/widget.svg": {
      "get": {
        "summary": "A badge of visitors or pageviews for today, 7 or 30 days, to put on a page.",
        "tags": [
          "Sharing"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Whoever holds the share link, and its password when it has one."
      }
    },
    "/api/teams/{teamId}/members": {
      "get": {
        "summary": "A team's members and their roles.",
        "tags": [
          "Teams and members"
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "team": {
                      "id": "default",
                      "name": "Default"
                    },
                    "members": [
                      {
                        "userId": "u_example1",
                        "email": "mira@quillmoor.example",
                        "name": "Mira Okafor",
                        "role": "owner",
                        "identity": true,
                        "managed": false
                      }
                    ]
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key."
      }
    },
    "/api/teams/{teamId}/members/{userId}": {
      "put": {
        "summary": "Gives somebody a role in the team, or changes it.",
        "tags": [
          "Teams and members"
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "enum": [
                      "owner",
                      "editor",
                      "viewer"
                    ]
                  },
                  "identity": {
                    "type": "boolean",
                    "default": false
                  },
                  "revokeKeys": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "role"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key."
      },
      "delete": {
        "summary": "Removes somebody from the team.",
        "tags": [
          "Teams and members"
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "revokeKeys",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key."
      }
    },
    "/api/teams/{teamId}": {
      "patch": {
        "summary": "Renames a team.",
        "tags": [
          "Teams and members"
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key."
      }
    },
    "/api/sites/{siteId}/members": {
      "get": {
        "summary": "Who has a role on this one site.",
        "tags": [
          "Teams and members"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "members": []
                  },
                  "meta": {
                    "siteId": "s_demo"
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in with `admin` on the site. Never a key."
      }
    },
    "/api/sites/{siteId}/members/{userId}": {
      "put": {
        "summary": "Gives somebody a role on this one site, or changes it.",
        "tags": [
          "Teams and members"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "enum": [
                      "owner",
                      "editor",
                      "viewer"
                    ]
                  },
                  "identity": {
                    "type": "boolean",
                    "default": false
                  },
                  "revokeKeys": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "role"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in with `admin` on the site. Never a key."
      },
      "delete": {
        "summary": "Removes somebody's role on this site.",
        "tags": [
          "Teams and members"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "revokeKeys",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in with `admin` on the site. Never a key."
      }
    },
    "/api/teams/{teamId}/invitations": {
      "get": {
        "summary": "The team's invitations still waiting.",
        "tags": [
          "Invitations"
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "invitations": []
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key."
      },
      "post": {
        "summary": "Invites somebody to the team; the link is in the answer, once.",
        "tags": [
          "Invitations"
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 320
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "owner",
                      "editor",
                      "viewer"
                    ]
                  },
                  "identity": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "email",
                  "role"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key."
      }
    },
    "/api/teams/{teamId}/invitations/{invitationId}": {
      "delete": {
        "summary": "Takes an invitation back.",
        "tags": [
          "Invitations"
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invitationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key."
      }
    },
    "/api/sites/{siteId}/invitations": {
      "get": {
        "summary": "The site's invitations still waiting.",
        "tags": [
          "Invitations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "invitations": []
                  },
                  "meta": {
                    "siteId": "s_demo"
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in with `admin` on the site. Never a key."
      },
      "post": {
        "summary": "Invites somebody to this one site; the link is in the answer, once.",
        "tags": [
          "Invitations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 320
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "owner",
                      "editor",
                      "viewer"
                    ]
                  },
                  "identity": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "email",
                  "role"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in with `admin` on the site. Never a key."
      }
    },
    "/api/sites/{siteId}/invitations/{invitationId}": {
      "delete": {
        "summary": "Takes an invitation back.",
        "tags": [
          "Invitations"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invitationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in with `admin` on the site. Never a key."
      }
    },
    "/api/invitations/lookup": {
      "post": {
        "summary": "What an invitation is for, for the page its link opens.",
        "tags": [
          "Invitations"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 200
                  }
                },
                "required": [
                  "token"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody."
      }
    },
    "/api/invitations/accept": {
      "post": {
        "summary": "Uses an invitation: by the account signed in, or by a new one with a password.",
        "tags": [
          "Invitations"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 200
                  },
                  "password": {
                    "type": "string",
                    "minLength": 12,
                    "maxLength": 200
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "required": [
                  "token"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody."
      }
    },
    "/api/teams/{teamId}/audit": {
      "get": {
        "summary": "The team's log of who gave whom what, and who read identities, newest first.",
        "tags": [
          "The audit log"
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "actor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "identity",
                "access",
                "log"
              ]
            }
          },
          {
            "name": "target",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "rows": [],
                    "accounts": {},
                    "next": null
                  },
                  "meta": {
                    "identity": true,
                    "limit": 5
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key."
      }
    },
    "/api/sites/{siteId}/audit": {
      "get": {
        "summary": "The same log for one site.",
        "tags": [
          "The audit log"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "actor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "identity",
                "access",
                "log"
              ]
            }
          },
          {
            "name": "target",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded on the invented site of the docs.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "data": {
                    "rows": [
                      {
                        "siteId": "s_demo",
                        "ts": 1790856000000,
                        "actor": {
                          "kind": "session",
                          "id": "u_example1",
                          "email": "mira@quillmoor.example"
                        },
                        "action": "read:identity",
                        "route": "GET /api/sites/:siteId/users/:userId/presence",
                        "fields": [
                          "userId"
                        ],
                        "target": "cust_1042",
                        "id": "5",
                        "kind": "identity"
                      },
                      {
                        "siteId": "s_demo",
                        "ts": 1790856000000,
                        "actor": {
                          "kind": "session",
                          "id": "u_example1",
                          "email": "mira@quillmoor.example"
                        },
                        "action": "read:identity",
                        "route": "GET /api/sites/:siteId/users/:userId",
                        "fields": [
                          "traits",
                          "userId"
                        ],
                        "target": "cust_1042",
                        "id": "4",
                        "kind": "identity"
                      },
                      {
                        "siteId": "s_demo",
                        "ts": 1790856000000,
                        "actor": {
                          "kind": "session",
                          "id": "u_example1",
                          "email": "mira@quillmoor.example"
                        },
                        "action": "read:identity",
                        "route": "GET /api/sites/:siteId/visitors/:visitorId",
                        "fields": [
                          "traits",
                          "userId"
                        ],
                        "target": "u:cust_1042",
                        "id": "3",
                        "kind": "identity"
                      },
                      {
                        "siteId": "s_demo",
                        "ts": 1790856000000,
                        "actor": {
                          "kind": "session",
                          "id": "u_example1",
                          "email": "mira@quillmoor.example"
                        },
                        "action": "read:identity",
                        "route": "GET /api/sites/:siteId/people",
                        "fields": [
                          "ips",
                          "traits",
                          "userId"
                        ],
                        "id": "2",
                        "kind": "identity"
                      },
                      {
                        "siteId": "s_demo",
                        "ts": 1790856000000,
                        "actor": {
                          "kind": "session",
                          "id": "u_example1",
                          "email": "mira@quillmoor.example"
                        },
                        "action": "read:identity",
                        "route": "GET /api/sites/:siteId/realtime",
                        "fields": [
                          "ip"
                        ],
                        "id": "1",
                        "kind": "identity"
                      }
                    ],
                    "accounts": {
                      "u_example1": {
                        "email": "mira@quillmoor.example",
                        "name": "Mira Okafor"
                      }
                    },
                    "next": "cursor_example1"
                  },
                  "meta": {
                    "identity": true,
                    "limit": 5
                  }
                }
              }
            }
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site."
      }
    },
    "/api/sites/{siteId}/ee/alerts": {
      "get": {
        "summary": "The site's alerts and where each one sends.",
        "tags": [
          "Alerts (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site.",
        "x-chokh-feature": "alerts"
      },
      "post": {
        "summary": "Creates an alert: a condition on a number, and the email, Telegram chat or webhook it goes to.",
        "tags": [
          "Alerts (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "condition": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "traffic"
                            ]
                          },
                          "metric": {
                            "type": "string",
                            "enum": [
                              "visitors",
                              "pageviews"
                            ]
                          },
                          "direction": {
                            "type": "string",
                            "enum": [
                              "up",
                              "down"
                            ]
                          },
                          "percent": {
                            "type": "integer",
                            "minimum": 20,
                            "maximum": 1000
                          },
                          "minimum": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 1000000
                          }
                        },
                        "required": [
                          "kind",
                          "metric",
                          "direction",
                          "percent",
                          "minimum"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "goal"
                            ]
                          },
                          "goalId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "direction": {
                            "type": "string",
                            "enum": [
                              "above",
                              "below"
                            ]
                          },
                          "count": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 1000000
                          },
                          "window": {
                            "anyOf": [
                              {
                                "type": "number",
                                "enum": [
                                  15
                                ]
                              },
                              {
                                "type": "number",
                                "enum": [
                                  60
                                ]
                              },
                              {
                                "type": "number",
                                "enum": [
                                  360
                                ]
                              },
                              {
                                "type": "number",
                                "enum": [
                                  1440
                                ]
                              }
                            ]
                          }
                        },
                        "required": [
                          "kind",
                          "goalId",
                          "direction",
                          "count",
                          "window"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "errors"
                            ]
                          },
                          "statuses": {
                            "type": "string",
                            "enum": [
                              "4xx",
                              "5xx",
                              "any"
                            ]
                          },
                          "count": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 1000000
                          },
                          "window": {
                            "anyOf": [
                              {
                                "type": "number",
                                "enum": [
                                  15
                                ]
                              },
                              {
                                "type": "number",
                                "enum": [
                                  60
                                ]
                              },
                              {
                                "type": "number",
                                "enum": [
                                  360
                                ]
                              },
                              {
                                "type": "number",
                                "enum": [
                                  1440
                                ]
                              }
                            ]
                          }
                        },
                        "required": [
                          "kind",
                          "statuses",
                          "count",
                          "window"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "silence"
                            ]
                          },
                          "minutes": {
                            "type": "integer",
                            "minimum": 5,
                            "maximum": 1440
                          }
                        },
                        "required": [
                          "kind",
                          "minutes"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "channels": {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "enum": [
                                "email"
                              ]
                            },
                            "to": {
                              "type": "string",
                              "format": "email",
                              "maxLength": 254
                            }
                          },
                          "required": [
                            "kind",
                            "to"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "enum": [
                                "telegram"
                              ]
                            },
                            "chatId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64,
                              "pattern": "^(-?\\d+|@[A-Za-z0-9_]{5,})$"
                            }
                          },
                          "required": [
                            "kind",
                            "chatId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "enum": [
                                "webhook"
                              ]
                            },
                            "url": {
                              "type": "string",
                              "format": "uri",
                              "maxLength": 2048
                            },
                            "secret": {
                              "type": "string",
                              "minLength": 16,
                              "maxLength": 256
                            }
                          },
                          "required": [
                            "kind",
                            "url"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 5
                  }
                },
                "required": [
                  "name",
                  "condition",
                  "channels"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site.",
        "x-chokh-feature": "alerts"
      }
    },
    "/api/sites/{siteId}/ee/alerts/{alertId}": {
      "delete": {
        "summary": "Deletes an alert.",
        "tags": [
          "Alerts (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "alertId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site.",
        "x-chokh-feature": "alerts"
      }
    },
    "/api/sites/{siteId}/ee/alerts/{alertId}/test": {
      "post": {
        "summary": "Sends an alert's message now, to check where it goes.",
        "tags": [
          "Alerts (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "alertId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site.",
        "x-chokh-feature": "alerts"
      }
    },
    "/api/sites/{siteId}/ee/digests": {
      "get": {
        "summary": "The site's scheduled email digests.",
        "tags": [
          "Digests (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site.",
        "x-chokh-feature": "digests"
      },
      "post": {
        "summary": "Schedules a digest by email, daily or weekly, with the same numbers in an attached PDF.",
        "tags": [
          "Digests (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cadence": {
                    "type": "string",
                    "enum": [
                      "daily",
                      "weekly"
                    ]
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 254,
                      "format": "email"
                    },
                    "minItems": 1,
                    "maxItems": 5
                  },
                  "hour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23,
                    "default": 8
                  },
                  "weekday": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 6
                  }
                },
                "required": [
                  "cadence",
                  "to"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site.",
        "x-chokh-feature": "digests"
      }
    },
    "/api/sites/{siteId}/ee/digests/{digestId}": {
      "delete": {
        "summary": "Stops a digest.",
        "tags": [
          "Digests (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "digestId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site.",
        "x-chokh-feature": "digests"
      }
    },
    "/api/sites/{siteId}/ee/digests/{digestId}/send": {
      "post": {
        "summary": "Sends a digest now.",
        "tags": [
          "Digests (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "digestId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `admin` on the site.",
        "x-chokh-feature": "digests"
      }
    },
    "/api/ee/teams": {
      "post": {
        "summary": "Creates a team, owned by whoever creates it.",
        "tags": [
          "More than one team (Chokh Pro)"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns a team. Never a key.",
        "x-chokh-feature": "teams"
      }
    },
    "/api/ee/teams/{teamId}": {
      "delete": {
        "summary": "Deletes a team that holds no site.",
        "tags": [
          "More than one team (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key.",
        "x-chokh-feature": "teams"
      }
    },
    "/api/ee/sites/{siteId}/team": {
      "put": {
        "summary": "Moves a site to another team the caller owns.",
        "tags": [
          "More than one team (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "teamId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  "revokeKeys": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "teamId"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in who owns the team. Never a key.",
        "x-chokh-feature": "teams"
      }
    },
    "/api/ee/oidc": {
      "get": {
        "summary": "Whether single sign-on is on, for the sign-in page.",
        "tags": [
          "Single sign-on (Chokh Pro)"
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody.",
        "x-chokh-feature": "oidc"
      }
    },
    "/api/ee/oidc/start": {
      "get": {
        "summary": "Sends the browser to the identity provider to sign in.",
        "tags": [
          "Single sign-on (Chokh Pro)"
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody.",
        "x-chokh-feature": "oidc"
      }
    },
    "/api/ee/oidc/callback": {
      "get": {
        "summary": "Where the provider sends the browser back; signs the person in.",
        "tags": [
          "Single sign-on (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 2048
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          {
            "name": "error",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody.",
        "x-chokh-feature": "oidc"
      }
    },
    "/api/ee/oidc/invite": {
      "post": {
        "summary": "Uses an invitation by signing in with the provider.",
        "tags": [
          "Single sign-on (Chokh Pro)"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 200
                  }
                },
                "required": [
                  "token"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "Anybody.",
        "x-chokh-feature": "oidc"
      }
    },
    "/api/ee/oidc/link": {
      "post": {
        "summary": "Connects the account signed in to an identity at the provider.",
        "tags": [
          "Single sign-on (Chokh Pro)"
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in. Never a key.",
        "x-chokh-feature": "oidc"
      }
    },
    "/api/ee/oidc/identity": {
      "get": {
        "summary": "Whether the account signed in is connected, and to what.",
        "tags": [
          "Single sign-on (Chokh Pro)"
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in. Never a key."
      },
      "delete": {
        "summary": "Disconnects it, unless it is the account's only way in.",
        "tags": [
          "Single sign-on (Chokh Pro)"
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A person signed in. Never a key."
      }
    },
    "/api/sites/{siteId}/ee/ping": {
      "get": {
        "summary": "Answers only when the licence key covers paid features: a way to check a key works.",
        "tags": [
          "Checking a licence (Chokh Pro)"
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope with the answer."
          },
          "default": {
            "description": "A refusal, in the envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Failure"
                }
              }
            }
          }
        },
        "x-chokh-who": "A session or a key with `read:stats` on the site.",
        "x-chokh-feature": "ee.ping"
      }
    }
  }
}
