| 1 | # COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| 2 | |
| 3 | Use Equipo’s person API to build a client for one team’s instance. The contract is in [equipo-v1.openapi.json](equipo-v1.openapi.json). JSON responses use UTC timestamps. IDs are opaque unless a field is explicitly an integer. |
| 4 | |
| 5 | Device bearers and browser sessions use different handlers on some routes. A device bearer reads the conversation, tasks, projects and events from the conversation engine. See “Talk to your Coordinator from a device” below. The preceding sections describe the earlier person API, including sign-in, devices, `/me`, notifications and errors shared by both clients. Person API routes use the `/api/v1` prefix. |
| 6 | |
| 7 | For a signed-in browser on the instance, fetch `/api/v1/me` to check your identity. Fetch `/api/v1/conversation` to read your conversation. Send a message with `POST /api/v1/conversation/messages`, an `Idempotency-Key` header, and this body: |
| 8 | |
| 9 | ```json |
| 10 | {"body":"What should we investigate next?"} |
| 11 | ``` |
| 12 | |
| 13 | ## Sign in a device |
| 14 | |
| 15 | Generate an Ed25519 key pair on the initiating device. Keep the private key there. Send its public key as unpadded base64url to `POST /api/v1/auth/devices`, with a device label and a fresh `Idempotency-Key`: |
| 16 | |
| 17 | ```json |
| 18 | {"public_key":"<base64url public key>","label":"My phone"} |
| 19 | ``` |
| 20 | |
| 21 | Keep `device_secret` private. Display `user_code` on the initiating device and open `verification_uri` in a browser. The signed-in person checks the device name and request time, then types the code from the initiating device. Opening the link does not approve anything. Approval requires a browser session; a bearer cannot approve another device. |
| 22 | |
| 23 | The challenge lasts ten minutes. Decode its `challenge` field from base64url to a JSON array whose first element is the instance ID. Generate a fresh random nonce with at least 128 bits of entropy. Sign the UTF-8 encoding of this compact JSON array with Ed25519: |
| 24 | |
| 25 | ```json |
| 26 | ["equipo.person.device.v1","<instance ID>","<challenge ID>","<challenge>","<nonce>"] |
| 27 | ``` |
| 28 | |
| 29 | Submit `id`, `device_secret`, `challenge`, `nonce`, and the unpadded base64url `signature` to `POST /api/v1/auth/devices/exchange`. Supply an `Idempotency-Key`. Poll no more often than every five seconds. A pending approval returns `409 authorization_pending`; throttling returns `429 slow_down`. Start again after `410 device_expired`. |
| 30 | |
| 31 | A successful exchange returns a bearer with audience `equipo.person.v1` and a thirty-day expiry. Use `Authorization: Bearer <token>` on person API requests. If the exchange response is lost, resend the same proof and nonce. For ten minutes after exchange, Equipo can return the same encrypted saved result. A different nonce cannot obtain another credential. |
| 32 | |
| 33 | Read your devices with `GET /api/v1/auth/devices`. Revoke one with `DELETE /api/v1/auth/devices/{id}`, an empty JSON object, its current revision in `If-Match`, and a fresh request key. Revocation takes effect immediately. Removing a member or changing their session epoch also invalidates their credentials. Runner and provider credentials cannot authenticate a person. |
| 34 | |
| 35 | ## Browser requests and invitation acceptance |
| 36 | |
| 37 | Browser writes need the verified session cookie and evidence that the request came from the instance's own origin. Equipo checks Origin, Referer and browser fetch metadata. Bearer requests must omit cookies. Cross-origin browser requests are rejected even if they carry a bearer. |
| 38 | |
| 39 | A verified invitation recipient can read their invitation and post its secret to `/api/v1/invites/{id}/accept` before joining the roster. That session cannot read other team resources until acceptance succeeds. Owners can create, inspect and revoke invitations. The share link is returned only by invitation creation and its authorized replay. |
| 40 | |
| 41 | ## Retry writes and handle revisions |
| 42 | |
| 43 | The earlier person API requires an `Idempotency-Key` on every mutation. Use a nonblank UTF-8 value of 1–256 bytes. Resource updates also need `If-Match: "<revision>"`. These header requirements do not apply to the conversation engine’s device routes. Use the body fields described in “Talk to your Coordinator from a device” and the contract for each operation. |
| 44 | |
| 45 | Use the revision returned by GET. Keep the original key, body and revision until the result is known. Retrying identical input returns the saved result after current access is checked. Reusing a key for changed input conflicts. |
| 46 | |
| 47 | A stale revision returns `409 revision_conflict`, with `current_revision` when the resource is visible. Fetch the current value before making a new decision. Missing preconditions return 428. Invalid fields return 422. Missing identity returns 401. Denied access returns 403. Missing or private resources return 404. Query or runner unavailability returns 503. |
| 48 | |
| 49 | Project settings use one ETag for the combined settings visible to you. PATCH with an `action` of `approval`, `default_playbook`, or `rules`. Personal settings permit the `approval` action, including an empty approval mode to inherit the team setting. Connection choices have their own `connections_revision` in the settings response. Use it for `PUT /api/v1/projects/{id}/connections`. Owner roster entries and device list entries also carry their own resource revisions. Budgets use revision zero until configured. |
| 50 | |
| 51 | The earlier person API accepts at most 64 KiB of JSON per mutation and 16 KiB of message text. It rejects unknown fields, duplicate keys, null mutation fields and trailing JSON. Use the input schema for each operation. When editing an installed playbook, retain its template reference. |
| 52 | |
| 53 | ## Read lists and private setup state |
| 54 | |
| 55 | Lists default to fifty items and accept `limit` from 1 to 100. Pass the returned `next_cursor` back to the same route with the same identity. Cursors expire after twenty-four hours. They cannot be moved between people, routes or instances. Inserts may appear on later pages; deleted resources are not repeated from a saved snapshot. On 410, fetch the list again without a cursor. |
| 56 | |
| 57 | Treat null counts, usage and allowance as unknown. They are not zero. Personal responses use `Cache-Control: no-store`. Keep your own conversation, device secrets and bearer credentials out of shared caches and logs. |
| 58 | |
| 59 | Account setup responses contain only `id`, `state`, `mode`, and `command`. Run the command at the runner terminal to complete supported provider sign-in. The instance does not return credential-home paths or provider login codes. Connection revocation stops future use and requests containment of dependent work; it does not delete local credential files. Remembered team links grant no access to another instance. |
| 60 | |
| 61 | ## Reconnect and answer questions |
| 62 | |
| 63 | After reconnecting, fetch the conversation, needs-you list and any open task again. Reconcile by resource ID and revision. Browser sessions can use the existing live invalidation stream to prompt these reads. With a device bearer, read `GET /api/v1/snapshot` and follow `GET /api/v1/events` instead, as described below. This API does not provide mobile push delivery. |
| 64 | |
| 65 | The following answer operation applies to earlier person API questions. Their IDs do not start with `q_`. Fetch `/api/v1/questions/{id}` before answering. A clarification accepts `kind: "clarification"` with `option_id` or `text`. A native permission question accepts `kind: "native"`, `behavior`, and only the `updated_input` shape permitted by that question. Post to `/api/v1/questions/{id}/answer` with the question’s original request revision in `If-Match`, an `Idempotency-Key`, and current person authentication. A notification action is never authentication. A cancelled, expired or superseded question cannot accept a new answer. |
| 66 | |
| 67 | Subscribe with `POST /api/v1/notification-subscriptions`, a fresh `Idempotency-Key`, and `{"device_id":"<your device ID>"}`. Use the returned `cursor` for `GET /api/v1/notifications?cursor=<cursor>`. Each subscription has its own delivery and acknowledgement state. A bearer can use only its bound device. A browser session can manage its own devices. |
| 68 | |
| 69 | Keep polling with `next_cursor`, including after an empty page. Delivery may repeat. Deduplicate by notification `id`. A notification contains `id`, `kind`, `resource_id`, `resource_revision`, `created_at`, `state` and an instance-relative `deep_link`. For `question`, fetch `/api/v1/questions/{resource_id}`; for `task_ready`, fetch `/api/v1/tasks/{resource_id}`; for `card`, fetch `/api/v1/cards/{resource_id}`. An `interrupted` event links to the affected task or conversation. Fetch that current view before retrying work. `superseded` means the event no longer represents current work. Acknowledgement never answers a question or approves work. |
| 70 | |
| 71 | After receiving an event, post `{"notification_id":"<notification ID>"}` to `/api/v1/notification-subscriptions/{id}/ack` with an `Idempotency-Key` and the subscription revision in `If-Match`. Save the returned revision. Retry a lost acknowledgement with its original key, body and revision. Only delivered events can be acknowledged. An out-of-order acknowledgement is saved, but the subscription cursor advances only after all earlier recipient events are acknowledged. Another device keeps its unread state. |
| 72 | |
| 73 | Subscriptions expire after thirty days or when their device credential expires, whichever comes first. Polling and acknowledgements do not renew them. Device revocation or roster removal disables them immediately. On `410 subscription_expired`, subscribe explicitly with a current credential and a new `Idempotency-Key`. On `410 cursor_expired`, fetch notifications without a cursor and check the conversation and Needs you for open questions. Start a replacement subscription to receive those events on a device again. |
| 74 | |
| 75 | Acknowledged history is kept for at least thirty days. Cleanup preserves current questions and entries unread by an active subscription. Notifications without a subscription cursor provide a private snapshot but do not record delivery to a device. To unsubscribe, send an empty JSON object to `DELETE /api/v1/notification-subscriptions/{id}` with its current revision and an `Idempotency-Key`. |
| 76 | |
| 77 | Web clients can follow the private Rastrillo notification topic through the browser session. Its name is `notifications/` followed by the lowercase SHA-256 hex digest of compact JSON `[team_id,address,subscription_id]`. Pass that topic with `@0` in the existing `/live?t=` protocol. Each stream write checks the current roster, device and subscription deadline. |
| 78 | |
| 79 | ## Talk to your Coordinator from a device |
| 80 | |
| 81 | Use `Authorization: Bearer <token>` with a person device token for the conversation engine’s routes. Without a bearer, these routes return `401 unauthenticated`. The exception is `GET /api/v1/events`, which also accepts a browser session with `Sec-Fetch-Site: same-origin`. Every JSON response has `Cache-Control: no-store`. Errors use the `Error` schema unless an operation specifies a different body, such as `CardConflict` for a card answer conflict. |
| 82 | |
| 83 | The schemas are generated from the engine’s types and checked against captured device responses. Response fields are required when the server always sends them. Fields that can be null are marked nullable. Response objects allow no fields beyond those in their schema. Request schemas do not mark fields as required. The server rejects unknown fields and validates the fields each operation needs. Missing or invalid input returns `422 invalid_input`. Send JSON with `Content-Type: application/json`. These JSON request bodies are limited to 32 KiB. An input type also used in a response has the suffix `Input`, such as `PreferencesInput`. Earlier person API schemas with the same name have the prefix `PersonAPI`, such as `PersonAPITask`. |
| 84 | |
| 85 | Some paths are shared with the earlier person API. On `GET /api/v1/tasks`, `/api/v1/needs-you`, `/api/v1/runners`, `/api/v1/connections` and `/api/v1/specialists`, an `Authorization` header selects the engine’s handler. A browser session without that header uses the earlier handler. |
| 86 | |
| 87 | Other shared paths select the handler by ID. `GET /api/v1/tasks/{id}` and `POST /api/v1/tasks/{id}/cancel` use the engine for IDs starting with `tk`. `GET /api/v1/questions/{id}` uses it for IDs starting with `q_`. `GET` and `DELETE /api/v1/connections/{id}` use it for IDs starting with `cn_`. Those engine handlers require a device bearer. Other IDs use the earlier handler with either a bearer or a browser session. Each shared operation in the contract describes the engine’s response. Its `x-earlierPersonAPI` extension records the earlier operation and when it applies. Do not generate a browser client for these paths from the main operation alone. `GET` and `POST /api/v1/projects` always use the engine and require a device bearer. |
| 88 | |
| 89 | Start with `GET /api/v1/snapshot`. It reads the initial client state in one transaction: `me`, the newest `messages`, their `turns` and any turns in flight, `cards`, `tasks`, `projects`, `runner`, `runners`, `connections`, `coordinator`, `housekeeping_summary`, and the event `cursor`. `runner` is the primary runner. Read older messages with `GET /api/v1/messages?before=<message ID>&limit=<count>`. `limit` is 1 to 200 and defaults to 50. |
| 90 | |
| 91 | Send a message with `POST /api/v1/messages`: |
| 92 | |
| 93 | ```json |
| 94 | {"text":"What is left?","idempotency_key":"<a new key for each message>"} |
| 95 | ``` |
| 96 | |
| 97 | Use a UTF-8 `idempotency_key` of 1–128 bytes. The prefixes `reply:`, `card:` and `handoff:` are reserved. Message text is trimmed before validation and storage, and is limited to 16 KiB. A new message returns `201` with the message and its turn. Retrying with the same key, trimmed text and attachment IDs in the same order returns `200` with the existing message and its current turn. Reusing the key with different text or attachments returns `409 idempotency_conflict`. |
| 98 | |
| 99 | To send images or files, upload each to `POST /api/v1/attachments` first. Send the file’s bytes as the body, its media type in `Content-Type`, and its name in the `filename` or `filename*` parameter of `Content-Disposition`. Each upload is limited to 10 MiB. Add the returned IDs to the message’s `attachments` array, at most five. The uploads must be yours and not already attached to another message. Text may be empty when you send attachments. |
| 100 | |
| 101 | An upload you have not sent is kept for 24 hours, and you may hold at most 20. To remove one before sending it, call `DELETE /api/v1/attachments/{id}`. The answer is `204` once it is gone. It is `404 not_found` when the upload is not yours or no longer exists: treat that as done. It is `409 attachment_sent` when it is already on a message; sent files stay. |
| 102 | |
| 103 | Follow the conversation with `GET /api/v1/events?after=<cursor>`, a stream of Server-Sent Events. A nonempty `after` takes precedence over `Last-Event-ID`. With neither, the stream starts at the newest event. The stream opens with `retry: 2000`. Each stored event has an `id: <cursor>` line, an `event: <type>` line and a `data:` line containing the event as JSON. A `ping` arrives every 20 seconds, with only `{"type":"ping"}` as its data. A cursor older than the retained events returns `410 cursor_expired`. Read the snapshot again and follow from its cursor. |
| 104 | |
| 105 | Each stored event has `cursor`, `type`, `resource`, `id`, `revision` and `data`. It may also have `turn_id`, `message_id` and `attempt`. The `type` and `resource` pair determines the `data` schema, such as `MessageEvent` or `ActivityStepEvent`: |
| 106 | |
| 107 | - `message`, `turn`, `card`, `project`, `runner`, `coordinator`, `connection`, `preference`, `thinking`, `task`, `step` and `question`, each with the resource of the same name, carry the current resource. |
| 108 | - `delta` with resource `turn` or `question` carries `turn_id`, `offset` and `text` to append to the draft. Apply it only when `offset` equals the draft’s length in UTF-8 bytes. |
| 109 | - `activity` with resource `turn` or `question` describes work before or between text updates. Its `kind` is `thinking` or `tool`, and `label` is the line to display. With resource `step`, it carries the step’s recent activity lines. |
| 110 | - `housekeeping` with resource `housekeeping` carries the housekeeping summary. With resource `action`, it carries one housekeeping action. |
| 111 | |
| 112 | Apply a resource event only when its `revision` is newer than the revision you hold. Deltas and activity have revision 0. Apply deltas by `offset`. Show a turn or question activity line until more text arrives or that turn or question ends. Roster removal or device revocation closes the stream. |
| 113 | |
| 114 | Answer a card with `POST /api/v1/cards/{id}/answer`. Send a `choice` from its `options` and its current revision: |
| 115 | |
| 116 | ```json |
| 117 | {"choice":"merge","revision":2} |
| 118 | ``` |
| 119 | |
| 120 | A successful answer returns `200` with `card`, `message` and `turn`. When the answer starts no turn, `message` and `turn` contain zero values, including zero timestamps and empty roles and states. An outdated revision on an actionable card returns `409 card_stale`. A card that is no longer actionable returns `409 card_answered`. Both use the `CardConflict` schema and include the current card in `card`. |
| 121 | |
| 122 | Cancel a turn in flight with `POST /api/v1/turns/{id}/cancel`. It returns `202` with the turn’s `attempt`, or `409 turn_ended` once the turn has ended. Post to a task’s thread with `POST /api/v1/tasks/{id}/thread`. Move a task to another project with `POST /api/v1/tasks/{id}/move`. The contract lists the other routes and their request bodies. |
| 123 | |
| 124 | Set a card aside with `POST /api/v1/cards/{id}/visibility`, sending `{"aside":true,"revision":2}`, or `false` to bring it back. It never answers, cancels or starts anything, and the card stays in Needs you. It returns `200` with the card. Its `aside` is `true` while you have set it aside. An outdated revision or a card that no longer waits on you returns `409 card_stale` with the current card. |
| 125 | |
| 126 | ## Receive pushes on a device |
| 127 | |
| 128 | Register the device with `POST /api/v1/push-registrations` and the device's bearer token: |
| 129 | |
| 130 | ```json |
| 131 | {"token":"<APNs token, hex>","environment":"production","platform":"ios","start_token":"<Live Activity push-to-start token, hex>"} |
| 132 | ``` |
| 133 | |
| 134 | `environment` is `production` or `development`. `platform` is `ios` or `macos`. Only `ios` sends `start_token`. The registration belongs to the device credential that sends it. A new registration replaces the previous one. A token belongs to one device credential at a time. Registering it removes it from any other device credential and anything waiting for that credential. It returns `200` with `environment`, `platform`, `live_activities` and `updated_at`, never a token. The registration is deleted when the device is revoked, when its person leaves the team, or when Apple says the token is no longer valid (`Unregistered`, `ExpiredToken`, `BadDeviceToken` or `DeviceTokenNotForTopic`). |
| 135 | |
| 136 | The server decides on pushes in the same transaction as the change, so a change that does not happen pushes nothing: |
| 137 | |
| 138 | - an alert when a card waits on you, with the card's question. `apns-collapse-id` is the card's ID and `equipo` is `{"kind":"card","card_id":"<card ID>","task_id":"<task ID or empty>"}`; |
| 139 | - an alert when the coordinator replies while you have no `/events` stream open, with the reply's first line and `{"kind":"reply","turn_id":"<turn ID>"}`; |
| 140 | - a passive alert when a task you started ends, or when one of its steps stops and waits for Retry, with `{"kind":"task","task_id":"<task ID>"}`; |
| 141 | - the badge showing your Needs you count when the device registers and whenever that count changes. |
| 142 | |
| 143 | Alerts that wait on you have the category `needs_you`. Each task you started gets a Live Activity, at most three at once for you: those of the three most recently started tasks. It starts by push-to-start when work starts, with `attributes-type` `EquipoTaskAttributes` and attributes `{"task_id":"<task ID>","origin":"<this instance's origin>"}`. A device sends an activity's token only to the account at that origin, and ignores an activity with no origin. Its content state has `task_id`, `title`, `stage`, `specialist`, `activity`, `needs_you`, `tone` (`positive`, `warning` or `negative`) and, at the end, `outcome` (`done`, `cancelled`, or `replaced` when a newer task took its place). It updates when the stage, step or `needs_you` changes, and at most once a minute for a new activity line. When the task starts needing you, the update is urgent but has no alert: the decision card's alert is the only sound. Send each running activity's own token with `POST /api/v1/push-registrations/activities`, `{"task_id":"tk...","token":"<hex>"}`, which returns `204`. When the token is received, the activity gets the task's full current state. After the task ends, the token is accepted only while the activity's end notification is waiting to be sent. The server then sends the end notification immediately. After that, it returns `409 task_ended`. The server forgets the token when the activity ends. |
| 144 | |
| 145 | ## Talk to the Assistant |
| 146 | |
| 147 | The routes under `/api/v1/assistant` serve Base's chat with the Assistant. Every route, `events` included, takes only `Authorization: Bearer <token>` with a person device token (audience `equipo.person.v1`). A session cookie is not accepted, and a request without a bearer gets `401 unauthenticated`. Every response has `Cache-Control: no-store`. Errors have the same body as the rest of this API: `code`, `copy_key`, `request_id` and, where it applies, `current_revision`. |
| 148 | |
| 149 | The Assistant keeps its own conversation. Its messages, turns, cards and events never appear in the Coordinator's, and an ID from the Coordinator's conversation is `404 not_found` on every Assistant route. |
| 150 | |
| 151 | Start with `GET /api/v1/assistant/snapshot`. It returns `me`, the newest messages and their turns, the cards, the event `cursor`, `available` and `can_attach`. `available` is false when you have no runner of your own, or when your runner needs an update before it can answer the Assistant. `can_attach` is true when a message with attachments would be taken now: your runner was last seen on protocol 33 or later. Offer files only when it is true. Read older messages with `GET /api/v1/assistant/messages?before=<message ID>&limit=<count>`. `limit` is 1 to 200 and defaults to 50. The `before` in the response is the cursor for the page before; it is empty at the start of the conversation. |
| 152 | |
| 153 | Send a message with `POST /api/v1/assistant/messages` and a key of your choosing, 1 to 128 bytes, in the body: |
| 154 | |
| 155 | ```json |
| 156 | {"text":"What can I do here?","idempotency_key":"<a new key for each message>"} |
| 157 | ``` |
| 158 | |
| 159 | A new message is `201`, with the message and its turn. The same key and text again return `200` with the same result; the same key with other text is `409 idempotency_conflict`. Without a runner of your own the answer is `409 no_runner`, and with a runner that needs an update it is `409 runner_too_old`. Nothing is stored in either case. |
| 160 | |
| 161 | A message to the Assistant may carry files. Upload each with `POST /api/v1/attachments`, as for the Coordinator, and send the IDs in `attachments`, at most five. Text may be empty when you send attachments: |
| 162 | |
| 163 | ```json |
| 164 | {"text":"What does this say?","attachments":["at_…"],"idempotency_key":"<a new key for each message>"} |
| 165 | ``` |
| 166 | |
| 167 | The same key with the same text and files returns `200`; the same key with other files is `409 idempotency_conflict`. An upload that is not yours, already sent, or more than a day old is `422 invalid_input`, and so is a sixth file. Files need your runner on protocol 33 or later: until it has been seen there, a message with `attachments` is `409 attachments_unavailable` and nothing is stored, while words alone still go. `can_attach` in the snapshot gives the same answer in advance. The Assistant reads the files in the turn they arrive and, while your runner still holds them (up to 14 days), in later turns too. When you hand work to the team from a message with files, the job goes ahead without them. Card answers and job threads take words only. |
| 168 | |
| 169 | Follow the conversation with `GET /api/v1/assistant/events?after=<cursor>`, a stream of Server-Sent Events. `after` wins over `Last-Event-ID`. With neither, the stream starts at the newest event. The stream opens with `retry: 2000`, then sends each event as `id: <cursor>`, `event: <type>` and `data:` with the event as JSON, whose own `data` field holds the message, turn, delta, glance, card or activity. The types are `message`, `turn`, `delta`, `glance`, `card` and `activity`, and a `ping` comes every 20 seconds. A cursor that is too old is `410 cursor_expired`. Read the snapshot again and follow from its cursor. |
| 170 | |
| 171 | When a turn that answers you starts, a `glance` event may come first: one short line to show while the Assistant works on its answer, such as "Looking into your invoices". Its `data` has `turn_id` and `text`. The text is one line of at most 8 words and 60 characters, with no markdown. Show it for the turn until the turn's first `delta` or its message arrives. A glance is never a message, and nothing keeps it: only a stream open at the time gets it, with no `id:` line and a `cursor` of 0, and reading the events again does not bring it back. Not every turn has one, none comes after the turn's first `delta` or once the turn has ended, and a `team_update` turn never has one. Glances need your runner on protocol 23 or later. |
| 172 | |
| 173 | A message has `role` `person` or `assistant`. A turn's `kind` is empty when it answers you, and `team_update` when the Assistant tells you, on its own, what the team did with something you asked for. A `team_update` turn may end with no message: its state is `replied` and its `reply_id` is empty. Cancel a turn in flight with `POST /api/v1/assistant/turns/{id}/cancel` and an empty JSON object. The answer is `202` with the turn's `attempt`, or `409 turn_ended` once the turn has ended. |
| 174 | |
| 175 | A card has `id`, `revision`, `kind`, `state`, `question`, `options`, `links` and `result`. Its kind is `question`, `confirm`, `outcome`, `connect` or `job`. A `job` card has states of its own, below; any other card is `open`, `answered` or `resolved`. `options` and `links` are always arrays, never null. A link has `label` and `url`, and may have `rel`: `rel: "equipo"` marks a link to the job's page in Equipo. A `connect` card asks you to connect something the Assistant needs, such as your Oficina apps: it has no options and one link, which you open in your browser to connect. It is answered by connecting, not through the API, and is `resolved` once you have. The Oficina apps' card link has `rel: "oficina_connect"`: call `POST /api/v1/assistant/oficina/connect` with `{"return_to":"<address on your origin>"}` and send the browser to the `url` it returns. The return address must be on an origin in `EQUIPO_ASSISTANT_HOSTS`, or the answer is `422 invalid_input`. After the consent page the browser comes back to it with `oficina_state` and `oficina_code`, which you pass to `POST /api/v1/assistant/oficina/connect/finish` as `{"state":"…","code":"…"}` with the same person's bearer, within two minutes. The answer is `200` with `status` `connected`, `denied`, `expired` or `unavailable`, or `403 forbidden` when the consent was started by someone else. When the consent fails, the browser comes back with `oficina` set to `denied`, `expired` or `unavailable` instead. Answer an open card with `POST /api/v1/assistant/cards/{id}/answer`, one option's `value` and the card's revision: |
| 176 | |
| 177 | ```json |
| 178 | {"choice":"Yes","revision":2} |
| 179 | ``` |
| 180 | |
| 181 | The answer is `200` with the card, your answer as a message, and its turn. When the answer starts no turn, `message` and `turn` are empty, with zero times: treat that as no new turn. A stale revision is `409` with code `card_stale`, and a card already answered is `409` with code `card_answered`. Both bodies carry the card as it is now in `card`. Answering a `question` card also needs your runner, so it can be `409 no_runner` or `409 runner_too_old`. |
| 182 | |
| 183 | When you ask for real work, such as building or fixing something, the Assistant hands it off as a job with a short title and sees it through. It answers questions about the job itself when your conversation already holds the answer, and asks you only when it does not. If the job stops, it tries to get it going again before telling you. It speaks up when the job is ready, done or stuck, or when it needs your answer, and otherwise stays quiet: the job card shows how the job is going. |
| 184 | |
| 185 | Each job has one `job` card, updated in place as the work goes on, so the same card `id` comes again in `card` events with a higher `revision`. Its `question` is the job’s title, `result` its short status, `detail` adds one sentence, and `started_at` gives the start time. Its state is `working`, `asking`, `ready`, `done`, `stopped` or `paused`. A paused job waits and will carry on by itself, for example when a plan’s limit resets. Its `result` says when that will be, in your time zone, such as “Paused until 21:00”, or says “Paused” if the time is unknown. Its `detail` explains why it paused and when it will carry on. A paused card has `carry_on: true` when “Carry on now” is available because another of your plans has room at no extra cost; otherwise `carry_on` is left out. To carry on, call `POST /api/v1/assistant/cards/{id}/carry_on` with the card’s revision and a key of your choosing, 1 to 128 bytes: |
| 186 | |
| 187 | ```json |
| 188 | {"revision":7,"idempotency_key":"<a new key for each tap>"} |
| 189 | ``` |
| 190 | |
| 191 | The answer is `200` with the card as it is now in `card`; the same key again gives the same answer. A stale revision is `409 card_stale`, a card that is not paused is `409 not_paused`, and a paused card without `carry_on` is `409 carry_on_unavailable`. Each `409` body carries the card as it is now in `card`. |
| 192 | |
| 193 | A job card takes no answer: answering one is `404 not_found`. Its links may include something to try, the published site, and the job's page in Equipo. A go-ahead or Publish card for a job carries `job`, the job card's `id`. `job`, `detail` and `started_at` are left out when they do not apply. |
| 194 | |
| 195 | `paused` is sent only to a client that asks for it: add `job_states=paused` to `GET /api/v1/assistant/snapshot` and `GET /api/v1/assistant/events`. Without it a paused job card comes as `working`, with the same `result` and `detail` and no `carry_on`. |
| 196 | |
| 197 | Times in `result` and `detail` use your time zone. Equipo uses `Europe/Dublin` unless you set a different one. Set it with `PUT /api/v1/assistant/time-zone` and an IANA time-zone name: |
| 198 | |
| 199 | ```json |
| 200 | {"time_zone":"Europe/Madrid"} |
| 201 | ``` |
| 202 | |
| 203 | The response is `200` with `time_zone`. If Equipo does not recognise the time zone, the response is `422 invalid_input`. A device can set its time zone with `PUT /api/v1/time-zone`. |
| 204 | |
| 205 | To set the person's time zone only if they haven't set one, add `"only_if_unset": true`. The response's `time_zone` is the one in effect. |
| 206 | |
| 207 | A job runs in its own thread, which you can follow in Equipo. Its messages, turns and cards never appear in the conversation that `/api/v1/snapshot` returns. Handing work off needs your runner on protocol 22 or later. A runner on protocol 19, 20 or 21 can still answer the Assistant, but cannot start a job. |
| 208 | |
| 209 | Tell Equipo where your Base operations live with `PUT /api/v1/assistant/host`: |
| 210 | |
| 211 | ```json |
| 212 | {"origin":"https://base.example","token":"<token from Base>"} |
| 213 | ``` |
| 214 | |
| 215 | The origin is `https://` and a host name with no path, or `http://` on loopback only. It must be on the instance's `EQUIPO_ASSISTANT_HOSTS` list, or the answer is `403 host_not_allowed`. The token is 20 to 512 visible ASCII characters, with no spaces. The answer is `200` with `origin` and `revision`; the token is never given back. A second `PUT` replaces the first. |
| 216 | |
| 217 | ## Projects and starting a request |
| 218 | |
| 219 | `GET /api/v1/projects` includes `cursor`, the event sequence read in the same transaction as its items. Ignore project events at or below that cursor, including viewer-only events with the same shared revision and events for projects absent from the list. |
| 220 | |
| 221 | |
| 222 | `GET /api/v1/projects` retains `items`, `allowed` and `home`. It also returns `connections` and `can_add` for repositories reachable by your primary runner that are not active projects. Your primary runner is your newest enrolled primary runner that has not been revoked or marked for removal. Execution currently requires the requesting person to be an active owner of this Equipo team. This is the same team-owner role that `can_add` checks. Execution also requires a usable primary runner. In this release, the connection is `amadan`, with forge `amadan`. The matching connection ID and forge value are intentional. Its title is `Amadan`, its state is `connected` or `unavailable`, and `can_add` indicates whether you are an owner of this Equipo team. Reachability comes from the stored latest runner hello. This is that runner's repository and capability report, not a live connectivity check. Each available entry has `repo`, `name`, `title`, `description`, `description_source`, `forge` and `connection_id`. The legacy `allowed` list remains the complete allowlist, including projects already added. Only an owner can add a project using the existing `POST /api/v1/projects` with `{ "repo": "oficina/home" }`. |
| 223 | |
| 224 | Project items are ordered with your stars first, followed by recent team activity. They gain `starred` (absent means false), `names` (owner-set team names), `personal_names` (only your learned names), `title_source`, `description_source`, `forge` and `connection_id`. The snapshot and project events also include your star and your private names. Empty optional arrays may be absent. Sources are `owner` or `repository`. Repository text is for display and search only. It is never authoritative for placement. Existing clients can ignore the added fields. |
| 225 | |
| 226 | `PUT /api/v1/projects/{id}/star` takes `{ "starred": true }` or `{ "starred": false }` and returns the project with your resulting star. Any current member may use it. It affects only the authenticated person's star. Repeating a request with the same value has the same effect. A removed or unknown project returns 404. No revision or idempotency key is needed. |
| 227 | |
| 228 | `PUT /api/v1/projects/{id}/details` is owner-only. It takes the current `revision`, `title` (1 to 120 bytes), `description` (up to 500 bytes), and `names` (up to 12 names, each 1 to 120 bytes), and returns the updated project. Text must be valid UTF-8 and contain no newlines or NUL. Names are trimmed, compared without case and stored in lowercase. Empty entries are ignored. A title or description that differs from its current displayed value becomes owner-set. Optional `use_title: true` explicitly makes the submitted title owner-set even when unchanged. Omitted or false does not. The web form offers an unchecked "Use the repository title for this project" control when the title comes from the repository. The comparison uses the server's project view at save time. This includes the saved repository-derived title and current repository description when those fields are not owner-set. This replaces the team's names and leaves each person's learned names alone. A stale revision returns 409 `idempotency_conflict`. All project writes described here check the current roster inside their transaction. |
| 229 | |
| 230 | `DELETE /api/v1/projects/{id}/names` takes `{ "name": "my portal" }` and removes that learned name for the authenticated person only. It returns 204, including when the name is already absent. Team names and other people's names stay unchanged. An unknown project returns 404. A name must be 1 to 120 bytes after trimming, valid UTF-8, with no newlines or NUL. Comparison ignores case. No revision or idempotency key is needed. The web project page offers the same action beside each of your names. Removal does not change the shared project revision, so it does not invalidate an owner's open details form. A `project` event goes only to the person who removed the name, with the unchanged shared revision. Clients must apply `personal_names` from same-revision viewer events in event-sequence order. An absent array means no personal names. |
| 231 | |
| 232 | "New request" on a project can open the composer with a removable project chip. Send its ID as optional `project_id` in `POST /api/v1/messages` alongside `text`, `idempotency_key` and optional `attachments`. The response message and message history include that ID. Omitting it keeps the ordinary conversation behavior. The project must be active and in your runner's current allowlist. Unknown projects return 404, and unreachable projects return 422 `repo_not_allowed`. Reusing an idempotency key with a different project returns 409 `idempotency_conflict`. Project-bearing messages start a separate turn and bind task placement to that project. If the project is removed or becomes unreachable before dispatch or during the turn, Equipo releases the binding and shows a notice. The request continues without a project. The original `project_id` remains in history and in the idempotency check. If a turn fails before reaching the model and its message is carried into a later turn, Equipo adds a separate note for the preceding request only, identifying the project selected for that request. The person's words remain quoted on their own. That selection does not bind the newest request or the whole later turn. The Assistant route (`POST /api/v1/assistant/messages`) rejects `project_id`. The job-thread send operation also rejects it. Its web route is `POST /jobs/{id}/messages`, with no device API route. |
| 233 | |
| 234 | For a plain conversation, the server resolves exact trusted names: owner-set team names, titles set by an owner, and repository keys (`amadan.net/owner/name`, also accepted as `owner/name`). When no owner-set title exists, the repository basename also matches. A unique trusted match takes priority over a learned personal name. A personal name can resolve a name with no trusted match or with several trusted matches. An unknown or ambiguous name opens a placement card only in a person turn whose request asks for work in a named project. A person turn responds to a person's message. A move-in turn is the Coordinator's initial setup work. Discovery searches, move-in turns and explore turns do not open that card. |
| 235 | |
| 236 | The card offers up to five reachable projects and, when more are available, "Choose another project." Starred projects come first. Name similarity and recent activity order the remaining choices. Each option is at most 80 bytes. Answer through `POST /api/v1/cards/{id}/answer`. The server marks the typed placement card with `placement_by_name: true`, including after a remember-name opt-out. Ordinary questions without options do not carry this marker. Every placement question, with options or by name, also carries `placement_question: true`; notifications never offer an action on it, so it opens in the app. Choosing another project keeps the card open, increments its revision and replaces the options with a text field. That response has the updated `card`; its `message` and `turn` are empty, and no turn starts. Submit the new revision and a project name or repository as `choice`. An unresolved or ambiguous name returns 422 `invalid_input`, leaving the card open. An open typed placement card can also take a composer message in that same conversation as its answer, including device `POST /api/v1/messages`. The whole message must resolve to one available project using the resolver above, or be that name in one of these short phrases: "It should go in <name>", "Put it in <name>" or "Use <name>", optionally ending with " please". Matching ignores case. A valid answer closes the card and resumes the original request, keeping the person's complete words in history. A composer message passes through an open card unless it clearly names one available project as described above. Messages with `project_id` or attachments always follow normal send behavior. Cards that are set aside, answered or closed never consume composer messages. An open card never causes a composer message to return 422. Retries preserve the original message and outcome. Other conversations are unaffected. |
| 237 | |
| 238 | A named placement card includes optional `remember_name`, the suggested private name. The web card shows a checked "Remember '<name>' for this project" box and an editable name. Card answers accept optional `remember_name`: only an explicit nonempty string confirms a name. An empty string or omission skips learning. The field is honoured only on a card that already carries a suggestion. The web sends the name explicitly when the box is checked. Clients without the control do not learn a name on a plain tap. The model may suggest the prefilled name, but only the person's final project answer with explicit `remember_name` learns it. Choosing another project preserves an edited suggestion or removes it after an opt-out. Learning waits for the later valid answer, which must also send the name explicitly. Composer answers skip learning. Names are trimmed and stored in lowercase for that person only. They must contain at least three Unicode characters, be at most 120 bytes, be valid UTF-8, and contain no newline or NUL. Stopwords and feature phrases are not learned. An ineligible name skips learning without refusing the project choice. Capitalisation and sentence shape do not determine learning. A repository key outside the allowlist retains the existing access-request flow. |
| 239 | |
| 240 | ## Delegated read-only operations |
| 241 | |
| 242 | Oficina Connect credentials use the separate [agent-access interface](agent-access.md). |
| 243 | It lists active projects and recent tasks, reads one task, and reads Needs you. |
| 244 | |
| 245 | ### Notification actions (opt-in) |
| 246 | |
| 247 | `GET /capabilities` advertises `notification_actions_v1`, false by default. |
| 248 | After completing the physical-device unlock and privacy checks, an operator |
| 249 | can enable it with `EQUIPO_NOTIFICATION_ACTIONS=1`. An app must first read |
| 250 | that capability before adding `actions_version: 1` and a random canonical |
| 251 | lowercase UUID `binding_id` to its push registration. Older servers strictly |
| 252 | reject unknown registration fields. Rotate the binding on account or sign-in |
| 253 | changes; never take an API origin or credential from a notification. |
| 254 | |
| 255 | Opted-in alerts may use `equipo.question.text.v1`, |
| 256 | `equipo.question.choices.v1`, `equipo.merge.v1` or `equipo.stopped.v1`. |
| 257 | The existing alert text is unchanged. The optional `equipo.actions` object |
| 258 | contains version, registration binding and notification IDs, plus the card |
| 259 | kind and revision, or task revision and failed step ID, revision and attempt. |
| 260 | It contains no option text, checks, review summary or credentials. Text input |
| 261 | is offered only for an optionless question already shown in full in the |
| 262 | alert. Unknown, incomplete and oversized metadata retains open-only behavior. |
| 263 | Every response requires foreground activation and authentication. Merge only |
| 264 | opens fresh task facts and the existing confirmation; unlock does not merge. |
| 265 | |
| 266 | `POST /cards/{id}/answer` accepts an optional `idempotency_key` in addition to |
| 267 | its revision and choice. `POST /tasks/{id}/retry` still accepts an empty body |
| 268 | or `{}` for existing callers. Notification retries instead supply all of |
| 269 | `revision`, `step_id`, `step_revision`, `attempt` and `idempotency_key`. |
| 270 | Partial bindings are invalid; stale bindings return `409 not_retryable`. |
| 271 | |
| 272 | Bound writes require the capability and a current device and person. A receipt |
| 273 | stores a digest and result identifiers atomically with the write, scoped to |
| 274 | person, credential, operation, target and key. Repeating the same request |
| 275 | returns its original result identifiers; the result's presentation fields may |
| 276 | reflect current state. A changed request under that key returns |
| 277 | `409 idempotency_conflict`. Receipts expire after seven days. The native app |
| 278 | keeps the immutable request before POST for at most 24 hours and retries only |
| 279 | when the person requests it. A 409 opens/refetches the relevant task or card; |
| 280 | it never applies an old answer to a replacement revision. |
| 281 | |
| 282 | A bound notification reads its card directly at `GET /cards/{id}`; it never |
| 283 | searches only the snapshot's newest 50 cards. The reserved `c_` prefix chooses |
| 284 | the thin store before authorization or lookup. Those reads require a current |
| 285 | device and member, the same person, Coordinator lane and a card that is not |
| 286 | held. Their projection and revision are identical to the snapshot's. A missing |
| 287 | or invisible card returns `not_found`, with no fallback to another store. |
| 288 | Legacy IDs keep the earlier person API projection on this same URL. |
| 289 | |