{"openapi":"3.1.0","info":{"title":"Tooley Commercial API","version":"1.3.0","description":"Tooley's commercial REST API: run tooley's file, document, image and\ndata tools from your own code with prepaid credits.\n\nHow it fits together:\n\n1. **Get a token.** Buy a credit package and redeem the one-time link\n   e-mailed to you (`POST /v1/retrieval/redeem` through the website).\n   The token (`tfk-…`) authorises your wallet; send it as an HTTP\n   bearer credential on every authenticated call.\n2. **Discover tools.** The catalogue (`GET /v1/tools`) lists every\n   priced tool with its credit price and the parameter schema it\n   accepts. This OpenAPI document describes the request ENVELOPE; the\n   per-tool parameter schema comes from the catalogue entry, not from\n   this document.\n3. **Submit jobs** (`POST /v1/tools/{slug}/jobs`): a flat JSON object\n   for parameter-only tools, or multipart form data (with the\n   parameters as a JSON string in the `params` field) for tools that\n   take files. Every submission is asynchronous: the API answers 202\n   immediately and the job runs in the background.\n4. **Poll** the job (`GET /v1/jobs/{id}`) until it reaches a terminal\n   state, then download each output (`GET /v1/jobs/{id}/outputs/{i}`).\n5. **Check your wallet** (`GET /v1/wallet/balance`): a job's price is\n   reserved at admission and settled on success; a failed job releases\n   the reservation and costs nothing.\n\nErrors always keep one shape: `{\"code\": \"...\", \"message\": \"...\"}` with\nthe same code mirrored in the `X-Error-Code` response header.\n\nTool parameters are NOT defined here. Each tool publishes its own JSON\nSchema fragment through `GET /v1/tools/{slug}` (`input.params`); the\nAPI validates the same schema server-side. Send the parameters flat in\nthe JSON body (or as the `params` JSON string in multipart form data)\n— never wrapped in a nested `params` object for JSON submissions.\n","x-app-version":"0.26.2"},"servers":[{"url":"https://api.tooley.work","description":"The commercial API's public origin."}],"security":[{"apiToken":[]}],"tags":[{"name":"Tools","description":"The public, priced catalogue and each tool's input contract."},{"name":"Jobs","description":"Prepaid asynchronous executions: submit, poll, cancel."},{"name":"Outputs","description":"A finished job's produced files."},{"name":"Wallet","description":"The authenticated wallet's credits and ledger history."},{"name":"Purchasing","description":"Packages, checkout, payment journey and one-time credential retrieval.","x-runtime-note":"Purchasing routes answer 503 S_PURCHASE_UNAVAILABLE on deployments without a configured gateway."}],"paths":{"/v1/tools/{slug}/jobs":{"post":{"operationId":"submitToolJob","summary":"Submit a job for a tool","tags":["Jobs"],"security":[{"apiToken":[]}],"responses":{"200":{"description":"Idempotent replay: the same job, unchanged (deduplicated).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobSubmission"}}}},"202":{"description":"Admitted: the job is queued and its price reserved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobSubmission"}}}},"401":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded; the body carries the stable R_RATE_LIMIT shape.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}},"Retry-After":{"description":"Seconds to wait before the next attempt.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"Admit prepaid work. Choose the request shape by the tool's `input.files.min`: 0 → one JSON object whose top-level keys are the tool's parameters; > 0 → multipart form data with the files in one or more `files` parts and the parameters as a JSON string in the `params` field. Sending JSON to a tool that takes files (or any other content type) is refused with 415.\n\nThe per-tool parameter schema is NOT defined here: fetch it from `GET /v1/tools/{slug}` (`input.params`), a draft 2020-12 JSON Schema (unknown keys refused, required keys enforced). The same schema validates server-side with `V_MISSING_PARAM` / `V_UNKNOWN_PARAM` / `V_INVALID_PARAM` refusals.\n\nUse an `Idempotency-Key` (header, or an `idempotency_key` form field on multipart; both together must match) to make retries safe: the same key with identical content returns the SAME job (HTTP 200, `deduplicated: true`); the same key with different content is a 409.\n\nAdmission reserves the price before the job exists: insufficient cover is a 402 and nothing is created. A successful admission answers 202 with `credits_reserved` — credits are pledged, never debited at this point.","parameters":[{"name":"slug","in":"path","required":true,"description":"The tool's catalogue id (the slug).","schema":{"type":"string","pattern":"^[a-z0-9][a-z0-9-]*$"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"A client-chosen stable key (≤ 200 characters) that makes a replay of the same request idempotent.","schema":{"type":"string","maxLength":200}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolParams"},"examples":{"parameterOnlyFlat":{"summary":"Parameter-only tool, flat JSON body","description":"The tool's parameters are the body's TOP-LEVEL keys. Never wrap them in a nested `params` object — a nested shape is refused with `V_MISSING_PARAM` (the real parameters are then considered absent).","value":{"value":"#336699","from_format":"auto"}}}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ToolJobMultipartBody"}}}}}},"/v1/tools":{"get":{"operationId":"listTools","summary":"List the priced commercial catalogue","tags":["Tools"],"security":[],"responses":{"200":{"description":"The catalogue (ascending by tool id).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolList"}}}}},"description":"Every tool callable through this API, sorted by id, with its fixed credit price and the input contract that describes what to send. Open without authentication."}},"/v1/tools/{slug}":{"get":{"operationId":"getTool","summary":"One tool's contract and price","tags":["Tools"],"security":[],"responses":{"200":{"description":"The tool's entry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tool"}}}},"404":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"The same catalogue entry as one object, or 404 J_TOOL_NOT_COMMERCIAL when the slug is unknown or carries no published price. This is how SDKs discover a tool's PARAMETER schema (`input.params`), file rules and retention window.","parameters":[{"name":"slug","in":"path","required":true,"description":"The tool's catalogue id (the slug).","schema":{"type":"string","pattern":"^[a-z0-9][a-z0-9-]*$"}}]}},"/v1/jobs/{job_id}":{"get":{"operationId":"getJob","summary":"Poll one job's state","tags":["Jobs"],"security":[{"apiToken":[]}],"responses":{"200":{"description":"The job object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"404":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded; the body carries the stable R_RATE_LIMIT shape.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}},"Retry-After":{"description":"Seconds to wait before the next attempt.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"The job object for an owned job. Poll only while `state` is `validated`, `queued` or `running`; terminal states are `result` (carries `result.outputs`), `failed` (carries `error`) and `cancelled`. Foreign and unknown job ids answer the identical 404 — no enumeration across wallets.","parameters":[{"name":"job_id","in":"path","required":true,"description":"The job id from the submission response.","schema":{"type":"string"}}]}},"/v1/jobs/{job_id}/cancel":{"post":{"operationId":"cancelJob","summary":"Cancel a queued job","tags":["Jobs"],"security":[{"apiToken":[]}],"responses":{"200":{"description":"The job object, now `cancelled`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"404":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"Cancelled jobs release their reservation; you are never charged for work that never ran. Only jobs still in `validated` or `queued` can be cancelled — once `running`, the call answers 409 J_NOT_CANCELABLE and the run either delivers a result or releases on failure. (The engine's own state machine keeps a charging state for legacy paid rows; prepaid wallet jobs pass straight from validated to queued and never park there.)","parameters":[{"name":"job_id","in":"path","required":true,"description":"The job id from the submission response.","schema":{"type":"string"}}]}},"/v1/jobs/{job_id}/outputs":{"get":{"operationId":"listJobOutputs","summary":"List a finished job's outputs","tags":["Outputs"],"security":[{"apiToken":[]}],"responses":{"200":{"description":"The output index.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OutputIndex"}}}},"402":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"The output index for a job in `state: result`: one entry per produced file with its relative download `url`. Asked before the job finishes it answers 409 J_NOT_DELIVERABLE; after the retention window closes the downloads answer 410 R_EXPIRED.","parameters":[{"name":"job_id","in":"path","required":true,"description":"The job's id.","schema":{"type":"string"}}]}},"/v1/jobs/{job_id}/outputs/{output_idx}":{"get":{"operationId":"downloadJobOutput","summary":"Download one output file","tags":["Outputs"],"security":[{"apiToken":[]}],"responses":{"200":{"description":"The output file's bytes, streamed with its documented filename.","content":{"*/*":{"schema":{"type":"string","format":"binary"}}}},"402":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"410":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"Streams the output's bytes (a real file download — treat it as binary data, not JSON). The `Content-Disposition` carries the suggested filename and `Content-Length` the exact size; the media type is the tool's own. Retention bounds availability (410 once the window closes).","parameters":[{"name":"job_id","in":"path","required":true,"description":"The job's id.","schema":{"type":"string"}},{"name":"output_idx","in":"path","required":true,"description":"The zero-based index from listJobOutputs.","schema":{"type":"integer","minimum":0}}]}},"/v1/wallet/balance":{"get":{"operationId":"getWalletBalance","summary":"Available and reserved credits","tags":["Wallet"],"security":[{"apiToken":[]}],"responses":{"200":{"description":"The wallet's balances.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WalletBalance"}}}},"401":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"The authenticated wallet's two balances. `reserved` is pledged to open work: it is neither spendable nor yet spent. A successful job's reservation settles (a debit on the ledger); a failed or cancelled job's reservation releases (nothing is debited)."}},"/v1/wallet/transactions":{"get":{"operationId":"listWalletTransactions","summary":"Wallet transaction history","tags":["Wallet"],"security":[{"apiToken":[]}],"responses":{"200":{"description":"The wallet's ledger rows.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WalletTransactions"}}}},"401":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"Newest-first ledger rows for the authenticated wallet: grant / reserve / settle / release / adjust movements with their running deltas and (for job rows) the job id. This is the authoritative record of what each job actually cost.","parameters":[{"name":"limit","in":"query","required":false,"description":"Rows to return (server default 50; the service clamps to 1..200).","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}]}},"/v1/credit-packs":{"get":{"operationId":"listCreditPacks","summary":"List purchasable credit packages","tags":["Purchasing"],"security":[],"responses":{"200":{"description":"The package catalogue.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditPackList"}}}},"503":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"The purchasable bundle catalogue, ascending by credits. Open; answers 503 S_PURCHASE_UNAVAILABLE while a deployment has purchasing disabled."}},"/v1/credit-packs/{pack_id}/checkout":{"post":{"operationId":"startCheckout","summary":"Start a credit-package checkout","tags":["Purchasing"],"security":[],"responses":{"201":{"description":"The checkout session reference and hosted payment URL.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutCreated"}}}},"404":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded; the body carries the stable R_RATE_LIMIT shape.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}},"Retry-After":{"description":"Seconds to wait before the next attempt.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"Open a hosted payment session for one package. The server decides the price, validates both email fields, and requires the immediate-service `ack` statement the website's purchase page shows (the exact string; a missing or altered value is 422 `V_ACK_REQUIRED` and no session is created). Redirect the customer's browser to `checkout_url`. After the payment completes the wallet is provisioned, credits arrive, and a one-time retrieval link is e-mailed to the address provided.","parameters":[{"name":"pack_id","in":"path","required":true,"description":"The pack id from listCreditPacks.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutRequest"}}}}}},"/v1/purchases/{purchase_id}":{"get":{"operationId":"getPurchase","summary":"Purchase journey status","tags":["Purchasing"],"security":[],"responses":{"200":{"description":"The purchase's journey state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Purchase"}}}},"404":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"The status of one purchase (the id is unguessable — this is a journey page's backing read, not a private account surface; nothing redeemable lives in the answer). `fulfilled` purchases carry the retrieval link's delivery state; `failed` purchases carry a note that no credits were granted. Cache-bypassing (no-store) and unguessable ids are the disclosure controls; the redeemable secret never appears here.","parameters":[{"name":"purchase_id","in":"path","required":true,"description":"The purchase id (p-…).","schema":{"type":"string","pattern":"^p-[A-Za-z0-9_-]{8,64}$"}}]}},"/v1/retrieval/redeem":{"post":{"operationId":"redeemRetrieval","summary":"Redeem a one-time retrieval link","tags":["Purchasing"],"security":[],"responses":{"200":{"description":"The wallet's API credential. Shown once.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RedeemResponse"}}}},"403":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"410":{"description":"Stable error shape; the same code rides the `X-Error-Code` response header.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded; the body carries the stable R_RATE_LIMIT shape.","headers":{"X-Error-Code":{"description":"The same stable code the body's `code` field carries.","schema":{"type":"string"}},"Retry-After":{"description":"Seconds to wait before the next attempt.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"description":"Exchange the link's id + secret for the wallet's API token. Works once; the answer is the only response that EVERY carries a plaintext token, so store it immediately. Replay is 409, expiry 410, wrong secret 403. The token never expires, but it cannot be shown again — losing it means recovering through the wallet-management journey on the website (or rotating the credential there).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RedeemRequest"}}}}}}},"components":{"securitySchemes":{"apiToken":{"type":"http","scheme":"bearer","description":"The wallet's API token (issued through the website's one-time retrieval link). Send it in the `Authorization` request header with the `Bearer` scheme."}},"schemas":{"ToolParams":{"type":"object","description":"A TOOL'S PARAMETERS, as a flat JSON object for the submission body. The concrete shape is NOT fixed here: every tool publishes its own draft-2020-12 JSON Schema through `GET /v1/tools/{slug}` (`input.params`) and the server validates against that same schema. Unknown keys are refused (`V_UNKNOWN_PARAM`), required keys are enforced (`V_MISSING_PARAM`). Never wrap the parameters in a nested `params` key."},"ToolInput":{"type":"object","description":"What the tool accepts. Copy this into your submission exactly: file count/caps and content types for multipart, the params JSON Schema for the request parameters.","properties":{"files":{"type":"object","properties":{"min":{"type":"integer","description":"Minimum accepted file count. 0 marks a parameter-only tool (JSON submissions)."},"max":{"type":"integer"},"max_bytes":{"type":"integer","description":"Per-file cap in bytes."},"content_types":{"type":"array","items":{"type":"string"},"description":"Accepted content types. Empty when the tool sniffs content itself (the tool decides)."}},"required":["min","max","max_bytes","content_types"]},"params":{"type":"object","description":"The tool's own JSON Schema (draft 2020-12) for the request parameters. Send the parameters FLAT in the JSON body: top-level keys of this object's properties, never wrapped in a nested `params` object. Unknown keys are refused (`V_UNKNOWN_PARAM`); required keys follow `required` (`V_MISSING_PARAM`)."},"text":{"$ref":"#/components/schemas/ToolTextCap","description":"Present only when the BROWSER workbench accepts pasted text for this tool. The commercial submission takes files or parameters, never pasted text."}},"required":["files","params"]},"ToolTextCap":{"type":"object","properties":{"max_bytes":{"type":"integer"}},"required":["max_bytes"]},"ToolJobMultipartBody":{"type":"object","properties":{"files":{"type":"array","items":{"type":"string","format":"binary"},"description":"The input file(s), as many `files` parts as the tool accepts (respect its `input.files.min`/`max`). Every part content type is sniffed from the bytes and checked against the tool's allowlist."},"params":{"type":"string","description":"The tool's parameters as ONE JSON string, shaped by the tool's `params` schema from the catalogue (`GET /v1/tools/{slug}`). Empty object `{}` when the tool declares no parameters. This form field is the ONE place a `params` wrapper exists — the JSON body shape has none.","contentMediaType":"application/json"},"idempotency_key":{"type":"string","description":"Optional alternative to the Idempotency-Key header (multipart only); when both are sent they must be identical."}},"required":["files"]},"Tool":{"type":"object","properties":{"id":{"type":"string","description":"Tool slug; the path parameter of the job endpoints."},"title":{"type":"string"},"description":{"type":"string","description":"One-paragraph description, bounded to 400 characters."},"credits":{"type":"integer","description":"Credits reserved per execution (2, 5 or 8). Fixed by the tool's own definition; no size multipliers.","enum":[2,5,8]},"category":{"type":"string","description":"Curated category slug (lowercase; empty when the tool carries none)."},"tags":{"type":"array","items":{"type":"string"}},"input":{"$ref":"#/components/schemas/ToolInput"},"output":{"type":"object","properties":{"files":{"type":"object","properties":{"max":{"type":"integer"}},"required":["max"]}},"required":["files"]},"retention":{"type":"object","description":"The tool's own retention policy. `result_minutes` bounds how long outputs stay downloadable; after it lapses the download answers 410 R_EXPIRED. `upload_delete_at` says when the JOB's inputs drop (immediate on reaching a terminal state, or kept until the result window closes). `text` inside `input` (when present) describes a pasted-text cap the BROWSER workbench serves; the commercial submission shapes are the two documented above only.","properties":{"result_minutes":{"type":"integer","description":"Minutes the produced outputs stay downloadable (0 = until the next retention sweep)."},"upload_delete_at":{"type":"string","enum":["immediate","on_result"],"description":"When the job's INPUT files are dropped."}},"required":["result_minutes","upload_delete_at"],"additionalProperties":false}},"required":["id","title","description","credits","input","output","retention"]},"ToolList":{"type":"object","properties":{"tools":{"type":"array","items":{"$ref":"#/components/schemas/Tool"}}},"required":["tools"]},"JobSubmission":{"type":"object","description":"THE submitted job's state. Credits are RESERVED at admission (nothing is debited yet); poll until a terminal state, then download outputs.","properties":{"job_id":{"type":"string"},"state":{"type":"string","description":"`queued` immediately after a new submission; the job object returned by an idempotent replay carries the job's CURRENT state.","enum":["validated","queued","running","result","failed","cancelled"]},"price_credits":{"type":"integer","description":"The tool's fixed tariff (2, 5 or 8)."},"poll_url":{"type":"string","description":"The job endpoint to GET for progress."},"deduplicated":{"type":"boolean","description":"False for a new admission (202); true on an idempotent replay of the same key + content (200) — no second reservation was made."},"credits_reserved":{"type":"integer","description":"Present only when `state` is `queued`: the credits held as a pledge until the job settles (debited) or releases (returned). Not a charge."}},"required":["job_id","state","price_credits","poll_url","deduplicated"]},"Job":{"type":"object","description":"One job's state, polled by the owner's token. The job object is small: outputs live behind `listJobOutputs`.","properties":{"id":{"type":"string"},"tool":{"type":"string","description":"The tool slug."},"state":{"type":"string","enum":["validated","queued","running","result","failed","cancelled"]},"created_ms":{"type":"integer","description":"Submission time as epoch milliseconds (UTC)."},"price_credits":{"type":"integer","description":"The tool's fixed tariff. Present on every wallet job."},"tariff":{"type":"object","description":"The tariff snapshot frozen at admission (`tool_id`, `credits`, `source: definition.yaml`) — a later price change never reprices this job.","properties":{"tool_id":{"type":"string"},"credits":{"type":"integer"},"source":{"type":"string"}},"required":["tool_id","credits","source"]},"started_ms":{"type":"integer"},"duration_ms":{"type":"integer"},"processor":{"type":"object","properties":{"name":{"type":"string"},"version":{"type":"string"}},"required":["name","version"]},"error":{"description":"Always present. `null` while the job has no failure; an object with the stable code, a user-safe message and whether a resubmission is worth trying when `state` is `failed`.","type":["object","null"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"retryable":{"type":"boolean","description":"Whether submitting the same request again is worth trying (platform faults) — never for validation refusals."}},"required":["code","message","retryable"]},"result":{"description":"Present when `state` is `result`.","type":"object","properties":{"outputs":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"name":{"type":["string","null"]},"content_type":{"type":["string","null"]},"bytes":{"type":"integer"},"fid":{"type":["string","null"],"description":"Internal file reference carried on job reads; download through `listJobOutputs`' relative `url`."}},"required":["index"]}},"metadata":{"type":"object","description":"The tool's own result metadata (per tool; see the tool's catalogue description)."}}}},"required":["id","tool","state","created_ms","processor","error"]},"OutputIndex":{"type":"object","properties":{"job_id":{"type":"string"},"outputs":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer","description":"The path parameter to fetch these bytes."},"name":{"type":["string","null"],"description":"The suggested filename (the download's Content-Disposition carries it)."},"content_type":{"type":["string","null"]},"bytes":{"type":"integer"},"url":{"type":"string","description":"Relative download URL; resolve against the API base."}},"required":["index","url"]}}},"required":["job_id","outputs"]},"WalletBalance":{"type":"object","properties":{"wallet_id":{"type":"string"},"available_credits":{"type":"integer","description":"Credits free to spend on new jobs."},"reserved_credits":{"type":"integer","description":"Credits pledged to running work: debited on settle, returned on release. Not spendable."},"next_expiration":{"description":"The soonest expiry that will reduce the spendable balance: `{expires_at_ms, credits}`. Null when the spendable balance has no expiry (grandfathered credits only) or the wallet is empty.","type":["object","null"],"properties":{"expires_at_ms":{"type":"integer"},"credits":{"type":"integer"}},"required":["expires_at_ms","credits"]},"expirations":{"type":"array","maxItems":5,"description":"The next (at most five) upcoming expirations, earliest first, plus the non-expiring remainder marked with a null date. Merged wallets can carry several validities; every listed expiry is independent of the others.","items":{"type":"object","properties":{"expires_at_ms":{"type":["integer","null"]},"credits":{"type":"integer"}},"required":["credits"]}},"expiring_now_credits":{"type":"integer","description":"Credits whose validity has already passed but which the scheduled expiry pass has not yet recorded. They cannot fund new jobs; the number returns to zero once the pass runs."}},"required":["wallet_id","available_credits","reserved_credits"]},"WalletTransactions":{"type":"object","properties":{"wallet_id":{"type":"string"},"transactions":{"type":"array","items":{"type":"object","description":"One immutable ledger row (newest first). Kinds: `grant` (purchases/top-ups/gifts), `reserve` (job admitted), `settle` (job succeeded — the only debit), `release` (job failed/cancelled — returned), `adjust`, `expire` (validity ended: the delta leaves spendability).","properties":{"ts_ms":{"type":"integer"},"kind":{"type":"string"},"delta_available":{"type":"integer"},"delta_reserved":{"type":"integer"},"job_id":{"type":["string","null"]},"note":{"type":["string","null"]}},"required":["ts_ms","kind","delta_available","delta_reserved"]}}},"required":["wallet_id","transactions"]},"CreditPack":{"type":"object","description":"One purchasable bundle. Prices are configured server-side; the client never sends an amount.","properties":{"id":{"type":"string","description":"The pack id for startCheckout."},"display_name":{"type":"string"},"credits":{"type":"integer"},"price_minor":{"type":"integer","description":"The configured price in minor units (pence for GBP)."},"currency":{"type":"string"},"display_note":{"type":"string"}},"required":["id","display_name","credits","price_minor","currency"]},"CreditPackList":{"type":"object","properties":{"gateway":{"type":"string","description":"The payment provider slug (\"stripe\")."},"packages":{"type":"array","items":{"$ref":"#/components/schemas/CreditPack"}}},"required":["gateway","packages"]},"CheckoutRequest":{"type":"object","properties":{"email":{"type":"string","format":"email","description":"Where the retrieval link is sent after the payment completes. The address is sealed at rest and never shown again."},"email_confirmation":{"type":"string","format":"email","description":"Must match email after trimming whitespace and ignoring case."},"ack":{"type":"string","description":"The customer's immediate-service acknowledgement: the EXACT statement shown next to the checkout form (see the terms page, 'Consumer cancellation rights'), passed letter for letter. A checkout without it (or with anything else) is refused with 422 V_ACK_REQUIRED before a session is created."}},"required":["email","email_confirmation","ack"],"additionalProperties":false},"CheckoutCreated":{"type":"object","properties":{"purchase_id":{"type":"string","description":"The purchase reference to poll with getPurchase; also the `purchase` query parameter the hosted checkout's success redirect carries."},"checkout_url":{"type":"string","description":"The hosted payment page to redirect the customer's browser to."},"credits":{"type":"integer"}},"required":["purchase_id","checkout_url","credits"]},"Purchase":{"type":"object","description":"The purchase journey's status (for the return URL and any status display). Fields beyond the core trio appear per state.","properties":{"purchase_id":{"type":"string"},"state":{"type":"string","enum":["created","paid","fulfilled","failed","refunded"],"description":"`fulfilled` = credits granted and the retrieval e-mail is the next step."},"credits":{"type":"integer"},"retrieval_link":{"type":"string","description":"Fulfilled purchases only: the retrieval page's PATH (never a redeemable URL). Redeeming needs the one-time secret that travels ONLY inside the delivery e-mail, so this value on its own does nothing: it is a display affordance for the journey page, not a credential and not a possession shortcut."},"email_state":{"type":"string","enum":["sent","failed","unknown"],"description":"Fulfilled purchases only: the recorded delivery state of the retrieval e-mail."},"note":{"type":"string","description":"State-specific sentence for humans (pending and failed states carry one)."}},"required":["purchase_id","state","credits"],"additionalProperties":false},"RedeemRequest":{"type":"object","description":"The parts of the one-time retrieval link (id from the path, secret from its query string). Both are single-use together and the secret is shown once in the e-mail link.","properties":{"retrieval_id":{"type":"string"},"secret":{"type":"string"}},"required":["retrieval_id","secret"],"additionalProperties":false},"RedeemResponse":{"type":"object","description":"The ONLY response anywhere that carries a plaintext API token. Treat it like a password; delivered exactly once.","properties":{"api_token":{"type":"string"},"wallet_id":{"type":"string"},"credential_id":{"type":"string"}},"required":["api_token","wallet_id","credential_id"]},"Error":{"type":"object","properties":{"code":{"type":"string","description":"Stable machine-readable error code (the same value the X-Error-Code header carries). Prefixes: V_ validation, J_ job/lifecycle, R_ rate/retention, E_ processor business refusal, P_/S_ platform fault, M_ management authorisation."},"message":{"type":"string","description":"A human-readable sentence the caller may show verbatim. It never quotes internal paths, tokens or exception text."}},"required":["code","message"],"additionalProperties":false}}}}