{
 "openapi": "3.1.0",
 "info": {
  "title": "Bot Creator API",
  "version": "1.0.0",
  "summary": "Public API for the bots you build with Bot Creator.",
  "description": "Authenticate with an API key created in the Studio (one key = one bot). Send `Authorization: Bearer bcm_k_…`.\n\nA key only works on /v1; it is refused everywhere else. API keys need an active Premium plan: without it, calls answer 403 key_suspended (the key is kept and works again after renewal). Revoking a key takes effect within 10 seconds.\n\nRate limits are per key: 600 reads and 60 writes per minute by default (headers X-RateLimit-Limit, X-RateLimit-Remaining, Retry-After on 429). Lists are `{items, next_cursor}`; pass next_cursor as `cursor`. Errors are `{code, message, details, request_id}`.\n\nWrites are last-write-wins: `revision` fields are informational, and If-Match / If-None-Match are refused with 400 precondition_unsupported rather than silently ignored.\n\nVersioning: /v1 only gets backward-compatible additions (new fields, new routes). A breaking change ships as /v2 with at least 6 months of coexistence and Deprecation/Sunset headers on the old routes.",
  "license": {
   "name": "Proprietary"
  }
 },
 "servers": [
  {
   "url": "https://api.bot-creator.fr",
   "description": "Production"
  },
  {
   "url": "https://dev.bot-creator.fr",
   "description": "Staging"
  }
 ],
 "tags": [
  {
   "name": "bot"
  },
  {
   "name": "commands"
  },
  {
   "name": "workflows"
  },
  {
   "name": "variables"
  },
  {
   "name": "meta"
  },
  {
   "name": "data"
  },
  {
   "name": "files"
  },
  {
   "name": "alerts"
  }
 ],
 "paths": {
  "/v1/openapi.json": {
   "get": {
    "operationId": "getOpenAPI",
    "summary": "This contract",
    "tags": [
     "meta"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OpenAPI 3.1 document"
     }
    }
   }
  },
  "/v1/bot": {
   "get": {
    "operationId": "getBotAlias",
    "summary": "Read the bot of the key (alias of GET /v1/bots/{botId})",
    "tags": [
     "bot"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [],
    "responses": {
     "200": {
      "description": "Bot summary",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Bot"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}": {
   "get": {
    "operationId": "getBot",
    "summary": "Read the bot",
    "tags": [
     "bot"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     }
    ],
    "responses": {
     "200": {
      "description": "Bot summary: engine, revision, counts and non-secret settings. Never the Discord token.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Bot"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/commands": {
   "get": {
    "operationId": "listCommands",
    "summary": "List commands",
    "tags": [
     "commands"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 50
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Opaque value: use next_cursor from the previous page."
     },
     {
      "name": "state",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "local",
        "published",
        "out_of_sync",
        "unpublished",
        "error",
        "unknown"
       ]
      },
      "description": "Keep only the commands in this Discord publication state."
     }
    ],
    "responses": {
     "200": {
      "description": "A page of commands (no scripts, only list fields).",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "type": "object",
           "required": [
            "items",
            "next_cursor"
           ],
           "properties": {
            "items": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/CommandSummary"
             }
            },
            "next_cursor": {
             "type": [
              "string",
              "null"
             ]
            }
           }
          },
          {
           "type": "object",
           "properties": {
            "revision": {
             "type": "string"
            }
           }
          }
         ]
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   },
   "post": {
    "operationId": "createCommand",
    "summary": "Create a command",
    "tags": [
     "commands"
    ],
    "x-required-scope": "write:commands",
    "security": [
     {
      "ApiKey": [
       "write:commands"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     }
    ],
    "responses": {
     "201": {
      "description": "Command created. It is NOT published at Discord unless the body sets discord.registration and the key has publish:commands.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CommandWrite"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    },
    "description": "The id is command.id, or generated. A new command without a discord block gets registration none: it exists in Bot Creator and nothing is sent to Discord. Publish it with POST …/publication.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CommandBody"
       }
      }
     }
    }
   }
  },
  "/v1/bots/{botId}/commands/{commandId}": {
   "get": {
    "operationId": "getCommand",
    "summary": "Read a command",
    "tags": [
     "commands"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The command and the configuration revision (also the ETag header).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CommandDetail"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   },
   "put": {
    "operationId": "putCommand",
    "summary": "Create or replace a command",
    "tags": [
     "commands"
    ],
    "x-required-scope": "write:commands",
    "security": [
     {
      "ApiKey": [
       "write:commands"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Command written.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CommandWrite"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    },
    "description": "The server compiles the command before writing: an error refuses the write with 422 validation_failed and the list of problems in details. Editing a command that is already published also updates the published copy at Discord (discord_publish in the response).",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CommandBody"
       }
      }
     }
    }
   },
   "patch": {
    "operationId": "patchCommand",
    "summary": "Edit part of a command (JSON merge patch, RFC 7386)",
    "tags": [
     "commands"
    ],
    "x-required-scope": "write:commands",
    "security": [
     {
      "ApiKey": [
       "write:commands"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Command written.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CommandWrite"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    },
    "description": "command is merged into the current command: objects merge recursively, null removes a key, arrays are replaced.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CommandBody"
       }
      }
     }
    }
   },
   "delete": {
    "operationId": "deleteCommand",
    "summary": "Archive a command",
    "tags": [
     "commands"
    ],
    "x-required-scope": "write:commands",
    "security": [
     {
      "ApiKey": [
       "write:commands"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Command deleted (definitive, history included). A published command is removed from Discord too.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Deletion"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/commands/{commandId}/history": {
   "get": {
    "operationId": "listCommandHistory",
    "summary": "Recent versions of a command",
    "tags": [
     "commands"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Most recent versions, newest first (metadata only).",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "items",
          "next_cursor"
         ],
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/CommandVersion"
           }
          },
          "next_cursor": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/commands/{commandId}/rollback/{historyId}": {
   "post": {
    "operationId": "rollbackCommand",
    "summary": "Restore a previous version of a command",
    "tags": [
     "commands"
    ],
    "x-required-scope": "write:commands",
    "security": [
     {
      "ApiKey": [
       "write:commands"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "historyId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Restored (recorded as a new version).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CommandWrite"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/commands/{commandId}/publication": {
   "get": {
    "operationId": "getPublication",
    "summary": "Discord publication state of a command",
    "tags": [
     "commands"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Registration intent, computed state and what the server knows to be published.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Publication"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   },
   "post": {
    "operationId": "publishCommand",
    "summary": "Publish a command at Discord",
    "tags": [
     "commands"
    ],
    "x-required-scope": "publish:commands",
    "security": [
     {
      "ApiKey": [
       "publish:commands"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Published. discord_publish says what was done.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Publication"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "502": {
      "$ref": "#/components/responses/Error502"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    },
    "description": "registration is global or guilds (with guild_ids). If Discord refuses, the answer is 502 discord_error with Discord's reason in details and the state unchanged: never assume a command is live without a 200.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/PublicationBody"
       }
      }
     }
    }
   },
   "delete": {
    "operationId": "unpublishCommand",
    "summary": "Remove a command from Discord, keep it in Bot Creator",
    "tags": [
     "commands"
    ],
    "x-required-scope": "publish:commands",
    "security": [
     {
      "ApiKey": [
       "publish:commands"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Unpublished: registration is now none.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Publication"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "502": {
      "$ref": "#/components/responses/Error502"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/workflows": {
   "get": {
    "operationId": "listWorkflows",
    "summary": "List workflows",
    "tags": [
     "workflows"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 50
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Opaque value: use next_cursor from the previous page."
     }
    ],
    "responses": {
     "200": {
      "description": "A page of workflows.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WorkflowPage"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/workflows/{name}": {
   "get": {
    "operationId": "getWorkflow",
    "summary": "Read a workflow",
    "tags": [
     "workflows"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Workflow name"
     }
    ],
    "responses": {
     "200": {
      "description": "The workflow and the revision.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WorkflowDetail"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   },
   "put": {
    "operationId": "putWorkflow",
    "summary": "Create or replace a workflow",
    "tags": [
     "workflows"
    ],
    "x-required-scope": "write:workflows",
    "security": [
     {
      "ApiKey": [
       "write:workflows"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Workflow name"
     }
    ],
    "responses": {
     "200": {
      "description": "Workflow written.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WorkflowWrite"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WorkflowBody"
       }
      }
     }
    }
   },
   "delete": {
    "operationId": "deleteWorkflow",
    "summary": "Archive a workflow",
    "tags": [
     "workflows"
    ],
    "x-required-scope": "write:workflows",
    "security": [
     {
      "ApiKey": [
       "write:workflows"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Workflow name"
     }
    ],
    "responses": {
     "200": {
      "description": "Deleted (definitive, history included).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Deletion"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/variables": {
   "get": {
    "operationId": "listVariables",
    "summary": "List variables",
    "tags": [
     "variables"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     }
    ],
    "responses": {
     "200": {
      "description": "Global variables (secret-looking names are masked) and the definitions of all scopes.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VariableList"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/variables/{scope}/{key}": {
   "get": {
    "operationId": "getVariable",
    "summary": "Read a variable value",
    "tags": [
     "variables"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "scope",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "global",
        "user",
        "guild",
        "channel",
        "guildMember"
       ]
      }
     },
     {
      "name": "key",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 100
      }
     },
     {
      "name": "scope_id",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Guild, channel or user id (not for global)."
     },
     {
      "name": "scope_aux_id",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Second id for guildMember (the user id)."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 50
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Opaque value: use next_cursor from the previous page."
     }
    ],
    "responses": {
     "200": {
      "description": "One value (scope_id given, or global) or a page of values.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VariableRead"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   },
   "put": {
    "operationId": "putVariable",
    "summary": "Write a variable value",
    "tags": [
     "variables"
    ],
    "x-required-scope": "write:settings",
    "security": [
     {
      "ApiKey": [
       "write:settings"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "scope",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "global",
        "user",
        "guild",
        "channel",
        "guildMember"
       ]
      }
     },
     {
      "name": "key",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 100
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Value written. The variable is defined on the fly if needed.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VariableWrite"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/VariableBody"
       }
      }
     }
    }
   },
   "delete": {
    "operationId": "deleteVariable",
    "summary": "Delete a variable value",
    "tags": [
     "variables"
    ],
    "x-required-scope": "write:settings",
    "security": [
     {
      "ApiKey": [
       "write:settings"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "scope",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "global",
        "user",
        "guild",
        "channel",
        "guildMember"
       ]
      }
     },
     {
      "name": "key",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 100
      }
     },
     {
      "name": "scope_id",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "scope_aux_id",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Value removed (the definition stays).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VariableWrite"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/collections": {
   "get": {
    "operationId": "listCollections",
    "summary": "List collections",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     }
    ],
    "responses": {
     "200": {
      "description": "Collections of all spaces with their counters and indexes.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataCollectionList"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   }
  },
  "/v1/bots/{botId}/data/usage": {
   "get": {
    "operationId": "getDataUsage",
    "summary": "Read data usage and limits",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     }
    ],
    "responses": {
     "200": {
      "description": "Documents and bytes used, and the limits of the creator's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataUsage"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   }
  },
  "/v1/bots/{botId}/data/export": {
   "get": {
    "operationId": "exportData",
    "summary": "Export all documents (NDJSON)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     }
    ],
    "responses": {
     "200": {
      "description": "One JSON object per line: space_kind, space_id, collection, id, rev, data, updated_at. gzip when the client sends Accept-Encoding: gzip. Always available, even above the limits.",
      "content": {
       "application/x-ndjson": {
        "schema": {
         "type": "string"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   }
  },
  "/v1/bots/{botId}/subjects/{userId}": {
   "delete": {
    "operationId": "eraseSubject",
    "summary": "Erase one person's data (GDPR)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "userId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     }
    ],
    "responses": {
     "200": {
      "description": "Number of documents deleted.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "deleted_documents": {
           "type": "integer"
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   }
  },
  "/v1/bots/{botId}/guilds/{spaceId}/collections/{collection}/docs": {
   "get": {
    "operationId": "listGuildDocs",
    "summary": "List documents (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 100
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Opaque value: next_cursor of the previous page."
     },
     {
      "name": "sort",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Field to sort on, `-` prefix for descending (`-xp`). Documents without the field are left out."
     },
     {
      "name": "filter",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "JSON `where` object, e.g. {\"xp\":{\"$gte\":100}}. Operators: $eq $ne $lt $lte $gt $gte $in $prefix. On large collections the fields must have a declared index (422 needs_index)."
     }
    ],
    "responses": {
     "200": {
      "description": "A page of documents. `next_cursor` is empty on the last page.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataPage"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     }
    }
   }
  },
  "/v1/bots/{botId}/guilds/{spaceId}/collections/{collection}/query": {
   "post": {
    "operationId": "queryGuildDocs",
    "summary": "Query documents (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataQuery"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "A page of documents. `next_cursor` is empty on the last page.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataPage"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     }
    }
   }
  },
  "/v1/bots/{botId}/guilds/{spaceId}/collections/{collection}/aggregate": {
   "post": {
    "operationId": "aggregateGuildDocs",
    "summary": "Count, sum, top or rank (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataAggregate"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "`count`, `sum`, `rank` (starts at 1, ties share a rank) or `docs` (top).",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "count": {
           "type": "integer"
          },
          "sum": {
           "type": "number"
          },
          "rank": {
           "type": "integer"
          },
          "docs": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/DataDoc"
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     }
    }
   }
  },
  "/v1/bots/{botId}/guilds/{spaceId}/collections/{collection}/docs/{docId}": {
   "get": {
    "operationId": "getGuildDoc",
    "summary": "Read a document (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "responses": {
     "200": {
      "description": "The document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   },
   "put": {
    "operationId": "putGuildDoc",
    "summary": "Replace or create a document (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataDocBody"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The stored document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     }
    }
   },
   "patch": {
    "operationId": "patchGuildDoc",
    "summary": "Merge into a document (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "description": "RFC 7386 merge patch: objects merge, null deletes a key, anything else replaces."
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The stored document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     }
    }
   },
   "delete": {
    "operationId": "deleteGuildDoc",
    "summary": "Delete a document (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "responses": {
     "200": {
      "description": "`deleted` is false when the document did not exist.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "deleted": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     }
    }
   }
  },
  "/v1/bots/{botId}/guilds/{spaceId}/collections/{collection}/docs/{docId}/ops": {
   "post": {
    "operationId": "applyGuildDocOp",
    "summary": "Atomic operation on a document (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataOp"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The stored document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     }
    }
   }
  },
  "/v1/bots/{botId}/guilds/{spaceId}/collections/{collection}": {
   "put": {
    "operationId": "setGuildCollection",
    "summary": "Set indexes, TTL and labels of a collection (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataCollectionConfig"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Saved; existing documents are re-indexed.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     }
    }
   }
  },
  "/v1/bots/{botId}/guilds/{spaceId}/batch": {
   "post": {
    "operationId": "batchGuildDocs",
    "summary": "Atomic batch of operations (guild space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord server id."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "ops"
        ],
        "properties": {
         "ops": {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/DataBatchOp"
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "One result per operation; all or nothing.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "results": {
           "type": "array",
           "items": {
            "type": "object"
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     }
    }
   }
  },
  "/v1/bots/{botId}/users/{spaceId}/collections/{collection}/docs": {
   "get": {
    "operationId": "listUserDocs",
    "summary": "List documents (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 100
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Opaque value: next_cursor of the previous page."
     },
     {
      "name": "sort",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Field to sort on, `-` prefix for descending (`-xp`). Documents without the field are left out."
     },
     {
      "name": "filter",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "JSON `where` object, e.g. {\"xp\":{\"$gte\":100}}. Operators: $eq $ne $lt $lte $gt $gte $in $prefix. On large collections the fields must have a declared index (422 needs_index)."
     }
    ],
    "responses": {
     "200": {
      "description": "A page of documents. `next_cursor` is empty on the last page.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataPage"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     }
    }
   }
  },
  "/v1/bots/{botId}/users/{spaceId}/collections/{collection}/query": {
   "post": {
    "operationId": "queryUserDocs",
    "summary": "Query documents (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataQuery"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "A page of documents. `next_cursor` is empty on the last page.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataPage"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     }
    }
   }
  },
  "/v1/bots/{botId}/users/{spaceId}/collections/{collection}/aggregate": {
   "post": {
    "operationId": "aggregateUserDocs",
    "summary": "Count, sum, top or rank (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataAggregate"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "`count`, `sum`, `rank` (starts at 1, ties share a rank) or `docs` (top).",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "count": {
           "type": "integer"
          },
          "sum": {
           "type": "number"
          },
          "rank": {
           "type": "integer"
          },
          "docs": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/DataDoc"
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     }
    }
   }
  },
  "/v1/bots/{botId}/users/{spaceId}/collections/{collection}/docs/{docId}": {
   "get": {
    "operationId": "getUserDoc",
    "summary": "Read a document (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "responses": {
     "200": {
      "description": "The document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   },
   "put": {
    "operationId": "putUserDoc",
    "summary": "Replace or create a document (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataDocBody"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The stored document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     }
    }
   },
   "patch": {
    "operationId": "patchUserDoc",
    "summary": "Merge into a document (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "description": "RFC 7386 merge patch: objects merge, null deletes a key, anything else replaces."
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The stored document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     }
    }
   },
   "delete": {
    "operationId": "deleteUserDoc",
    "summary": "Delete a document (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "responses": {
     "200": {
      "description": "`deleted` is false when the document did not exist.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "deleted": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     }
    }
   }
  },
  "/v1/bots/{botId}/users/{spaceId}/collections/{collection}/docs/{docId}/ops": {
   "post": {
    "operationId": "applyUserDocOp",
    "summary": "Atomic operation on a document (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataOp"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The stored document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     }
    }
   }
  },
  "/v1/bots/{botId}/users/{spaceId}/collections/{collection}": {
   "put": {
    "operationId": "setUserCollection",
    "summary": "Set indexes, TTL and labels of a collection (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataCollectionConfig"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Saved; existing documents are re-indexed.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     }
    }
   }
  },
  "/v1/bots/{botId}/users/{spaceId}/batch": {
   "post": {
    "operationId": "batchUserDocs",
    "summary": "Atomic batch of operations (user space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord user id."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "ops"
        ],
        "properties": {
         "ops": {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/DataBatchOp"
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "One result per operation; all or nothing.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "results": {
           "type": "array",
           "items": {
            "type": "object"
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     }
    }
   }
  },
  "/v1/bots/{botId}/bot-space/{spaceId}/collections/{collection}/docs": {
   "get": {
    "operationId": "listBotSpaceDocs",
    "summary": "List documents (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 100
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Opaque value: next_cursor of the previous page."
     },
     {
      "name": "sort",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Field to sort on, `-` prefix for descending (`-xp`). Documents without the field are left out."
     },
     {
      "name": "filter",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "JSON `where` object, e.g. {\"xp\":{\"$gte\":100}}. Operators: $eq $ne $lt $lte $gt $gte $in $prefix. On large collections the fields must have a declared index (422 needs_index)."
     }
    ],
    "responses": {
     "200": {
      "description": "A page of documents. `next_cursor` is empty on the last page.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataPage"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     }
    }
   }
  },
  "/v1/bots/{botId}/bot-space/{spaceId}/collections/{collection}/query": {
   "post": {
    "operationId": "queryBotSpaceDocs",
    "summary": "Query documents (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataQuery"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "A page of documents. `next_cursor` is empty on the last page.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataPage"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     }
    }
   }
  },
  "/v1/bots/{botId}/bot-space/{spaceId}/collections/{collection}/aggregate": {
   "post": {
    "operationId": "aggregateBotSpaceDocs",
    "summary": "Count, sum, top or rank (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataAggregate"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "`count`, `sum`, `rank` (starts at 1, ties share a rank) or `docs` (top).",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "count": {
           "type": "integer"
          },
          "sum": {
           "type": "number"
          },
          "rank": {
           "type": "integer"
          },
          "docs": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/DataDoc"
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     }
    }
   }
  },
  "/v1/bots/{botId}/bot-space/{spaceId}/collections/{collection}/docs/{docId}": {
   "get": {
    "operationId": "getBotSpaceDoc",
    "summary": "Read a document (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "read:data",
    "security": [
     {
      "ApiKey": [
       "read:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "responses": {
     "200": {
      "description": "The document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   },
   "put": {
    "operationId": "putBotSpaceDoc",
    "summary": "Replace or create a document (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataDocBody"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The stored document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     }
    }
   },
   "patch": {
    "operationId": "patchBotSpaceDoc",
    "summary": "Merge into a document (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "description": "RFC 7386 merge patch: objects merge, null deletes a key, anything else replaces."
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The stored document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     }
    }
   },
   "delete": {
    "operationId": "deleteBotSpaceDoc",
    "summary": "Delete a document (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "responses": {
     "200": {
      "description": "`deleted` is false when the document did not exist.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "deleted": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     }
    }
   }
  },
  "/v1/bots/{botId}/bot-space/{spaceId}/collections/{collection}/docs/{docId}/ops": {
   "post": {
    "operationId": "applyBotSpaceDocOp",
    "summary": "Atomic operation on a document (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     },
     {
      "name": "docId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Document id, 1 to 128 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataOp"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The stored document.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DataDoc"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     }
    }
   }
  },
  "/v1/bots/{botId}/bot-space/{spaceId}/collections/{collection}": {
   "put": {
    "operationId": "setBotSpaceCollection",
    "summary": "Set indexes, TTL and labels of a collection (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     },
     {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Collection name: [a-z0-9_][a-z0-9_.-]{0,63}."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DataCollectionConfig"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Saved; existing documents are re-indexed.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     }
    }
   }
  },
  "/v1/bots/{botId}/bot-space/{spaceId}/batch": {
   "post": {
    "operationId": "batchBotSpaceDocs",
    "summary": "Atomic batch of operations (bot space)",
    "tags": [
     "data"
    ],
    "x-required-scope": "write:data",
    "security": [
     {
      "ApiKey": [
       "write:data"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "spaceId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Any value: the bot space is a single constant space."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "ops"
        ],
        "properties": {
         "ops": {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/DataBatchOp"
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "One result per operation; all or nothing.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "results": {
           "type": "array",
           "items": {
            "type": "object"
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     }
    }
   }
  },
  "/v1/bots/{botId}/files": {
   "get": {
    "operationId": "listFiles",
    "summary": "List stored files",
    "description": "Files the bot stores (the ones its scripts write with `$fileUpload`, `bc.files`…), ordered by path. `prefix` keeps the paths that start with it. Pass `next_cursor` as `cursor` for the next page.",
    "tags": [
     "files"
    ],
    "x-required-scope": "read:files",
    "security": [
     {
      "ApiKey": [
       "read:files"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "prefix",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Only paths starting with this text."
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "The `next_cursor` of the previous page."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 50
      }
     }
    ],
    "responses": {
     "200": {
      "description": "A page of files, with what the bot's files take in total.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/FileList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   },
   "delete": {
    "operationId": "deleteFile",
    "summary": "Delete a file",
    "description": "Deletes the file and gives its space back to the account quota. Idempotent: deleting a missing file answers 200 with `deleted: false`.",
    "tags": [
     "files"
    ],
    "x-required-scope": "write:files",
    "security": [
     {
      "ApiKey": [
       "write:files"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "path",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Logical path of the file, e.g. `exports/report.csv`. Segments are separated by `/`; no leading or trailing `/`, no `.` or `..` segment, 1 to 255 bytes."
     }
    ],
    "responses": {
     "200": {
      "description": "Whether the file existed.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "deleted": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   }
  },
  "/v1/bots/{botId}/files/info": {
   "get": {
    "operationId": "getFileInfo",
    "summary": "Read a file's metadata",
    "description": "Size, content type and last update, without the content.",
    "tags": [
     "files"
    ],
    "x-required-scope": "read:files",
    "security": [
     {
      "ApiKey": [
       "read:files"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "path",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Logical path of the file, e.g. `exports/report.csv`. Segments are separated by `/`; no leading or trailing `/`, no `.` or `..` segment, 1 to 255 bytes."
     }
    ],
    "responses": {
     "200": {
      "description": "The file.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/File"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   }
  },
  "/v1/bots/{botId}/files/content": {
   "get": {
    "operationId": "downloadFile",
    "summary": "Download a file",
    "description": "Returns the raw bytes as `application/octet-stream`, always as an attachment. The type stored with the file is in the `X-File-Content-Type` header.",
    "tags": [
     "files"
    ],
    "x-required-scope": "read:files",
    "security": [
     {
      "ApiKey": [
       "read:files"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "path",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Logical path of the file, e.g. `exports/report.csv`. Segments are separated by `/`; no leading or trailing `/`, no `.` or `..` segment, 1 to 255 bytes."
     }
    ],
    "responses": {
     "200": {
      "description": "The raw content.",
      "headers": {
       "X-File-Content-Type": {
        "schema": {
         "type": "string"
        },
        "description": "Content type stored with the file."
       }
      },
      "content": {
       "application/octet-stream": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   },
   "put": {
    "operationId": "uploadFile",
    "summary": "Upload or replace a file",
    "description": "The request body is the raw content and `Content-Type` is stored as the file's type. Replaces the file when the path exists. Up to 25 MiB per file; the account storage quota applies (a replacement only counts its difference).",
    "tags": [
     "files"
    ],
    "x-required-scope": "write:files",
    "security": [
     {
      "ApiKey": [
       "write:files"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "path",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Logical path of the file, e.g. `exports/report.csv`. Segments are separated by `/`; no leading or trailing `/`, no `.` or `..` segment, 1 to 255 bytes."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/octet-stream": {
       "schema": {
        "type": "string",
        "format": "binary"
       }
      }
     },
     "description": "Raw bytes of the file. Any Content-Type is accepted."
    },
    "responses": {
     "200": {
      "description": "The stored file.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/File"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "413": {
      "description": "The file exceeds 25 MiB (`file_too_large`).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   }
  },
  "/v1/bots/{botId}/files/link": {
   "post": {
    "operationId": "createFileLink",
    "summary": "Create a public link",
    "description": "Returns a signed link anyone can open to read the file until it expires, with no API key. Default 1 hour, at most 7 days. A link cannot be revoked before its expiry: delete the file to make it stop working. Images, audio, video, plain text and PDF open in the browser; every other type downloads.",
    "tags": [
     "files"
    ],
    "x-required-scope": "read:files",
    "security": [
     {
      "ApiKey": [
       "read:files"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "path"
        ],
        "properties": {
         "path": {
          "type": "string"
         },
         "ttl_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 604800,
          "default": 3600
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The link.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "url": {
           "type": "string",
           "format": "uri"
          },
          "expires_at": {
           "type": "string",
           "format": "date-time"
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   }
  },
  "/v1/bots/{botId}/preview": {
   "post": {
    "operationId": "previewScript",
    "summary": "Preview what a script returns",
    "description": "Runs a BDFD script in the sandbox with sample values and returns the messages it would send (content, embeds, components). Nothing is sent to Discord, nothing is written (variables, database, files) and there is no network access: the engine only reads the scenario you send. Pass exactly one of `script` or `command_id`. JavaScript and graph commands are not supported yet.",
    "tags": [
     "commands"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/PreviewBody"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The simulated result. A script error is a 200 with ok=false.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Preview"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "503": {
      "description": "sandbox_unavailable: the preview engine is not reachable; retry shortly.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/preview": {
   "post": {
    "operationId": "previewPublic",
    "summary": "Preview a script without a bot or an API key",
    "description": "Same engine and same response as the per-bot preview, with an example context only (empty database, sample author, channel and server). No key, no bot: meant for documentation and playgrounds. Limited per IP address (20 per minute), script up to 20,000 characters. Use the per-bot route to preview with the options of one of your commands.",
    "tags": [
     "commands"
    ],
    "x-required-scope": "none",
    "security": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "script"
        ],
        "properties": {
         "script": {
          "type": "string",
          "maxLength": 20000
         },
         "scenario": {
          "$ref": "#/components/schemas/PreviewBody/properties/scenario"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The simulated result.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Preview"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     },
     "503": {
      "description": "sandbox_unavailable: no preview engine is reachable; retry shortly.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/examples/{page}": {
   "get": {
    "operationId": "getDocExamples",
    "summary": "Examples of a documentation page, with their computed result",
    "description": "Every BDFD example of a documentation page together with the message it produces, computed in advance by the real engine. Nothing is executed by this call: it is public, cached and not subject to the preview limits. `ok=false` means the example could not run with the sample values.",
    "tags": [
     "commands"
    ],
    "x-required-scope": "none",
    "security": [],
    "parameters": [
     {
      "name": "page",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Page slug, as in /docs/{slug}.json (for example dbget)."
     }
    ],
    "responses": {
     "200": {
      "description": "The examples of the page.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DocExamples"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     }
    }
   }
  },
  "/v1/bots/{botId}/alerts": {
   "get": {
    "operationId": "listAlerts",
    "summary": "List a server's alerts",
    "description": "Alerts of one server (RSS, YouTube, Twitch, Bluesky) with the limits that apply to it. The bot owner must have turned alerts on, on a paid plan.",
    "tags": [
     "alerts"
    ],
    "x-required-scope": "read:bots",
    "security": [
     {
      "ApiKey": [
       "read:bots"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "guild_id",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord ID of the server the alerts belong to."
     }
    ],
    "responses": {
     "200": {
      "description": "The alerts.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AlertList"
        }
       }
      }
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   },
   "post": {
    "operationId": "createAlert",
    "summary": "Create an alert",
    "description": "Creates an alert on a server and starts it (set `start` to false to leave it paused). Same limits as the `$createAlert` script function: active alerts per server and total per bot depend on the plan.",
    "tags": [
     "alerts"
    ],
    "x-required-scope": "write:settings",
    "security": [
     {
      "ApiKey": [
       "write:settings"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     }
    ],
    "responses": {
     "201": {
      "description": "The alert.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Alert"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error400"
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     },
     "422": {
      "$ref": "#/components/responses/Error422"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/AlertBody"
       }
      }
     }
    }
   }
  },
  "/v1/bots/{botId}/alerts/{alertId}": {
   "delete": {
    "operationId": "deleteAlert",
    "summary": "Delete an alert",
    "description": "Deletes the alert of a server.",
    "tags": [
     "alerts"
    ],
    "x-required-scope": "write:settings",
    "security": [
     {
      "ApiKey": [
       "write:settings"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "alertId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the alert."
     },
     {
      "name": "guild_id",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Discord ID of the server the alerts belong to."
     }
    ],
    "responses": {
     "204": {
      "description": "Deleted."
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    }
   }
  },
  "/v1/bots/{botId}/alerts/{alertId}/pause": {
   "post": {
    "operationId": "pauseAlert",
    "summary": "Pause an alert",
    "description": "Alerts of a server run only while active; resuming is refused when the server's active limit is reached.",
    "tags": [
     "alerts"
    ],
    "x-required-scope": "write:settings",
    "security": [
     {
      "ApiKey": [
       "write:settings"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "alertId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the alert."
     }
    ],
    "responses": {
     "200": {
      "description": "The alert.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Alert"
        }
       }
      }
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/AlertGuildBody"
       }
      }
     }
    }
   }
  },
  "/v1/bots/{botId}/alerts/{alertId}/resume": {
   "post": {
    "operationId": "resumeAlert",
    "summary": "Resume an alert",
    "description": "Alerts of a server run only while active; resuming is refused when the server's active limit is reached.",
    "tags": [
     "alerts"
    ],
    "x-required-scope": "write:settings",
    "security": [
     {
      "ApiKey": [
       "write:settings"
      ]
     }
    ],
    "parameters": [
     {
      "name": "botId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the bot the key belongs to. Any other bot answers 404 bot_not_found."
     },
     {
      "name": "alertId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identifier of the alert."
     }
    ],
    "responses": {
     "200": {
      "description": "The alert.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Alert"
        }
       }
      }
     },
     "409": {
      "$ref": "#/components/responses/Error409"
     },
     "404": {
      "$ref": "#/components/responses/Error404"
     },
     "401": {
      "$ref": "#/components/responses/Error401"
     },
     "403": {
      "$ref": "#/components/responses/Error403"
     },
     "429": {
      "$ref": "#/components/responses/Error429"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/AlertGuildBody"
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "ApiKey": {
    "type": "http",
    "scheme": "bearer",
    "description": "API key `bcm_k_<id>_<secret>` created in the Studio. Scopes: read:bots, write:commands, publish:commands, write:workflows, write:settings, read:data, write:data, read:files, write:files."
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "required": [
     "code",
     "message"
    ],
    "properties": {
     "code": {
      "type": "string",
      "description": "Stable machine-readable code."
     },
     "message": {
      "type": "string"
     },
     "details": {},
     "request_id": {
      "type": "string",
      "description": "Quote it to the support."
     }
    }
   },
   "Bot": {
    "type": "object",
    "properties": {
     "bot_id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "engine": {
      "type": "string"
     },
     "revision": {
      "type": "string"
     },
     "command_count": {
      "type": "integer"
     },
     "workflow_count": {
      "type": "integer"
     },
     "settings": {
      "type": "object",
      "additionalProperties": true
     }
    }
   },
   "CommandSummary": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "trigger": {
      "type": "string"
     },
     "content_hash": {
      "type": "string"
     },
     "description": {
      "type": "string"
     },
     "type": {
      "type": "string"
     },
     "folder": {
      "type": "string"
     },
     "option_count": {
      "type": "integer"
     },
     "node_count": {
      "type": "integer",
      "description": "Number of nodes of the graph"
     },
     "action_count": {
      "type": "integer",
      "description": "Deprecated alias of node_count"
     },
     "execution_mode": {
      "type": "string",
      "description": "graph, bdfd_script or javascript"
     }
    },
    "additionalProperties": true
   },
   "CommandDetail": {
    "type": "object",
    "properties": {
     "bot_id": {
      "type": "string"
     },
     "revision": {
      "type": "string"
     },
     "command": {
      "type": "object",
      "additionalProperties": true
     }
    }
   },
   "CommandBody": {
    "type": "object",
    "required": [
     "command"
    ],
    "additionalProperties": false,
    "properties": {
     "command": {
      "type": "object",
      "additionalProperties": true,
      "description": "The command document. Same format as the Studio; read an existing one with GET to see it. data.discord.registration is none, global or guilds (with data.discord.guildIds)."
     }
    }
   },
   "CommandWrite": {
    "type": "object",
    "properties": {
     "revision": {
      "type": "string"
     },
     "command": {
      "type": "object",
      "additionalProperties": true
     },
     "history_id": {
      "type": "string"
     },
     "runner_synced": {
      "type": "boolean"
     },
     "runner_sync_reason": {
      "type": "string"
     },
     "next_step": {
      "type": "string"
     },
     "warnings": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "discord_publish": {
      "type": "string"
     },
     "discord_error": {
      "type": "string"
     },
     "compile": {
      "type": "object",
      "properties": {
       "errors": {
        "type": "array",
        "items": {
         "type": "object",
         "additionalProperties": true
        }
       },
       "warnings": {
        "type": "array",
        "items": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    },
    "description": "runner_synced false means the change is saved but the running bot did not receive it: read runner_sync_reason and next_step."
   },
   "Deletion": {
    "type": "object",
    "properties": {
     "revision": {
      "type": "string"
     },
     "deleted": {
      "type": "boolean"
     },
     "runner_synced": {
      "type": "boolean"
     },
     "runner_sync_reason": {
      "type": "string"
     },
     "next_step": {
      "type": "string"
     },
     "discord_publish": {
      "type": "string"
     },
     "discord_error": {
      "type": "string"
     }
    }
   },
   "CommandVersion": {
    "type": "object",
    "properties": {
     "history_id": {
      "type": "string"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "size_bytes": {
      "type": "integer"
     },
     "content_hash": {
      "type": "string"
     },
     "revision": {
      "type": "string"
     }
    }
   },
   "PublicationBody": {
    "type": "object",
    "required": [
     "registration"
    ],
    "additionalProperties": false,
    "properties": {
     "registration": {
      "type": "string",
      "enum": [
       "global",
       "guilds"
      ]
     },
     "guild_ids": {
      "type": "array",
      "items": {
       "type": "string",
       "pattern": "^[0-9]{17,20}$"
      }
     }
    }
   },
   "Publication": {
    "type": "object",
    "properties": {
     "command_id": {
      "type": "string"
     },
     "registration": {
      "type": "string",
      "enum": [
       "none",
       "global",
       "guilds"
      ]
     },
     "registration_explicit": {
      "type": "boolean"
     },
     "guild_ids": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "state": {
      "type": "string",
      "enum": [
       "local",
       "published",
       "out_of_sync",
       "unpublished",
       "error",
       "unknown"
      ]
     },
     "publications": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": true
      }
     },
     "discord_publish": {
      "type": "string"
     },
     "discord_error": {
      "type": "string"
     }
    }
   },
   "WorkflowPage": {
    "allOf": [
     {
      "type": "object",
      "required": [
       "items",
       "next_cursor"
      ],
      "properties": {
       "items": {
        "type": "array",
        "items": {
         "type": "object",
         "additionalProperties": true
        }
       },
       "next_cursor": {
        "type": [
         "string",
         "null"
        ]
       }
      }
     },
     {
      "type": "object",
      "properties": {
       "revision": {
        "type": "string"
       }
      }
     }
    ]
   },
   "WorkflowDetail": {
    "type": "object",
    "properties": {
     "bot_id": {
      "type": "string"
     },
     "revision": {
      "type": "string"
     },
     "workflow": {
      "type": "object",
      "additionalProperties": true
     }
    }
   },
   "WorkflowBody": {
    "type": "object",
    "required": [
     "workflow"
    ],
    "additionalProperties": false,
    "properties": {
     "workflow": {
      "type": "object",
      "additionalProperties": true
     }
    }
   },
   "WorkflowWrite": {
    "type": "object",
    "properties": {
     "revision": {
      "type": "string"
     },
     "workflow": {
      "type": "object",
      "additionalProperties": true
     },
     "runner_synced": {
      "type": "boolean"
     },
     "runner_sync_reason": {
      "type": "string"
     },
     "next_step": {
      "type": "string"
     },
     "compile": {
      "type": "object",
      "properties": {
       "errors": {
        "type": "array",
        "items": {
         "type": "object",
         "additionalProperties": true
        }
       },
       "warnings": {
        "type": "array",
        "items": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    }
   },
   "VariableList": {
    "type": "object",
    "properties": {
     "global": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": true
      }
     },
     "definitions": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": true
      }
     }
    }
   },
   "VariableRead": {
    "type": "object",
    "properties": {
     "scope": {
      "type": "string"
     },
     "key": {
      "type": "string"
     },
     "found": {
      "type": "boolean"
     },
     "value": {},
     "items": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": true
      }
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     },
     "total": {
      "type": "integer"
     }
    }
   },
   "VariableBody": {
    "type": "object",
    "required": [
     "value"
    ],
    "additionalProperties": false,
    "properties": {
     "value": {
      "description": "Any JSON value."
     },
     "scope_id": {
      "type": "string"
     },
     "scope_aux_id": {
      "type": "string"
     }
    }
   },
   "VariableWrite": {
    "type": "object",
    "properties": {
     "ok": {
      "type": "boolean"
     },
     "scope": {
      "type": "string"
     },
     "key": {
      "type": "string"
     },
     "deleted": {
      "type": "boolean"
     },
     "runner_synced": {
      "type": "boolean"
     },
     "runner_sync_reason": {
      "type": "string"
     },
     "next_step": {
      "type": "string"
     }
    }
   },
   "DataDoc": {
    "type": "object",
    "properties": {
     "space": {
      "type": "object",
      "properties": {
       "kind": {
        "type": "string",
        "enum": [
         "guild",
         "bot",
         "user"
        ]
       },
       "id": {
        "type": "string"
       }
      }
     },
     "collection": {
      "type": "string"
     },
     "id": {
      "type": "string"
     },
     "data": {
      "type": "object"
     },
     "rev": {
      "type": "integer",
      "description": "Incremented at every write."
     },
     "size_bytes": {
      "type": "integer"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     },
     "expires_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "DataPage": {
    "type": "object",
    "properties": {
     "docs": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/DataDoc"
      }
     },
     "next_cursor": {
      "type": "string"
     }
    }
   },
   "DataDocBody": {
    "type": "object",
    "required": [
     "data"
    ],
    "properties": {
     "data": {
      "type": "object",
      "description": "The document: a JSON object. Keys starting with $ and __proto__ are refused."
     },
     "ttl_seconds": {
      "type": "integer",
      "minimum": 1
     },
     "rev": {
      "type": "integer",
      "description": "Optional compare-and-set: refused with 409 conflict if the stored revision differs."
     }
    }
   },
   "DataQuery": {
    "type": "object",
    "properties": {
     "where": {
      "type": "object"
     },
     "sort": {
      "type": "array",
      "maxItems": 1,
      "items": {
       "type": "array",
       "items": {
        "type": "string"
       },
       "minItems": 2,
       "maxItems": 2
      },
      "example": [
       [
        "xp",
        "desc"
       ]
      ]
     },
     "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
     },
     "after": {
      "type": "string",
      "description": "next_cursor of the previous page."
     }
    }
   },
   "DataAggregate": {
    "type": "object",
    "required": [
     "op"
    ],
    "properties": {
     "op": {
      "type": "string",
      "enum": [
       "count",
       "sum",
       "top",
       "rank"
      ]
     },
     "field": {
      "type": "string"
     },
     "where": {
      "type": "object"
     },
     "id": {
      "type": "string",
      "description": "Document id (rank)."
     },
     "n": {
      "type": "integer",
      "description": "Number of documents (top), default 10."
     },
     "desc": {
      "type": "boolean",
      "default": true
     }
    }
   },
   "DataOp": {
    "type": "object",
    "required": [
     "op"
    ],
    "properties": {
     "op": {
      "type": "string",
      "enum": [
       "incr",
       "push",
       "pull",
       "addToSet"
      ]
     },
     "path": {
      "type": "string",
      "description": "Dotted path, e.g. stats.wins."
     },
     "value": {
      "description": "Value to push, pull or add."
     },
     "delta": {
      "type": "number",
      "description": "incr: integers stay exact up to 2^53-1."
     },
     "min": {
      "type": "number"
     },
     "max": {
      "type": "number"
     },
     "max_len": {
      "type": "integer",
      "description": "push and addToSet keep the newest max_len items."
     },
     "rev": {
      "type": "integer",
      "description": "Compare-and-set on the revision."
     },
     "return": {
      "type": "string",
      "enum": [
       "doc",
       "none"
      ],
      "default": "doc",
      "description": "doc returns the stored document, none applies the write and answers {\"ok\":true} without it."
     }
    }
   },
   "DataBatchOp": {
    "type": "object",
    "required": [
     "op",
     "collection",
     "id"
    ],
    "properties": {
     "op": {
      "type": "string",
      "enum": [
       "set",
       "create",
       "merge",
       "incr",
       "push",
       "pull",
       "addToSet",
       "delete",
       "transfer"
      ]
     },
     "collection": {
      "type": "string"
     },
     "id": {
      "type": "string"
     },
     "path": {
      "type": "string"
     },
     "value": {},
     "delta": {
      "type": "number",
      "description": "incr delta, or transfer amount."
     },
     "to_id": {
      "type": "string",
      "description": "transfer: destination document."
     },
     "min": {
      "type": "number"
     },
     "max": {
      "type": "number"
     },
     "max_len": {
      "type": "integer"
     },
     "rev": {
      "type": "integer"
     },
     "ttl_seconds": {
      "type": "integer"
     },
     "return": {
      "type": "string",
      "enum": [
       "doc",
       "none"
      ],
      "default": "doc",
      "description": "doc keeps the document in the result, none leaves it out."
     }
    }
   },
   "DataCollectionConfig": {
    "type": "object",
    "properties": {
     "indexes": {
      "type": "array",
      "items": {
       "type": "object",
       "required": [
        "name",
        "field",
        "type"
       ],
       "properties": {
        "name": {
         "type": "string"
        },
        "field": {
         "type": "string"
        },
        "type": {
         "type": "string",
         "enum": [
          "text",
          "number",
          "bool",
          "timestamp"
         ]
        }
       }
      }
     },
     "default_ttl_seconds": {
      "type": "integer",
      "minimum": 1
     },
     "subject_field": {
      "type": "string",
      "description": "Field holding a Discord user id: used by the GDPR erase route."
     },
     "field_labels": {
      "type": "object",
      "additionalProperties": {
       "type": "string",
       "enum": [
        "pii",
        "secret",
        "discord_user_id",
        "message_content"
       ]
      }
     }
    }
   },
   "DataCollectionList": {
    "type": "object",
    "properties": {
     "collections": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "space_kind": {
         "type": "string"
        },
        "name": {
         "type": "string"
        },
        "docs": {
         "type": "integer"
        },
        "bytes": {
         "type": "integer"
        },
        "indexes": {
         "type": "array",
         "items": {
          "type": "object"
         }
        },
        "default_ttl_seconds": {
         "type": "integer"
        }
       }
      }
     }
    }
   },
   "DataUsage": {
    "type": "object",
    "properties": {
     "docs": {
      "type": "integer"
     },
     "bytes": {
      "type": "integer"
     },
     "max_docs": {
      "type": "integer"
     },
     "max_bytes": {
      "type": "integer"
     },
     "paid": {
      "type": "boolean"
     }
    }
   },
   "File": {
    "type": "object",
    "properties": {
     "path": {
      "type": "string"
     },
     "size": {
      "type": "integer",
      "description": "Bytes."
     },
     "content_type": {
      "type": "string"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "FileList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/File"
      }
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     },
     "used_bytes": {
      "type": "integer",
      "description": "Space taken by this bot's files."
     },
     "count": {
      "type": "integer",
      "description": "Number of files of this bot."
     },
     "max_file_bytes": {
      "type": "integer"
     }
    }
   },
   "PreviewBody": {
    "type": "object",
    "description": "Exactly one of script or command_id.",
    "properties": {
     "script": {
      "type": "string",
      "maxLength": 100000,
      "description": "BDFD script to simulate."
     },
     "command_id": {
      "type": "string",
      "description": "Simulate the saved BDFD script of this command, with its declared option types."
     },
     "scenario": {
      "type": "object",
      "description": "Sample values.",
      "properties": {
       "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Option name -> value."
       },
       "optionTypes": {
        "type": "object",
        "additionalProperties": {
         "type": "string",
         "enum": [
          "string",
          "integer",
          "number",
          "boolean",
          "user",
          "channel",
          "role",
          "mentionable"
         ]
        },
        "description": "Option name -> type, so the value is converted like on Discord."
       },
       "variables": {
        "type": "object",
        "additionalProperties": true,
        "description": "Runtime variables (names with a dot, e.g. member.isAdmin) or stored member variables (plain names)."
       },
       "permissions": {
        "description": "Permissions of the member running the command."
       },
       "memberRoles": {
        "type": "array",
        "items": {
         "type": "string"
        },
        "description": "Role IDs of the member running the command."
       },
       "channelParentId": {
        "type": "string",
        "description": "ID of the category of the channel."
       }
      }
     }
    }
   },
   "Preview": {
    "type": "object",
    "required": [
     "ok",
     "error",
     "diagnostics",
     "messages",
     "effects",
     "simulated"
    ],
    "properties": {
     "ok": {
      "type": "boolean"
     },
     "error": {
      "type": [
       "string",
       "null"
      ],
      "description": "Runtime error, if the script failed."
     },
     "diagnostics": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": true
      },
      "description": "Located problems (message, function, line)."
     },
     "messages": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": true
      },
      "description": "Messages the script would send; each has a payload with content, embeds and components."
     },
     "effects": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Kinds of side effects that were simulated and NOT performed."
     },
     "simulated": {
      "type": "boolean",
      "const": true
     }
    }
   },
   "DocExamples": {
    "type": "object",
    "required": [
     "page",
     "examples"
    ],
    "properties": {
     "page": {
      "type": "string"
     },
     "examples": {
      "type": "array",
      "items": {
       "type": "object",
       "required": [
        "script",
        "ok",
        "messages"
       ],
       "properties": {
        "script": {
         "type": "string"
        },
        "ok": {
         "type": "boolean"
        },
        "error": {
         "type": [
          "string",
          "null"
         ]
        },
        "diagnostics": {
         "type": "array",
         "items": {
          "type": "object",
          "additionalProperties": true
         }
        },
        "messages": {
         "type": "array",
         "items": {
          "type": "object",
          "additionalProperties": true
         }
        }
       }
      }
     }
    }
   },
   "Alert": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "guild_id": {
      "type": "string"
     },
     "channel_id": {
      "type": "string"
     },
     "action": {
      "type": "string",
      "enum": [
       "workflow",
       "message",
       "both"
      ]
     },
     "name": {
      "type": "string"
     },
     "source_kind": {
      "type": "string",
      "enum": [
       "rss",
       "youtube",
       "twitch",
       "bluesky"
      ]
     },
     "source": {
      "type": "object",
      "additionalProperties": {
       "type": "string"
      }
     },
     "status": {
      "type": "string",
      "enum": [
       "active",
       "paused"
      ]
     },
     "last_error": {
      "type": "string"
     },
     "last_sent_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     }
    }
   },
   "AlertList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Alert"
      }
     },
     "limits": {
      "type": "object",
      "description": "Plan limits and counters (enabled, paid, limits, active, total_in_bot)."
     }
    }
   },
   "AlertBody": {
    "type": "object",
    "required": [
     "guild_id",
     "name",
     "source_kind",
     "source",
     "channel_id"
    ],
    "properties": {
     "guild_id": {
      "type": "string"
     },
     "name": {
      "type": "string",
      "maxLength": 60
     },
     "source_kind": {
      "type": "string",
      "enum": [
       "rss",
       "youtube",
       "twitch",
       "bluesky"
      ]
     },
     "source": {
      "type": "object",
      "description": "One key by kind: `url` (rss), `channel` (youtube), `login` (twitch), `handle` (bluesky).",
      "additionalProperties": {
       "type": "string"
      }
     },
     "channel_id": {
      "type": "string"
     },
     "action": {
      "type": "string",
      "enum": [
       "workflow",
       "message",
       "both"
      ],
      "default": "workflow"
     },
     "start": {
      "type": "boolean",
      "default": true
     }
    }
   },
   "AlertGuildBody": {
    "type": "object",
    "required": [
     "guild_id"
    ],
    "properties": {
     "guild_id": {
      "type": "string"
     }
    }
   }
  },
  "responses": {
   "Error401": {
    "description": "invalid_authorization, invalid_key, key_revoked or key_expired.",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Error403": {
    "description": "missing_scope (details.required_scope names it) or key_suspended (account suspended or Premium inactive: the key works again once the account is back in order).",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Error429": {
    "description": "rate_limited. Retry after Retry-After seconds.",
    "headers": {
     "Retry-After": {
      "schema": {
       "type": "integer"
      }
     }
    },
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Error400": {
    "description": "invalid_payload, invalid_pagination, invalid_state, or precondition_unsupported (If-Match / If-None-Match are refused: writes are last-write-wins).",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Error404": {
    "description": "bot_not_found (also for a bot that is not the key's) or the resource does not exist.",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Error409": {
    "description": "already_exists: a command with this id exists; use PUT to replace it.",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Error422": {
    "description": "validation_failed (details list the problems; nothing was written) or bot_setting_invalid (unknown variable scope, missing scope_id).",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Error502": {
    "description": "discord_error: Discord refused; details carry its reason.",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   }
  }
 }
}
