Quickstart
- Create an account, add an agent in the console and create its API key.
- Add prepaid credits and set the agent’s guardrails: spending caps and allowed services.
- Submit a task. The response normally already carries the quote (
status: "quoted") with a price and an ETA. - Approve the quote. Credits are held in escrow and an expert is matched.
- Receive the verified result by webhook (
task.completed), or poll the task until its status isdelivered, then accept or dispute it.
These are plain HTTP examples; there is no SDK to install. Amounts are in USD and durations in minutes.
curl -X POST https://citephy.com/api/v1/tasks \
-H "Authorization: Bearer $BACANCY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"service": "bug_fix",
"title": "Fix authentication failure on token refresh",
"description": "Token refresh fails intermittently; 3 tests in auth.spec.ts fail.",
"repository": "northwind-labs/checkout-service",
"acceptance_criteria": ["Authentication works", "All tests pass"],
"max_budget": 99,
"deadline_minutes": 120
}'When the status is quoted, approve it:
curl -X POST https://citephy.com/api/v1/tasks/BAC-1024/approve \
-H "Authorization: Bearer $BACANCY_API_KEY"Authentication
Every request carries an API key as a bearer token: Authorization: Bearer bac_live_…. Keys look like bac_live_ followed by 32 hex characters.
- Each key belongs to one agent, so every agent’s spend and task history stay separate.
- We store only a SHA-256 hash of the key. Copy it when you create it.
- Rotate or revoke a key in the console at any time. A revoked key, an unknown key and a key of a disabled agent all get the same
401unauthorized. - Keys carry scopes:
tasks:create,tasks:approveandtasks:read. A call the key is not scoped for gets403scope_missing. Keys created in the console carry all of them, pluswebhooks, which is reserved and not checked by any endpoint yet.
MCP server
The MCP server is a stateless Streamable HTTP endpoint (JSON-RPC over POST https://citephy.com/api/mcp), authenticated with the same API key. Add it to Claude Code, Cursor or any MCP client:
{
"mcpServers": {
"bacancy-human-api": {
"type": "http",
"url": "https://citephy.com/api/mcp",
"headers": { "Authorization": "Bearer YOUR_API_KEY" }
}
}
}The agent then sees these eleven tools:
| Tool | What it does |
|---|---|
| create_task | Submit a task. Same fields as POST /api/v1/tasks. Returns the task with its quote. |
| get_quote | Price, ETA and whether the quote is within the agent's approval rules. |
| approve_quote | Approve the quote. Credits are held in escrow and an expert is matched. |
| get_task | Current status and details of a task. |
| get_result | The verified result of a delivered task (null until it is delivered). |
| list_tasks | List the agent's tasks, newest first. Arguments: status, limit, cursor. |
| reply | Send a message on a task. Answering an expert's question resumes the work. |
| cancel_task | Cancel a task before work starts. Held credits are released. |
| accept_result | Accept a delivered result. Held credits are charged. Optional rating 1 to 5. |
| dispute_result | Dispute a delivered result against one acceptance criterion. |
| decide_change_request | Approve or reject the expert's proposed new price. Arguments: task_id, decision (approve or reject). |
A tool that fails (validation, guardrails, wrong state) returns a normal result with isError: true and the same { error: { code, message, details? } } body as the REST API, so the model can read it and react. A batch may hold 1 to 10 messages and is processed in order; anything else is JSON-RPC error -32600. Request bodies over 256KB are rejected with 413. There is no SSE stream: GET returns 405.
REST endpoints
JSON in, JSON out. Paths are relative to https://citephy.com. A task {id} is either its id (UUID) or its task_id reference such as BAC-1024. An agent sees only the tasks it created. Request bodies are limited to 256KB (413 above that).
| Method | Path | Scope | What it does |
|---|---|---|---|
| GET | /api/v1/services | tasks:read | The active services with base price and turnaround: { services: [...] }. |
| POST | /api/v1/tasks | tasks:create | Submit a task. It is checked against the agent's guardrails first. Returns 201 with the task and, usually, its quote. |
| GET | /api/v1/tasks | tasks:read | List this agent's tasks, newest first: { tasks, next_cursor }. Query: status, limit (1-100, default 20), cursor. |
| GET | /api/v1/tasks/{id} | tasks:read | Get one task. {id} is the id (UUID) or the reference, e.g. BAC-1024. |
| POST | /api/v1/tasks/{id}/approve | tasks:approve | Approve the quote. Credits are held in escrow and an expert is matched. No body. |
| POST | /api/v1/tasks/{id}/cancel | tasks:create | Cancel before work starts (up to and including matched). Held credits are released. No body. |
| POST | /api/v1/tasks/{id}/reply | tasks:create | Send a message on an open task. Answering the expert's question resumes the deadline clock. |
| GET | /api/v1/tasks/{id}/messages | tasks:read | The conversation: { messages: [{ id, sender, body, is_question, created_at }] }. |
| POST | /api/v1/tasks/{id}/change-request | tasks:approve | Approve or reject the expert's proposed new price while the task is change_requested. 403 policy_violation when the guardrails leave the decision to a person. |
| POST | /api/v1/tasks/{id}/accept | tasks:approve | Accept a delivered result. Escrow is charged and the task is returned as settled. |
| POST | /api/v1/tasks/{id}/dispute | tasks:create | Dispute a delivered result against an acceptance criterion. |
Every task endpoint except /messages returns the task object. /approve and /cancel take no body; the other POST endpoints take JSON:
| Endpoint | Body | Rules |
|---|---|---|
| /reply | { "message": "Use the staging tenant." } | message: 1 to 5,000 characters. |
| /change-request | { "decision": "approve" } | decision: approve or reject. Approving holds (or releases) the price difference. |
| /accept | { "rating": 5 } | rating: optional integer 1 to 5. The body may be empty. |
| /dispute | { "criterion": "All tests pass", "observation": "auth.spec.ts still fails on main." } | criterion: 1 to 500 characters. observation: 10 to 5,000 characters. |
Lists are newest first and paged with a cursor: pass the previous page’s next_cursor as cursor; it is null on the last page. status filters by one task state and limit is 1 to 100 (default 20).
curl "https://citephy.com/api/v1/tasks?status=delivered&limit=20" \
-H "Authorization: Bearer $BACANCY_API_KEY"
{
"tasks": [ ... ],
"next_cursor": "2026-01-12T09:14:03.120000+00:00"
}Task object
Send these fields to POST /api/v1/tasks:
| Field | Type | Notes |
|---|---|---|
| service | string | A service slug from the rate card, e.g. bug_fix. |
| title | string | Short summary, 3 to 200 characters. |
| description | string | What is wrong and what you need, 10 to 10,000 characters. Under 20 characters the task is scoped by a person. |
| repository | string, optional | owner/name of a repository connected to your workspace and allowed. |
| context | object or array, optional | Anything that helps the expert: failing tests, logs, earlier attempts. 50KB at most as JSON. |
| acceptance_criteria | string[], optional | How the result is judged. Up to 20. With none, the task is scoped by a person. |
| max_budget | number, optional | The most this task may cost, in USD. A higher quote waits for a person to approve. |
| deadline_minutes | integer | When you need it, 15 to 43,200. Under 120 minutes adds the rush rate. |
Every task endpoint answers with the same object: the request fields (except context, which is not echoed back) plus these. Money is in USD.
| Field | Type | Notes |
|---|---|---|
| id | string | UUID of the task. |
| task_id | string | Human reference such as BAC-1024. Accepted anywhere an id is. |
| status | string | See Task states. |
| quote | object | null | base, complexity_adjustment, rush, total (USD) and eta_minutes. Null until quoted. |
| price | number | null | Current price in USD. Differs from quote.total after an approved change request. |
| eta_minutes | integer | null | Estimated working time. |
| needs_scoper | boolean | True while a person still has to price the task; status stays submitted. |
| within_policy | boolean | False when the price is outside the agent's approval rules. |
| approval_required | boolean | True while status is needs_approval. |
| approval_reasons | string[] | Why a person must approve. Empty when within policy. |
| change_request | object | null | { new_price, reason } while status is change_requested. |
| result | object | null | pull_request, summary, root_cause, tests_passed, human_verified, evidence. Null until verified. |
| amount_charged | number | USD charged so far. 0 until the task settles. |
| amount_refunded | number | USD returned to credits by a dispute refund. |
| currency | string | Always USD. |
| expert | object | null | { title } of the assigned expert once matched. Never a name or id. |
| *_at, acceptance_deadline | string | null | ISO timestamps: created_at, updated_at, quoted_at, approved_at, matched_at, started_at, delivered_at, acceptance_deadline, accepted_at, settled_at, cancelled_at. |
The task from the quickstart, right after it was created:
{
"id": "5f0c1d1e-8a43-4f0b-9c58-2b7f3f1f6a10",
"task_id": "BAC-1024",
"status": "quoted",
"service": "bug_fix",
"title": "Fix authentication failure on token refresh",
"description": "Token refresh fails intermittently; 3 tests in auth.spec.ts fail.",
"repository": "northwind-labs/checkout-service",
"acceptance_criteria": ["Authentication works", "All tests pass"],
"max_budget": 99,
"deadline_minutes": 120,
"quote": { "base": 49, "complexity_adjustment": 0, "rush": 0, "total": 49, "eta_minutes": 110 },
"price": 49,
"eta_minutes": 110,
"needs_scoper": false,
"within_policy": true,
"approval_required": false,
"approval_reasons": [],
"change_request": null,
"result": null,
"amount_charged": 0,
"amount_refunded": 0,
"currency": "USD",
"expert": null,
"created_at": "2026-01-12T09:14:03.120000+00:00",
"updated_at": "2026-01-12T09:14:03.480000+00:00",
"quoted_at": "2026-01-12T09:14:03.400000+00:00",
"approved_at": null,
"matched_at": null,
"started_at": null,
"delivered_at": null,
"acceptance_deadline": null,
"accepted_at": null,
"settled_at": null,
"cancelled_at": null
}Task states
The state machine is the API contract. The happy path runs submitted → quoted → approved → matched → in_progress → in_verification → delivered → accepted → settled. Exception states can interrupt it. An action in the wrong state returns 409 invalid_state. accepted is transient: accepting a result settles it in the same step, so you only ever observe settled.
| State | Meaning |
|---|---|
| submitted | Passed the policy check. Normally quoted in the same call; a task that needs a person to scope it stays here with needs_scoper true. |
| quoted | Price and ETA are set. Approve or cancel within 24 hours, or the quote expires. |
| approved | Credits are held in escrow and the task is offered to the best-matched expert. |
| matched | An expert accepted the offer. The task can still be cancelled. |
| in_progress | The expert is working. The deadline clock is running. |
| in_verification | The expert submitted. Checks and review are under way. |
| delivered | Verified result is ready. The 48-hour acceptance window is open. |
| accepted | Transient. Accepting (or the window closing) settles in the same step, so the API returns settled and no task.accepted webhook is sent. |
| settled | Escrow charged. Final state. |
| needs_approval | The quote is outside the agent's approval rules, so a person on your team must approve it in the console. |
| needs_clarification | The expert asked a question. The clock is paused; no reply in 24 hours cancels the task. |
| change_requested | The expert asked for a new price. The clock is paused until it is approved or rejected. |
| rework | Verification or a dispute sent the work back to the expert. |
| disputed | You disputed the delivered result. Credits stay on hold until it is resolved. |
| refunded | A dispute ended in a full or partial refund to your credits. Final state. |
| cancelled | Cancelled before work started, or after an unanswered question. Held credits are released. Final state. |
| expired | The quote was not approved within 24 hours. Final state. |
Experts are ranked on skill fit, quality, current load and time to the deadline. The task is offered to the best match with a 5-minute window to accept, then to the next.
Webhooks
Set an https webhook URL on the agent and the state changes of the tasks that agent created are posted to it as task.<status>. Delivery is the exception: it is sent as task.completed with "status": "delivered". There is no task.accepted event; acceptance arrives as task.settled.
| Event | Sent when |
|---|---|
| task.submitted | Only when the new task is waiting for a person to scope it. |
| task.quoted | A quote is ready and the agent may approve it. |
| task.needs_approval | The quote needs a person's approval. |
| task.approved | Credits are held and an expert is being matched. Sent once. |
| task.reassigned | The task was taken back from its expert and is being offered to another. The payload status is approved; the hold is unchanged. |
| task.matched | An expert accepted the task. |
| task.in_progress | Work started, or resumed after a reply or a change-request decision. |
| task.needs_clarification | The expert asked a question; the clock is paused. |
| task.change_requested | The expert proposed a new price; the clock is paused. |
| task.in_verification | The expert submitted the work. |
| task.rework | Verification or a dispute sent the work back. |
| task.completed | Verified and delivered. The payload status is delivered. |
| task.disputed | The result was disputed. Sent a second time with escalated: true if the dispute is escalated to a senior lead. |
| task.settled | Accepted, auto-accepted, or the dispute was rejected. Carries amount_charged. |
| task.refunded | A dispute was refunded. amount_charged appears only for a partial refund. |
| task.cancelled | Cancelled by you, or after an unanswered question. |
| task.expired | The quote was not approved in time. |
Every payload has event, task_id (the reference), status, currency and occurred_at. result is included once the result has been verified, and amount_charged only once something has been charged, so it is absent from task.completed and present on task.settled. escalated: true appears only on the second task.disputed, sent when a dispute is escalated to a senior lead.
POST /your/webhook
content-type: application/json
user-agent: bacancy-human-api-webhooks/1
x-bacancy-event: task.completed
x-bacancy-signature: 3f1c…e9 (hex HMAC-SHA256 of the body)
{
"event": "task.completed",
"task_id": "BAC-1024",
"status": "delivered",
"result": {
"pull_request": "PR-482",
"summary": "Refresh tokens are now rotated atomically.",
"root_cause": "Two concurrent refreshes invalidated each other's token.",
"tests_passed": true,
"human_verified": true,
"evidence": [
{ "key": "build", "label": "Build", "status": "passed", "detail": "" },
{ "key": "tests", "label": "Test suite", "status": "passed", "detail": "212 passed" },
{ "key": "failing_tests", "label": "Previously failing tests", "status": "passed", "detail": "3 of 3" },
{ "key": "lint", "label": "Lint and types", "status": "passed", "detail": "" },
{ "key": "security", "label": "Security scan", "status": "passed", "detail": "" }
]
},
"currency": "USD",
"occurred_at": "2026-01-12T11:02:44.019Z"
}Each request carries the event name in x-bacancy-event and is signed: the x-bacancy-signature header is the HMAC-SHA256 of the raw request body, keyed with the agent’s webhook secret and hex-encoded. Verify it before trusting the payload:
import { createHmac, timingSafeEqual } from "node:crypto";
// rawBody: the request body exactly as received, before JSON.parse.
export function isFromBacancy(rawBody: string, signature: string, secret: string) {
const expected = createHmac("sha256", secret).update(rawBody).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(signature);
return a.length === b.length && timingSafeEqual(a, b);
}
// isFromBacancy(body, request.headers.get("x-bacancy-signature") ?? "", WEBHOOK_SECRET)Respond with a 2xx within 5 seconds. A delivery is attempted once: failures are not retried and redirects are not followed, and URLs that resolve to private addresses are refused. Every attempt is logged on the task in the console, and you can always read the current state with GET /api/v1/tasks/{id}.
Guardrails
Guardrails are set per agent in the console and enforced before a task reaches a human. They apply to tasks the agent submits, not to tasks a person creates in the console. A new agent starts with a $100 cap per task, a $1,500 monthly budget, 5 open tasks, and bug fixing, code review and manual QA allowed.
Checked when a task is submitted
- The service is one the agent may buy.
- The repository, if given, is connected and allowed.
- The agent is under its open-task limit.
A failure is 403 policy_violation with the failed checks in details.checks, or 429 open_task_limit when only the limit failed.
The agent can approve a quote itself when
- The price is within the per-task cap. This always applies.
- The price is within the task’s own max_budget.
- Charged this month plus currently held, plus this price, stays within the monthly budget.
- The task does not mention sensitive data (production data, PII, card data, health records), unless you switched off approval for production access.
Otherwise the task moves to needs_approval, approval_reasons says why, and only a person on your team can approve it in the console; the agent’s own /approve returns 403 policy_violation. The rules are checked again when the agent approves, and the monthly budget is enforced atomically at that moment, so two approvals racing for the last of the budget cannot both succeed. A change request (the expert proposing a new price) is reported in change_request. A person decides it in the console; the agent may decide it itself through /change-request only when “Change requests that raise a price” is switched off in its guardrails and, to approve, the new price is within the same limits as a quote. Otherwise it gets 403 policy_violation.
Verification
Nothing reaches you unverified. When the expert submits, the task moves to in_verification. It is delivered only when all five checks (build, test suite, previously failing tests, lint and types, security scan) are recorded as passed and a reviewer has completed the review checklist. The checks come back to you as result.evidence.
The reviewer is a lead engineer, never the task’s own expert, or a member of our operations team. Peer review is mandatory when the task touches authentication, payments or personal data, when the price is $99 or more, or when the expert’s quality score is under 4.5.
A failed verification sends the task to rework. A second failure flags it for our operations team.
Acceptance and disputes
Delivery opens a 48-hour acceptance window (acceptance_deadline). Call /accept, optionally with a rating, to settle straight away: the response already has status: "settled" and amount_charged. Or call /dispute with the criterion that was not met and your observation. If the window closes with no action, the task is accepted and settled automatically. A dispute is resolved by our team in one of these ways:
- 1Rework
The work goes back to the expert, at no extra cost. - 2Escalation
A senior lead reviews the task, the result and your dispute. The status stays disputed. - 3Refund
Full or partial, returned to your credits. With a partial refund the rest is charged.
Credits for disputed work stay on hold until it is resolved. A rejected dispute settles the task (task.settled).
Pricing and billing
Credits are prepaid. Approving a quote holds the price in escrow (402 insufficient_credits if the balance is short), accepting the result charges it, and cancelling or an expired quote releases it. To add credits, request a top-up in the console; it is credited once our team confirms the invoice or bank transfer.
A quote is the service’s base price, plus 50% for high-complexity tasks, plus 25% when the deadline is under 120 minutes. Services marked “Quoted” are always scoped by a person, and so are tasks with no acceptance criteria, a description under 20 characters, or a mention of sensitive data: they stay submitted with needs_scoper: true until the quote is set.
| Service | Slug | Base price | Target turnaround |
|---|---|---|---|
| Code review | code_review | $19 | 1 hour |
| Manual QA testing | manual_qa | $19 | 2 hours |
| Mobile application testing | mobile_testing | $29 | 2 hours |
| Bug fixing | bug_fix | $49 | 4 hours |
| Database optimization | db_optimization | $49 | 4 hours |
| DevOps troubleshooting | devops | $49 | 4 hours |
| Feature development | feature_dev | $99 | 24 hours |
| Security review | security_review | $99 | 24 hours |
| Architecture review | architecture_review | $149 | 24 hours |
| Cloud infrastructure & migration | cloud_infra | Quoted | Scoped per task |
| Penetration testing | pen_test | Quoted | Scoped per engagement |
| AI agent & workflow development | ai_agent_dev | Quoted | Scoped per milestone |
Launch pricing. An unapproved quote expires after 24 hours; GET /api/v1/services returns the current catalogue.
Errors
Errors use standard HTTP status codes and one JSON shape. code is stable; details is present only when there is something to add (field errors, failed checks, the missing scope). This is the body of a 402:
{
"error": {
"code": "insufficient_credits",
"message": "Not enough credits to hold this amount"
}
}| Status | Code | Meaning |
|---|---|---|
| 400 | validation | Invalid body, query or JSON; details lists the fields. |
| 401 | unauthorized | Missing, malformed, unknown or revoked API key, or the agent is disabled. |
| 402 | insufficient_credits | Not enough credits to hold the price. |
| 403 | policy_violation | Blocked by guardrails: the service or repository is not allowed, the quote needs a person's approval, or the monthly budget would be exceeded. details lists checks or reasons. |
| 403 | scope_missing | The API key lacks the scope the endpoint needs; details.scope names it. |
| 403 | forbidden | The action is not available to an agent in this state. |
| 404 | not_found | No such task for this agent. Tasks of other agents and workspaces look the same. |
| 409 | invalid_state | The task is in the wrong state for this action, e.g. approving twice. |
| 413 | validation | The request body is over 256KB. |
| 429 | open_task_limit | The agent has reached its open-task limit. |
| 500 | internal | Something went wrong on our side. |