Products
Company Workspace
Roye's company product, built on the public APIs. Manage a company's charter, teams and appointments, and keep each appointee's module identities in step with employment. Contract 2 adds managed agents, a budget and operation under a policy.
Contracts 1 and 2 are previews on the local service only: never pinned, not hosted or published, subject to change. A request without Roye-Contract-Version gets contract 1.
Quickstart
A trusted backend creates a company with an explicit charter and bindings, waits for setup, then hires. Persist each idempotencyKey with its input before sending. In contract 1 your own process does the work (customer_hosted).
import { Roye } from '@roye-ai/client';
// Trusted backend, 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 });
// An explicit charter and bindings. Persist the key with the input first.
const company = await roye.companies.create({
displayName: 'support-desk',
charter: { purpose: 'Answer customer tickets and keep the answers current.' },
bindings: [
{ module: 'communication', create: { displayName: 'support-desk' } },
{ module: 'knowledge', create: { displayName: 'support-desk' } },
],
idempotencyKey: 'cmp-support-desk-1',
});
// Setup continues after create returns. An expired wait returns the latest state and cancels nothing.
const state = await company.ready({ waitMs: 20_000 });
const workspace = await company.module('communication');
const space = await company.module('knowledge');const writer = await company.appointments.hire({
responsibility: 'Draft answers to open tickets.',
roleLabel: 'Support writer',
execution: { kind: 'customer_hosted' },
idempotencyKey: 'apt-writer-1',
});
await writer.ready({ waitMs: 20_000 });For managed agents, see launch from your own template.
Contract 1 and contract 2
Send Roye-Contract-Version: 2 on each contract 2 request, or use roye.companies.v2. The response echoes the version; other values get contract_version_unsupported. The SDK adds only local checks. Contract 1 differs:
customer_hostedonly; a budget or policy at create isunsupported_capability.- Usage, operation and observation routes are
contract_version_unsupported. - No Work binding and no
work_assignmentorunsent_questionhandoff items. - Managed appointees, and companies with a policy or Work binding or that left
manual, are hidden and refused by name; such a company stays contract 2 only. One that had a managed appointee cannot be archived or deleted.
Concepts
cmp_company: charter, lifecycle, readiness.pol_operating policy (policyRevision).tem_team, with an optional parent and lead.apt_appointment: a person, process or managed agent, with its platform actor and module principals.prv_immutable personnel revision of an appointment, with its author.mbd_binding to one module resource; one per module.cst_setup: the keyed module calls a change needs.hof_handoff of what an ended appointee still held.
Resources belong to one project and environment. IDs are opaque; readiness is derived on read. … is /v1/companies/{cmp}.
Credentials and authority
| Credential | Held by | Can |
|---|---|---|
Management key (ryk_) | Your backend | Every ordinary route. |
| Developer sign-in | The console | Read, repair setups, dispose handoff items. Sees no secret. |
Manager bearer (rcp_) | A separate backend | Only GET …/manager/grant, POST …/manager/personnel, GET …/manager/appointments/{apt}, which nothing else reaches. |
Module credentials (rac_, rkt_, rwt_) | Module processes | Nothing: 403 forbidden. |
The current organization owner is required, and rechecked before any replay, for manager grants, personnel-proposal decisions, setup adoption and handoff items with managementOwnerRequired: true. GET /v1/companies/management-eligibility reports organizationOwner (advisory). Titles, role labels and reporting lines grant no authority.
Lifecycle
| State | What happens |
|---|---|
provisioning | Setup running or blocked. Name, charter and teams can change; no hiring. |
open | Hires, appointment and team changes, handoff dispositions. |
hired, suspended | Suspend blocks the Communication actor and revokes Knowledge tokens; resume restores both. |
ending | Contract 2: the session cancels the appointee's dispatched work, then ended. |
ended | Principals retire, the actor is never reused, a handoff opens. An unfinished hire ends setup_cancelled. |
archived | Mode none; teams, appointments and session end; modules unbind. Only handoff withdrawals and retries, repair, unbind and delete follow; every other change is company_not_open. No restore. |
deleting, deleted | After the archive setup. deleteCreatedResources also deletes created module resources; the purge is staged and idempotent. |
One setup runs per appointment: changes get setup_incomplete while it runs or is blocked, and end, replace or archive cancel it. Replace hires the successor and ends the predecessor in one commit. Responses are commit-time snapshots.
// Each change needs the revision you last read and a key. Revise records a personnel revision.
const current = await writer.get();
await writer.revise({ expectedRevision: current.revision, changes: { roleLabel: 'Senior support writer' }, idempotencyKey: 'apt-writer-revise-1' });
// Replace creates the successor with its own actor and hire setup and ends the writer as replaced.
const replaced = await writer.replace({
expectedRevision: (await writer.get()).revision,
successor: { responsibility: 'Draft answers to open tickets.', roleLabel: 'Support writer', execution: { kind: 'customer_hosted' } },
idempotencyKey: 'apt-writer-replace-1',
});Launch from your own template
A template is your application's data: role titles and instructions, initial staff, planning and budget defaults. Your app resolves it into the explicit contract 2 create, with charter, bindings, budget and policy. Roye keeps no template catalog for customers, and a create that names a template is 400 invalid_request.
Under contract 2, create the company, staff it and start it once the owner approves its policy. roye.companies.v2.launch() runs these calls; there is no launch route.
| Step | Call | Rules |
|---|---|---|
| 1. Create | POST /v1/companies with the resolved policy | A lost response is recovered by the create key, never sent again under a new one. |
| 2. Readiness | GET …/readiness?waitMs=20000 | Repeat until ready. |
| 3. Hire | POST …/appointments per initialStaff role | managed, with the role's persona and your agent profile and model. Wait for each. |
| 4. Read | GET /v1/companies/{cmp} | policyRevision, resolvedPolicy, controlRevision in one read. |
| 5. Approve | Outside Roye | Show resolvedPolicy; never assume approval. |
| 6. Start | POST …/start | 409 revision_conflict: read and ask again. |
Hire and start keys derive from the create key (launch.http), so a crashed launch replays instead of repeating. launch() stops before approval with started: false on an expired wait, or with unready naming a pending, blocked or proposed appointee. Rerun it with the same key and maxOutputTokens; a started company skips approve.
// Contract 2 preview: the documented launch sequence through the SDK. Persist the create key first.
// The template is your app's data: resolve its roles, staffing and defaults into the explicit create.
const result = await roye.companies.v2.launch({
idempotencyKey: 'launch-beta-1',
displayName: 'Beta launch',
charter: { purpose: 'Launch the beta notes.' },
bindings: [
{ module: 'communication', create: { displayName: 'Communication' } },
{ module: 'knowledge', create: { displayName: 'Knowledge' } },
{ module: 'work', create: { displayName: 'Work board' } },
],
budget: { limitCredits: 2000 },
policy: myTemplate.policy, // budget.reserveCredits below the limit
agent: { profile: { id: 'text-standard', revision: '2' }, model: '<enabled model>' },
approve: async (review) => askOwner(review.resolvedPolicy, review.policyRevision),
});
if (!result.started) console.log(result.readiness); // resumable: call launch again with the same key# Persist the create key with its body before the create.
POST /v1/companies
Roye-Contract-Version: 2
{ "idempotencyKey": "launch-beta-1", "displayName": "Beta launch", "charter": { … }, "bindings": [ … ], "budget": { "limitCredits": 2000 }, "policy": { …resolved by your app… } }
# Each staffingPlan hire: hi_ + first 40 hex of sha256("launch-beta-1" + "\n" + role)
POST /v1/companies/{companyId}/appointments
{ "idempotencyKey": "hi_…", "role": "writer", "execution": { "kind": "managed", … }, … }
# After the owner approves: st_ + first 40 hex of sha256("launch-beta-1" + "\n" + policyRevision + "\n" + controlRevision)
POST /v1/companies/{companyId}/start
{ "idempotencyKey": "st_…", "policyRevision": "pol_…", "expectedControlRevision": 3 }agent names the Agents profile and model of every initial hire, so no paid model is chosen for you. The brief your app collects becomes the charter purpose. A role with deliverableGrants gets a Deliverables collection in the company's Knowledge space, and planner.outputSchemaVersion: plan.draft-6 lets a plan cancel and replace a task the session can no longer move.
The example app keeps its launch-team template in apps/roye-company-example/src/templates.ts and shows it on its launch page as app data.
Managed appointees
Under contract 2 a hire or successor may be managed: an Agents contract 2 definition body (persona, profile, model, optional output schema) without its key. What Agents would refuse is refused with the hire; the project definition quota gives 429 quota_exceeded.
The setup creates the definition under a derived key, so a retry returns it; execution.agentRef is null until then. The definition outlives the company. Revise it with changes.definition on …/revisions; the operating principal cannot.
| Readiness | Meaning |
|---|---|
pending | No definition yet (setup_incomplete). |
ready | Agents reports it eligible. |
blocked | Live Agents reason: definition_archived, definition_purged, profile_retired, model_unavailable, accounting_unavailable, agents_unavailable. |
// Company contract 2 is a preview selected per request through roye.companies.v2; it never pins.
const preview = roye.companies.v2.get(companyId);
const agent = await preview.appointments.hire({
responsibility: 'Answer customer tickets.',
roleLabel: 'Support agent',
// The Agents contract 2 definition body without its key: Company derives the key from the setup step.
execution: {
kind: 'managed',
definition: { persona: { instructions: 'Answer tickets briefly.' }, profile: { id: 'text-standard', revision: '2' }, model },
},
idempotencyKey: 'apt-support-agent-1',
});
// Pending until the setup created the definition; then Agents eligibility is read live.
const readiness = await agent.ready({ waitMs: 20_000 });
const view = await agent.get(); // view.execution: { kind: 'managed', agentRef: { definitionId, revision } }Budget
A contract 2 create can take budget: { limitCredits, reserveCredits? } in whole credits, which are not a price. The reserve defaults to 0 and must be below the limit (400 invalid_request). The company shows budgetRef, or null. Managed turns reserve under it; only a verified reviewer's review turn uses the reserve. The usage read reports no amount: read what you owe from the Company budget in Billing.
| `GET …/usage` field | Meaning |
|---|---|
limit, reserveCredits | The limit and reserve you set. |
pending.count | Managed turns whose reported cost has not arrived yet. |
unknown.count | Managed turns with no usage evidence; a count, never zero cost. |
state, revision | open, exhausted or blocked; the revision a raise names. |
POST …/budget/raise takes that revision and a limitCredits above the current limit (else 400 invalid_request). It reopens an exhausted budget, never clears a block, and refuses an archived company (company_not_open).
// Contract 2 preview: a company created with a finite budget in credits (the reserve defaults to 0).
const budgeted = await roye.companies.v2.create({
displayName: 'launch-desk',
charter: { purpose: 'Ship the launch notes within budget.' },
bindings: [],
budget: { limitCredits: 5_000 },
idempotencyKey: 'cmp-launch-desk-1',
});
const usage = await budgeted.usage();
// usage carries the limit, the reserve, the state and the pending and unknown counts, with no spent amount.
const raised = await budgeted.budget.raise({
expectedRevision: usage.revision,
limitCredits: 8_000,
idempotencyKey: 'budget-raise-1',
});Operating policy and control
A contract 2 policy sets roles and grants, initial staff, planner, review routing and personnel limits. The same policy keeps the same policyRevision, so you start what you reviewed. Its budget.reserveCredits sets the reserve: a create-body reserveCredits is invalid_request, and a reserve above 0 needs a budget. Replace it with POST …/policy, in manual only.
| Action | Body | Effect |
|---|---|---|
POST …/start | policyRevision, expectedControlRevision | From manual, for an open, ready company with a policy: 202, starting. Unassociated after 10 minutes, it fails (activation_expired, activation_failed) back to manual. |
POST …/pause | expectedControlRevision? | autonomous to paused: session and grant kept, Work claims wait with their attempts. |
POST …/resume | mode, expectedControlRevision | autonomous continues the session or gets 403 standing_grant_withdrawn; manual ends it. |
POST …/stop | expectedControlRevision | starting, autonomous or paused to manual; the grant is withdrawn. |
In autonomous, the company's operating session is its operating principal. Outside an open, autonomous company, its session or the current revision, its module calls get company_not_active or stale_company_revision.
// Contract 2 preview: an operating policy at create; the policy's reserve sets the budget's reserve.
const policy = {
roles: [
{ role: 'lead', title: 'Lead', instructions: 'Plan the launch.', turnKinds: ['plan', 'work'], workGrants: ['plan', 'work'] },
{ role: 'editor', title: 'Editor', instructions: 'Review every deliverable.', turnKinds: ['review'], workGrants: ['review'] },
],
initialStaff: ['lead', 'editor'],
planner: { role: 'lead', outputSchemaVersion: 'plan.1' },
reviewRouting: { defaultReviewerRole: 'editor', byTaskKind: {} },
personnel: { rosterMax: 5, hireableRoles: ['editor'], minHireIntervalMs: 0 },
budget: { reserveCredits: 1_000 },
};
const operated = await roye.companies.v2.create({
displayName: 'launch-desk',
charter: { purpose: 'Run the launch.' },
bindings: [],
budget: { limitCredits: 5_000 },
policy,
idempotencyKey: 'cmp-launch-desk-2',
});
await operated.ready({ waitMs: 20_000 });
// Start the exact policy revision you reviewed, at the control revision you read.
const control = await operated.control();
const started = await operated.operation.start({
policyRevision: operated.view.policy!.policyRevision,
expectedControlRevision: control.controlRevision,
idempotencyKey: 'start-1',
});
// started.control.mode is 'starting'; read control() until it is 'autonomous' with a session.
await operated.operation.stop({ expectedControlRevision: (await operated.control()).controlRevision, idempotencyKey: 'stop-1' });Observe
| Read | Route | Returns |
|---|---|---|
| Control | GET …/control | Mode, controlRevision, session, pending start, previous sessions, completion. |
| Sessions | GET …/sessions | Associations and start outcomes. |
| Obligations | GET …/obligations | Held, dispatched or unknown work per module. |
| Runtime | GET …/runtime | With runtime_observation: admissions, active and unknown counts, nextWakeAt, blockers. |
| Operating session | GET …/sessions/ID | health, nextWakeAt, awaitingPlanning; /entries (heldReason), /exceptions. Another company's session is 404 not_found. |
| Events | GET …/events?cursor= | A polling page. |
| Session events | GET …/session-events?cursor= | The events of the company's own sessions, kept 7 days, with no waitMs. An older cursor is 410 cursor_expired. |
A null count is unknown, not zero. A page may be short or empty while next is set; read until next is null. company.observe() reads both event pages and returns a token of two cursors: persist it, pass it back, deduplicate by eventId. The SDK drops unknown fields.
const company = roye.companies.v2.get(result.company.id);
const obligations = await company.obligations();
const board = await company.module('work');
const { current } = await company.operation.sessions();
const session = company.operation.session(current.sessionId);
const awaiting = (await session.get()).awaitingPlanning;
const stalled = await session.exceptions({ kind: 'stalled' });
// One observation step; persist the token (the two cursors) and pass it back.
let token = loadToken(); // { company, sessions }, or undefined the first time
const step = await company.observe({ token, waitMs: 20000 }); // { companyEvents, sessionEvents, token }
token = step.token;Work binding and personnel
Under contract 2 a company can bind one Work board, at create or with POST …/bindings. A hire's role gives its Work participant the role's grants and its Knowledge member the role's collections; no role, no Work grants. The participant moves with the other principals.
| Rule | What it means |
|---|---|
| Roster | Hires, approvals and replacements fit rosterMax; hired, suspended and ending appointments count. Beyond it: 429 quota_exceeded. |
| Operating principal | Only revises labels, team and manager, withdraws listed item kinds, resumes what it suspended, and keeps the last ready planner and reviewer. Otherwise personnel_authority_exceeded. |
| Archive | Closes the board (undispatched tasks cancelled, claimed and uncertain work kept), then unbinds it. |
| Proposal | An operating-principal hire outside policy (role_not_hireable, roster_max, hire_interval): employment: proposed, no setup or roster place. Lapses after 7 days or on archive. |
| Decide | POST …/appointments/{apt}/approve or /reject at its revision, by management or the console, never the operating principal. Approval rechecks policy and roster, then hires as you. |
// Contract 2 preview: bind a Work board and staff it by policy role.
const staffed = await roye.companies.v2.create({
displayName: 'launch-desk',
charter: { purpose: 'Run the launch.' },
bindings: [
{ module: 'communication', create: { displayName: 'launch-desk' } },
{ module: 'knowledge', create: { displayName: 'launch-desk' } },
{ module: 'work', create: { displayName: 'launch-desk' } },
],
policy,
idempotencyKey: 'cmp-launch-desk-3',
});
const lead = await staffed.appointments.hire({
responsibility: 'Plan the launch.',
roleLabel: 'Lead',
role: 'lead', // its Work participant gets the role's Work grants
execution: { kind: 'customer_hosted' },
idempotencyKey: 'apt-lead-1',
});// Proposals: hires the operating principal made outside the policy wait for you.
const { items } = await staffed.appointments.list({ employment: 'proposed' });
for (const proposal of items) {
const handle = staffed.appointments.get(proposal.id);
if (proposal.proposal?.outsidePolicy.includes('roster_max'))
await handle.reject({ expectedRevision: proposal.revision, idempotencyKey: `reject-${proposal.id}` });
else await handle.approve({ expectedRevision: proposal.revision, idempotencyKey: `approve-${proposal.id}` });
}A manager grant (POST …/manager-grants, list, /{grant}/revoke) gives a manager bearer finite personnel authority. Its secret is returned once; a replay shows credential.status: not_replayable, so revoke and reissue. SDK: managerGrants, personnelProposals, manager.
| Manager grant | Rule |
|---|---|
| Scope | hire, suspend, resume, end, replace on listed targets and specs; never budget, policy or grants. |
| Checks | Owner, expiry, revocation, autonomous control, policy and roster, again before a replay. Replays use no admission. |
| Outside policy | A personnel proposal (GET …/personnel-proposals[/{proposal}]), decided at …/{proposal}/decision; approved_pending until reapproval applies it. |
Prospective Employment
A contract 2 create may set employmentProfile (profile: employment-agreement-required-1, employerPartyId); omit it for legacy staffing. The employer is an organization party in the company's own project and environment; each employee is a person or agent party. Initial staffing stays held, unsigned hires and replacements are refused, and a changed signed scope needs a new intent and agreement.
| Step | Route | Result |
|---|---|---|
| Reserve | POST …/employment-intents with idempotencyKey, employeePartyId, expiresAt, appointment; one per employee party | 201: a held intent with appointment and setup IDs, the appointment specification, revision, digest and agreement: null. expiresAt is epoch milliseconds in the future, at most 30 days away. |
| Read | GET …/employment-intents/{intent} | No list route; persist the ID. |
| Agree | Agreements API: POST /v1/agreements | Between the employer and employee, terms documentDigest set to the intent digest. Offer it; each party accepts, and a backend key accepting for a party sends evidence. |
| Fulfill | POST …/{intent}/fulfill with idempotencyKey, expectedRevision, agreementId | 201: appointment and setup. The intent and appointment record the agreement ID, terms revision and digest. |
| Release | POST …/{intent}/release with idempotencyKey, expectedRevision and no other field | 200. Only a held intent; frees its staffing place. A stale revision is revision_conflict. A hold not fulfilled by expiresAt is released. |
- The intent routes need
Roye-Contract-Version: 2(otherwisecontract_version_unsupported) and a company created with this profile (otherwiseunsupported_capability). - Fulfill needs an unexpired
heldintent, an agreement that is formed or active, and both parties in standing. Another pair of parties or another digest isbinding_invalid; an unformed agreement, a party not in standing or an intent notheldisinvalid_transition. - The appointment is productive only while that agreement is active and both parties are in standing. An ended or expired agreement, or a suspended or retired party, blocks fresh work at once. A Company sweep offboards an appointment whose agreement ended.
- Ending the appointment does not end the agreement; a party ends it with
POST /v1/agreements/:agreementId/end.
# Company calls use the Company caller's token or key; each party accepts with its own credential.
POST /v1/companies
Authorization: Bearer <Company management token or key>
X-Roye-Project: <company project>
X-Roye-Environment: development
Roye-Contract-Version: 2
Content-Type: application/json
{ "idempotencyKey": "company-required-1", "displayName": "Release desk", "charter": { "purpose": "Write release notes" }, "bindings": [],
"employmentProfile": { "profile": "employment-agreement-required-1", "employerPartyId": "<represented organization party>" } }
# Every Company request below carries the same headers.
POST /v1/companies/<companyId>/employment-intents
{ "idempotencyKey": "reserve-1", "employeePartyId": "<person or agent party>", "expiresAt": <future epoch milliseconds>,
"appointment": { "responsibility": "Draft release notes", "roleLabel": "Writer", "execution": { "kind": "customer_hosted" } } }
201 Created
{ "id": "cei_…", "companyWorkspaceId": "cmp_…", "appointmentId": "apt_…", "setupId": "cst_…", "appointment": { … },
"revision": 1, "digest": "<64 hex>", "state": "held", "agreement": null, … }
# Agreements API, as the employer: an ordinary agreement whose terms document is the intent digest.
POST /v1/agreements
Authorization: Bearer <employer representative's key or token>
X-Roye-Project: <company project>
X-Roye-Environment: development
Roye-Contract-Version: 1
Content-Type: application/json
{ "idempotencyKey": "employment-1", "partyIds": ["<employer party>", "<employee party>"],
"terms": { "title": "Writer employment", "documentDigest": "<intent digest>", "attributes": { "role": "Writer" }, "startsAt": null, "expiresAt": null } }
# Offer it, then each party accepts the exact terms.
POST /v1/companies/<companyId>/employment-intents/<intentId>/fulfill
{ "idempotencyKey": "fulfill-1", "expectedRevision": 1, "agreementId": "<formed agreement>" }
201 Created
{ "appointment": { "id": "apt_…", … }, "setup": { "id": "cst_…", … } }
# Lost response: recover under the original caller, contract version and key.
POST /v1/operations/recover
{ "module": "companies", "kind": "employment_intents.fulfill",
"target": { "companyWorkspaceId": "<companyId>", "employmentIntentId": "<intentId>" }, "idempotencyKey": "fulfill-1" }
GET /v1/companies/<companyId>/setups/<setupId>
# Repair the original setup if blocked; never hire again.
# Instead of fulfilling, release a held intent to free its staffing place.
POST /v1/companies/<companyId>/employment-intents/<intentId>/release
{ "idempotencyKey": "release-1", "expectedRevision": 1 }// Thin SDK, same HTTP fields and Company authority.
const company = roye.companies.v2.get(companyId);
const reserved = await company.employmentIntents.reserve({
idempotencyKey: 'reserve-1', employeePartyId, expiresAt,
appointment: { responsibility: 'Draft release notes', roleLabel: 'Writer', execution: { kind: 'customer_hosted' } },
});
const intent = company.employmentIntents.get(reserved.id); // no request until get()
const exact = await intent.get();
// Each party's own client creates, offers and accepts the agreement through roye.agreements.
// Persist the exact fulfill input, target and key before sending.
const originalSetup = await intent.fulfill({ idempotencyKey: 'fulfill-1', expectedRevision: exact.revision, agreementId });
// Ending the appointment leaves the agreement active; a party ends it with roye.agreements.get(agreementId).end(...).Handoffs
End or replace opens a handoff (pendingWork: require_handoff by default, or withdraw_undispatched). It collects up to 1,000 items until its 14-day deadline, then closes closed_unresolved.
| Item | transfer | withdraw |
|---|---|---|
communication_request | To the successor's actor. | Cancelled. |
communication_delivery | To the successor's actor. | closed_by_module_expiry on expiry. |
knowledge_responsibility | Successor gets read and contribute. | not_transferred. |
work_assignment | Contract 2: reassigned in Work. | Withdrawn, or reassign_next_plan. |
unsent_question | Contract 2: kept for the successor's next turn. | Recorded as withdrawn. |
original_obligation | Not allowed. | Not allowed; credentials, claims and uncertain effects are never inherited. |
- A disposition's derived key is
handoffId_ordinal_dispositionSequence; a retry reuses it. - A transfer waits for a ready successor (
appointment_not_ready); a task under review waits asdeferred_review. - An operated company transfers undisposed items per
handoffDefaults.withSuccessor; to decide yourself, dispose first or pause.
// An ended appointment leaves a handoff. Transfer needs a ready successor; withdraw needs none.
const handoff = company.handoffs.get(handoffId);
const { items } = await handoff.get();
for (const item of items.filter((candidate) => candidate.state === 'pending'))
await handoff.dispose(item.ordinal, {
disposition: 'transfer',
successorAppointmentId: replaced.successor.id,
idempotencyKey: `dispose-${handoffId}-${item.ordinal}-1`,
});Verified completion
When every goal on the bound board is closed, the operating principal requests a completion stop (no route or SDK method). Company records it only if each named goal closed with that outcome and none is open or lapsed. The control record's completion shows the goals and outcome (achieved, partial, abandoned); the session ends completed, the grant is withdrawn, and the company never starts again (409 invalid_transition).
# After the operating principal's completion stop, the control view shows the verified completion.
GET /v1/companies/{companyId}/control
Roye-Contract-Version: 2
200 OK
{ "mode": "manual", "session": null,
"previousSessions": [ { "sessionId": "aos_…", "reason": "completed", … } ],
"completion": { "sessionId": "aos_…", "controlRevision": 9, "completedAt": 1767830400000,
"goals": [ { "goalId": "wgl_…", "outcome": "achieved", "closeReason": "Launched." } ], "outcome": "achieved" }, … }Briefs and acceptance
Briefs and the owner's acceptance of delivered work are your application's data. The example app turns each brief into a Work goal on the company's board through company.module('work'). It records the owner's acceptance in its own state once every task of that goal is accepted in Work and none is still open.
Roye keeps no brief or acceptance record for your app, so the prompts and decisions stay in your repository.
Setups and repair
Each module call is a step under a derived key, so a retry or repair returns the original resource. A request drives up to 32 calls; the rest waits for repair or the server sweep.
| State | Meaning |
|---|---|
running | Steps remain; five attempts per transient refusal. |
blocked | step_failed, authority_revoked or deadline_exceeded. |
completed, completed_with_skips | Done, or a target was gone and the binding broke. |
cancelled | By archive or an end; late resources are cleaned up. |
Fix the cause, then POST …/setups/{cst}/repair with a new key; you become the subject of the remaining steps. Manager setups need adoptManagerAuthority: true, owner-authorized setups adoptOwnerAuthority: true. Repair never restarts a completed company.
// A blocked setup keeps its original IDs. Read the failing step, fix the cause, then repair under a new key.
const blocked = await company.setups.get(setupId);
const failing = blocked.steps.find((step) => step.state === 'blocked' || step.state === 'failed');
await company.setups.repair(setupId, { idempotencyKey: 'repair-1' });Endpoints
Paths are under /v1/companies. Each takes the management key; mutations take an idempotencyKey. Contract 2 routes are in their sections above.
| Routes | Purpose |
|---|---|
POST /, GET /, GET …, POST …, POST …/charter, GET …/readiness, …/archive, …/delete | Company |
POST …/teams, GET …/teams[/{tem}], POST …/teams/{tem}, …/teams/{tem}/dissolve | Teams |
POST …/bindings, GET …/bindings[/{mbd}], POST …/bindings/{mbd}/unbind | Bindings |
POST …/appointments, GET …/appointments[/{apt}], …/{apt}/readiness, …/{apt}/revisions, /suspend, /resume, /end, /replace | Appointments |
GET …/setups[/{cst}], POST …/setups/{cst}/repair | Setups |
GET …/handoffs[/{hof}], POST …/handoffs/{hof}/items/{ordinal}, /retry | Handoffs |
Limits
Preview placeholders, refused with typed errors such as payload_limit and quota_exceeded.
| Limit | Value |
|---|---|
| Companies | 10 per project and environment; 3 bindings each. |
| Teams, appointments | 50 teams, 4 deep; 100 current appointments. |
| Charter | 32 KiB, 32 context references, 32 goal IDs. |
| Policy | 16 roles, 32 initial staff, 32 review routes; per role 8 collection grants, 4,000 instruction characters. |
| Setups | 1,024 steps; a 24-hour deadline blocks, never cancels. |
| Handoffs | 1,000 items, 14 days, 16 unsent questions. |
| Manager grants | 8 active, 128 lifetime, 30-day expiry, 16 targets, 16 admissions. |
| Personnel proposals | 16 pending, 64 lifetime, 48-hour expiry. |
| Obligations | Above 500 binding records or 60 unbound boards and workspaces: 503 unavailable, no partial list. |
| Waits, pages, retention | 30-second waits; 64 items per page (default 32); 7-day replay and event retention. |
Not in this preview: hosting, Agents, Actions and Automation bindings, exports, an event stream, console changes beyond repair and disposition, scheduled sweeps, rate limits and billing.
Errors
Errors use the shared envelope; another project's resource reads as not_found.
| Code | HTTP | What to do |
|---|---|---|
invalid_request, payload_limit, unsupported_capability, contract_version_unsupported | 400, 413 | Fix the input, or send version 2 or a supported option. |
unauthorized, forbidden, not_found | 401, 403, 404 | Use this project's management key. |
authority_revoked, standing_grant_withdrawn, personnel_authority_exceeded | 403 | Repair with current authority, or stop and start. |
budget_unavailable | 404 | The company has no budget. |
not_ready, setup_incomplete, company_not_open, appointment_not_ready, company_not_active, stale_company_revision, already_active | 409 | Read readiness, the setup or control; wait or repair. |
binding_invalid, binding_broken, artifact_unavailable | 409 | Re-read the resource. |
idempotency_conflict, revision_conflict, invalid_transition, team_not_empty | 409 | Recover the original, or re-read and decide with a new key; dissolve with reassignTo. |
quota_exceeded, rate_limited | 429 | Reduce the roster or back off with the same key. |
cursor_expired, operation_replay_expired | 410 | Read current state; a deleted company is unrecoverable. |
operation_pending, unavailable | 202, 503 | Observe the original, or retry with the same key and input. |
Recovery
Never retry an uncertain call under a new key. Resend the same input, or, as the original caller, call POST /v1/operations/recover with module: companies, the kind, target and key. A key reused under the other contract version is idempotency_conflict.
| Situation | What to do |
|---|---|
| Lost create, start, raise, transition or hire | Recover create (empty target), start, budget.raise, policy.revise, pause, resume, stop or appointments.hire, then read the setup, starts on …/sessions, usage or control. Never hire again. |
| Lost reserve, release or fulfill | Recover employment_intents.reserve with target { companyWorkspaceId }, or employment_intents.release or employment_intents.fulfill with { companyWorkspaceId, employmentIntentId }, under contract 2 and the original key. Fulfill recovers even if authority changed. Then read the intent and setup; never hire again. |
| Lost disposition | Resend the same disposition and key; another disposition is a new request. |
| Lost manager secret | Revoke and reissue. |
| Interrupted delete | Resend with its key; the purge resumes. |
// The create response was lost and the company ID is unknown. Recover by the original key alone,
// with the credential that performed it.
const original = await roye.operations.recover({
module: 'companies',
kind: 'create',
target: {},
idempotencyKey: 'cmp-support-desk-1',
});
// The same intent with the same key replays the original commit-time snapshot.
const again = await roye.companies.create(sameInputAsBefore); // idempotencyKey: 'cmp-support-desk-1'Usage
No Company operation is metered or charged, and Company runs no inference itself. With a contract 2 budget, …/usage reports the cap state and the counts of pending and unknown turns, with no amount. Billing reports the customer-priced Company budget. Without a budget there is no usage read.
Runnable example
apps/roye-api-examples/src/company-workspace/ runs the contract 1 flow, from create to delete, without inference. apps/roye-company-example launches a company from its own launch-team template with owner approval, and keeps its briefs and acceptance records. See examples/README.md.