Skip to content

Collaboration and automation

Work API

Record what must be done and whether it was done acceptably, from tasks with exact inputs and criteria to fenced claims and independent reviews. It needs no company, model or Roye inference, and workers and reviewers only need outbound HTTPS.

Local preview

Contract 1 and the contract 2 preview run on the local service only. Neither is hosted or published, and both may change. Nothing is metered or charged and no price is implied; the console shows spend as absent, never as zero.

Quickstart

Run this on a trusted backend, and save every idempotencyKey with its intent before sending.

backend.ts
import { Roye } from '@roye-ai/client';

// Server-side only: the management key never reaches a browser.
const roye = new Roye({ baseURL, token: () => process.env.ROYE_PROJECT_KEY!, projectId, environment: 'development', intents });
const board = await roye.work.boards.create({ displayName: 'docs-pipeline', idempotencyKey: 'wbd-docs-1' });
const writer = await board.participants.create({ kind: 'agent', displayName: 'writer', grants: ['work'], idempotencyKey: 'wpa-writer' });
const editor = await board.participants.create({ kind: 'human', displayName: 'editor', grants: ['review'], idempotencyKey: 'wpa-editor' });

// One short-lived token per participant process. The secret is in this response only.
const writerToken = await writer.tokens.issue({ scopes: ['read', 'write'], idempotencyKey: 'wtk-writer-1' });
const editorToken = await editor.tokens.issue({ scopes: ['read', 'write'], idempotencyKey: 'wtk-editor-1' });

const outline = await board.tasks.create({
  assigneeParticipantId: writer.id,
  spec: {
    title: 'Outline',
    instructions: 'Outline the setup guide.',
    criteria: [{ criterionId: 'c1', description: 'Covers setup', deliverableKind: 'declared', required: true }],
  },
  idempotencyKey: 'wts-outline',
});
// Starts only after the outline is accepted, and reads its accepted result as an input.
const draft = await board.tasks.create({
  assigneeParticipantId: writer.id,
  dependencies: [outline.id],
  spec: { title: 'Draft', instructions: 'Write the guide.', inputs: [{ kind: 'accepted_result', taskId: outline.id }] },
  idempotencyKey: 'wts-draft',
});

Each participant process holds only its own token.

worker.ts
import { RoyeWorkParticipant } from '@roye-ai/client';

// Worker process: holds only the writer's token (rwt_...).
const worker = new RoyeWorkParticipant({ baseURL, token: () => process.env.WORKER_TOKEN!, boardId, participantId: writerId, intents });
const task = await worker.tasks.get(outlineId);
const claim = await worker.tasks.claim(outlineId, {
  expectedAssignmentId: task.currentAssignment!.id,
  expectedAssignmentRevision: task.currentAssignment!.revision,
  leaseMs: 300_000,
  idempotencyKey: 'claim-outline-1',
});
await claim.submit({
  artifacts: [{ kind: 'declared', label: 'outline.md', contentDigest: 'sha256:<64 hex characters>' }],
  criteriaResponses: [{ criterionId: 'c1', artifactIndexes: [0] }],
  idempotencyKey: 'sub-outline-1',
});
reviewer.ts
// Reviewer process: holds only the editor's token, a different participant with the review grant.
const reviewer = new RoyeWorkParticipant({ baseURL, token: () => process.env.REVIEWER_TOKEN!, boardId, participantId: editorId, intents });
const [pending] = (await reviewer.reviews.pending()).items;
await reviewer.submissions.decide(pending.submission.id, {
  decision: 'accept', // or 'request_changes' or 'reject'
  criteriaResults: [{ criterionId: 'c1', met: true }],
  rationale: 'Covers setup.',
  idempotencyKey: 'rev-outline-1',
});

Concepts

Resources belong to one project and environment. IDs are opaque, so do not parse prefixes. A token sees only its own board.

ResourceMeaning
Board (wbd_)Participants, goals, tasks and a review policy. Deleting it cancels open work and erases text; IDs, states, attribution and digests remain.
Participant (wpa_)agent, service or human, with grants plan, work, review.
Goal (wgl_)An optional outcome over tasks, closed by a person as achieved or abandoned, never by task counts.
Task (wts_)A spec revision with exact inputs, criteria and bounds, plus dependencies, a state and blockers.

