Mohur

Developers

Mohur API reference

Create UPI payments from your own site, find them by your order number, try everything in test mode, and get a signed webhook the moment the bank confirms. JSON over HTTPS. Amounts are in paise.

Quick start

  1. Create an account, add a UPI account under Configuration, and connect Gmail or the Android SMS app.
  2. Under Developers, create a test key. It starts with mhr_test_.
  3. Create a payment, send the customer to checkout_url, and listen for payment.paid.
  4. Swap in a mhr_live_ key when you are ready. Nothing else changes.
curl
curl https://mohur.sanjeevaniprime.com/api/v1/payments \
  -H "Authorization: Bearer mhr_test_..." \
  -H "Content-Type: application/json" \
  -d '{ "amount": 49900, "title": "Order 1042", "reference": "order-1042" }'

Keys and test mode

Send your key as Authorization: Bearer <key>. Keys are stored as a hash; you see one only when you create it. Keep it on your server, never in a browser or app.

KeyWhat it does
mhr_live_…Real payments: a real QR for your UPI ID, confirmed from your bank's email or SMS. Sends to live webhooks.
mhr_test_…Test payments: no UPI ID is shown and nothing is matched to your bank. You move them with simulate. They stay out of the dashboard totals and only reach test webhooks. Every object has livemode: false.

A key only ever sees payments of its own mode. Keys created before test mode existed (mhr_…) are live keys.

Create a payment

POST /api/v1/payments. Returns 201 with the payment object.

FieldDescription
amountRequired. Integer paise, 100 to 10000000 (₹1 to ₹1,00,000).
titleShown to the customer. Up to 100 characters.
referenceYour order number. Lets you look the payment up later without storing Mohur's ID.
noteUp to 50 characters, shown in the customer's UPI app next to the payment ID.
customer.name / .email / .phoneOptional. Shown on your dashboard and in webhooks.
redirect_urlWhere to send the customer after paying. Must match your allowed domains if you set any.
upi_account_idOptional. Pin the payment to one of your UPI accounts instead of using rotation.

Send an Idempotency-Key header to retry safely: the same key returns the same payment instead of creating a second one.

The response also carries upi_intent, a upi://pay link. On a phone, open it to jump straight into the customer's UPI app, or draw it as your own QR.

Node.js

js
const res = await fetch("https://mohur.sanjeevaniprime.com/api/v1/payments", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MOHUR_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "order-1042",
  },
  body: JSON.stringify({
    amount: 49900,
    title: "Order 1042",
    reference: "order-1042",
    customer: { name: "Asha", email: "asha@example.com" },
    redirect_url: "https://yourshop.in/thanks",
  }),
});
const payment = await res.json();
// Send the customer to payment.checkout_url

PHP

php
<?php
$ch = curl_init("https://mohur.sanjeevaniprime.com/api/v1/payments");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("MOHUR_KEY"),
    "Content-Type: application/json",
    "Idempotency-Key: order-1042",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "amount" => 49900,
    "title" => "Order 1042",
    "reference" => "order-1042",
    "redirect_url" => "https://yourshop.in/thanks",
  ]),
]);
$payment = json_decode(curl_exec($ch), true);
header("Location: " . $payment["checkout_url"]);

Python

python
import os, requests

r = requests.post(
    "https://mohur.sanjeevaniprime.com/api/v1/payments",
    headers={"Authorization": f"Bearer {os.environ['MOHUR_KEY']}", "Idempotency-Key": "order-1042"},
    json={"amount": 49900, "title": "Order 1042", "reference": "order-1042"},
    timeout=10,
)
payment = r.json()

The payment object

json
{
  "id": "7F3A9C21B0",
  "object": "payment",
  "status": "pending",
  "amount": 49900,
  "amount_payable": 49903,
  "currency": "INR",
  "title": "Order 1042",
  "reference": "order-1042",
  "note": null,
  "source": "api",
  "link_id": null,
  "livemode": true,
  "customer": { "name": "Asha", "contact": null, "email": "asha@example.com" },
  "utr": null,
  "payer_vpa": null,
  "payer_name": null,
  "verified_by": null,
  "checkout_url": "https://mohur.sanjeevaniprime.com/checkout/7F3A9C21B0",
  "upi_intent": "upi://pay?pa=shop@okhdfcbank&pn=Shop&am=499.03&cu=INR&tn=7F3A9C21B0",
  "created_at": "2026-11-27T10:00:00.000Z",
  "settled_at": null
}

amount_payable can be a few paise above amount: the paise tell two payments of the same price apart. The customer pays the exact payable amount.

Look up a payment

GET /api/v1/payments/{id or reference}. Pass Mohur's 10-character payment ID, or the reference you sent. If several payments share a reference, the newest is returned.

curl
curl https://mohur.sanjeevaniprime.com/api/v1/payments/order-1042 -H "Authorization: Bearer mhr_live_..."

After a customer is redirected back to you, always look the payment up here before you deliver. The address bar can be edited; this answer cannot.

