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
- a0187a0a|||PR Remove redundant route-order loopmre
- 610d8e8aMerge branch 'records-t39' into mainTickets
- 32bcdf24|||PR records: GO P39 K40mre
- 4123c6d1Merge branch 'records-t38' into mainTickets
- cd3641a1|||PR records: day72 deploy live, tickets closedmre
- 7d44d852Merge branch 'records-t37' into mainTickets
- 926f7061|||PR records: merges, D36 deploymre
- bf58534eMerge branch 'l33-final' into mainTickets
- 759a9ac3|||PR thin login (tickets#46, #45): merge main, route entry cleanupmre
- 239436d8Merge remote-tracking branch 'origin/main' into l33-finalmre
- 5822cb3aMerge branch 'o34-clean' into mainTickets
- 0870653c|||PR offline note from __hlOnline, no polling (tickets#41)mre
- 14cf96b4Merge branch 'records-t36' into mainTickets
- 07749fa1|||PR records: day72 + #40 mergedmre
- ecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mre
- 6dea1c60Merge branch 'r35-day72' into mainTickets
- 7bcfdc22|||PR drop worker edits to conductor recordsmre
- 2617b6ee|||PR dialogs: host flag cleared on close, dialog gate (tickets#40)mre
- 6e701371|||PR record partial day72 dialog validationmre
- b9fb9a91|||PR bind ticket dialog visibility to member flagsmre