---
title: "Update task"
method: PATCH
path: "/api/tasks/{sid}"
tags: ["tasks"]
---

# Update task

`PATCH /api/tasks/{sid}`

## Request

- Base URL: `https://beta.getsales.io/unibox/v1`
- URL: `https://beta.getsales.io/unibox/v1/api/tasks/{sid}`
- Auth: HTTP bearer and API key in header `Team-SID`

Edit a task and move it between states: done completes it, canceled discards it, open reopens a done task and clears the pick. A task carrying options closes with chosen_option_id. A play's draft (kind play_draft) closes done with its words as edited in draft, or canceled (the play skips them); a play's question (kind play_question) closes done with the chosen option, and with workflow_sid when its key is move or add and play_ref names no workflow. Empty patch: 422 nothing_to_update.

Contract:
- MCP tool `update_task`, registry package `mcp.unibox/tasks`, mount `unibox.inbox`.
- Operation `update`, response envelope `update`.
- Flags: none.

## Path parameters

- `sid` string, required: Task sid (ub_tk_…).

## Request body

- UpdateTaskRequest: Request body of `update_task`.
  - `title` string: Replacement title, 1..255 chars.
  - `body` string, nullable: Replacement detail (full replace); null clears it.
  - `due_at` string, nullable: ISO 8601 UTC deadline; null clears the deadline and takes the task out of the due sweep.
  - `expires_at` string, nullable: ISO 8601 UTC, after now (422 otherwise): the new instant the sweep cancels the open task at; null takes the expiry off. A close (done or canceled) clears it, and so does a reopen past it.
  - `state` 'open' | 'done' | 'canceled': done = complete it (completed_at stamped), canceled = discard it, open = reopen it (completed_at and the pick cleared). The service applies the value it is given; it runs no transition guard.
  - `assignee_user_sid` string, nullable: Reassign the work; null unassigns it.
  - `chosen_option_id` integer, nullable: The arm picked from options. Required with state=done on a task that carries options, and refused (422 chosen_option_id) on one that does not or for an id outside the list.
  - `draft` string, nullable: A play's draft, as edited (2026-10-14): the words that go when the task closes done. Kept on any other task but meaningless there.
  - `workflow_sid` string, nullable: A play's question only: the workflow a move or an add puts the person into (play_ref.workflow_sid). Required with state done when the chosen option's key is move or add and the ref names none (422 workflow_sid); 422 on a task that is no play's question.

## Response `200`

`update` success envelope.

