Plan and run a Work
A Work is Gavana’s chat-first way to make a campaign visual. You describe what you want in plain words; Gavana writes a brief, proposes exactly three distinct directions with a recommendation, and lays them out on a canvas. Nothing is generated until someone picks one direction and confirms. Then only that direction runs.
It is the right shape when a person should choose between creative options before anything is paid for. When you already know exactly what image you want, use Generate and observe an image instead.
Only the last step spends provider credit. POST /works, /continue, and
reading a Work never start paid work. POST /works/{workId}/execute does, and it
refuses unless the body says confirm: true. Get explicit approval in the
current turn before sending it, and never auto-retry it.
Scopes: canvas:read, canvas:write, asset:read to plan; add
image:generate to execute or refresh. Reading a Work needs only canvas:read.
Reading its snapshot through /runs needs job:manage as well.
You end up with: a work: handle holding the brief and the three directions,
the canvas they live on, and — after execution — a durable node: and asset:
for the finished image.
What a Work accepts
Work v1 prepares social campaigns only. It picks the Social Campaign Template, or Cross-brand Social Campaign when the request describes a collaboration, partnership, or co-branded “Brand x Brand” campaign. Both are strict:
- The request must be about social content. A request that names no social
channel is refused with
400rather than squeezed into the wrong Template. - It always produces three directions and runs one of them, as a single 4:5 image. Asking for a different number of directions, several outputs, or a square or landscape format is refused with a message pointing you to direct image generation.
- References must already be durable
node:orasset:handles, up to 12. A URL is not accepted — bring an image in first withPOST /images/importorPOST /assets. - A Work runs once. After its run has started, start a new Work for another direction.
The sequence
Prepare the Work
POST /api/canvas-agent/v1/works
Authorization: Bearer cba_<token-id>.<secret>
Content-Type: application/json{
"request": "Instagram launch visual for our matte black travel bottle. Calm, premium, outdoors.",
"canvasId": "canvas:9Kd2Jv7QpR:task-…",
"references": [{ "handle": "asset:9Kd2Jv7QpR:7d3e9f21", "role": "product" }],
"idempotencyKey": "bottle-launch-work-001"
}| Field | Rules |
|---|---|
request | Required, 1 to 8000 characters, in the person’s own words |
canvasId | Optional. An existing canvas handle you can edit. Omit it and Gavana creates a canvas for this Work. |
references | Optional, up to 12. A handle string, or { handle, role } with role one of identity, style, product |
idempotencyKey | Required, 8 to 200 characters, stable for this exact request |
A new Work answers 201. Resending the same request with the same key answers
200 with replayed: true and the same Work.
Read the directions
The response wraps the Work with its canvas and what you may do next:
{
"workId": "work:…",
"status": "waiting_for_choice",
"canvas": { "id": "task-…", "handle": "canvas:9Kd2Jv7QpR:task-…", "revision": "…", "href": "…" },
"canvasSync": { "sourceRevision": "…", "currentRevision": "…", "status": "current", "affectedOutputIds": [] },
"permissions": { "canEdit": true, "canRefresh": true },
"progress": { "state": "waiting_for_choice", "completed": 0, "total": 1 },
"work": {
"handle": "work:…",
"state": "waiting_for_choice",
"template": { "id": "social-campaign", "version": "1.0.0", "handle": "template:social-campaign@1.0.0", "name": "…", "label": "…" },
"brief": { "request": "…", "summary": "…", "objective": "…", "audience": "…", "channels": ["social"], "assumptions": ["…"], "questions": [], "references": [], "refinements": [] },
"directions": [
{
"id": "…",
"handle": "direction:…",
"label": "…",
"name": "…",
"summary": "…",
"creative": { "coreIdea": "…", "camera": "…", "composition": "…", "lighting": "…", "motionTexture": "…", "copyHierarchy": "…" },
"rationale": "…",
"recommended": true,
"branchNodeHandle": "node:…",
"targetNodeHandle": "node:…"
}
],
"recommendation": { "directionId": "…", "reason": "…" },
"decision": { "handle": "decision:…", "kind": "select_direction", "status": "open" },
"costConfirmation": { "required": true, "confirmed": false, "paidJobsStarted": 0 },
"cost": { "estimated": 1, "unit": "image_generations" },
"runs": []
}
}work.directions always holds exactly three. Each one names its creative choices
— idea, camera, composition, lighting, texture, copy hierarchy — and its
branchNodeHandle and targetNodeHandle on the canvas, where the person can see
and edit it. work.recommendation says which one Gavana would pick, and why.
Show all three, with the recommendation, to the person you are working for.
permissions.canEdit is true for the owner and editors, who may continue and
execute; permissions.canRefresh is true only for the owner.
Answer or adjust, if needed
Each call to POST /works/{workId}/continue takes an action and its own
idempotencyKey, and none of them starts paid work:
action | Body | Effect |
|---|---|---|
answer | { "action": "answer", "answer": "…", "idempotencyKey": "…" } | Records an answer to the brief’s questions |
adjust | { "action": "adjust", "adjustment": "…", "idempotencyKey": "…" } | Records a change to the brief, such as “warmer light” |
select_direction | { "action": "select_direction", "directionId": "…", "idempotencyKey": "…" } | Chooses one direction, by its id or direction: handle |
acknowledge_canvas | { "action": "acknowledge_canvas", "rebase": true, "idempotencyKey": "…" } | Accepts edits someone made on the canvas, without overwriting them |
{ "rebase": true, "idempotencyKey": "…" } on its own is shorthand for
acknowledge_canvas. Answers and adjustments still have to fit the Template: one
that asks for another format or more outputs is refused like the original
request would be.
Choose one direction
{ "action": "select_direction", "directionId": "direction:…", "idempotencyKey": "bottle-launch-select-001" }The Work moves to ready_to_run. Nothing is generated yet.
Confirm before spending
Say what will run, then wait for a yes:
This generates 1 image for the ”…” direction on Bottle launch, and charges your image provider. Proceed?
work.cost.estimated is the number of image generations the run will start.
Approval is for this run only.
Execute the chosen direction
POST /api/canvas-agent/v1/works/{workId}/execute
Authorization: Bearer cba_<token-id>.<secret>
Content-Type: application/json{ "confirm": true, "idempotencyKey": "bottle-launch-execute-001" }202. The Work moves to running, work.costConfirmation.paidJobsStarted
becomes 1, and work.runs gains one entry with its run: handle, the
selectedDirectionId, and the outputHandles it will fill.
Execute refuses with 409, starting nothing, when:
- no direction has been chosen yet;
- the canvas changed since the Work last saw it — acknowledge it with
continuefirst, then execute; - the Work has already started its one run;
- planning was degraded, so the directions were never verified — start a new Work later, or generate directly.
Read the result
GET /works/{workId} returns the stored Work and never polls a provider or
writes anything, so it is safe to call as often as you like:
{
"status": "completed",
"work": {
"runs": [
{
"handle": "run:…",
"status": "completed",
"outputHandles": ["node:…"],
"outputs": [
{ "nodeHandle": "node:…", "assetHandle": "asset:…", "status": "succeeded", "previewUrl": "https://app.gavana.ai/api/canvas-agent/v1/assets/preview?token=…" }
]
}
]
}
}A stored Work can lag the provider. The owner can call
POST /works/{workId}/refresh to reconcile provider progress into the Work and
its canvas; that call may write, which is why it needs canvas:write and
image:generate. To read without any chance of writing, use
GET /runs/{workId}/snapshot with the work: handle — it reports the stored
state, never reconciles, and needs job:manage and canvas:read.
Store the durable handles
Keep outputs[].nodeHandle and outputs[].assetHandle. Do not store
previewUrl — it is a short-lived capability.
When the canvas changes under the Work
The directions live on a canvas that people can edit. If someone changes it, the
Work reports canvasSync.status: "stale" instead of overwriting the edit, and
continue and execute refuse with 409 and the two revisions in
details.canvasRevision and details.workRevision.
Acknowledge the change, then carry on:
{ "action": "acknowledge_canvas", "rebase": true, "idempotencyKey": "bottle-launch-ack-001" }When it fails
| Response | Meaning | What to do |
|---|---|---|
400 on prepare | The request is not a social campaign, asks for another format or count, or includes a URL | Rephrase, import the reference first, or use direct image generation |
409 on prepare | The same key was used for a different request, or the canvas has no free space for the Work | Use a new key, or prepare on a new canvas |
409 on continue | Same key with a different step, the canvas changed, or the run has already started | Read the message; acknowledge the canvas, or start a new Work |
409 on execute | See the list in the execute step | Nothing started; fix the cause, then ask again |
403 on refresh | Only the Work’s owner can reconcile provider progress | Read with GET /works/{workId} instead |
A run with status: "failed" | The paid run did not produce an image; the outputs carry error and retryable | Surface it. A Work runs once, so another attempt is a new Work and a new approval. |
Next
- Generate and observe an image — direct generation when you already know the image you want
- Works — the generated contract for all five operations
- Runs — snapshots and recovery
- Idempotency — why each step carries its own stable key