Confirm an offer
POST/chat/plans/:planId/confirm
Says yes to an offer the agent made and starts its run. THIS SPENDS CREDITS: the run is launched from the stored plan at the price the offer showed (plan.price.totalCredits), never from anything sent here. Answers 202 with the run; confirming a plan that already started answers 200 with the SAME run and starts nothing. An offer of pictures for a draft piece (reply.proposal.pieceOffer) has no run: it answers pieceId instead of runId, read the piece with GET /pieces/{pieceId} (its slides say waiting while a picture is being made), and only the pictures actually made are charged, at most plan.price.totalCredits. An offer to MAKE a designed piece (reply.proposal.draftOffer) makes the piece only now, then its pictures: it answers the new pieceId, and total is the pictures it will make (0 when its design holds no picture: the piece is made and nothing is charged). A piece that cannot be made as the offer stands (the account lost the feature, a product or brand was deleted) answers AGENT_CHAT_PLAN_CANNOT_RUN, with nothing charged. An offer whose pictures name no product, on an account that cannot have a picture made from a description alone (its start says needs-product), is never made: confirming it answers AGENT_CHAT_PLAN_NEEDS_PRODUCT and nothing is made or charged. A price that moved since the offer was shown is refused with nothing charged. The key needs chat and runs:write.
Request
Responses
- 200
- 202
- 400
- 401
- 402
- 403
- 404
- 409
- 422
- 429
- 503
The plan had already started: the same run.
The run was started.
Bad Request. The Idempotency-Key header is malformed (INVALID_IDEMPOTENCY_KEY), or the plan cannot be generated as it stands (AGENT_CHAT_PLAN_NOT_LAUNCHABLE; nothing was charged).
Unauthorized. Missing, malformed, unknown, revoked, or expired bearer token — or the token owner no longer holds the required entitlement (ENTITLEMENT_LOST). A uniform problem body is returned with a distinct code; no owner/condition detail (no-leak).
Payment Required (AGENT_CHAT_PLAN_UNAFFORDABLE). The account has fewer credits than the offer's whole total (its pictures, clips and video together); details.required is that total and details.spendable what is left. Nothing was made or charged; the same offer can be confirmed once the account has the credits.
Forbidden. The key lacks chat or runs:write (API_TOKEN_SCOPE_DENIED), or the account does not have the agent or the public API turned on (BETA_ACCESS_REQUIRED).
Not Found (AGENT_CHAT_PLAN_NOT_FOUND). No plan with this id belongs to the key's account - another account's returns this SAME uniform 404 (no-leak).
Conflict. The plan expired (AGENT_CHAT_PLAN_EXPIRED), was replaced (AGENT_CHAT_PLAN_SUPERSEDED), was declined (AGENT_CHAT_PLAN_DECLINED), is too large (AGENT_CHAT_PLAN_TOO_LARGE), is being confirmed right now (AGENT_CHAT_CONFIRM_IN_PROGRESS, retry after Retry-After), or its price moved (AGENT_CHAT_PLAN_PRICE_CHANGED: for a change of a made piece, any one step’s price) or the account is over its spend window (AGENT_CHAT_ACCOUNT_SPEND_CAP_EXCEEDED), or a change of a made piece could not be started (AGENT_CHAT_PIECE_CHANGE_NOT_STARTED: details.reason says why - it was edited since, another change of it is running, a step’s clip or frame is gone, or the account cannot spend it). Nothing was charged.
Response Headers
Seconds to wait before retrying.
Unprocessable Content. The plan can never run as it stands (AGENT_CHAT_PLAN_CANNOT_RUN), or its pictures name no product this account can have pictured (AGENT_CHAT_PLAN_NEEDS_PRODUCT: ask which product it is for). Nothing was made or charged; ask for a new one.
Too Many Requests. More requests per minute on this key than the chat plane allows.
Service Unavailable. Public writes are paused (WRITES_PAUSED), generations are paused (CREATE_API_DISABLED), the plan could not be started just now (AGENT_CHAT_LAUNCH_UNAVAILABLE), or the spend window could not be read (AGENT_CHAT_ACCOUNT_SPEND_UNAVAILABLE). Nothing was charged; retry after Retry-After.
Response Headers
Seconds to wait before retrying.