Credentials

The management key and a participant token are never interchangeable: management routes refuse a token before any lookup, and the client checks each prefix.

CredentialHeld byCan
Management key (ryk_)Your trusted backend (roye.work)Everything on its project's boards, including claiming for an assignee, deciding reviews and clearing effects.
Participant token (rwt_, ID wtk_)One participant's process (RoyeWorkParticipant)Short-lived; the secret is returned once. read reads its board, and write enables its grants.
Developer sign-inThe consoleReads board records and token metadata and records review decisions. Never sees a key or token.

Task lifecycle

StateMeaning
openClaimable by its assignee once assigned and unblocked.
claimedHeld by one fenced claim with a lease.
in_reviewAwaiting review. Reassignment and spec revisions are refused.
changes_requestedSame assignment. A new claim gets a new fence, up to the rework and attempt limits.
acceptedFinal. Dependents can start, and the result reads as exact references.
rejectedFinal. A review rejected the submission.
cancelledFinal. By a principal or board deletion. Any claim is revoked and a pending submission withdrawn.
expiredFinal. The deadline passed before acceptance.

Dependencies and blockers

  • Prerequisites are tasks on the same board, acyclic and within the limits. Edges change only while the task is open or changes_requested, with the board's expectedDependencyRevision.
  • A dependency is met when its prerequisite is accepted and unsatisfiable once it is rejected, cancelled or expired. Meanwhile the task shows dependency_pending or dependency_unsatisfiable, and claims get task_blocked.
  • An accepted_result input resolves at claim time to exact artifact references, never to content.
  • Other blockers: unassigned, assignee_suspended, assignee_inactive, attempts_exhausted, effect_unresolved, and agreement_not_active on a board with an agreement gate.

Review

  • A submission immutably maps exact artifact references (a Knowledge revision with its digest, or a declared digest) to criteria. Its completion report is never acceptance.
  • Each submission gets one immutable decision (accept, request_changes, reject) with per-criterion results, a rationale and attribution. Reviewers are your key or participants with review, scope write and an allowed reviewer kind.
  • With separation of duties on (the default), anyone who held or acted on the attempt gets separation_of_duties.
  • The reviewer must read every live cited artifact, or gets artifact_unavailable. A withdrawn or deleted one refuses accept but does not block request_changes or reject.
  • Evidence references (Roundtable runs, Agents executions, check outputs) are evidence, never the decision.

Claims, fences and effects

  • A claim names the current assignment ID and revision (else stale_assignment) and gets the task's next fence. Only the current fence can renew, observe, wait, release or submit.
  • Lease end, reassignment or withdrawal, release, task cancellation, participant retirement, board deletion or the deadline ends the claim; the old fence then gets stale_claim.
  • Neither a lease nor a wait passes the deadline, and expiry does not prove the holder's effects did not happen.
  • Holders report external effects as effect_reported observations (applied, not_applied, unknown). An uncleared unknown effect in the task's followUpOf chain refuses new claims with effect_unresolved; board policy may also refuse accepting its attempt.
  • Management clears it by acknowledging the duplicate risk or resolving it as applied or not_applied with attributed evidence. These customer-attested records verify nothing and change nothing else.
  • Work does not detect effects and links no Agents or Actions records in this preview, so set followUpOf on replacement work.

Task references

A task can carry your own references, so you need no separate map from task IDs to your records. externalRef is one opaque reference, such as a ticket key or an order ID: 1 to 200 characters from letters, digits and . _ : @ / + = -. metadata holds up to 16 string values of at most 500 characters, under keys of 1 to 64 letters, digits, _, . or - that start with a letter.

  • Both are set only when the task is created and are part of the create request's idempotency digest, so the same key with other references gets idempotency_conflict.
  • Every task view shows them, as null and {} when absent. Work never interprets them, does not keep externalRef unique and does not search by it.
  • Board deletion erases them with the rest of the task text, and project retention erases them once the task is older than the content lifetime of 30 days.