- UpdateTaskResponse
  - `success` true, required
  - `operation` 'update', required
  - `item` object, required
    - `sid` string, required: Task sid (ub_tk_…).
    - `team_sid` string, required: Owning team (ts_tm_…, external - gs.service.id).
    - `title` string, required: One line stating the work, 1..255 chars.
    - `state` 'open' | 'done' | 'canceled', required: open = on the queue; done = completed (completed_at stamped); canceled = discarded. There is no delete.
    - `created_by` object, required: Actor that opened the task. actor_type user = a person, agent = the AI SDR (escalation or a plan step), system = the workflow bridge.
      - `actor_type` 'user' | 'support' | 'api_key' | 'system' | 'agent', required
      - `actor_sid` string, nullable, required
      - `team_sid` string, required
      - `actor_name` string, nullable: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
      - `oauth_client_sid` string, nullable: The acting OAuth client (id_oc_*); null off the OAuth path.
      - `reason` string, nullable: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
      - `permissions` object, required: Internal audit context: the grant set the actor held at write time. Not a contract.
      - `cluster_id` integer, nullable: Internal audit context: the cluster that served the write.
      - `trace_id` string, nullable: Internal audit context: the trace id of the request that wrote the row.
    - `conversation_sid` string, nullable, required: The thread this task hangs on (ub_cv_…); null = standalone, which no inbox surface lists yet.
    - `person_sid` string, nullable, required: The playtables person the thread was linked to AT CREATION (cr_pp_…) - a denorm, never backfilled by later linking; null when the thread had no primary link.
    - `body` string, nullable, required: Free text. On agent-created rows this is the context bundle: why a human is needed, plus the facts to act without re-reading the thread.
    - `due_at` string, nullable, required: ISO 8601 UTC deadline; null = undated. Once it passes, the due sweep (every 5 minutes) flips the owning thread to needs_you: the "Task due" cue.
    - `assignee_user_sid` string, nullable, required: User expected to do the work (us_mb_…, external - gs.service.id); null = unassigned. A label, not a lock.
    - `completed_at` string, nullable, required: ISO 8601 UTC; stamped on open -> done and cleared on reopen. Null while open, and on a canceled task.
    - `workflow_task_sid` string, nullable, required: The playtables manual_task / manual_router node this co-pilot task stands for (wf_tk_…), set only by the internal bridge; null on tasks people and the agent open. Closing such a task reports the outcome back to playtables.
    - `options` object[], nullable, required: The arms a manual_router node offers (1..9, authored order); null on every other task. Non-null means this task completes WITH a pick.
      - `id` integer, required: Arm id, unique inside this task; echoed back as chosen_option_id on completion.
      - `label` string, required: What the arm says to the human (1..255 chars) - the router branch, in authored order; on a play's question the plain English fallback of the choice.
      - `key` string, nullable: A play's question only: the choice the option stands for (remove | keep | move about a journey the play paused, add for a person in none). Absent on a router's arm.
    - `chosen_option_id` integer, nullable, required: The picked arm, set with the open -> done transition of a task that carries options; null otherwise, and cleared on reopen.
    - `expires_at` string, nullable, required: ISO 8601 UTC; a task still open at this instant is canceled by the sweep (every 5 minutes) and keeps the instant, which is how an expired task reads (canceled WITH expires_at). A close by a person clears it; null = it never expires. A task the product opens itself (the AI SDR's, a hand-over's, a workflow node's) takes a month by default; a live visit alert takes its site's live_alert_task_minutes.
    - `source_ref` string, nullable, required: What produced a system task, <source>:<its sid>: escalation:ub_cv_... the AI SDR's hand-off, website_live:sg_ws_... a live visit alert. null on a person's task. Read-only.
    - `kind` 'manual' | 'play_draft' | 'play_question', required: manual = a person's, the agent's or a workflow node's work item (every task until 2026-10-14); play_draft = a play's draft (a congratulation, a comment, a person entering a workflow) whose words wait in draft, Send approves them as edited and Skip (canceled) drops them; play_question = a play's question about a journey (remove | keep | move) or a person in none (add), answered with a chosen option. Set by the bridge; read-only.
    - `draft` string, nullable, required: A play's draft: the words the person sends, as edited before Send (update draft, then state=done, or both at once); null on every other task.
    - `play_ref` object, nullable, required: A play's task: the play, its table and the workflow the act names or the person picked; null on every other task.
      - `play_sid` string, required: The play (pt_pl_..., external - playtables).
      - `play_name` string, required: Display denorm, frozen when the task opened.
      - `playtable_sid` string, nullable, required: The table the play lives in (pt_tb_...), the way into its playbook; null when unknown.
      - `workflow_sid` string, nullable, required: The workflow the act names (a person entering it, a move's destination) when the play named one, or the one the person picked on a question whose choice needs one (move, add); null until then.
    - `created_at` string, required: ISO 8601 UTC.
    - `updated_at` string, required: ISO 8601 UTC; bumped by every edit and state move.
    - `deleted_at` string, nullable, required: ISO 8601 UTC; null = live. No writer in v1 (canceled is the discard), so this stays null.
  - `updated_fields` string[], required
  - `previous_values` object, required
  - `kept_fields` string[]: The fields this write did not change because the person's own value stands on them (stamped person); read the item for what landed.
  - `meta` object, required
    - `trace_id` string, required: UUID v7; same 128-bit value as the X-Trace-Id header.
    - `span_id` string, required: 16 hex chars, root span of this request.
    - `timestamp` string, required: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
    - `duration_ms` integer, required: Server-side wall clock.
    - `team_sid` string, nullable: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
    - `actor_type` string, nullable: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.

## Other responses

- `4XX`: MCP error envelope. `error.code` is one of validation_failed, nothing_to_update, not_found, relation_not_found, invalid_transition, limit_exceeded, payment_required, duplicate_rejected, conflict, delete_blocked, unauthorized, forbidden, rate_limited, not_implemented.
- `5XX`: MCP error envelope with `error.code` internal_error or service_unavailable.

---

[API](https://skmtc.dev/getsales/apis/getsales-public-contract-gs-service-unibox.md) - [All operations](https://skmtc.dev/getsales/apis/getsales-public-contract-gs-service-unibox/llms.txt) - [OpenAPI document](https://skmtc.dev/getsales/apis/getsales-public-contract-gs-service-unibox/revisions/8f1bc317897f?raw)
