Raw API

Run a test buy from end to end

Four calls take you from nothing to gold in a user's portfolio. Test mode is stateful — balances persist, the float is debited, and the same code works unchanged in Live.

6 min read · 3 screenshots

Buys are two steps on purpose. You quote to lock a price for ten minutes, then confirm to execute it. The price your user sees and the price they get are the same number, and the gap between the two calls is yours to spend showing them a confirmation screen.

  1. Register a user

    In the Playground, open the Users & KYC tab and send the registration preset. Trusted server-to-server registration returns a persistent user_code you replay on every later call.

    POST/partner/users/initusers
    Body
    { "flow": "api", "mobile": "9000000001" }
    Sandbox user codes are deterministic — the same mobile always maps to the same user_code for your partner account. That makes test fixtures reproducible, and it means re-running this call is harmless.
  2. Lock a quote

    Switch to the Trade tab and send the buy quote. The user_code from the previous step is already filled in.

    POST/partner/buy/quotebuy
    The OroPocket Playground showing a buy quote request and its response in the live log, including a quote id, the gram quantity, the rate per gram and a fee and GST breakdown.
    The response carries the grams, the rate, the full fee breakdown and how long the quote is good for.

    Read the breakdown object rather than doing the arithmetic yourself: a 0.25% platform fee comes off first, then 3% GST is carved out, and what remains is what actually buys metal.

    Wallet problems surface here, not at confirmation. A 402 INSUFFICIENT_PARTNER_FUNDS at quote time means your billing account is short — see Top up your billing account.
  3. Confirm it

    Send the confirmation with the quote_id. In Test mode settlement is simulated and the response is tagged simulated: true; the shape is identical to Live.

    POST/partner/buy/confirmbuy
    The OroPocket Playground live log showing a successful buy confirmation response with a transaction reference, the settled gram quantity and a completed status.
    Confirmed. The grams are now in that user's balance and your float has been debited.
    Always send an Idempotency-Key header on confirmations in production. A replay returns the original response with idempotent_replay: true instead of buying twice — which is what you want when a network timeout leaves you unsure whether the first call landed.
  4. Check the portfolio

    Read the balance back to confirm the metal arrived.

    GET/partner/users/:user_code/portfoliobalance

    The same trade now also appears on the Transactions page labelled API, and in Logs.

Magic values for testing edge cases

Test mode has fixed inputs that force specific outcomes, listed on a card in the Playground itself so you never have to look them up.

The Test-mode magic values card in the OroPocket Playground, listing the fixed OTP, email code, approving and rejecting PAN numbers, Aadhaar OTP and the withdrawal amount that fails, with a Reset test data button.
Deterministic outcomes, so you can test the unhappy paths without waiting for one.
ValueForces
1234Any OTP — login, embed, gifting, Aadhaar.
123456The email verification code.
ABCDE1234FA PAN that verifies successfully.
ZZZZZ9999ZA PAN that is rejected, so you can build the failure path.
an amount ending .01A withdrawal that fails and refunds.

Starting over

Reset test data on the same card clears every test user, balance, trade and withdrawal and reseeds your float to ₹1,00,000. It cannot be undone, and it only ever touches sandbox — there is no equivalent for Live, by design.

Next: set up webhooks so you learn about settlement without polling. For parameters and every field in the response, see the raw API guide.