# Stackrank > Stack ranking tool at https://ranked.lbyte.app. A signed-in user runs ranking campaigns: a prompt and 2 to 50 options that respondents drag into order through a public share link. An agent holding the user's personal access token can list their campaigns, draft new ones, edit them, close live ones, and read the results. All endpoints are JSON under https://ranked.lbyte.app/api. Fields are camelCase. Ids are UUIDs: take them from responses, never guess them. ## What Stackrank stores Per user: campaigns (title, prompt, status, share link), their options (text, link, or uploaded image), and the responses people submitted through the share link (an optional respondent name and their full order). Nothing else about respondents. ## Auth - Every call needs the user's token: `Authorization: Bearer sr_...` (`sr_` plus 43 characters). Only the header counts; cookies are ignored when it is present. - The user creates one while signed in at https://ranked.lbyte.app/dashboard/agents (Agent access), picks 30 or 90 days, and can revoke it there. If you do not have one, ask the user. Never log, store in shared places, or repeat the token. - A missing, malformed, revoked, or expired token is 401 `{"error": "Unauthorized"}`. Retrying will not help: ask the user for a new token. - Session-only, 403 `{"error": "session-required"}` for any token, and done by the user in the app: - publishing: `"status": "live"` on create or update. It opens the public ranking link, which outlives your token. Create drafts and send the user to https://ranked.lbyte.app/dashboard/{id} to publish. - closing a draft: `"status": "closed"` on a draft would also put its link online. - image uploads (`/api/uploads/...`). Use text or link options. - token management (`/api/tokens`). ## Main loop: draft a campaign and read results 1. `GET /api/campaigns`: `{"campaigns": [{id, title, prompt, status, createdAt, responseCount, shareUrl}]}`, newest first. `status` is `draft`, `live`, or `closed`; `shareUrl` is null for drafts. 2. `POST /api/campaigns`: 201 `{"id": "..."}`. Always send `"status": "draft"` (the default is `live`, which a token may not use). ```json { "title": "Q3 roadmap priorities", "prompt": "Drag these into the order you would build them.", "status": "draft", "items": [ { "kind": "text", "title": "Offline mode", "value": "Work without a connection" }, { "kind": "link", "title": "Public API", "value": "https://example.com/api-spec" } ] } ``` `title` 2 to 140 characters, `prompt` 2 to 1000, 2 to 50 `items`. Each item has `title` (1 to 160) and `value`: free text up to 4000 characters for `text`, an http(s) URL for `link`. 3. Tell the user the draft is at https://ranked.lbyte.app/dashboard/{id} and that they publish it there. 4. `GET /api/campaigns/{id}`: the campaign with results. `items` are sorted by `averageRank` (1 is top; null until someone responds) and carry `id`, `position` (the order respondents first see), `kind`, `title`, `value`, `firstPlaceCount`, `minRank`, `maxRank`. `responses` lists each submission, newest first, with `respondentName` (may be null) and `order` (`[{rank, itemId, title}]`). ## Editing - Ask the user before you remove options or overwrite a title, prompt, or option they wrote. Say what will change and wait for a yes. - `PATCH /api/campaigns/{id}` with `{"title", "prompt", "items"}` replaces the whole content; it is not a partial update. Send every option you want to keep: any existing option missing from `items` is deleted. Start from a fresh `GET /api/campaigns/{id}`, change only what the user asked for, and send the rest back unchanged. Array order is the display order. Keep an option by sending its `id` with `kind`, `title`, `value` (and `fileId` for an existing image option, as read from step 4). An item without `id` is new. Once a campaign has a response, options can be renamed or reordered but not added or removed (400). - A token may edit the content of a live campaign too, and respondents see the change at once. Ask the user before editing a live campaign. - `PATCH /api/campaigns/{id}` with `{"status": "closed"}` stops new rankings on a live campaign and keeps the responses. A token may close only a live campaign; closing a draft is 403 `session-required`. Closing an already closed campaign returns 200 and changes nothing, so a retried close is safe. Ask the user before closing: people holding the link are turned away. - `PATCH /api/campaigns/{id}` with `{"status": "draft"}` takes the link offline, from any status. A token may do this, but only the user can put the campaign back online. - There is no delete route. ## Errors Every error is `{"error": ""}` with a matching status. - 400 `Invalid request`: the body failed validation. Other 400 messages explain an edit that is not allowed. - 401 `Unauthorized`: bad, revoked, or expired token. - 403 `session-required`: the action is the user's to take in the app (see Auth). - 404 `Campaign not found`: no such campaign, or it is not this user's.