references.ts
// Your ticket key and labels travel with the task; Work stores them and never interprets them.
const task = await board.tasks.create({
  assigneeParticipantId: writer.id,
  externalRef: 'JIRA:DOCS-1042',
  metadata: { batch: '7', locale: 'ko-KR' },
  spec: { title: 'Translate the setup guide', instructions: 'Translate the guide into Korean.' },
  idempotencyKey: 'wts-docs-1042',
});
// task.externalRef === 'JIRA:DOCS-1042'; task.metadata.locale === 'ko-KR'.

Agreement gate

A board can require one agreement to be active before anyone works on it, such as the master services agreement of a client engagement. Name the agreement and the digest of the terms you expect in requiresAgreement when you create the board, or set it with a board update; null clears it. Work asks the Agreements API in the same transaction, on every claim, renewal, resumption, submission and blocker read, whether the agreement is active. It never sees the parties, the terms or the evidence, and when the agreement is active again under the same digest, work continues with no write from you.

  • Agreements must know the agreement under that terms digest, with a party in your project and environment, or the declaration gets 409 stale_reference.
  • The agreement may still be an offer, or a draft when your project holds its proposer, because only the proposer sees a draft.
While the agreement is not activeWhat happens
TasksEvery workable task shows the blocker agreement_not_active.
A new claim409 task_blocked
A held claimRenewing, resuming and submitting get 409 task_blocked; observations, waits and release still work. Its standing.admissible is false, so Agents and Actions stop work that references it.
A submission pending reviewStill decidable, because it was made while the agreement was active.
A service without AgreementsDeclaring the gate gets 400 unsupported_capability, and a board that already declares one shows the blocker.
agreement-gate.ts
// msa is the agreement your backend read from /v1/agreements: its id and the termsDigest both sides accept.
const engagement = await roye.work.boards.create({
  displayName: 'client-engagement',
  requiresAgreement: { agreementId: msa.id, termsDigest: msa.termsDigest },
  idempotencyKey: 'wbd-engagement-1',
});
const contractor = await engagement.participants.create({ kind: 'human', displayName: 'contractor', grants: ['work'], idempotencyKey: 'wpa-contractor' });

// Until both parties sign, each workable task shows the blocker and a claim gets 409 task_blocked.
const ticket = await engagement.tasks.create({
  assigneeParticipantId: contractor.id,
  externalRef: 'CLIENT-42',
  spec: { title: 'Fix the login redirect', instructions: 'Reproduce the bug and fix it.' },
  idempotencyKey: 'wts-client-42',
});
ticket.blockedReasons.includes('agreement_not_active'); // true while the agreement is not active

// Clear the gate with null. The update takes the board's current revision.
await engagement.update({ requiresAgreement: null, expectedRevision: engagement.view.revision, idempotencyKey: 'wbd-engagement-ungate' });

Contract 2 preview

Contract 2 adds fields and calls and removes nothing. Send Roye-Contract-Version: 2 on every contract 2 request; the response echoes it, and a request without it is contract 1.

  • /v1/capabilities lists both versions as preview, pinnable: false. roye.work.v2 wraps the same calls; the participant SDK stays on contract 1.
  • Contract 1 refuses contract 2 fields and query parameters (400 invalid_request). A key used under one version is idempotency_conflict under the other.

Added fields

ViewFields (`null` or absent when unused)
BoardcompanyBinding, contract2Only (true once the board has ever been bound), companyClosure
ParticipantprincipalRef, appointmentRef (management view only)
Assignmentassignee.actorRef (actorId, appointmentRef), pinned at assignment
TaskcancelReason, blocked reason appointment_not_ready, the origin value controller (contract 1 tasks are always deliberate) and the controller record. A task the operating principal created has origin controller and a controller record naming its operating session, control revision and dispatch entry; other tasks have controller: null.
GoalcloseReason
Claimholder.kind operating_principal, admittedControlRevision, carriedControlRevision
Submission and reviewsubmittedBy, reviewer.attribution, reviewer.decidedVia, evidenceRefs[].digest

New calls

The assignment list takes actorId, goal close takes an optional reason, and GET /goals/{wgl}/deliverables pages a goal's accepted tasks as exact artifact references with current Knowledge status, never content.

contract-2.http
GET /v1/work/boards/wbd_…/assignments?actorId=<actorId>&state=active
Authorization: Bearer <management key>
X-Roye-Project: <projectId>
X-Roye-Environment: development
Roye-Contract-Version: 2

# 200, Roye-Contract-Version: 2
# { "items": [ { "id": "was_…", "state": "active",
#     "assignee": { "participantId": "wpa_…", "actorRef": { "actorId": "…", "appointmentRef": { "appointmentId": "…", "revision": 1 } } }, … } ],
#   "next": null }

POST /v1/work/goals/wgl_…/close
Roye-Contract-Version: 2
Content-Type: application/json

{ "idempotencyKey": "wgl-close-1", "expectedRevision": 3, "outcome": "achieved", "reason": "Shipped in the launch." }

# 200: the goal view with closeReason.

Company-bound boards

Company Workspace binds boards, projects appointees as participants and closes boards after archiving, in process without HTTP routes. A board ever bound is contract 2 only: contract 1 lists omit it, and contract 1 requests on it or its records get 400 contract_version_unsupported.

  • Each claim is checked against the company. A failed check sets standing.admissible to false, and Agents refuses or fails executions on the claim with stale_work_claim.
  • The operating principal creates tasks, assigns, claims for projected appointees and submits, in process.
ConditionClaim and blockerMeaning
Company not open409 company_not_active, blocker company_not_activeNo claim is admitted.
Company paused (mode not manual, starting or autonomous)409 company_not_active, blocker held_company_pausedDispatch holds, keeping assignment, attempts and deadline. Held claims continue.
Projected appointment not hired and ready409 appointment_not_ready, same blockerAssignees without a projected appointment are not checked.
Board closed after archivingOpen work ends cancelled (company_archived). No new tasks (409 company_not_active).Work with an unresolved effect ends once it settles. A held claim may still submit; if it ends unsubmitted, the task is cancelled. Reviews decide as usual, but request_changes cancels. companyClosure shows progress.
Operating principal decides for a reviewerdecidedVia operating_principal, verified evidence digestMust cite the reviewer's own completed Agents turn on this submission with that outputDigest, else stale_reference.

Endpoints

Routes are under /v1/work; mutations take an idempotencyKey in the body. Key is the management key. Tokens need read to read, and write plus the named grant to write.

OperationRouteCredential
BoardsPOST /boards, GET /boards[/{wbd}], POST /boards/{wbd}[/suspend|resume|delete], GET /boards/{wbd}/summaryKey. A token reads its own board and summary.
EventsGET /boards/{wbd}/events?cursor=&limit=&waitMs=: a polling page, waitMs up to 30 s, 7-day retention, no streamKey or token
ParticipantsPOST /boards/{wbd}/participants[/{wpa}[/suspend|resume|retire|grants]], GET /boards/{wbd}/participants[/{wpa}]Key. A token reads the directory.
TokensPOST, GET /boards/{wbd}/participants/{wpa}/tokens[/{wtk}], POST /tokens/{wtk}/revokeKey
GoalsPOST /boards/{wbd}/goals, POST /goals/{wgl}/revisions|close, GET /goals/{wgl}, GET /boards/{wbd}/goals, GET /goals/{wgl}/deliverables (contract 2)Key or token (plan to write)
TasksPOST /boards/{wbd}/tasks, POST /tasks/{wts}/revisions|cancel|dependencies, …/dependencies/{prerequisite}/remove; GET /tasks/{wts}, GET /boards/{wbd}/tasks|claimableKey or token (plan to write)
AssignmentsPOST /tasks/{wts}/assignments, POST /assignments/{was}/reassign|withdraw; GET /assignments/{was}, GET /boards/{wbd}/assignmentsKey or token (plan to write)
ClaimsPOST /tasks/{wts}/claims; GET /claims/{wcl}, GET /tasks/{wts}/claims?idempotencyKey=Assignee token with work, or key for the assignee. Reads: holder or key.
Hold a claimPOST /claims/{wcl}/lease|wait|resume|release|observationsHolder, with its fence
SubmitPOST /claims/{wcl}/submissions; GET /submissions/{wsb}, GET /tasks/{wts}/submissionsHolder. Reads: key or token.
ReviewGET /boards/{wbd}/reviews/pending, POST /submissions/{wsb}/reviews; GET /reviews/{wrv}, GET /tasks/{wts}/acceptanceKey or token (review for the queue and decisions)
EffectsGET /tasks/{wts}/effects[/records[/{wef}]], POST /tasks/{wts}/effects/acknowledge|resolveReads: key or token. Writes: key.

