tickets
All repositories: gitoria
3.0 KB
# Connecting an app to a tickets project (for app workers, e.g. gitoria)Source of truth: `README.md` section "Connecting an app to a project" of tickets.worldapi.org. Base URL: `https://tickets.worldapi.org`.Always send a `user-agent` header (Cloudflare blocks default script agents).## 1. Send the browser to tickets`GET /connect?app=<name>&label=<owner/repo>&return=<url>&state=<opaque>`- `app` required (≤ 60 chars); `label`, `state` optional (state ≤ 200 chars, comes back unchanged).- `return` = the app's page that receives the answer: https on `worldapi.org` or a subdomain (dev copies: an origin listed in thetickets env `TICKETS_CONNECT_ORIGINS`). Max 500 chars, URL-safe characters only, no `#`. Otherwise `400` with a reason.- Answer: redirect to `/connect/<nonce>`. There the person logs in (ident), picks a project they are ADMIN of (or makes a new one) and confirms.## 2. The return redirectThe browser comes back to `<return>?code=<one-time code>&state=<state>` (`?` becomes `&` if `return` already has a query).The code is valid 5 minutes and works once. The request itself is valid 1 hour.## 3. Exchange (from the app's SERVER, never the browser)`POST /api/connect/exchange` with `Content-Type: application/json`, body `{"code": "<code>"}`→ `200 {"key": "tktc_<48 hex>", "project": "<slug>", "title": "<title>", "api": "https://tickets.worldapi.org/api/projects/<slug>"}`.Wrong / used / expired code → `400 {error}`. GET → 405. The key is shown ONCE; store it like a secret.A second connection of the same app + label to the same project replaces the first (old key dies). An admin can disconnect: key dies at once.## 4. Using the keyEvery call: `Authorization: Bearer tktc_…` and, on every write, `X-Tickets-Identity: <ident public id of the person>`.The person must have logged in to tickets once and chosen a display name; the project's roles apply to them. The person is the author.The key reaches ITS project only (other project → 403; no/unknown identity → 403 naming the header) and only these writes (JSON, strict — unknown fields → 400):| what | request | body ||---|---|---|| create ticket | `POST <api>/tickets` | `{"subject": "…", "summary"?: "…", "source"?: "…", "assignee"?: "…"}` || event: comment | `POST <api>/tickets/<n>/comments` | `{"text": "…"}` (Markdown) || event: state change | `POST <api>/tickets/<n>/state` | `{"state": "…", "text"?: "…"}` |`<api>` = the `api` value from the exchange (`/api/projects/<slug>`). Create answers `201 {ticket, existed}` (`200` if the same ticket exists)."Mentioned in PR" / "fixed by commit" = a comment, or a state change with a `text`. Any other endpoint with a key → 401.Reads need no key: `GET <api>/tickets`, `GET <api>/tickets/<n>` (add `Accept: text/markdown` for the Markdown view),`GET /api/projects/<slug>/connections` (who is connected).```bashcurl -s -A gitoria -H "Authorization: Bearer $KEY" -H "X-Tickets-Identity: $IDENT_ID" \-H 'content-type: application/json' -d '{"text":"Fixed by commit abc123"}' "$API/tickets/7/comments"```
Branches
Latest commits
- 361bc0fetickets: re-vendor Hybriel 7a684920 (WIP, not deployed); on Error exits 1 at startup; migrate passes its log by reference; gate checks follow lazy sessions and the 413 refusalmre
- 8a69999cident#28: /login/callback never signs out the session it finds; a valid code puts the user on the same sessionmre
- 337e9b21tickets#37: a comment's files are open to everyone who can read the commentmre
- 1800600ftickets: write the standby service out in full so the boot gate can read the main servicemre
- 8179d287tickets: standby service on its port plus 10 and a deploy that hands over through it without a gapmre
- 0398145ctickets: the table grid rule is marked functional for check-thememre
- 40fddc20tickets takes components e54f83a: tables get thin grey lines from the theme, desktop toolbar stays one row with the Table button, F4 check counts 11 buttonsmre
- c1b77d61tickets#35: text typed before the editor is built is taken in once by the build (the input handler no longer writes it to the field first, which doubled the first letters); the gate failure shows the surfacemre
- 32bf1873tickets#35: the gate types right after the load with the CPU slowed, no waitingmre
- 64ea9ca2tickets#35: text typed into the reply editor before the page has finished starting is kept; the gate types right after loadmre
- ccd3a327tickets: the security gate expects frame-src to be exactly the ident address (the sign-in frame), still no wildcard or selfmre
- 4348dbabident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- 66ef3005Merge branch 'iw-ident-widget'mre
- bc0ad663tickets: a gap between your name and Log out in the phone header (they touched); gate checks itmre
- 2f818d46UX2: report, LOG line, e2e fixes, gate pause after loadmre
- af3ef7c4gate: the legacy state line says progressmre
- 62480a00tickets#33: a state change with a note is a comment card in the feed (same framework rendering, can be liked, edited, deleted), its state line stands alone; gate checks for a new comment with and without a state change, at once and after a reloadmre
- 4ae80007UX: Respond is one composer (state in its footer, button says what happens); New ticket / New project windows in the list heading row; project form shared; theme copied from layouts; gates and a lisbeth e2emre
- f03b438atickets header: the selector alone top right plus your name and Log out as before the theme missions; the user icon is gonemre
- 81f10e4eident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre