Quick start
- Create an account, add a UPI account under Configuration, and connect Gmail or the Android SMS app.
- Under Developers, create a test key. It starts with
mhr_test_. - Create a payment, send the customer to
checkout_url, and listen forpayment.paid. - Swap in a
mhr_live_key when you are ready. Nothing else changes.
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.
| Key | What 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.
| Field | Description |
|---|---|
| amount | Required. Integer paise, 100 to 10000000 (₹1 to ₹1,00,000). |
| title | Shown to the customer. Up to 100 characters. |
| reference | Your order number. Lets you look the payment up later without storing Mohur's ID. |
| note | Up to 50 characters, shown in the customer's UPI app next to the payment ID. |
| customer.name / .email / .phone | Optional. Shown on your dashboard and in webhooks. |
| redirect_url | Where to send the customer after paying. Must match your allowed domains if you set any. |
| upi_account_id | Optional. 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
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_urlPHP
<?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
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
{
"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 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 https://mohur.sanjeevaniprime.com/api/v1/payments/7F3A9C21B0/simulate \
-H "Authorization: Bearer mhr_test_..." \
-H "Content-Type: application/json" \
-d '{ "outcome": "paid" }'Payment links
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.
| Event | When |
|---|---|
| payment.created | A payment was created. |
| payment.paid | The bank confirmed it, or you approved it. |
| payment.on_hold | No bank alert arrived in time. It can still become paid. |
| payment.declined | You declined it. |
| payment.expired | Abandoned: nobody said they paid and no money arrived. |
| Header | Meaning |
|---|---|
| mohur-signature | t=<unix seconds>,v1=<hex HMAC-SHA256> of t + "." + raw body, keyed with the endpoint's signing secret. |
| mohur-event | The event type, as in the body. |
| mohur-event-id | Same in every retry. Store it and skip events you have already handled. |
| mohur-sequence | Counts up for each event of a payment. Retries can arrive out of order, so ignore a sequence lower than the last one you applied. |
{
"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
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
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
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
| Status | Meaning |
|---|---|
| pending | QR shown, waiting for the customer. |
| verifying | The customer said they paid. Waiting for the bank alert. |
| on_hold | No alert in time. Becomes paid if the money arrives or you approve it. |
| paid | Final. Deliver the order. |
| declined | Final. You declined it. |
| expired | Abandoned. 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.
| HTTP | code | When |
|---|---|---|
| 400 | invalid_request | A field is missing or wrong. |
| 401 | unauthorized | Missing or unknown API key. |
| 403 | live_key / test_key | The call needs the other kind of key. |
| 404 | not_found | No such payment for this key's mode. |
| 409 | idempotency_conflict | The Idempotency-Key was used with a different amount. |
| 409 | already_final / invalid_state | The payment cannot move that way. |
| 409 | not_configured | Add a UPI account first. |
| 422 | redirect_not_allowed | redirect_url is not on your allowed domains. |
| 422 | invalid_request | Every UPI account has reached its daily or monthly limit. |
| 429 | rate_limited | Over 120 requests a minute for this key. |
Mohur is open source under the MIT licence. Found something unclear? Open an issue on GitHub.