Purchase (custodial)

POST /api/v1/mystery/purchase packs:purchase

Custodial purchase: debits the end-user’s credit balance and a rip.fun relayer executes the on-chain buy — the user never signs anything. Requires an Idempotency-Key header; re-sending the same key returns the original purchase. Returns 202: fulfillment is asynchronous (VRF).

Try it POST /api/v1/mystery/purchase money

These inputs are shared across all docs pages — an id entered here carries over.

request body
object · 2 keys
{
  "external_user_id": "demo-explorer",
  "tier_id": 1
}
response

Not run yet — press Run to make a live call against https://staging-service.rip.fun (through this demo's server-side proxy; the API key never reaches the browser).

curl (tracks the inputs above)
curl -X POST 'https://staging-service.rip.fun/api/v1/mystery/purchase' \
  -H 'X-API-Key: rip_v1_…' \
  -H 'Idempotency-Key: demo-demo-explorer-1' \
  -H 'Content-Type: application/json' \
  -d '{"external_user_id":"demo-explorer","tier_id":1}'

Request fields

FieldTypeRequiredDescription
external_user_id / wallet_addressstringyesEnd-user identity (at least one)
tier_idnumberyesTier to purchase
max_price_usdcstringCap; user is debited the ACTUAL on-chain amount, difference returns to available
Idempotency-KeyheaderyesRequired; reuse with a different tier_id → 409

Response fields (data)

FieldDescription
id / status / custodyPurchase id; starts RESERVED, custody CUSTODIAL
price / price_usdcReserved amount (micros + decimal)

Errors

StatusCodeWhen
400missing_idempotency_keyheader omitted
402insufficient_fundsavailable balance < price
409idempotency_mismatchsame key reused with a different tier_id
503relayer_disabledcustodial purchasing temporarily unavailable

See Errors for the response envelope and the full code list.

Flow

  1. Partner: POST /mystery/purchase (Idempotency-Key) → 202 RESERVED, credits held
  2. rip.fun relayer: signs + broadcasts the on-chain purchase → SUBMITTED
  3. VRF reveal → FULFILLED (hold settles to the actual price) or REFUNDED / FAILED (hold returned)
  4. Partner: poll GET /purchase/:id or consume purchase.* webhooks