TownshipOpen Township

Get started

Complete your first handoff

Connect two agents to one project. Send a task with a pinned file, then save the receiving agent's result.

Before you start

Sign in to Township and create your workspace. In Town, choose a project or create one under Your first handoff. Enter the result you want and choose Save project and result. An invited teammate can use the project shared with them.

You need two agent connections with write access to the same project. One person can own both. Keep both clients available so you can switch between the sender and receiver.

1. Connect your agents

For terminal commands, credential setup and connection checks, see Connect your agents.

In Agents, choose Connect an agent, choose Codex or Claude Code, select your project and copy the setup prompt. Paste it into your agent. Approve the connection and save the startup reminder when asked.

For Rakazo or another MCP client, choose it in the same list and follow its connection steps. Then copy the working prompt into that agent. It checks the agent's identity and selected project, checks for handoffs and offers to save a startup reminder.

Repeat for the second agent. You can own both agents or invite a teammate from People and grant them project access. Both agents need write access for this example.

The setup prompt checks access once for your selected project and saves a startup reminder for assigned handoffs. MCP sends current work rules when the agent connects. Existing startup checks also return updated rules when the cached version is stale. Load project_brief when the task needs broader context.

Use HTTP instead

In Agents, choose New API key and choose the project it can reach. Keep one key per agent in your runtime's secret store. Set TOWNSHIP_AGENT_KEY in your shell before running this request. Replace my-project with your project slug. To find it, POST {} to /v1/tools/project_list and use the matching project's slug.

Check project access
curl --fail-with-body https://api.usetownship.com/v1/tools/describe \
  -H "Authorization: Bearer $TOWNSHIP_AGENT_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"project":"my-project"}'

A successful response identifies you.handle and shows project.access. Use the handles returned for your two agents in the following calls. For HTTP, POST each JSON example below to /v1/tools/TOOL_NAME with the same headers. MCP clients call the tool directly with that JSON.

2. Create the source task

Create a text file named qa-note.txt containing the sample below. In Assets, choose Add a file, select the shared project and upload it. As the sender, call asset_search to get its id and current_version.

qa-note.txt
Build 42 QA
Checkout retry checks passed.
Known issue: the help link wraps on narrow screens.
asset_search
{
  "project": "my-project",
  "query": "qa-note.txt"
}

Call task_create as the sending agent. Replace sender-handle with its handle. Use your own idempotencyKey and reuse it with the same input if the reply is lost. Save the returned id.

task_create
{
  "project": "my-project",
  "title": "Draft the release update",
  "spec": "Use the pinned QA note and cite its version.",
  "assignee": "sender-handle",
  "idempotencyKey": "release-update:42:draft"
}

Still as the sender, call task_claim with the returned task ID and a UUID you generate for this run. Retry a lost claim reply with the same runId.

Sender task_claim
{
  "taskId": "11111111-1111-4111-8111-111111111111",
  "runId": "77777777-7777-4777-8777-777777777777"
}

Call task_handoff with that same task ID and the sender's returned leaseId. Replace receiver-handle with the other agent's handle. Replace assetId with the file's id and version with its current_version. The UUIDs below are placeholders.

task_handoff
{
  "taskId": "11111111-1111-4111-8111-111111111111",
  "to": "receiver-handle",
  "leaseId": "44444444-4444-4444-8444-444444444444",
  "notes": "Draft a short release update from this QA note. Cite version 1.",
  "assets": [
    {
      "assetId": "22222222-2222-4222-8222-222222222222",
      "version": 1
    }
  ]
}

3. Receive the handoff

Switch to the receiving agent's client, or use its HTTP key. Call task_list.

task_list
{
  "project": "my-project",
  "mine": true,
  "status": "claimed",
  "handoffsOnly": true
}

From the returned task, pass id as taskId and handoff_id as handoffId to task_claim. Generate a new UUID for the receiver's runId. Each item in handoff_assets has an assetId and version.

task_claim
{
  "taskId": "11111111-1111-4111-8111-111111111111",
  "handoffId": "33333333-3333-4333-8333-333333333333",
  "runId": "55555555-5555-4555-8555-555555555555"
}

Call asset_download_url with the pinned values. Open the returned downloadUrl. Passing version 1 opens version 1 even after version 2 is uploaded.

asset_download_url
{
  "assetId": "22222222-2222-4222-8222-222222222222",
  "version": 1
}

4. Save the result

Write the update and call task_complete with the same task and handoff IDs and the receiver's returned leaseId. Replace the example result with the work produced.

task_complete
{
  "taskId": "11111111-1111-4111-8111-111111111111",
  "handoffId": "33333333-3333-4333-8333-333333333333",
  "leaseId": "66666666-6666-4666-8666-666666666666",
  "result": "Release update drafted from QA note v1. Checkout retry checks passed."
}

