You can place a first successful e-Stamp order in the StampMitra sandbox in about ten minutes once you hold a sandbox key. The path has seven calls: check that a state is open, find the article code, validate the order, create it with an Idempotency-Key, read the order, deal with the PAN card, and receive a signed webhook. Every sample on this page is complete and runnable in cURL, Node.js and Python, and every request body comes from the same single example the API reference uses.
The sandbox is free and never touches a real wallet, so you can repeat any step as often as you like. It runs the same body checks as production, which means the errors you hit here are the errors you would hit live. The page ends with what changes when you move to a live key: two funded wallets, a human review step and a different status vocabulary.
This guide is general technical information about the StampMitra API, not legal advice. Stamp duty, forms and procedure differ by state, so confirm legal questions with qualified counsel or the state authority.
Key takeaways
- The ten minutes start when you hold a sandbox key (
sk_test_...). Account creation with its email and mobile codes is separate and comes first. - Seven calls reach a placed order: states availability, the article list, the requirements read, validate, create, read order and stamps, and the PAN card. A webhook receiver finishes the loop.
- Every body on this page is the one order example in the reference: two stamp lines, one state (
MH), articleART1, a first and a second party, and apanCardImagelink on each line. POST /v1/estamp/ordersneeds anIdempotency-Keyheader. Without it the answer is400and nothing is created. The same key with the same body replays; the same key with another body is422.- Validate never saves and never charges. Its
quoteshowsfaceValueTotal,serviceFeeTotal,gstOnFeeandserviceWalletDebitTotal, so you see the money before you create. - A PAN card link is optional when you place an order and mandatory to complete the stamp. Until one is on file the stamp waits.
- A sandbox order advances by itself and is
ISSUEDafter about half a minute. A live order isPENDING_REVIEWand waits for a person. - Live ordering needs a funded Stamp Duty Wallet and a funded Service wallet. If either is short, create answers
402PAYMENT_REQUIREDand charges nothing.
What does the ten-minute path look like?
Think of it as a short checklist where each line leaves you with one piece of proof. The times assume a laptop, a terminal and a key already stored in an environment variable. They are an honest budget, not a promise: the first run of any script includes installing a package, and email codes arrive at their own pace.
| Step | What you do | Call | Time | Proof you are done |
|---|---|---|---|---|
| 1 | Get and store a sandbox key | GET /v1/estamp/states/availability | 3 min | A 200 with a data array of states |
| 2 | Check the state is open | same call | 1 min | MH shows active: true |
| 3 | Find the article code | GET .../instruments, GET .../requirements | 1 min | You can name ART1 and its rules |
| 4 | Validate the order | POST /v1/estamp/orders/validate | 1 min | valid: true and a quote |
| 5 | Create the order | POST /v1/estamp/orders | 1 min | An order id and two stamp ids |
| 6 | Read order and stamps | GET /v1/estamp/orders/{id} and .../stamps | 1 min | Status moves towards ISSUED |
| 7 | PAN card and webhook | POST .../pan-card, a receiver, a test event | 2 min | panCard is not NOT_PROVIDED, and a verified delivery in your log |
The sequence matters because each call feeds the next. The states call proves your key and your scope. The requirements read tells you what the body must contain, validate proves the body, and create spends the sandbox balance. Skipping straight to create works, but then a field mistake costs you a round trip with a less helpful error than validate gives.
Two environment variables carry the whole page: STAMPMITRA_API_KEY for the key and, after step 5, ORDER_ID for the order you created. Every sample reads them and refuses to run if they are missing, so a typo fails loudly on your machine rather than as a confusing 401 from the server.
Step 1: How do I get a sandbox key?
Open the signup page, choose your account type and enter your details. StampMitra asks you to confirm your email with a code and then your mobile number with a code, so only you can issue keys for the workspace. A profile screen follows that you can skip. There is no card and no approval wait for the sandbox.
On the dashboard open Keys. If a sandbox key is listed, use Copy key: the dashboard fetches the key for you and puts it on the clipboard without showing it. If none is listed, choose Create sandbox key, name it and enter the code that arrives by email. The raw value is shown once on creation, so copy it then. An older sandbox key that cannot be copied is easy to replace: rotate it and the new one can. A sandbox key starts with sk_test_; a live key starts with sk_live_. The prefix is what decides the environment, because both use the same host.
Store the key in your shell, never in source code:
export STAMPMITRA_API_KEY="sk_test_paste_your_key_here"Now prove the key with the first real call. The samples below ask which states accept e-Stamp orders right now. It needs the estamp.read scope, which sandbox keys carry, and it doubles as your smoke test: a 200 means the host is reachable, the key is valid and the scope is present.
# List the states that accept e-Stamp orders right now. A 200 also proves your key works.
: "${STAMPMITRA_API_KEY:?Set STAMPMITRA_API_KEY to your sk_test_ key}"
curl -sS "https://api-b2b.stampmitra.in/v1/estamp/states/availability?active=true" \
-H "Authorization: Bearer $STAMPMITRA_API_KEY" \
-w "\nHTTP %{http_code}\n"If you get a 401, the key is missing, mistyped or revoked, or it lacks the scope. If you get a 429, you have used the sandbox allowance of 10 requests a minute, or the daily allowance, which resets at midnight IST. The call history for the key is kept in the dashboard Logs page, with the full request and response, which is the fastest place to look when a sample behaves differently from this page.
Where does the key go on every request?
Send it as Authorization: Bearer <key> or as x-api-key: <key>. The samples use the Bearer form. Keep the key out of URLs, logs and client-side code. A browser app should call your own backend, which holds the key and calls StampMitra.
Step 2: How do I check that my state is open?
A state can be switched off for a while, for example during a government portal outage, so the first question for any order is whether the state is accepting orders. The availability call you just ran answers it. Each row has the state code, its name, an active flag that is the live operational switch, and the static flags eStampAvailable and traditionalAvailable. A row with active: false is rejected by validate and create with the per-row code STATE_INACTIVE, so checking first saves a failed call.
The active=true filter in the sample returns only the open states. activeCount in the response counts open states whatever the filter, which makes a handy health number for a status page of your own. The call is cheap and meant to be called often, but not on every keystroke of a form: cache the answer for a minute or so.
The sandbox serves a small sample catalogue rather than the live one. At the time of writing it contains Delhi, Gujarat, Karnataka and Maharashtra as available states and Uttar Pradesh as a deliberate dead end, so you can see what an unavailable state looks like. This guide uses Maharashtra (MH). Production reads the live catalogue, which is larger and changes, so never copy a state list from the sandbox into your code. The state, instrument and article page lists every lookup route and the sandbox table in full.
What do the state flags tell me?
GET /v1/estamp/states/{stateCode} returns the flags that decide which fields an order needs: sroRequired, cessRequired, propertyAreaRequired, fatherHusbandNameRequired, firstPartyAddressRequired and panCardImageRequired. A flag that is null means not known, not no. You do not have to read them one by one, because the requirements call in step 3 resolves them into a concrete field list for the article and amount you choose.
Step 3: How do I find the right article code?
An article is the instrument type of a state, such as an agreement, an affidavit or an indemnity bond, and its code is what the order carries in articleCode. Codes are scoped to their state: the same string in two states can be two different instruments. List the articles of MH with the first sample below and find the row that matches your document. In the sandbox the agreement article is ART1, which the order body uses.
# List the articles (instrument types) of MH. Find the row for your document and note its article code.
: "${STAMPMITRA_API_KEY:?Set STAMPMITRA_API_KEY to your sk_test_ key}"
curl -sS "https://api-b2b.stampmitra.in/v1/estamp/states/MH/instruments" \
-H "Authorization: Bearer $STAMPMITRA_API_KEY" \
-w "\nHTTP %{http_code}\n"The reference does not publish the field names of this list, so print the JSON once and read the column that holds the code. Then save one real response as a fixture in your tests. When the catalogue changes shape your fixture fails in your pipeline, not in front of a customer.
The next call is the most useful read in the whole flow. It takes the state, the article and the denomination and answers with the rules that apply to exactly that combination: which fields are required, the minimum and any allowedAmounts or multipleOf step for the denomination, and an exampleBody you can post to validate unchanged.
# Read which fields this state, article and denomination need, plus a ready-made example body.
: "${STAMPMITRA_API_KEY:?Set STAMPMITRA_API_KEY to your sk_test_ key}"
curl -sS "https://api-b2b.stampmitra.in/v1/estamp/states/MH/requirements?articleCode=ART1&denomination=1000&category=e_stamp" \
-H "Authorization: Bearer $STAMPMITRA_API_KEY" \
-w "\nHTTP %{http_code}\n"Read three things in the answer. First, denomination: when allowedAmounts is present, render a dropdown of exactly those values, and when multipleOf is set, an amount that is not a whole multiple is rejected with AMOUNT_NOT_MULTIPLE. Second, fields: every entry marked required is what validate and create reject when it is blank. Third, exampleBody: its names and values are illustrations, but its shape is a safe starting point. The sandbox article used here accepts only a few denominations, and the order body sticks to them.
Step 4: How do I validate an order before creating it?
Validate runs the same checks StampMitra applies at creation, without saving anything and without charging. It is the call to put behind a "review your order" screen. It needs the estamp.orders.validate scope, and it answers with a success status whether the result is READY_TO_PLACE, WARNINGS or NEEDS_INFORMATION. Today that success status is 201, so treat any 2xx as success and read the body for the verdict. A 400 is reserved for a body that cannot be accepted at all.
The body is the one example of the reference: an order reference of your own, and a stamps array of one to five thousand lines that must all belong to one state. Each line carries clientReference, state, category, articleCode, denomination, the parties, a purpose and the panCardImage link. Read it in the Node or Python sample, which print it in full.
# Validate the order. Nothing is saved and nothing is charged.
: "${STAMPMITRA_API_KEY:?Set STAMPMITRA_API_KEY to your sk_test_ key}"
curl -sS -X POST "https://api-b2b.stampmitra.in/v1/estamp/orders/validate" \
-H "Authorization: Bearer $STAMPMITRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"reference": "order-2026-0917",
"stamps": [
{
"clientReference": "line-001",
"state": "MH",
"category": "e_stamp",
"articleCode": "ART1",
"denomination": 1000,
"firstParty": {
"name": "Jane Doe",
"address": "12 MG Road, Pune"
},
"secondParty": {
"name": "John Smith"
},
"purpose": "Rental Agreement",
"panCardImage": "https://cdn.example.com/kyc/pan-4417.jpg"
},
{
"clientReference": "line-002",
"state": "MH",
"category": "e_stamp",
"articleCode": "ART1",
"denomination": 500,
"firstParty": {
"name": "Jane Doe"
},
"secondParty": {
"name": "Acme Pvt Ltd"
},
"purpose": "Indemnity Bond",
"panCardImage": "https://cdn.example.com/kyc/pan-4418.jpg"
}
]
}' \
-w "\nHTTP %{http_code}\n"A good answer looks like this. The example is generated from the reference, so its numbers are illustrations and your own quote will show your own totals.
{
"valid": true,
"reference": "order-2026-0917",
"state": "MH",
"status": "READY_TO_PLACE",
"isTest": false,
"counts": {
"total": 2,
"e_stamp": 2,
"traditional_stamp": 0
},
"errors": [],
"warnings": [],
"quote": {
"faceValueTotal": 1500,
"serviceFeeTotal": 208,
"gstOnFee": 37.44,
"serviceWalletDebitTotal": 208
},
"documentsRequired": [
{
"type": "PAN_CARD_IMAGE",
"required": false,
"recommended": true,
"uploadWith": "POST /v1/estamp/orders/{id}/documents"
}
],
"createdAt": "2026-10-29T09:12:03.000Z"
}How do you read it? valid is false only when a detail is missing, which pairs with the status NEEDS_INFORMATION and a non-empty errors list. warnings carry pricing or compliance notes that you should show to your user before they confirm. The quote holds four totals in rupees: faceValueTotal is the duty, serviceFeeTotal is StampMitra's service charge before GST, gstOnFee is the GST on that charge, and serviceWalletDebitTotal is what the Service wallet will pay for the order. documentsRequired has one PAN_CARD_IMAGE entry whose required is always false, because the card is advice at this stage, never a block. Step 7 explains why that matters.
How do I make validate return warnings or errors on purpose?
Put a test marker in the order reference or in a line's clientReference, and the sandbox forces an outcome. SBX-WARNING makes validate answer WARNINGS with a pricing note while create proceeds normally, and SBX-DUPLICATE makes validate answer WARNINGS while create answers 409. Other markers force the payment, issuance and expiry failures described in step 6. The whole value must be the marker, and matching ignores case and surrounding spaces. This is the quickest way to exercise your warning screen without hunting for a real data problem.
Step 5: How do I create the order safely?
Creating an order spends money, so the endpoint insists on an Idempotency-Key header: a unique string of one to 255 printable characters for each logical attempt. Think of it as the order's fingerprint. If your server times out and retries with the same key and the same body, StampMitra replays the original response, with no second order and no second debit. If you send the same key with a different body, you get 422 IDEMPOTENCY_KEY_REUSED. If you send it while the first request is still running, you get 409 IDEMPOTENCY_IN_PROGRESS with a Retry-After header. Leave the header out and you get 400 IDEMPOTENCY_KEY_REQUIRED, with nothing created.
Derive the key from something stable that you own, such as an agreement id plus a version, and save it before you send. Change it only when the body changes. The samples use first-order-0001, overridable through an IDEMPOTENCY_KEY variable, so running a sample twice with the same body is a safe replay, and editing the body and running again is a good way to see the 422 for yourself. Keys are scoped to your organisation, the route and the environment, and are kept for 24 hours.
# Create the order. The Idempotency-Key is required, so a retry can never place it twice.
: "${STAMPMITRA_API_KEY:?Set STAMPMITRA_API_KEY to your sk_test_ key}"
curl -sS -X POST "https://api-b2b.stampmitra.in/v1/estamp/orders" \
-H "Authorization: Bearer $STAMPMITRA_API_KEY" \
-H "Idempotency-Key: ${IDEMPOTENCY_KEY:-first-order-0001}" \
-H "Content-Type: application/json" \
-d '{
"reference": "order-2026-0917",
"stamps": [
{
"clientReference": "line-001",
"state": "MH",
"category": "e_stamp",
"articleCode": "ART1",
"denomination": 1000,
"firstParty": {
"name": "Jane Doe",
"address": "12 MG Road, Pune"
},
"secondParty": {
"name": "John Smith"
},
"purpose": "Rental Agreement",
"panCardImage": "https://cdn.example.com/kyc/pan-4417.jpg"
},
{
"clientReference": "line-002",
"state": "MH",
"category": "e_stamp",
"articleCode": "ART1",
"denomination": 500,
"firstParty": {
"name": "Jane Doe"
},
"secondParty": {
"name": "Acme Pvt Ltd"
},
"purpose": "Indemnity Bond",
"panCardImage": "https://cdn.example.com/kyc/pan-4418.jpg"
}
]
}' \
-w "\nHTTP %{http_code}\n"The Node and Python samples end by printing export ORDER_ID=... and one line per stamp. Run the export line in your shell, because the next samples read ORDER_ID. With cURL, copy the id field of the response yourself. Use the id, which begins with estord_ and, in the sandbox, estord_sbx_, and not the separate orderId field: the order routes take id.
What does create actually do? It debits the duty from the Stamp Duty Wallet and the service charges from the Service wallet, in one step, and reaches StampMitra's validation stage. It needs the estamp.orders.create scope. In the sandbox the wallets are simulated counters that start with credit, so you can create straight away. On a live key it does not place the order with the issuing side by itself, because a person confirms placement separately. That is why the live status is a pre-placement value, PENDING_REVIEW, and never "completed".
What if the create call times out?
Do not create a second order with a new key. Resend the identical request with the same key, which either replays the stored answer or tells you the first one is still running. If you lost the key as well, list your orders with GET /v1/estamp/orders: your own reference is on every order, so you can find out whether the first attempt landed.
Step 6: How do I read the order and the quote?
Set ORDER_ID to the id from the create answer and read the order. The route needs the estamp.orders.read scope. You get the status, the stamp count, the counts per category, a documents object that says whether a PAN card is MISSING or RECEIVED, and a list of advisories, which are non-blocking hints. A 404 means no order with that id exists for your organisation, and the usual cause is an id from the other environment.
# Read the order: status, counts, the PAN card state and any advisories.
: "${STAMPMITRA_API_KEY:?Set STAMPMITRA_API_KEY to your sk_test_ key}"
: "${ORDER_ID:?Set ORDER_ID to the id returned by the create call}"
curl -sS "https://api-b2b.stampmitra.in/v1/estamp/orders/$ORDER_ID" \
-H "Authorization: Bearer $STAMPMITRA_API_KEY" \
-w "\nHTTP %{http_code}\n"A sandbox order advances on its own with the time since it was created, so you can poll the same call and watch it move. The defaults are CREATED at once, PAYMENT_PENDING after about five seconds, PROCESSING after about fifteen and ISSUED after about thirty. Do not hard-code those times: the order body carries a sandbox object with nextStatusAt, and an environment can shorten the timeline. Poll with a gentle backoff rather than in a tight loop, because every sandbox request counts toward the daily allowance.
Then list the stamps, which is where per-stamp progress lives. Each stamp has its own status (PLACED, ASSIGNED, GENERATING, VERIFYING, VERIFIED or CANCELLED), a verified flag and a panCard object with the state of the payer's PAN card. The order status and the stamp status are different vocabularies. In the sandbox the stamps reach VERIFIED when the order is ISSUED.
# List the stamps of the order, each with its own status and PAN card state.
: "${STAMPMITRA_API_KEY:?Set STAMPMITRA_API_KEY to your sk_test_ key}"
: "${ORDER_ID:?Set ORDER_ID to the id returned by the create call}"
curl -sS "https://api-b2b.stampmitra.in/v1/estamp/orders/$ORDER_ID/stamps" \
-H "Authorization: Bearer $STAMPMITRA_API_KEY" \
-w "\nHTTP %{http_code}\n"{
"items": [
{
"id": "eststamp_4f21ab",
"clientReference": "line-001",
"status": "PLACED",
"verified": false,
"panCard": {
"status": "PROCESSING",
"code": null,
"message": null
},
"state": "MH",
"category": "e_stamp",
"amount": 1000,
"purpose": "Rental Agreement"
}
],
"count": 1,
"nextCursor": null
}Where is the quote after creation? The priced totals come from validate, so store the quote you showed your user together with your own order record. The order itself reports status and counts. To see the money move, read the two wallet ledgers (GET /v1/stamp-duty-wallet/transactions and GET /v1/service-fee-wallet/transactions), where a sandbox order shows a debit, and a failed or cancelled one shows a single refund. The order page and the payment page describe both ledgers.
How do I test the unhappy endings?
The same markers work in create. SBX-PAYMENT-FAILED ends the order as PAYMENT_FAILED, SBX-ISSUANCE-FAILED as ISSUANCE_FAILED, SBX-CANCELLED as CANCELLED and SBX-EXPIRED as EXPIRED. Each one credits the sandbox wallets back once. Run each ending against your status mapping, and make the mapping tolerant of values you have never seen, because the live vocabulary is different. Once an order is ISSUED, the certificate is one call away through the documents page, and the sandbox file is a sample, not a legal document.
Step 7: What about the PAN card?
The payer's PAN card is the one piece of this flow that people trip over, so the rule deserves a plain statement. You can place an order without a PAN card. You cannot complete a stamp without one. Until a PAN card is on file, the stamp waits. Validate and create accept the order, create lists an advisory called PAN_CARD_RECOMMENDED when no link was sent, and nothing is held back, yet the stamp does not move to completion.
That is why every line of the example body carries panCardImage: an https link, on the default port, with no credentials in it, to the payer's PAN card, which StampMitra must be able to download without a login. JPG, PNG, WebP, GIF, HEIC and PDF are accepted. A link that is not https, or has a user name or an odd port, fails with HTTPS_URL_REQUIRED, and a link the issuing side refuses fails with INVALID_PAN_CARD_LINK. The API never gives the file back to you, so keep your own copy. Treat the image as personal data: share it only through a link that expires and that you control, and collect it with the payer's consent.
You can also send or replace the link later, per stamp, with POST /v1/estamp/stamps/{stampId}/pan-card, which needs the estamp.orders.create scope. Take the stamp id from the stamps list in step 6, and export it as STAMP_ID. The call answers 202 with PROCESSING, because the check is asynchronous, and the verdict appears in the stamp's panCard object.
# Send or replace the payer's PAN card link for one stamp. Answers 202 and checks the link in the background.
: "${STAMPMITRA_API_KEY:?Set STAMPMITRA_API_KEY to your sk_test_ key}"
: "${STAMP_ID:?Set STAMP_ID to a stamp id from the stamps list of the order}"
curl -sS -X POST "https://api-b2b.stampmitra.in/v1/estamp/stamps/$STAMP_ID/pan-card" \
-H "Authorization: Bearer $STAMPMITRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"panCardImage": "https://cdn.example.com/kyc/pan-4417.jpg"
}' \
-w "\nHTTP %{http_code}\n"{
"stampId": "eststamp_4f21ab",
"panCard": {
"status": "PROCESSING",
"code": null,
"message": null
}
}What are the PAN card states?
panCard.status | Meaning | What to do |
|---|---|---|
NOT_PROVIDED | No link has been sent for this stamp | Send one with the call above |
PROCESSING | The link is being checked | Poll the stamp again shortly |
VERIFIED | The card is on file and accepted | Nothing |
IN_REVIEW | A person is looking at it | Wait, and keep polling |
REJECTED | The card was refused | Ask the payer for a clearer image and send a new link |
FAILED | The link could not be fetched or processed | Check that the link opens without a login, then send it again |
StampMitra does not promise a webhook when a PAN card is rejected, so the stamp's panCard object is the source of truth and your poller is the safety net. A stamp that has progressed too far, or is already fulfilled or cancelled, answers 409 when you try to change its PAN link.
Step 8: How do I receive and verify webhooks?
Polling works, but a webhook tells you sooner. For an order created through these routes you can expect, in the sandbox, order.created when it is created, order.payment_confirmed and order.fulfilment_started when processing begins, then order.fulfilment_completed and order.document_ready when it is issued. A failure sends order.failed followed by order.refund_completed, and a cancellation sends order.cancelled followed by order.refund_completed. The sandbox payload carries orderId, reference, status and sandbox: true, and the document event adds the stamp ids. Confirm the event coverage for your account before a live feature depends on it, and keep polling as the backstop.
Setting up an endpoint takes about two minutes:
- Open the Webhooks page of the dashboard, pick the Sandbox tab and choose Add endpoint. Sandbox and live endpoints are separate, and a sandbox event never reaches a live endpoint.
- Enter an
httpsURL that is reachable from the internet. For a laptop, a tunnelling tool gives you one. Choose the events you want, or leave all unchecked to receive every event. Confirm with the code that arrives by email. - Copy the signing secret now. It is shown once and starts with
whsec_. Store it asWEBHOOK_SECRETon the machine that runs your receiver. - Run the receiver below, then use Send test event on the endpoint card. The delivery log shows the attempt, the response and the headers that were sent. A test event carries
X-Webhook-Test: true.
Each delivery is a signed POST. The signature header X-Webhook-Signature holds the hex HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with your secret, and X-Webhook-Timestamp is the Unix time in seconds at which it was signed. During a secret rotation, X-Webhook-Signatures lists every valid signature as v1=<hex>, and you accept the request if any entry matches a secret you hold. X-Webhook-Event-Id stays the same on every retry, so use it to ignore repeats. The receiver below does all of it: it keeps the raw bytes, checks the timestamp against a five-minute window, compares in constant time, de-duplicates and answers 200 quickly.
// webhook-receiver.mjs: receive StampMitra webhooks, verify the signature, acknowledge fast.
// Node.js 18 or newer. Run: npm install express && WEBHOOK_SECRET=... node webhook-receiver.mjs
import crypto from "node:crypto";
import express from "express";
const secret = process.env.WEBHOOK_SECRET;
if (!secret) throw new Error("Set WEBHOOK_SECRET to the signing secret of your endpoint");
const app = express();
const seen = new Set(); // use a database or Redis in production
// express.raw keeps the exact bytes: the signature covers them, so never re-serialise parsed JSON.
app.post("/webhooks/stampmitra", express.raw({ type: "application/json" }), (req, res) => {
const timestamp = req.get("X-Webhook-Timestamp") ?? "";
const signature = req.get("X-Webhook-Signature") ?? "";
const eventId = req.get("X-Webhook-Event-Id") ?? "";
const age = Math.abs(Date.now() / 1000 - Number(timestamp));
const expected = crypto.createHmac("sha256", secret).update(`${timestamp}.${req.body.toString("utf8")}`).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(signature);
if (!Number.isFinite(age) || age > 300 || a.length !== b.length || !crypto.timingSafeEqual(a, b)) {
return res.status(400).send("invalid signature");
}
if (seen.has(eventId)) return res.sendStatus(200); // a retry of an event you already handled
seen.add(eventId);
const event = JSON.parse(req.body.toString("utf8"));
console.log("verified", event.coreEventType, event.coreOrderId, req.get("X-Webhook-Test") === "true" ? "(test)" : "");
res.sendStatus(200); // acknowledge first, do the real work off the request path
});
app.listen(3000, () => console.log("listening on http://localhost:3000/webhooks/stampmitra"));You do not need the dashboard to test your verification code. The cURL sample signs a body exactly the way StampMitra does and posts it to your local receiver, so you can see a verified delivery and a rejected one (change one character of the body) in seconds.
# Send a signed test delivery to your own endpoint, exactly as StampMitra signs one.
: "${WEBHOOK_SECRET:?Set WEBHOOK_SECRET to the signing secret of your endpoint}"
URL="${WEBHOOK_URL:-http://localhost:3000/webhooks/stampmitra}"
BODY='{"coreOrderId":"core_order_9f3a1c2b8e4d4a5f","coreEventType":"DOCUMENT_READY","occurredAt":"2026-10-29T09:30:00.000Z"}'
TS=$(date +%s)
SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" -hex | sed 's/^.* //')
curl -sS -X POST "$URL" \
-H "Content-Type: application/json" \
-H "X-Webhook-Timestamp: $TS" \
-H "X-Webhook-Signature: $SIG" \
-H "X-Webhook-Event-Id: evt_local_0001" \
-d "$BODY" \
-w "\nHTTP %{http_code}\n"Answer within ten seconds, because redirects are not followed and a slow endpoint counts as a failure. Failed deliveries are retried with exponential backoff at roughly one minute, five minutes, thirty minutes, two hours and twelve hours, and are dead-lettered after six attempts in all. An endpoint that fails many times in a row is switched off, with a banner in the dashboard, and you re-enable it after you fix it. The webhooks page lists every event name and the verification samples in more languages.
Can I run the same calls in Postman or Insomnia?
Yes, and for a first look it is often the quickest way to see the shapes. StampMitra generates a Postman collection from the same data as the OpenAPI document, so the bodies match this page. Copy these values:
- Collection URL for Postman (Import, then Link):
https://developer.stampmitra.in/postman.json - OpenAPI URL for Insomnia (Import, then From URL):
https://developer.stampmitra.in/openapi.json - Collection variable
baseUrl:https://api-b2b.stampmitra.in - Collection variable
apiKey: yoursk_test_key
Send the requests of the e-Stamp folder in this order: Live state availability, List instruments (articles) for a state, Required and optional fields for a stamp combination, Validate an e-Stamp order before creating it, Create an e-Stamp order, Get an e-Stamp order, then List the stamps in an order. Three details save time. Pick Create an e-Stamp order and not the plain Create an order that sits above it, which is the older generic route and takes a free-form body. Set the path variable :id to your order id before you send the read calls, and :stateCode to MH. And check the Idempotency-Key header: the collection fills it with a Postman-generated unique value, and Insomnia may not understand that placeholder, so type any unique string there if the answer is IDEMPOTENCY_KEY_REQUIRED or IDEMPOTENCY_KEY_INVALID. The Postman page has the download button and the list of folders.
If you would rather generate a typed client than write requests by hand, the same OpenAPI document feeds the official SDKs, and the reference has a copy of every request and response example.
Which errors will I hit on a first order?
Most first-order failures are one of a handful. Every error body has the shape { "error": { "code", "message", "requestId" } }, with field where an input is at fault, and details on some errors: details.errors[] lists each finding of a rejected order body as { field, code, message, index }, and details.wallet names the wallet that was short on a 402. Quote the requestId when you write to support. The table below uses the codes of the published specification, so it changes when the specification does.
| Code | HTTP | Where it appears | What it means | What to do |
|---|---|---|---|---|
VALIDATION_FAILED | 400 | Message of a BAD_REQUEST, with details.errors[] | The body is malformed or a line cannot be accepted | Read each field, code and index in details.errors[], fix the line and resend. Nothing was created |
UNAUTHORIZED | 401 | error.code | The key is missing or invalid, or it lacks the scope the route needs | Check the sk_test_ value and that the key carries the scope named in this guide's step |
FORBIDDEN | 403 | error.code | The IP is not allowed, the plan entitlement is not enabled, or a limit was reached. On wallet routes, the key has no wallet scope | Fix the IP allowlist, apply for the entitlement, or ask support to enable the wallet scopes |
PAYMENT_REQUIRED | 402 | error.code, with details.wallet | The Stamp Duty Wallet or the Service wallet cannot cover the order. details.wallet is STAMP_DUTY or SERVICE_FEE | Top up the named wallet and retry with the same Idempotency-Key. Nothing was created or charged |
IDEMPOTENCY_KEY_REQUIRED | 400 | error.code | POST /v1/estamp/orders was sent without an Idempotency-Key | Add the header and resend. Nothing was created |
IDEMPOTENCY_KEY_REUSED | 422 | error.code | The key was already used with a different body | Use a new key for a different request, or resend the original body |
IDEMPOTENCY_IN_PROGRESS | 409 | error.code | A request with this key is still running | Resend the identical request after the Retry-After delay |
STATE_INACTIVE | 400 | details.errors[].code | The state is not accepting orders right now | Check state availability and retry later |
MIXED_STATE | 400 | details.errors[].code | Lines for more than one state in one order | Create one order per state |
AMOUNT_NOT_MULTIPLE | 400 | details.errors[].code | The state sells only in whole multiples of a step | Read denomination.multipleOf in the requirements call |
HTTPS_URL_REQUIRED | 400 | details.errors[].code | panCardImage is not an https link on the default port without credentials | Send a plain https link that opens without a login |
INVALID_PAN_CARD_LINK | 400 | details.errors[].code | The PAN card link was refused | Send a link to the payer's PAN card that anyone with the link can download |
SANDBOX_ESTAMP_ORDER_LIMIT | 429 | error.code | Sandbox only: too many open or stored sandbox orders | Wait for open orders to finish, which takes about half a minute, or cancel them |
A few of these deserve a second look. VALIDATION_FAILED is not a standalone error.code: it is the start of the message of a 400 whose error.code is BAD_REQUEST, so match on the per-field codes. UNAUTHORIZED is the code for a missing scope as well as a bad key, and FORBIDDEN is for the account's entitlements, which is why an e-Stamp route can work in the sandbox and answer 403 on a live key before production access is granted. For a wider tour of retries, backoff and which statuses are safe to resend, read the errors and handling guide and the one on retries and idempotency.
What changes when I go live?
Your code stays the same: the host, the paths, the body and the headers are identical, and only the key changes from sk_test_ to sk_live_. Everything around the code changes.
Production access. A live key needs an approved production access request, and e-Stamp is approved as one decision on the estamp service, separate from the verification APIs. Apply from the dashboard when the sandbox flow works. Scopes you used in the sandbox may differ on a live key, so check the 401 and 403 rows above on your first live read.
Two funded wallets. A live order is paid only from two prepaid wallets. The Stamp Duty Wallet pays the government duty, which carries no GST and no markup. The Service wallet pays StampMitra's per-paper charges, the same balance that pays for verification calls, and the GST on those fees is collected when you top it up. Both wallets must hold enough at the moment you create the order. If either is short, create answers 402 PAYMENT_REQUIRED, names the wallet in details.wallet, creates nothing and charges nothing. Top both up from the Wallet page of the dashboard, and read the balances before you show your final button. The wallet routes need their own scopes, which live keys do not always carry, so ask support to enable them if your server reads balances.
Pricing. The exact charges depend on the state, the number of papers and the rates agreed for your organisation, so do not copy figures from a guide. Run validate with the real order and read the quote: the service totals and GST are in it, and the duty is passed through. The billing guide explains the per-paper structure, when GST applies and how invoices work, and the pricing page has the price book.
Review and timing. A live order is PENDING_REVIEW after creation and does not advance by itself: a person confirms placement. The sandbox has no such step, so its thirty seconds say nothing about live turnaround. Rehearse one low-value live order from end to end before launch, because that is the only way to see the real wait, the real PAN card handling and the real certificate. Live-only rejections such as STATE_INACTIVE, AMOUNT_NOT_MULTIPLE and a PAN link the issuing side refuses can only appear against live data. The sandbox versus production guide covers the key swap and the rollout checklist.
How StampMitra helps
StampMitra gives developers one API key, one base URL and a typed e-Stamp surface that checks every field of an order before money moves. Validate never saves or debits anything. Create refuses to run without an idempotency key. The two wallets are separate on purpose: duty stays duty, and service charges stay service charges, so your finance team can reconcile each one. The OpenAPI document, the Postman collection and the reference examples are generated from the same data as this guide, so the bodies you copy here are the bodies the API validates.
What the API does today is documented on the e-Stamp reference and in the API reference for orders: catalogue and state lookups, duty and value, order validate, create, list, get, cancel and export, per-stamp reads, PAN card handling, documents and certificates, wallets and webhooks. Webhook endpoints are managed on the dashboard, with a signed test event, secret rotation and a delivery log. For a deeper walk through the whole journey, including certificates, polling design and reconciliation, read the complete e-Stamp order flow guide.
What is next is planned, not promised: more first-class examples for other states and instruments, and broader webhook coverage for stamp-level events. If something on this page does not behave as written, write to [email protected] with the requestId of the call, and say which step you were on. To start now, create a sandbox account, or read the quickstart first.
API reference at a glance
e-Stamp Order Creation
POST /v1/ordersRequest parameters
| Field | Type | Description |
|---|---|---|
Authorizationrequired | header | Bearer <api-key> (e.g. sk_test_... in sandbox, sk_live_... in production). The x-api-key header is also accepted. |
Idempotency-Key | header | Optional idempotency key (1 to 255 characters), kept for 24 hours. The same key and the same request replays the stored response; the same key with a different request is 422 IDEMPOTENCY_KEY_REUSED; the same key while the first request is still running is 409 IDEMPOTENCY_IN_PROGRESS (see Retry-After). |
externalOrderIdrequired | string | Your own reference for this order. |
externalCustomerIdrequired | string | Your own reference for the customer. |
serviceCoderequired | string | The entitled service to order (e.g. an estamp.* code). |
details | object | Free-form service-specific payload. Not validated for e-Stamp: use POST /v1/estamp/orders instead. |
POST /v1/orders{
"externalOrderId": "ord_ext_123",
"createdAt": "2026-10-15T09:41:07.000Z",
"serviceCode": "estamp.instrument.rent_agreement"
}POST /v1/orderse-Stamp Order Creation: ₹5 API fee per successful call, pay-as-you-go (up to 100 calls per API per day; more on Business or a commercial deal).
Order Status & Document Access
GET /v1/orders/:id/documentsRequest parameters
| Field | Type | Description |
|---|---|---|
Authorizationrequired | header | Bearer <api-key> (e.g. sk_test_... in sandbox, sk_live_... in production). The x-api-key header is also accepted. |
GET /v1/orders/:id/documentsOrder Status & Document Access: ₹5 API fee per successful call, pay-as-you-go (up to 100 calls per API per day; more on Business or a commercial deal).
Frequently asked questions
How long does a first e-Stamp order take in the sandbox?
About ten minutes once you hold a sandbox key: one call to check the state, one to find the article code, validate, create, read the order and stamps, add the PAN card and receive a test webhook. Account creation with its email and mobile codes comes before that and is not counted.
Do I need to fund a wallet to place a sandbox order?
No. Sandbox keys use simulated Stamp Duty and Service wallets that start with credit, never touch a payment provider and never debit real money. A live order is different: both real wallets must hold enough when you create it, or create answers 402 PAYMENT_REQUIRED and charges nothing.
Why does creating an e-Stamp order need an Idempotency-Key?
Creating an order spends money, so the header is required. The same key with the same body replays the original response with no second order or debit, a different body under the same key is 422 IDEMPOTENCY_KEY_REUSED, and a missing header is 400 IDEMPOTENCY_KEY_REQUIRED with nothing created.
Is the PAN card mandatory when I place an e-Stamp order?
You can place the order without it, and validate marks it as advisory only. The PAN card is mandatory to complete the stamp, so until one is on file the stamp waits. Send an https link in panCardImage on each line, or later with the stamp's pan-card route.
What does validate do that create does not?
Validate runs the same checks as creation without saving anything and without charging. It returns READY_TO_PLACE, WARNINGS or NEEDS_INFORMATION, a list of field findings, and a quote with the duty total, service fee total, GST on the fee and the Service wallet debit, so you can show the cost before confirming.
How do I find the article code for my document?
List the state's articles with GET /v1/estamp/states/{stateCode}/instruments and choose the row for your instrument, then call the requirements route with that articleCode and your denomination. It returns the required fields, any allowed amounts and a ready example body. Article codes are scoped to their state.
How do I verify a StampMitra webhook signature?
Keep the raw request body, compute the hex HMAC-SHA256 of the timestamp header, a dot and that body with your endpoint secret, and compare it with X-Webhook-Signature in constant time. Reject timestamps far from your clock, ignore repeated X-Webhook-Event-Id values and answer with a 2xx within ten seconds.
Can I try the flow in Postman or Insomnia instead of code?
Yes. Import the collection from developer.stampmitra.in/postman.json into Postman, or the OpenAPI document from developer.stampmitra.in/openapi.json into Insomnia, set baseUrl and apiKey, and send the e-Stamp folder in order. Choose Create an e-Stamp order, not the older generic Create an order request.
What changes when I move from sandbox to a live key?
The code stays the same and only the key changes. You need approved production access for e-Stamp, a funded Stamp Duty Wallet and a funded Service wallet, and you should expect a PENDING_REVIEW status because a person confirms placement. Run validate to read the real quote, since charges depend on state and agreed rates.
Why do I get 401 or 403 on an e-Stamp call?
A 401 UNAUTHORIZED means the key is missing or invalid or lacks the scope the route needs, such as estamp.orders.create. A 403 FORBIDDEN means an IP allowlist, an entitlement that is not enabled yet or a limit. Wallet routes also answer 401 or 403 until support enables the wallet scopes on a live key.
Sources
Verified 2026-11-25 against the StampMitra Developers codebase and the pages it publishes. No external website was used for API behaviour, and nothing on this page is legal advice.
- StampMitra OpenAPI document: request schemas, error codes and webhook definitions, verified 2026-11-25.
- Order page: validate, create, idempotency, the sandbox simulation and its test markers, verified 2026-11-25.
- Order status and document access page: stamps, PAN card states and webhook events in the sandbox, verified 2026-11-25.
- State, instrument and article page: availability, requirements and the sandbox catalogue, verified 2026-11-25.
- Payment page: the Stamp Duty Wallet, the Service wallet and the 402 behaviour, verified 2026-11-25.
- StampMitra webhooks page and the dashboard Webhooks page: headers, signing, retries and test events, verified 2026-11-25.