Documentation

Create a Run

Execute a balance-funded tool request with a fixed contract, spending cap and idempotency key.

View as Markdown
On this page

Endpoint

Use funding.mode = balance on this endpoint. Wallet per_run funding uses the separate wallet-payment protocol, even though it shares the RunRequest schema.

Replace all example placeholders and supply an input matching the inspected schema. maxChargeMicros is an exact integer string; for balance funding, 1000000 micro-units equals 1 USD. Use the inspected price and unit. For successful_url pricing, cover every submitted URL in maxChargeMicros. The platform settles only successful URLs and releases the unused hold. For credit pricing, cover the maximum usage described in the quote. For max_call pricing, reserve the quoted maximum and read the actual charge from the Run. For executed_step pricing, cover max_steps and the finalization allowance in the quote. For browser_minute pricing, cover the requested lease minutes.

HTTP 422 json_too_large means the complete normalized request exceeded 1 MiB, including escaped strings, numbers in decimal form and defaults. Reduce the input before submitting again. The rejected request creates no Run or balance hold.

Within the same account workspace, the same idempotency key and effective request recover the original Run, even across different API keys. A changed request with the same idempotency key conflicts. Persist the full request before submission.

HTTP 202 means billing is still HELD or REVIEW; execution may already have ended. HTTP 200 does not prove successful execution. Keep runId and follow pollAfterMs. Execution, billing and result availability must be checked separately.

HTTP
POST /v1/runs

Request body

request.json · replace all placeholders
{
  "toolId": "<toolId from inspect>",
  "toolRevision": "<toolRevision from inspect>",
  "priceRevision": "<priceRevision from inspect>",
  "input": {
    "<required field>": "<value matching inputSchema>"
  },
  "idempotencyKey": "<unique key saved for this task>",
  "maxChargeMicros": "<integer spending cap in USD micro-units>",
  "funding": {
    "mode": "balance"
  }
}
FieldTypeRequiredConstraints
toolIdstringRequired—
toolRevisionstringRequired—
priceRevisionstringRequired—
inputJSON valueRequired—
idempotencyKeystringRequiredMin length: 1; Max length: 128
maxChargeMicrosstringRequiredPattern: ^[0-9]+$
fundingobjectRequired—
cacheControlobjectOptional / conditional—

Request example

Set PURRKEY_API_KEY in your trusted server or terminal environment. Replace any angle-bracket placeholders with values from your own inspection or Run.

Bash
curl --fail-with-body --request POST 'https://api.purrkey.app/v1/runs' \
  -H "Authorization: Bearer $PURRKEY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary @request.json

Successful response

Success HTTP status: 200, 202. Top-level response fields are listed below. Conditional and nested requirements are defined in the downloadable OpenAPI contract.

FieldTypeRequiredConstraints
runIdstringRequired—
toolIdstringRequired—
toolRevisionstringRequired—
toolNamestringOptional / conditional—
statusstringRequiredQUEUED | SUBMITTING | RUNNING | WAITING_PROVIDER | SUCCEEDED | FAILED | CANCELED | TIMED_OUT | UNKNOWN
billingobjectRequired—
createdAtstringRequireddate-time
updatedAtstringRequireddate-time
cancelRequestedAtstringOptional / conditionaldate-time
paymentobjectOptional / conditional—
inputJSON valueOptional / conditional—
resultobjectRequired—
errorobjectOptional / conditional—
pollAfterMsintegerOptional / conditionalint32; Minimum: 0

Errors and related reading