APUPI

Developer documentation

Replace https://API_HOST with your gateway's API address. Your dashboard shows it, with your Merchant ID.

RegistrationAuthenticationCreate paymentStatusWebhooksVerify UTRTest modePayment linksUPI intent

Merchant registration API

Register a business from your own system. The account stays PENDING until the operator approves it.

curl -X POST https://API_HOST/api/v1/merchants/register \
  -H "Content-Type: application/json" \
  -d '{"businessName":"My Shop","email":"owner@myshop.com","password":"a-long-password",
       "mobile":"9876543210","upiId":"myshop@bank"}'

# 201 {"registrationId":"…","status":"PENDING"}

Check the status:

curl -X POST https://API_HOST/api/v1/merchants/register/status \
  -H "Content-Type: application/json" \
  -d '{"email":"owner@myshop.com","password":"a-long-password"}'

# {"status":"APPROVED","merchantId":"…"}

Get keys once approved. Every call issues new keys and the old ones stop working.

curl -X POST https://API_HOST/api/v1/merchants/register/keys \
  -H "Content-Type: application/json" \
  -d '{"email":"owner@myshop.com","password":"a-long-password"}'

# {"merchantId":"…","apiKey":"apupi_live_…","webhookSecret":"…",
#  "testApiKey":"apupi_test_…","testWebhookSecret":"…"}

Authentication

Send both headers from your server. Never put a key in a web page or mobile app.

X-Merchant-Id: YOUR_MERCHANT_ID
X-Merchant-Key: apupi_live_…   (or apupi_test_… for test mode)

Create a payment

curl -X POST https://API_HOST/api/v1/payments \
  -H "Content-Type: application/json" \
  -H "X-Merchant-Id: YOUR_MERCHANT_ID" \
  -H "X-Merchant-Key: YOUR_API_KEY" \
  -d '{"orderId":"ORDER-1001","amount":"499","returnUrl":"https://myshop.com/thanks"}'

Redirect the customer to checkoutUrl from the response, or open it in a popup on your page:

<script src="https://CHECKOUT_HOST/apupi.js"></script>
<script>
  Apupi.pay({ checkoutUrl: checkoutUrlFromYourServer,
    handler: function (result) { /* update your screen only */ } });
</script>

Only one payment can be active on a UPI ID at a time. Other customers wait in a queue, and the payment window is 5 minutes. New orders are refused (503) while no observer is connected.

Check status

curl https://API_HOST/api/v1/payments/PAYMENT_ID -H "X-Merchant-Key: YOUR_API_KEY"

Webhooks

Set your webhook URL in the dashboard. Fulfil orders only from a verified webhook, never from the browser. Compute the HMAC over the raw request body.

import crypto from 'node:crypto';

app.post('/api/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const expected = 'sha256=' + crypto.createHmac('sha256', process.env.APUPI_WEBHOOK_SECRET)
    .update(req.body).digest('hex');
  const got = String(req.headers['x-gateway-signature'] || '');
  if (got.length !== expected.length ||
      !crypto.timingSafeEqual(Buffer.from(got), Buffer.from(expected))) return res.sendStatus(401);

  const event = JSON.parse(req.body);
  // Check event.method: for COD no money has been received yet.
  // Make this idempotent on event.orderId.
  res.sendStatus(200);
});

Verify a stuck payment

curl -X POST https://API_HOST/api/v1/payments/PAYMENT_ID/verify \
  -H "Content-Type: application/json" -H "X-Merchant-Key: YOUR_API_KEY" \
  -d '{"utr":"514850573246"}'

The order is marked paid only if the gateway already holds a bank alert with that UTR, for the same account and amount, inside the order's window.

resultMeaning
VERIFIEDPaid
NOT_FOUNDNo bank alert with this UTR yet
ALREADY_USEDUTR paid another order
AMOUNT_MISMATCHDifferent amount
OUTSIDE_WINDOWNot paid during this order's window
NOT_ELIGIBLENo QR was shown, or the status cannot be verified

Test mode

Create a payment with your apupi_test_ key. The checkout shows two buttons, success and failure, and no money moves. Test webhooks carry "mode":"test", the header X-Gateway-Mode: test, and are signed with your test webhook secret, so your live handler rejects them.

Create links in the dashboard under Payment links. When a customer pays, your webhook receives metadata.paymentLinkId.

UPI intent for your mobile app

curl -X POST https://API_HOST/api/v1/payments/PAYMENT_ID/intent -H "X-Merchant-Key: YOUR_API_KEY"

# {"status":"ACTIVE","upiIntent":"upi://pay?pa=…&am=499.00&tn=…",
#  "apps":{"android":{"phonepe":"intent://pay?…"},"ios":{"phonepe":"phonepe://pay?…"}}}

The call takes the 5 minute payment slot; QUEUED means call again shortly. Open upiIntent or one app link. Opening an app is not payment: fulfil only from the webhook. Some UPI apps restrict link payments to personal UPI IDs, so test with yours, and test iOS links on a real device. Test mode has no UPI links.