Skip to content

HTTP API: setup wizard

Part of the HTTP API reference. How the wizard works and why it is built this way: Setup wizard.

cicord serve and cicord dev started in a directory without cicord.yaml (and without a repository already created by the wizard) serve only:

  • the admin console;
  • the endpoints of this page;
  • /healthz, and /readyz (503 setup mode).

Every other /api/* and /auth/* path answers 503 setup_required (message, hint); / redirects (302) to /admin/setup. The runtime prints a one-time link <public url>/admin/setup?token=<token> (<admin url>/admin/setup?token=… with --admin-url; the public host then only answers /healthz and /readyz, see Admin host).

  • GET /api/v1/setup/status (anonymous) returns {"active", "completed", "authenticated", "simulator"?, "view"?: SetupView}. view is set only for a valid setup session. Without the wizard (normal runtime): {"active": false, "completed": true, "authenticated": false}.
  • POST /api/v1/setup/session {"token"} returns the same shape and sets the cookie cicord_setup (HttpOnly, SameSite=Strict, Secure behind HTTPS, 24 hours).
    • The token is consumed: a reused or wrong token answers 401 unauthenticated. After completion: 410 gone.
    • The usual CSRF rule applies (X-Cicord-Request).
  • Every other /api/v1/setup/* endpoint needs the setup session, otherwise 401 unauthenticated with a hint. After completion: 410 gone.
  • Until completion, the setup session is an admin on every server for the rest of the API, like the runtime bearer token; /me returns the user setup.

Wizard errors use the error envelope with explanations:

{"error": {"code", "message", "hint"?, "details"?, "link"?, "diagnostics"?}}

link is the page where the fix happens (the developer portal…).

Code Status Meaning
invalid_token 422 Discord rejected the bot token.
intents 409 A plugin needs a privileged intent that is off.
invalid 400 / 422 Bad input, or a plugin config that does not validate (with diagnostics).
conflict 409 Step prerequisites not met, configuration already active, plugin already installed.
unavailable 503 Discord, git or the runtime could not be reached.
gone 410 Setup already complete.

All under /api/v1/setup. SetupView is described below.

Endpoint Body Result
POST /intent {"intent": "existing" | "new"} SetupView (moves to discord)
POST /step {"step"} SetupView
POST /discord/token {"token"} SetupView
POST /discord/recheck SetupView
GET /discord/invite {"url", "scopes": ["bot", "applications.commands"], "permissions": "Administrator"}
GET /discord/servers {"servers": [{"id", "name", "iconUrl"?}]}
POST /server {"serverId"} {"view", "checks": [Check], "ok"}
POST /server/check Same as POST /server
POST /repo {"provider": "embedded" | "github" | "local", "url"?, "branch"?, "token"?} SetupView
POST /import {"confirm"?: bool} {"view", "plan": Plan | null, "needsConfirm", "files", "warnings"}
POST /oauth {"clientSecret"} SetupView
POST /oauth/skip SetupView
GET /oauth/test {"ok", "user"?, "servers"?}
GET /verify Report
GET /plugins The catalog (as /api/v1/catalog)
POST /plugins/install {"plugin", "config"} {"result": {"instance", "health", "message"?, "command"?, "revision"?, "mode", "pullRequestUrl"?}, "view"}
POST /finish SetupView (completed: true)
  • POST /step moves to a step whose prerequisites are met, else 409 conflict with a hint. repository re-runs the server checks and refuses while one fails. Steps up to repository cannot be revisited once the configuration is active.
  • POST /discord/token validates the token with Discord (/users/@me, /oauth2/applications/@me), derives the bot key, the application ID and the privileged intents from the application flags, and stores the token encrypted under DISCORD_TOKEN_<BOT>.
  • POST /discord/recheck re-reads the application (privileged intents) with the stored token.
  • GET /discord/servers lists the servers the bot is in (GET /users/@me/guilds). The UI polls it every 2.5 seconds while the invite is open.
  • POST /server picks the server (it must be in that list) and checks it: member, permissions, hierarchy.
  • POST /repo: providers in SetupView lists the choices of this runtime (serve: embedded, github; dev: local, embedded). For github, the remote is checked with the token, which is stored encrypted as CICORD_GIT_TOKEN.
  • POST /import imports the server and computes a preflight plan before anything changes. If the plan is not empty, it answers needsConfirm: true with the plan; call again with confirm: true to go on. Otherwise it writes the first commit and activates the runtime without restart, then answers with the runtime’s first plan (changes: [] when everything was adopted). Repeating the call after activation returns the same result.
  • POST /oauth checks the OAuth2 client secret with Discord and stores it (CICORD_DISCORD_CLIENT_SECRET). POST /oauth/skip skips admin login.
  • GET /oauth/test reports whether this browser has a Discord login session after “Test login” (/auth/login in another tab).
  • GET /verify runs the checklist on the wizard’s server. The events check counts messages since the Verify step started.
  • POST /plugins/install installs a catalog plugin. Privileged intents are checked against the application. The config is validated on a copy of the repository; then the sources are written to plugins/<name>/ and the instance (every capability granted) to bots/<bot>/bot.yaml.
  • POST /finish completes the setup and revokes the setup sessions.

With cicord dev --sim --setup only (otherwise 404), these endpoints stand in for discord.com:

Endpoint Body Result
GET /sim {"servers", "owner"}
POST /sim/bot {"name"?} {"token"} (a simulated application, intents off)
POST /sim/intents {"enabled"} 204
POST /sim/invite {"serverId"?, "low"?} 204 (low puts the bot role at the bottom)
POST /sim/raise-role 204
POST /sim/message 204 (the owner sends a message)
// SetupView (never contains secret values)
{ "step": "welcome|discord|server|repository|login|verify|plugin|done", "steps": [...],
"completed": false, "mode": "serve|dev", "simulator": false, "version": "0.1.0",
"intent"?: "existing|new", "providers": ["embedded", "github"], "publicUrl": "…",
"bot"?: { "key", "secretRef", "applicationId", "applicationName", "userId", "username",
"avatarUrl"?, "flags", "tokenStored", "portalUrl", "intents": Check },
"inviteUrl"?: "https://discord.com/oauth2/authorize?client_id=…&permissions=8&scope=bot+applications.commands…",
"server"?: { "id", "name", "iconUrl"?, "key" },
"repo"?: { "provider", "url"?, "branch", "tokenStored"? },
"activated": false, "revision"?: "…", "firstPlan"?: Plan,
"login": { "configured", "skipped", "testedAs"?, "clientId"?, "redirectUrl", "redirectUrls", "portalUrl", "fromEnv" },
// redirectUrl: the callback of the host the wizard runs on (the admin URL with --admin-url);
// redirectUrls: every callback the Discord application must list (public, then admin)
"plugin"?: { "name", "instance", "command"?, "skipped"? } }
// Check
{ "id": "token|intents|member|permissions|hierarchy|commands|events|plan|writeback",
"status": "ok|warn|fail|pending|skip", "message": "…", "hint"?: "…", "link"?: "…", "data"?: {…} }
// Report (/setup/verify, /servers/{server}/diagnostics)
{ "server", "bot", "checks": [Check], "ranAt", "ok", "plan"?: Plan }

ok is true when no check is fail or pending. fail blocks the step. The UI titles checks by id; message and hint are written for people.

These endpoints answer in any mode.

  • GET /api/v1/catalog (admin of a server, the setup session or the bearer token) returns {"plugins": [CatalogPlugin]}: the official plugins bundled in the binary (welcome, onboarding, tickets, polls, levels, moderation, reaction-roles, audit-log, announcements).

    { "name", "displayName", "description", "version", "keywords": [], "source": "official",
    "capabilities": [], "intents": [], "privilegedIntents": [], "network": [],
    "schema": {…}, "commands": [{"name", "description"}] }
  • GET /api/v1/servers/{server}/diagnostics[?since=<RFC 3339>] (admin) returns a Report: the Verify checklist on demand. since bounds the events check; by default any message since the runtime started counts.