HTTP API: setup wizard
Part of the HTTP API reference. How the wizard works and why it is built this way: Setup wizard.
Setup mode
Section titled “Setup mode”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).
Session
Section titled “Session”GET /api/v1/setup/status(anonymous) returns{"active", "completed", "authenticated", "simulator"?, "view"?: SetupView}.viewis 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 cookiecicord_setup(HttpOnly,SameSite=Strict,Securebehind 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).
- The token is consumed: a reused or wrong token answers
- Every other
/api/v1/setup/*endpoint needs the setup session, otherwise401 unauthenticatedwith ahint. 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;
/mereturns the usersetup.
Errors
Section titled “Errors”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. |
Wizard endpoints
Section titled “Wizard endpoints”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 /stepmoves to a step whose prerequisites are met, else409 conflictwith ahint.repositoryre-runs the server checks and refuses while one fails. Steps up torepositorycannot be revisited once the configuration is active.POST /discord/tokenvalidates 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 underDISCORD_TOKEN_<BOT>.POST /discord/recheckre-reads the application (privileged intents) with the stored token.GET /discord/serverslists the servers the bot is in (GET /users/@me/guilds). The UI polls it every 2.5 seconds while the invite is open.POST /serverpicks the server (it must be in that list) and checks it:member,permissions,hierarchy.POST /repo:providersinSetupViewlists the choices of this runtime (serve: embedded, github;dev: local, embedded). Forgithub, the remote is checked with the token, which is stored encrypted asCICORD_GIT_TOKEN.POST /importimports the server and computes a preflight plan before anything changes. If the plan is not empty, it answersneedsConfirm: truewith the plan; call again withconfirm: trueto 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 /oauthchecks the OAuth2 client secret with Discord and stores it (CICORD_DISCORD_CLIENT_SECRET).POST /oauth/skipskips admin login.GET /oauth/testreports whether this browser has a Discord login session after “Test login” (/auth/loginin another tab).GET /verifyruns the checklist on the wizard’s server. Theeventscheck counts messages since the Verify step started.POST /plugins/installinstalls 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 toplugins/<name>/and the instance (every capability granted) tobots/<bot>/bot.yaml.POST /finishcompletes the setup and revokes the setup sessions.
Simulator stand-ins
Section titled “Simulator stand-ins”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) |
Shapes
Section titled “Shapes”// 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.
Catalog and diagnostics
Section titled “Catalog and diagnostics”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 aReport: the Verify checklist on demand.sincebounds theeventscheck; by default any message since the runtime started counts.