Skip to main content
Some APIs need more time than one HTTP connection can reliably stay open. AnyAPI runs those calls as durable Requests, which continue if your client disconnects or your process restarts. AnyAPI submits a paid provider job at most once. If the provider’s response to a submission is lost, AnyAPI never repeats the paid operation; when the provider offers no way to look the job up, that Request can expire instead. POST /v1/run/{sku} returns the standard success envelope when the result is ready during the initial wait. Otherwise it returns 202 Accepted with a Request ID.

Start a durable call

Send an Idempotency-Key with every durable call. Reuse the same key only when you are resuming the same logical invocation with the same SKU and input.
Prefer: respond-async asks AnyAPI to return the Request snapshot immediately, even if an existing same-key Request has already completed. Omit it to wait up to 10 seconds. You can also send Prefer: wait=N; AnyAPI clamps N to 90 seconds. A pending response includes Location, Retry-After, and X-Anyapi-Request-Id headers:

Poll the Request

Read the Request from the URL in Location. Polling reads stored state and never repeats the paid operation.
The public status is queued, running, succeeded, failed, or expired. Honor retryAfterSeconds before polling again: AnyAPI admits one read of a pending Request per that interval, and an earlier read returns 429 with a new Retry-After. Reading a Request is free. A succeeded snapshot includes the standard run envelope as result. A failed snapshot includes a safe AnyAPI error code. Request IDs are private to the wallet customer that created them. Unknown IDs and IDs owned by another customer both return 404.

Lookups charged when they start

Some lookups, such as youtube.channel_contact, are charged as soon as AnyAPI starts them. If the answer is ready during the initial wait, you get the usual 200 result. Otherwise the 202 arrives within seconds and its snapshot also carries:
  • costUsd: what the lookup was charged in USD. That charge is final: it is never taken again when the answer arrives and never refunded, whatever the answer is.
  • collectUrl: a link to GET /v1/requests/{requestId}/collect?token=... that reads this one Request with no API key. Hand it to whoever needs the answer.
  • note: a short instruction for finishing the lookup.
Collecting is free, through collectUrl or GET /v1/requests/{requestId} with your key. Both share one pace per Request: read no faster than Retry-After (one read every 5 seconds for youtube.channel_contact), or you get 429 with a new Retry-After. Keep reading until status is succeeded; the answer is in result.output. You can collect a charged lookup for up to 31 days. If its data is gone before the answer is read, the Request fails and the charge stays; a retry with the same Idempotency-Key returns that failure instead of buying a second lookup. collectUrl returns 404 for a wrong token, an unknown Request, or a Request whose connected app was disconnected.

Resume safely

Keep both the Request ID and the original idempotency key until the call completes. If a client wait times out, resume with GET /v1/requests/{requestId}. Do not send another paid POST. AnyAPI returns the same active Request for concurrent calls that use the same key, SKU, and input. It replays a completed success. Reusing a key with different input returns 409. Successful output remains retrievable for 24 hours, whatever your response retention setting. After that, the output stays readable for the rest of your retention window (see Read a past response), and once it ends the Request metadata remains available with resultExpired: true.
Durable execution currently requires an authenticated wallet API key. It is not available through anonymous, x402, or MPP payment flows.