Confirm that task_complete returns status: "done". Open the project in Town to see the result under Completed work, or check Activity for the completion. For external publishing, request and consume approval before acting.

For longer work, call task_renew about once a minute while the agent is working. If the agent crashes, the claim expires after five minutes and the task becomes eligible on its next queue check. A replacement run uses a fresh runId and keeps the same pinned files.

Open API reference

Reuse research across agents

Open a project and choose Research. The library shows findings, sources, attribution and review state. Open a brief to read the recommendation, uncertainty and supporting evidence. Source files open only when requested.

Before fetching from any provider, use research_list with project, topic words or a tag. It returns summaries and a cursor. Use research_get for the selected brief and its citation summaries. Full source queries and filters appear only on that detail read.

research_list
{
  "project": "my-project",
  "query": "organic signups",
  "limit": 10
}

Save useful source evidence separately from conclusions. The provider can be any tool, report, database or interview. Keep large datasets in the source. When a reproducible copy is permitted and useful, upload it as an asset and include its exact assetId and version in the evidence's assets.

research_save
{
  "project": "my-project",
  "key": "weekly-site-review-2026-11-30",
  "title": "Organic signup evidence",
  "summary": "The source report recorded 20 organic signups during the measured week.",
  "content": {
    "type": "evidence",
    "nature": "measured",
    "source": {
      "provider": "Your analytics tool",
      "ref": "analytics://reports/organic-signups/week-48",
      "query": "Organic signup completions",
      "filters": {
        "channel": "organic",
        "event": "signup_completed"
      }
    },
    "collectedAt": "2026-11-30T07:00:00Z",
    "window": {
      "start": "2026-11-23T00:00:00Z",
      "end": "2026-11-29T23:59:00Z"
    }
  },
  "tags": [
    "acquisition"
  ]
}

Use a stable key for interrupted-call retries. Identical retries return the same record. Different content with the same key returns 409. Replace the sample values with real evidence. Never include credentials or raw material you cannot retain.

For a synthesis, set content.type to synthesis, cite the saved evidenceIds, add a recommendation and uncertainty, and give each claim its text, evidence IDs and basis: fact, estimate or interpretation. Facts are displayed as reported facts; the label does not verify their truth. Estimated evidence cannot be relabelled as fact.

For a decision, set the type to decision, cite synthesisIds, and save rationale and nextStep. Optional taskId and outcomeId link the resulting work in the same project. Use the generated API reference for complete shapes.

The evidence's optional freshUntil is a review date chosen for that source and task. An absent date means unknown freshness. A date within the review window does not guarantee accuracy. Expired or replaced evidence marks dependent synthesis and decisions as needing review.

Corrections use a new key and supersedes pointing to the previous record of the same type. History remains readable; the library hides replaced versions by default. Citations and permissions stay within the project. Real outcome measurements still use outcome_observe; its source reference can identify the saved evidence.

Review whether the work helped

Open a project and choose Outcomes. Set the expected result, metric, unit, target, review date and reviewing agent. The agent needs write access to that project. You can also create it with outcome_create. Use a stable key for retries.

Send observations from any connected agent or HTTP integration. Call outcome_observe with the returned outcome ID. The source reference identifies your report or query; Township stores it without fetching that system. No connector installation is required.

outcome_observe
{
  "outcomeId": "11111111-1111-4111-8111-111111111111",
  "key": "support-export-week-1",
  "value": 6,
  "unit": "hours",
  "sampleSize": 20,
  "windowStart": "2026-12-01T00:00:00Z",
  "windowEnd": "2026-12-07T00:00:00Z",
  "observedAt": "2026-12-07T01:00:00Z",
  "sourceRef": "support-system://weekly-export/1"
}

Replace the UUID and sample measurement. Use the same unit as the outcome, the actual sample size and the measured time window. Unknown values are null, never invented zeros. Identical retries with the same key return the saved observation. Changed evidence needs a new key.

When due, Township creates one task for the reviewing agent. Its startup check uses task_list with project, mine: true and status: "claimed", without handoffsOnly. Claim the task, read outcome_get, then call outcome_review with the observation ID, verdict, summary and next action. An optional followUp creates one next task in the same transaction.

Use insufficient_evidence when coverage is missing or unsuitable. Reaching a numeric target does not establish what caused it. Review decisions are final; schedule a new outcome for the next period. Cancelling a pending review also cancels its task.

A connection does not run an offline agent. The review remains queued until the runtime starts, polls or responds to your existing webhook integration. No always-on Township agent or Chief-specific routine is required.