Payment ID or Request ID? Recover a D20DAO API Call
Recover an interrupted D20DAO agent API call on Arc. Follow payment status, distinguish replacement requests and avoid treating a timeout as permission to pay again.
Recover the purchase before buying again
After an HTTP timeout, follow the existing paid call before authorizing another draw. paymentId identifies the payment-backed call; requestId identifies one Arc request opened for it. The distinction matters when the original request expires and the service opens a replacement.
Arc's November 23 developer guide describes recording paid-agent outcomes and stopping purchases when a payment result is unclear. That concern gives D20DAO builders a concrete recovery task: retain the existing call's identity and resolve its state. A missing response alone does not establish that no payment occurred.
Keep payment identity with the application operation
Keep the API environment, paymentId, statusUrl, original operation, seed and parameters with your application's operation record. Add each requestId and transaction link as it becomes available. During settling or requesting, do not assume an onchain request already exists.
If the first response was lost, the documented paymentId derivation uses the signed authorization's payment-network chain ID, payer and nonce. That network is not automatically Arc, where the randomness request runs. Preserve the original ordered item list too: status reads return indices, so recovered results need that list to recover their labels correctly.
Choose the lookup that follows the paid call
GET /v1/payments/{paymentId} reads the paid call and follows its replacement request. The returned statusUrl is keyed to that payment identity. Use this route for recovery of the purchase.
GET /v1/random/{requestId} reads one particular request opened by this API. It is useful for inspecting that request, but an expired original ID does not tell the whole story of a paid call later served by a replacement. Both lookups are free and rate limited. Retain the original IDs rather than replacing the operation record whenever another response arrives.
Read status as well as the HTTP code
The free GET routes can return HTTP 200 while reporting a call or request that is not fulfilled. At the paid POST route, HTTP 202 can cover payment confirmation, work in progress or refund_due. Do not mark an application operation complete merely because its HTTP request succeeded.
Read status and, when pending, stage. The schema distinguishes settling, requesting, expiring and replacing. Follow retryAfterSeconds when supplied instead of polling in a tight loop. A fulfilled result is final; refund_due requires the policy's refund handling and does not mean a refund has already reached the payer.
Keep replacement history within the same purchase
The documented API recovery path provides one replacement at the service's cost if the original request expires without a result. Fields such as replaces, replacedBy and replacementId describe that relationship when present. Payment-level status follows the replacement; keep both request records linked to the original operation.
Do not start another paid call merely because the original request shows expired or refunded. The coordinator's onchain fee refund goes to the API's relay, which funded that request. It is separate from the customer's API payment and any refund due under the API policy.
A conflict response does not undo an earlier payment
The API documents resending the same payment as recovery of the same result. Preserve the original request context rather than editing it to bypass an error. HTTP 409 distinguishes payment_conflict, for changed signature, seed, operation or relevant parameters, from payment_pending, where earlier Gateway payments are still being confirmed.
The response's not-charged description must not be read as proof that an earlier payment was refunded. The spec also compares items by length rather than label content. Keep the original labels locally; a replay response is not proof that a changed list is the one your application committed to.
Keep recovery durable across MCP restarts
MCP users can call the free get_result tool with paymentId to follow the paid call. A requestId lookup remains specific to that request. The current MCP server's identical-draw suppression uses in-process state and a five-minute recent-outcome cache; it is not a durable application identity across restarts or separate processes.
If a draw reports charged as unknown, stop new draws for that operation and reconcile the existing payment. Do not assume get_result itself proves the charged state or that invoking draw again is always free. A transport timeout, cache miss or lookup failure is not fresh spending authorization.
Use acceptance cases for ambiguous outcomes
Use these requirements when implementing recovery. They are proposed checks, not executed test results:
- Lose the first response without treating the missing answer as proof of nonpayment.
- Read a successful HTTP status with a pending or refund_due body without completing the application action.
- Follow one payment through a replacement while retaining its original request history.
- Handle a replay conflict without changing parameters or authorizing another purchase automatically.
- Restart the MCP process and recover through saved payment identity rather than relying on its old memory cache.