Request a draft description and precondition from the project's AI provider
const url = 'https://beta-api.plune.ai/v1/test-cases/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/draft';const options = { method: 'POST', headers: {Prefer: 'respond-async', Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://beta-api.plune.ai/v1/test-cases/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/draft \ --header 'Authorization: Bearer <token>' \ --header 'Prefer: respond-async'The call to the provider happens inside this request, up to 60 seconds (ADR-0001), so the answer already carries the outcome — drafted, the provider failed, or the call was aborted on timeout. With a fallback provider connected a request can take up to two such attempts (#829, ADR 0052), which a proxy may cut: send Prefer: respond-async (RFC 7240) to get 202 at once with the call in_progress (header Preference-Applied: respond-async) while the server finishes the chain on its own, then read GET on this path until pending is no longer in_progress. The checks, limits and cost are the same in both modes. Nothing about the case changes here (AC-01); a prior draft awaiting_decision for this case is replaced, whoever requested it (AC-19). One request per case at a time: while a call for this case is still running — anyone’s, for as long as the provider call can last — a new request is refused with 409 and nothing is paid for twice. The checks (that, and both rate-limit windows) and the start of the call are one atomic step, so requests that arrive together cannot all pass the same check. No request body: the code snapshot, provider, model and language all come from the case and the project’s AI settings, never from the client.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Header Parameters
Section titled “Header Parameters ”#829: respond-async answers 202 at once; the outcome is then read with GET on this path.
Responses
Section titled “ Responses ”The call’s outcome — awaiting_decision with the draft, or failed/aborted with no text (AC-09). A 200 either way: the request itself succeeded.
One call record (ADR-0002), as returned to a project member. When mine is false — a pending draft somebody else requested — every field below requestedAt is withheld (AC-19): content, tokens and cost are for the requester alone until a decision is made.
object
Whether the caller is the member who requested this call.
userId of the member who asked — resolve through GET /v1/members like TestCaseMeta.createdBy.
The drafted description, present while there is one to show (mine, and state carries text).
«Чого чернетка не бачила» — fixtures, hooks, helpers (AC-14). Never a field of the case.
Whether the case’s code snapshot changed, beyond whitespace, since this call was requested (AC-04b).
The average price per token of this call (costUsd ÷ tokens) — input and output tokens are priced apart. null means “ціна невідома” (the model has no price) or that the provider reported no tokens to price; never 0 (SAD §8 rule 6, AC-15).
null exactly when unitPriceUsd is null.
Present exactly when state is failed.
#829 (ADR 0052): which attempt of the request this record is - 1 the primary provider, 2 the fallback.
#829: true when the fallback provider made the draft. The page shows it before the member accepts.
#829: one element per attempt of the request, the first the primary. One element when only the primary was tried. Never the provider’s own text (AC-09).
#829 (ADR 0052): one attempt of one request.
object
ADR-0004 — the ways to connect a provider on this feature; each later addition is its own task. plune (#1427): Plune AI, the platform’s own key through OpenRouter, paid for in credits — the model is the plan’s (Free a low-cost one, a paid plan Haiku 5.5), no key and no fallback of the owner’s. Only the case draft runs on it; every other AI action reads a project on plune as one with no provider connected.
Examples
AC-01 — the provider answered in time
{ "id": "6f1c2b3a-0000-4000-8000-0000000000c1", "state": "awaiting_decision", "mine": true, "requestedBy": "u-member1", "requestedAt": "2026-09-16T09:12:04.151Z", "description": "Opens the checkout page with an empty cart and asserts the empty-state message.", "precondition": "A logged-in user with an empty cart.", "unseenNote": "Does not see the `beforeEach` hook, which navigates to /checkout and logs the user in.", "codeChangedSinceRequest": false, "inputTokens": 812, "outputTokens": 96, "unitPriceUsd": 0.0000031, "costUsd": 0.0028, "durationMs": 4210}AC-09 — the provider did not answer within 60 s
{ "id": "6f1c2b3a-0000-4000-8000-0000000000c1", "state": "aborted", "mine": true, "requestedBy": "u-member1", "requestedAt": "2026-09-16T09:12:04.151Z", "durationMs": 60000}AC-09 — the provider rejected the stored credentials
{ "id": "6f1c2b3a-0000-4000-8000-0000000000c1", "state": "failed", "mine": true, "requestedBy": "u-member1", "requestedAt": "2026-09-16T09:12:04.151Z", "failureKind": "key_rejected", "durationMs": 340}#829: only for Prefer: respond-async — the call is reserved and in_progress; the chain finishes in the background and GET on this path shows its end.
One call record (ADR-0002), as returned to a project member. When mine is false — a pending draft somebody else requested — every field below requestedAt is withheld (AC-19): content, tokens and cost are for the requester alone until a decision is made.
object
Whether the caller is the member who requested this call.
userId of the member who asked — resolve through GET /v1/members like TestCaseMeta.createdBy.
The drafted description, present while there is one to show (mine, and state carries text).
«Чого чернетка не бачила» — fixtures, hooks, helpers (AC-14). Never a field of the case.
Whether the case’s code snapshot changed, beyond whitespace, since this call was requested (AC-04b).
The average price per token of this call (costUsd ÷ tokens) — input and output tokens are priced apart. null means “ціна невідома” (the model has no price) or that the provider reported no tokens to price; never 0 (SAD §8 rule 6, AC-15).
null exactly when unitPriceUsd is null.
Present exactly when state is failed.
#829 (ADR 0052): which attempt of the request this record is - 1 the primary provider, 2 the fallback.
#829: true when the fallback provider made the draft. The page shows it before the member accepts.
#829: one element per attempt of the request, the first the primary. One element when only the primary was tried. Never the provider’s own text (AC-09).
#829 (ADR 0052): one attempt of one request.
object
ADR-0004 — the ways to connect a provider on this feature; each later addition is its own task. plune (#1427): Plune AI, the platform’s own key through OpenRouter, paid for in credits — the model is the plan’s (Free a low-cost one, a paid plan Haiku 5.5), no key and no fallback of the owner’s. Only the case draft runs on it; every other AI action reads a project on plune as one with no provider connected.
Example
{ "state": "in_progress", "failureKind": "key_rejected", "attempt": 1, "attempts": [ { "role": "primary", "provider": "anthropic", "outcome": "key_rejected" } ]}Headers
Section titled “Headers ”No / invalid token or session
#1427 — the project is on Plune AI and no grant of the owner of its plan has this draft’s price left: 1 credit, 2 for a prompt over 10 000 estimated tokens (a draft is never split across grants). No draft is written and nothing is sent to a model. Of two requests at a balance of 1, one is let in and the other gets this. A draft that fails or is aborted gives its credit back. code says what else happened (D12–D14): pack_being_bought — overage is on and a pack is being bought for the plan: a pending pack row and its ai-credit-overage job were written now, or one already in flight is waited for; the provider is asked by the worker, never during this request, and the credits come with its payment. overage_cap_reached — overage is on, and one more pack would pass this month’s cap. credits_spent — otherwise (overage off, Free, no way to pay, or a pack that failed within the last day). credits_spent writes nothing; overage_cap_reached writes nothing either, except once a calendar month (UTC): the first stop of the month marks it on the overage setting and queues the owner’s «cap reached» letter. tier is the plan of the owner who pays (the screen words the refusal by it).
object
Free and Personal are an account’s, Team and Enterprise a company’s; Free may also be a company’s, as the row that cancels its Team.
Example
{ "error": "no Plune AI credits left for this draft — connect your own key (free) or move to a paid plan", "code": "credits_spent", "tier": "free"}A bearer token asked — requesting a draft is a human-session action only (AC-06)
object
Example
{ "error": "requires a human session — a token cannot request or decide a draft"}Not found or not yours
object
Example generated
{ "error": "example"}The action a client should not have been able to reach — the availability check (GET on this same path) already said no, and something changed the state in between.
object
Examples
AC-07 — AI was turned off between the check and this request
{ "error": "AI is disabled for this project"}{ "error": "no AI provider is connected for this project"}AC-08
{ "error": "this case has no code snapshot yet"}AC-08 — manual or eval case
{ "error": "a draft from code is only possible for an automated case"}A call for this case is already running (a double click, or a colleague asking at the same moment)
{ "error": "a draft request for this case is already in progress"}The saved key does not decrypt under this server’s key (a rotated key, a damaged row) — recorded as the owner’s last issue, `key_rejected`
{ "error": "the saved AI provider key cannot be read — the project owner has to save it again"}AC-10 — refused without calling the provider. Two independent windows: the member’s own (30 per 60 minutes) and the project’s (200 per 24 hours); both survive a restart (backed by ai_calls, ADR-0001) — unlike #/components/responses/RateLimited elsewhere in this document, this is not the in-memory per-instance limiter. code names the window that refused: member_limit or project_limit. A third refusal, ai_budget_spent (#1286), carries no Retry-After: the owner’s monthly dollar limit is used up until the 1st (UTC) — capUsd, spentUsd (known-price calls only) and resetsOn say so; the owner raises the limit with PATCH /v1/settings/ai. Calls already made stand.
object
Examples
{ "error": "rate limit exceeded — you can request another draft in 42 minutes", "code": "member_limit"}{ "error": "rate limit exceeded — this project can request another draft in 3 hours", "code": "project_limit"}Headers
Section titled “Headers ”Seconds until enough calls have left the window for this request to pass — the time until the call that has to leave does, not the length of the window; the longer of the two when both are full. The message says the same in words
SAD §7/§11 — the server has no encryption key, so no project’s AI can work
object
Example
{ "error": "AI platform not configured — contact your operator"}