Limits

Preview values until measured costs set them.

LimitValue
Boards, participants, open tasks100 boards per project and environment. 1,000 participants and 10,000 open tasks per board.
Task specInstructions 32 KiB, text inputs 4 KiB. 32 inputs, 16 criteria, 16 capability references.
Dependencies32 prerequisites per task, depth 16. A graph check visits at most 512 tasks (dependency_limit).
Task boundsDeadline 30 days (max 180), attempts 5 (max 20), rework rounds 3 (max 10), 20 reassignments.
ClaimsLease 30 s to 15 min. Active hold 24 h. A wait up to 7 days, 14 in total. 100 observations of 2 KiB.
Submissions16 artifacts, an 8 KiB completion report, 16 effect keys per claim.
Tokens1 hour by default, at most 24 hours.
Pages and replay32 items per page by default, at most 64. Replay window 7 days.

Not in this preview: the automation controller, per-task spend, exports, retention purge of closed tasks, rate limits, token quotas and multiple reviewers.

Errors

Errors use the shared envelope.

CodeHTTPWhat to do
invalid_request, payload_limit, bounds_exceeded400, 413Fix the input.
contract_version_unsupported400Send a known version. Bound boards and contract 2 reads need Roye-Contract-Version: 2.
unauthorized, credential_expired, credential_revoked401Get a new token from your backend.
forbidden, separation_of_duties, reviewer_not_eligible403Use an eligible principal. There is no privileged fallback.
not_found404Absent, or on another board or project.
stale_claim, stale_assignment, stale_submission, stale_reference, revision_conflict, invalid_transition, task_busy, already_assigned, dependency_cycle409Re-read, then decide again with a new key. Never resubmit an old decision.
idempotency_conflict409The key was reused with other input or version. Recover the original.
artifact_unavailable409Cite a readable current revision, or request changes.
task_blocked, board_not_active, participant_suspended, company_not_active, appointment_not_ready409Resolve the blocked reasons (and companyClosure on bound boards), resume, wait or reassign.
attempts_exhausted, rework_limit, dependency_limit409Revise the bounds within limits, accept or reject, or cancel.
quota_exceeded429A count limit is used up. Stay within it or cancel work.
effect_unresolved409Management clears the effect. Never bypass it with a new task.
cursor_expired410Re-read the state lists and restart from a fresh cursor.
unavailable503Retry with the same key and input.

Recovery

Save each idempotencyKey with its input before sending. After an uncertain call, resend the same intent with the same key, never a new one, or recover the original through POST /v1/operations/recover with the same credential.

SituationWhat happens and what to do
Lost claimSame key and input, including the expected assignment: the original claim returns with its fence, inputs and current state, never a second attempt.
Lost submission or reviewSame key: the original bytes return even after the task moved on. Any other decision is stale_submission.
Lost token issueThe replay has secretStatus not_replayable and no secret. Revoke the token and issue a new one with a new key.
Processor crashThe claim expires with its lease, and a new attempt follows, subject to the effect barrier. The old fence is refused.
recovery.ts
// Recover a lost claim with the worker's own client: recovery is scoped to the principal that sent it.
const original = await worker.operations.recover({
  module: 'work',
  kind: 'tasks.claims.create',
  target: { taskId: outlineId },
  idempotencyKey: 'claim-outline-1',
});

Runnable example

apps/roye-api-examples/src/work/ runs this flow end to end, with rework, recovery and stale claims; see examples/README.md.