List payments

GET /api/v1/payments?status=paid&reference=order-1042&page=1. 25 per page, newest first. status is one of the statuses, or open for pending and verifying.

Simulate (test mode)

POST /api/v1/payments/{id}/simulate with {"outcome": "paid"}, on_hold, declined or expired. Test keys only. The payment moves exactly as a real one would, and the same webhooks fire. The test checkout page has the same buttons, so you can click through your own flow.

curl
curl https://mohur.sanjeevaniprime.com/api/v1/payments/7F3A9C21B0/simulate \
  -H "Authorization: Bearer mhr_test_..." \
  -H "Content-Type: application/json" \
  -d '{ "outcome": "paid" }'

POST /api/v1/links with title, and optionally amount (paise; leave out to let the customer type it), description, reusable, redirect_url and expires_at (ISO 8601). Returns the link's url. Links take real money from anyone who opens them, so they need a live key.

Redirects

When a payment is confirmed, the checkout page counts down and sends the customer to redirect_url with ?payment_id= added. List your domains under Developers → Allowed redirect domains and any other redirect_url is refused with 422 redirect_not_allowed. Do this before going live: it stops a leaked key from sending your customers to someone else's site.

Webhooks

Add an endpoint under Developers → Webhooks and choose live or test. Mohur sends a POST with a JSON body for every change. Answer with any 2xx within 10 seconds. Failures are retried after 30 s, 2 min, 10 min, 1 h and 6 h.

EventWhen
payment.createdA payment was created.
payment.paidThe bank confirmed it, or you approved it.
payment.on_holdNo bank alert arrived in time. It can still become paid.
payment.declinedYou declined it.
payment.expiredAbandoned: nobody said they paid and no money arrived.
HeaderMeaning
mohur-signaturet=<unix seconds>,v1=<hex HMAC-SHA256> of t + "." + raw body, keyed with the endpoint's signing secret.
mohur-eventThe event type, as in the body.
mohur-event-idSame in every retry. Store it and skip events you have already handled.
mohur-sequenceCounts up for each event of a payment. Retries can arrive out of order, so ignore a sequence lower than the last one you applied.
json
{
  "id": "evt_3kq9x0f2m1ab",
  "type": "payment.paid",
  "sequence": 2,
  "livemode": true,
  "created_at": "2026-11-27T10:00:41.000Z",
  "data": { "id": "7F3A9C21B0", "status": "paid", "utr": "432178650123", "...": "the payment object" }
}

Verify a webhook

Check the signature against the raw body, before parsing it, and reject anything older than five minutes.

Node.js

js
import crypto from "node:crypto";

export function verify(rawBody, header, secret) {
  const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
  const want = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  return v1?.length === want.length && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(want));
}

PHP

php
<?php
function mohur_verify(string $raw, string $header, string $secret): bool {
  parse_str(str_replace(",", "&", $header), $p);
  if (abs(time() - (int)($p["t"] ?? 0)) > 300) return false;
  $want = hash_hmac("sha256", $p["t"] . "." . $raw, $secret);
  return hash_equals($want, $p["v1"] ?? "");
}

$raw = file_get_contents("php://input");
if (!mohur_verify($raw, $_SERVER["HTTP_MOHUR_SIGNATURE"] ?? "", getenv("MOHUR_WEBHOOK_SECRET"))) {
  http_response_code(400); exit;
}
$event = json_decode($raw, true);

Python

python
import hashlib, hmac, time

def verify(raw: bytes, header: str, secret: str) -> bool:
    p = dict(part.split("=", 1) for part in header.split(","))
    if abs(time.time() - int(p.get("t", 0))) > 300:
        return False
    want = hmac.new(secret.encode(), f"{p['t']}.".encode() + raw, hashlib.sha256).hexdigest()
    return hmac.compare_digest(want, p.get("v1", ""))

Statuses

StatusMeaning
pendingQR shown, waiting for the customer.
verifyingThe customer said they paid. Waiting for the bank alert.
on_holdNo alert in time. Becomes paid if the money arrives or you approve it.
paidFinal. Deliver the order.
declinedFinal. You declined it.
expiredAbandoned. Can still become paid if the customer proves payment by UTR.

Errors and limits

Errors are JSON: {"error": "message", "code": "invalid_request", "field": "amount"}. field is there when one input is at fault.

HTTPcodeWhen
400invalid_requestA field is missing or wrong.
401unauthorizedMissing or unknown API key.
403live_key / test_keyThe call needs the other kind of key.
404not_foundNo such payment for this key's mode.
409idempotency_conflictThe Idempotency-Key was used with a different amount.
409already_final / invalid_stateThe payment cannot move that way.
409not_configuredAdd a UPI account first.
422redirect_not_allowedredirect_url is not on your allowed domains.
422invalid_requestEvery UPI account has reached its daily or monthly limit.
429rate_limitedOver 120 requests a minute for this key.

Mohur is open source under the MIT licence. Found something unclear? Open an issue on GitHub.