Everything in the e-Stamp flow exists to produce one file: the certificate. The last step is where you find out whether it exists yet, fetch it before the link dies, put it somewhere durable and tell the customer. It is also the step where impatience, a short-lived URL and a sandbox whose certificate is only a sample file combine to create most of the late-night bugs. This page covers how to read an order and its stamps, what each status means, how the certificate route behaves, how to download and store the file safely, how to combine polling with webhooks, how to cancel or replace a stamp, and how to test the path, including what the sandbox simulates and what it cannot tell you. It is step eight, the last, of the eight-step e-Stamp flow.
A framing that helps: your product moves through three questions in this order. Is the order still being reviewed? Is a stamp being produced? Is the certificate available yet? Each has its own route and its own statuses, and treating them as one question is the most common reason a product tells a customer something untrue.
The routes at a glance
All routes use the base URL https://api-b2b.stampmitra.in, authenticate with Authorization: Bearer <key> or x-api-key, and sit behind the estamp.enabled entitlement.
| Route | Answers | Scope | Metered by StampMitra |
|---|---|---|---|
GET /v1/estamp/orders | Which orders do I have, and in what status | estamp.orders.read | No |
GET /v1/estamp/orders/:id | Where is this order | estamp.orders.read | No |
GET /v1/estamp/stamps/:stampId | What state is this stamp in | estamp.stamps.read | No |
GET /v1/estamp/stamps/:stampId/certificate | Is the certificate available, and where is it | estamp.stamps.read | No |
POST /v1/estamp/stamps/:stampId/cancel | Cancel a stamp | estamp.stamps.cancel | No |
POST /v1/estamp/stamps/:stampId/replace | Replace a defective stamp | estamp.stamps.replace | No |
The reference page for this step also documents the generic document routes GET /v1/orders/:id/documents and GET /v1/orders/:id/documents/:documentId/download under documents.read. Those belong to the generic order resource, and a section below explains how they relate. For e-Stamp orders created through the e-Stamp routes, the stamp and certificate routes above are the path.
GET/v1/orders/:id/documents
List documents for an order
Request 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/documents/:documentId/download
Get a document download URL
Request 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. |
Response fields
| Field | Type |
|---|---|
downloadUrl | string |
expiresAt | string |
Reading an order
The order is the container, and its status describes review, not production. A read returns the order record you saw at creation, updated.
export STAMPMITRA_API_KEY="sk_test_xxxxxxxxxxxx"
export BASE="https://api-b2b.stampmitra.in"
curl -s "$BASE/v1/estamp/orders/estord_9c1f2a3b" -H "Authorization: Bearer $STAMPMITRA_API_KEY"{
"id": "estord_9c1f2a3b",
"orderId": "6a0e2b9a-5f1d-4c63-9c2e-0d4e7b1f3a55",
"reference": "lease-2026-0412",
"state": "MH",
"status": "READY_TO_PLACE",
"isTest": false,
"stampCount": 1,
"stamps": [{ "id": "eststamp_4f21ab", "clientReference": "line-001" }],
"errors": [],
"warnings": [],
"createdAt": "2026-10-29T09:12:03.000Z",
"updatedAt": "2026-10-29T10:40:11.000Z"
}The order statuses are PENDING_REVIEW, READY_TO_PLACE, WARNINGS, NEEDS_INFORMATION, VALIDATION_FAILED and CANCELLED, covered on the order page. They are the platform's own pre-placement vocabulary. The thing to take from this page's point of view is that an order status never says "stamped". Once an order has been placed, the interesting information moves to its stamps, which you reach through the ids in stamps[].
Reading a stamp
GET /v1/estamp/stamps/:stampId returns one stamp with the issuing side's own fields.
curl -s "$BASE/v1/estamp/stamps/eststamp_4f21ab" -H "Authorization: Bearer $STAMPMITRA_API_KEY"{
"id": "eststamp_4f21ab",
"clientReference": "line-001",
"bulkOrderId": "estord_9c1f2a3b",
"status": "GENERATING",
"verified": false,
"state": "MH",
"category": "e_stamp",
"amount": 1000,
"uin": null,
"costCentre": "CC-100",
"businessUnit": "BU-Retail",
"purpose": "Leave and licence agreement"
}| Field | What it tells you |
|---|---|
id | The stamp id |
clientReference | Your own line reference, echoed |
bulkOrderId | The order this stamp belongs to |
status | The issuing side's lifecycle status |
verified | Whether the stamp has completed verification |
state, category | State and e_stamp or traditional_stamp |
amount | The stamp's denomination |
uin | The unique identification number, present once generated |
costCentre, businessUnit, purpose | Your tags and the stated purpose, where supplied |
The read merges the platform's own record of the stamp with a live read from the issuing side for fields such as verified and amount, so a slow upstream can make this call slower than a pure database read. Do not poll it in a tight loop.
What each stamp status means
| Status | Meaning | What to do |
|---|---|---|
PLACED | The order was placed with the issuing side | Wait; a stamp is being assigned |
ASSIGNED | A stamp has been assigned to the line | Wait |
GENERATING | The certificate is being generated | Poll the certificate route at a relaxed pace |
VERIFYING | Generated, now being verified | Poll the certificate route |
VERIFIED | Verified. The certificate follows | Fetch the certificate when available turns true |
CANCELLED | Cancelled at the issuing side | Stop polling; handle as cancelled |
A stamp that is VERIFIED and a certificate that is available are separate facts. The certificate is delivered to the platform after verification, and the certificate route reports whether that has happened. Treat VERIFIED as "very soon" and available: true as the only evidence that a file exists to fetch.
Map unknown status strings to a "needs attention" state instead of throwing, and keep the raw value. The vocabulary belongs to the issuing side, and it can grow.
The certificate route
GET /v1/estamp/stamps/:stampId/certificate is a deliberate passthrough with an explicit discriminator. It always returns HTTP 200 for a stamp that exists, with one of two shapes.
{ "available": false, "status": "not_yet_available" }{
"available": true,
"status": "available",
"downloadUrl": "https://api-b2b.stampmitra.in/v1/estamp/certificates/eststamp_4f21ab/download?token=...",
"expiresAt": "2026-10-29T10:05:00.000Z",
"certificateNumber": "IN-MH-2026-0917-001234"
}| Field | Meaning |
|---|---|
available | Whether the certificate has been delivered and can be downloaded |
status | not_yet_available or available |
downloadUrl | A time-limited, presigned URL hosted by StampMitra. Present only when available |
expiresAt | When the URL stops working, an ISO 8601 timestamp. Present only when available |
certificateNumber | The certificate number, once issued. It can be null even when the certificate is available |
Four rules follow from this design.
not_yet_availableis not an error. It is HTTP 200, because the stamp exists and the file does not yet. Poll, with backoff.- The route never falls back to a live call to the issuing side. It reports what the platform has ingested. If the file has not arrived, it says so.
- The URL is StampMitra's, never a third party's. The platform rewrites the issuing side's own link before it reaches you, and the link you receive lives five minutes.
certificateNumbercan be null. Do not make it a required field in your database.
Downloading safely
The five-minute lifetime is the single most important operational fact on this page. A downloadUrl is a ticket to fetch the file right now, not a stable address. Fetch the URL immediately after you receive it, stream the file to your own storage, verify what you stored, and only then mark the stamp as delivered.
// Node 18+; server side only
import { createHash } from "node:crypto";
import { writeFile } from "node:fs/promises";
const BASE = "https://api-b2b.stampmitra.in";
const headers = { Authorization: `Bearer ${process.env.STAMPMITRA_API_KEY}` };
export async function fetchCertificate(stampId, saveTo) {
const res = await fetch(`${BASE}/v1/estamp/stamps/${stampId}/certificate`, { headers });
const body = await res.json();
if (res.status === 404) return { state: "unknown-stamp" };
if (!res.ok) throw Object.assign(new Error(body.error?.message), { status: res.status, requestId: body.error?.requestId });
if (!body.available) return { state: "pending" };
// The link lives five minutes: use it now, in the same function
const file = await fetch(body.downloadUrl);
if (!file.ok) return { state: "download-failed", status: file.status }; // fetch a fresh link next time
const bytes = Buffer.from(await file.arrayBuffer());
if (bytes.subarray(0, 4).toString() !== "%PDF") return { state: "not-a-pdf" };
await writeFile(saveTo, bytes);
const sha256 = createHash("sha256").update(bytes).digest("hex");
return { state: "stored", certificateNumber: body.certificateNumber ?? null, sha256, size: bytes.length };
}import hashlib, os, requests
BASE = "https://api-b2b.stampmitra.in"
H = {"Authorization": f"Bearer {os.environ['STAMPMITRA_API_KEY']}"}
def fetch_certificate(stamp_id: str, save_to: str) -> dict:
r = requests.get(f"{BASE}/v1/estamp/stamps/{stamp_id}/certificate", headers=H, timeout=20)
body = r.json()
if r.status_code == 404:
return {"state": "unknown-stamp"}
if not r.ok:
err = body["error"]
raise RuntimeError(f"{r.status_code} {err['code']} req={err['requestId']}")
if not body["available"]:
return {"state": "pending"}
f = requests.get(body["downloadUrl"], timeout=60) # the link lives five minutes
if not f.ok:
return {"state": "download-failed", "status": f.status_code}
if not f.content.startswith(b"%PDF"):
return {"state": "not-a-pdf"}
with open(save_to, "wb") as out:
out.write(f.content)
return {"state": "stored", "certificate_number": body.get("certificateNumber"),
"sha256": hashlib.sha256(f.content).hexdigest(), "size": len(f.content)}If the download fails, do not retry the old URL. Request the certificate route again and use the fresh link, since each call to the route returns a new presigned URL. Never put the downloadUrl in an email, a notification or a log, because it is a bearer ticket for a customer document. And never ship your API key to a browser to let the user download directly: stream the file through your own server, or serve it from your own storage with your own access control.
A polling schedule that respects everyone
Polling is the fallback that always works, so make it cheap and polite. A fixed interval is wasteful early and slow late. A graduated schedule fits the shape of the wait.
| Time since the order was placed | Poll the stamp or certificate every |
|---|---|
| First 10 minutes | 60 seconds |
| 10 minutes to 2 hours | 5 minutes |
| 2 to 24 hours | 30 minutes |
| After 24 hours | 2 hours, and raise an internal alert |
Add jitter so that a thousand stamps do not all poll on the same second, honour 429 responses by doubling the wait, and poll stamps individually rather than in a tight loop over the whole list. Stop polling a stamp on CANCELLED or once the certificate is stored. Your expected waiting time should come from your own measurements, since the catalogue's processingTimeHours is only an expectation.
// Decide when to look at a stamp next, in milliseconds
export function nextPollDelayMs(placedAt, now = Date.now()) {
const ageMin = (now - new Date(placedAt).getTime()) / 60_000;
const base = ageMin < 10 ? 60_000 : ageMin < 120 ? 5 * 60_000 : ageMin < 1440 ? 30 * 60_000 : 2 * 3600_000;
return Math.round(base * (0.8 + Math.random() * 0.4)); // +/- 20 percent jitter
}Keeping polling cheap
Polling costs nothing on StampMitra's side, since these reads are not metered, but it is not free. It consumes rate limit, it loads your own workers and, for stamp reads, it can touch the issuing side. A few habits keep it cheap. Poll the certificate route in preference to the stamp route once a stamp is VERIFYING or later, because the certificate route answers your real question directly. Keep one scheduler that owns the next-poll time for every stamp, instead of a timer per stamp. Store the next poll time in the database so that a restart does not make every stamp poll at once. And measure: the number of polls per stored certificate is a good health number, and a figure much above the length of your schedule means something is polling too eagerly.
Webhooks as hints
The webhooks reference lists the order lifecycle events: order.created, order.payment_confirmed, order.fulfilment_started, order.fulfilment_completed, order.failed, order.cancelled, order.refund_completed and order.document_ready. The last one is the one this step cares about: a generated document, such as an e-stamp certificate, is ready to download. A delivery is a signed POST with a JSON body.
{
"coreOrderId": "core_order_9f3a1c2b8e4d4a5f",
"coreEventType": "FULFILMENT_COMPLETED",
"occurredAt": "2026-09-25T09:05:00.000Z",
"orderId": "ord_4f5a6b7c8d9e0f1a",
"externalOrderId": "ord_ext_123",
"status": "FULFILMENT_COMPLETED"
}| Header | Value |
|---|---|
X-Webhook-Signature | Hex HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with your endpoint secret |
X-Webhook-Signatures | During a secret rotation, every currently valid signature as v1=<hex> entries |
X-Webhook-Timestamp | Unix seconds when the attempt was signed. Part of the signed string |
X-Webhook-Event-Id | A stable event id. Use it to de-duplicate retries |
Failed deliveries retry with exponential backoff, at roughly one minute, five minutes, thirty minutes, two hours and twelve hours, and are dead-lettered after six attempts. Verify against the raw bytes, reject timestamps far from your clock (the official SDKs default to 300 seconds), compare in constant time, de-duplicate on the event id and answer with a 2xx quickly, doing real work off the request path. Register endpoints on the Webhooks page of the dashboard; the webhooks page has verification code in seven languages.
One caveat matters here. The events are keyed to the platform's generic order lifecycle, and the example payload shows its field names. For an order created through the e-Stamp routes, do not assume that every event in the list fires, or that the payload carries a stamp id. Confirm coverage for your account with developer support before you depend on any event, and design so that you do not have to.
Webhooks and polling, together
The sturdy design treats an event as a nudge and the certificate route as the truth.
- On an event, verify the signature, de-duplicate on the event id, and enqueue a job to look at the order's stamps. Respond 2xx immediately.
- In the job, read each stamp and its certificate route, and act only on what they return.
- On a schedule, poll every stamp that is not yet stored, using the graduated schedule above, as a backstop for events that never came or came out of order.
- Make everything idempotent. Fetching a certificate you already stored should be a cheap no-op.
With this design a lost event costs you a few minutes of latency, a duplicated event costs nothing, and an event that arrives before the certificate does is simply a poll that finds not_yet_available.
Storing certificates
A certificate is a legal document that may matter for years, and the five-minute link means your copy is the only durable one you control.
| Practice | Why |
|---|---|
| Store the PDF in durable, access-controlled object storage, not on an application server's disk | Disks are lost, and certificates are not replaceable by you |
Name the object from your own ids, such as agreement/{id}/stamp/{stampId}.pdf | Predictable, searchable, not dependent on the platform's links |
Record stampId, certificateNumber, uin, sha256, size, fetchedAt and the order ids in a table | The metadata is what you search, not the file |
| Keep the file immutable and versioned | A re-fetch should never overwrite the original silently |
| Encrypt at rest and restrict who and which services can read it | The document names the parties |
| Back it up and test the restore | A certificate you cannot restore is a certificate you do not have |
| Apply a retention rule that matches your own obligations | Keeping forever is a decision, not a default |
StampMitra's data retention and deletion schedule describes what the platform keeps on its side. Do not treat that as your archive: your records are yours to keep and protect.
Metadata worth recording with every file
The PDF is the document, and the metadata is how you find it, prove it and explain it. Record at least the following next to each stored certificate, in a table you can query.
| Column | Source | Why it matters |
|---|---|---|
stamp_id, platform_order_id, core_order_id | The create response | Join keys to the platform's records |
agreement_id, client_reference | Your own | Which document this certificate belongs to |
certificate_number, uin | The certificate route and the stamp | What the customer or an authority may quote |
state, category, amount | The stamp | What was bought, for audits and reports |
status_at_fetch, verified | The stamp | The state of the stamp when you stored the file |
sha256, size_bytes, storage_key | Your storage step | Integrity and location |
fetched_at, fetched_by_job, request_id | Your worker | Who fetched it, when, and the request that returned the link |
Add a row to an audit table each time the file is read by a person or a service, and each time it is shared. When a customer asks months later for "the stamp for my lease", a single query by agreement id should return the file, its number and its history.
Checking a certificate
A stamp carries identifiers you can record and check. The uin is the unique identification number of the stamp, and the certificateNumber is the number on the certificate. The verified flag on the stamp says that verification completed on the issuing side. A practical routine is to store all three, to show the certificate number to the customer next to the download, and to treat the file as the primary document. If you or your customer need independent assurance, an e-stamp certificate can generally be checked with the issuing authority's own verification facility for the state, using the certificate number, and the right place and procedure are the state's to define, so confirm them with the authority or your counsel.
Do a basic sanity check on every download: the file starts with %PDF, it is of a plausible size, and the certificate number you stored matches the one in the response. If a file fails any check, keep it aside, alert a person and fetch again. Do not hand a customer a file you have not looked at.
Cancelling and replacing a stamp
Stamp-level actions exist for the cases an order-level cancel cannot reach.
| Action | Route | When it works | When it does not |
|---|---|---|---|
| Cancel a stamp | POST /v1/estamp/stamps/:stampId/cancel | While the stamp is in a cancellable state at the issuing side | VERIFIED or already cancelled returns 409 INVALID_STATE |
| Replace a stamp | POST /v1/estamp/stamps/:stampId/replace | After a generation or printing defect, where the stamp is replaceable | A stamp not in a replaceable state returns 409 INVALID_STATE |
Use replace for a defect in the stamp, not for a wrong detail. A wrong party name or amount is a new order. A replace returns the replacement stamp, which has its own id, so record the link between the old and the new stamp and start polling the new one. A cancel does not guarantee an immediate refund, and the ledger is where you will see any credit, as the payment page explains.
The generic document routes
The reference also lists GET /v1/orders/:id/documents, which lists the documents of a generic order, and GET /v1/orders/:id/documents/:documentId/download, which returns a short-lived signed URL. They need the documents.read scope and return a downloadUrl and an expiresAt.
{
"downloadUrl": "https://files.stampmitra.in/signed/doc_00789.pdf?token=abc123",
"expiresAt": "2026-10-29T09:56:07.000Z"
}These belong to the generic order resource, the platform-wide one that works for any entitled service code. An e-Stamp order created through POST /v1/estamp/orders is read and fulfilled through the stamp and certificate routes above. If you also use the generic resource for another service, the same rules apply to its download URLs: they are short-lived, they are bearer tickets, and you should fetch and store immediately. If a download is not yet supported for an order, the platform answers with a clear "not available yet" message instead of a broken link.
Delivering the certificate to your customer
A stored file is not yet a delivered one. How you hand the certificate over is a product decision with a few firm edges.
- Serve it from your own storage, behind your own login. The customer clicks a link in your app, your server checks who they are and streams the file. Never forward the platform's
downloadUrl. - Notify with a link, not an attachment, by default. An email that says "your stamp is ready" and points to your authenticated page keeps the document out of inboxes. If a customer needs the file by email, attach it deliberately and say who it was sent to.
- Give every party access that they should have. A tenant and a landlord are both parties to the instrument. Decide who may see the certificate, and record each download with who, when and from where.
- Show the certificate number beside the download, so that the customer has something to quote if they are ever asked for it.
- Be careful with printouts. Whether a printed copy of an e-stamp certificate is acceptable, and for what, depends on the state and the purpose, so do not tell a customer a printout is enough. Point them to the state's rule or to their adviser.
- Mind the order of events. A stamp is meant to be purchased on or before the date the document is executed. Tell customers to sign after the certificate is ready, and show the certificate date in your signing flow.
- Keep your own links short-lived too. If you issue time-limited links to your own storage, set an expiry that matches your risk, and make "send me a new link" one click.
A good delivery screen is dull: the document, its number, a download button, who else can see it, and one line about what to do next.
Binding the certificate to the signed agreement
The certificate and the agreement are two files that belong together, and your system should make that link explicit.
- Store them under one agreement id, with the stamp id, the certificate number and the
uinon the same record. - Keep the hash of each file so that a later copy can be checked against what you stored.
- Check the parties. Before the agreement goes to signing, compare the names on the certificate with the names in the agreement. A mismatch is far cheaper to fix before signature than after.
- Check the amount and the state. The denomination and the state on the stamp should match what the agreement was priced and drafted for.
- Record the sequence. Keep timestamps for stamp purchased, certificate stored, agreement signed and, where relevant, registered, so that the order of events is demonstrable.
- Decide what a mismatch triggers. A defect in the stamp is a replace. A wrong name or amount is a new order and, if the first stamp is unused, a cancellation. Put that decision in a runbook with a named owner.
If your product also handles signing, the e-sign policy describes how that service is treated. Registration, where a document needs it, is a separate step with its own rules, and your records should leave room for it.
What goes wrong, and what to do
| Situation | Signal | What to do |
|---|---|---|
| The certificate is not there yet | available: false, HTTP 200 | Keep polling on the schedule |
| The download link expired | The download fails with an error | Call the certificate route again for a fresh link |
| The stamp was cancelled | Status CANCELLED | Stop polling, tell the customer, check the ledger |
| A stamp stays in one status for far too long | No change past your alert threshold | Alert internally, then contact developer support with the stamp id |
| The file is not a PDF or looks wrong | Fails your sanity check | Keep it aside, fetch again, escalate if it repeats |
| An event arrives but the certificate is not available | Poll shows not_yet_available | Treat the event as early; the schedule will catch it |
| The same event arrives twice | Same X-Webhook-Event-Id | Ignore the repeat |
| Your endpoint was down for hours | Gaps in events | The polling backstop covers it; check dead-lettered deliveries with support |
A stamp that never seems to arrive
Sometimes the wait is simply long. A short runbook turns an anxious customer into a routine escalation.
- Read the order and the stamp. Note both statuses and
updatedAt. - Compare the elapsed time with your own measured tail for that state, not with a catalogue estimate.
- If the order is still in a pre-placement status, the delay is in review. Check for
NEEDS_INFORMATION, which means the platform is waiting for you. - If the stamp is in
PLACED,ASSIGNED,GENERATINGorVERIFYINGwell past your tail, collect the stamp id, the order ids, the timestamps and a recentrequestId. - Contact developer support with that bundle, and tell the customer what you know and what you have done.
Give the customer a truthful sentence and a next update time. Silence is what turns a delay into a complaint.
Errors and how to react
All errors use { "error": { "code", "message", "requestId" } }.
| Status | Code | When | What to do |
|---|---|---|---|
| 400 | BAD_REQUEST | The organisation is not entitled to e-Stamp | Check entitlement and production access |
| 401 | UNAUTHORIZED | Missing or invalid key | Fix the key |
| 403 | FORBIDDEN | Valid key without estamp.orders.read or estamp.stamps.read | Add the scope |
| 404 | NOT_FOUND | No such order or stamp for your organisation | Check the id and which key you used |
| 409 | CONFLICT | Cancel or replace is not possible in the stamp's current state | Read the status and stop |
| 429 | TOO_MANY_REQUESTS | Rate limit exceeded | Back off and add jitter |
| 502 | INTERNAL_ERROR | Upstream unreachable | Retry with backoff; keep polling on schedule |
A 404 on a stamp deserves a second look at which id you used. The stamp ids come from stamps[].id on the order, and an order id in a stamp path is a classic mix-up.
Sandbox and production
A sandbox key can take an order all the way to a certificate. The order advances by itself (see the order page), its stamps follow it, and the certificate route answers with a real, downloadable file. That file is a sample, and the difference matters, so this chapter is explicit about both what you can exercise and what you still cannot. Every e-Stamp sandbox request counts toward the sandbox limits (10 requests a minute and 200 a day per organisation, and 50 a day per IP address, resetting at midnight IST), so polling an order, a stamp or a certificate spends the same allowance as creating one. Poll at a sensible interval.
Stamps and the certificate in sandbox
A sandbox stamp has its own status that follows the order's clock.
| Order status | Stamp status | Certificate route |
|---|---|---|
CREATED, PAYMENT_PENDING | PLACED | { "available": false, "status": "not_yet_available" } |
PROCESSING, first third | ASSIGNED | not yet available |
PROCESSING, second third | GENERATING | not yet available |
PROCESSING, last third | VERIFYING | not yet available |
ISSUED | VERIFIED, with verified: true and a uin | available: true with a downloadUrl, expiresAt and certificateNumber |
PAYMENT_FAILED, ISSUANCE_FAILED, CANCELLED, EXPIRED | CANCELLED | not yet available, and it stays so |
When the certificate is available, downloadUrl is a short-lived link that works for five minutes and needs no API key header, exactly the situation your download code must handle in production. It serves one small PDF, the same bytes for every stamp, watermarked SANDBOX SAMPLE, NOT A VALID STAMP. Nothing is stored per order. The certificateNumber starts with SBX-, and the uin on the stamp starts with IN-SBX, so neither can be mistaken for a real one. After the five minutes the link answers 404, which gives you a real expired-link case to test. The link itself needs no API key, so it does not use that allowance. It has its own small cap of 60 requests an hour per IP address, and the 61st answers 429 with the code SANDBOX_DOWNLOAD_LIMIT and a Retry-After header. Asking the certificate route for the link does count toward the sandbox limits.
Use that file to prove the whole path: fetch inside the window, check the %PDF bytes, store the file, attach it to your customer's record and send the notification. Do not keep the sample as if it were a certificate, and do not let it reach a customer.
Cancel and replace in sandbox
The rules are the production ones. A stamp can be cancelled until its certificate is delivered, so a VERIFIED stamp answers 409 and a second cancel of a cancelled stamp answers 409. A stamp cannot be replaced while it is only PLACED or after it is CANCELLED. A replacement returns a new stamp with a new id, the old stamp becomes CANCELLED, and the new stamp runs its own short timeline of about fifteen seconds from ASSIGNED to VERIFIED. The order lists the new stamp, not the old one. Cancelling the order cancels all its stamps and credits the sandbox wallets back.
Webhook events in sandbox
If the organisation has a webhook endpoint registered for the sandbox environment, each change sends the documented event to it, signed exactly like a production delivery. A production endpoint never receives a sandbox event.
| When | Events sent |
|---|---|
| The order is created | order.created |
It enters PROCESSING | order.payment_confirmed, then order.fulfilment_started |
It becomes ISSUED | order.fulfilment_completed, then order.document_ready |
| Payment fails, issuance fails or it expires | order.failed, then order.refund_completed |
| It is cancelled | order.cancelled, then order.refund_completed |
PAYMENT_PENDING has no event of its own. The payload carries orderId, reference, status and sandbox: true, the document_ready event adds the stampIds, and a failure adds the failure object. The event id stays the same on every retry, so de-duplicate on it. Events are queued within about ten seconds of the change, so keep polling as the backstop, as the earlier chapters advise.
What the sandbox still cannot tell you
Cover the rest with a small production rehearsal. The sandbox cannot show you the real review wait, because it has no reviewer. It cannot show you a real certificate, with its real bytes and layout, or how long a real delivery takes. It cannot tell you whether a given state will issue, since state availability is a production fact. Before launch, create one low-value production order, watch it all the way to a stored and checked certificate, and keep the fixture it produces. Production needs an approved production access request and funded wallets. The sandbox versus production guide covers the switch.
What to measure
A few numbers tell you whether this step is healthy.
- Time from placement to certificate stored, as a median and a slow tail, by state. This is your honest delivery expectation.
- Stamps older than your alert threshold without a stored certificate. The count should be zero on a good day.
- Download failures, by cause: expired link, bad file, network. A rise in expired links means your fetch is not immediate.
- Poll volume per stamp. A stamp polled hundreds of times means the schedule is too tight.
- Events received, duplicated and out of order, if you use webhooks, so you know how much to trust them.
- Dead-lettered webhook deliveries, which point to endpoint downtime.
Alert on the first two and look at the rest weekly.
Worked example: three stamps, one slow
A broker app placed an order with three lines: a leave and licence agreement, an indemnity bond and an affidavit. The order was placed at nine in the morning, and the app holds three stamp ids with their clientReference values.
At 9:05 the first poll reads each stamp. All three are PLACED. At 9:40 the lease and the affidavit are VERIFYING and the bond is still ASSIGNED. At 10:15 the app receives an order.document_ready event. It verifies the signature, records the event id, and enqueues a job. The job reads all three certificate routes. Two return available: true, and the job downloads each immediately, checks the %PDF header, stores the files with their hashes and certificate numbers, and marks those stamps delivered. The third returns not_yet_available, so the job leaves it on the schedule.
At 10:30 the broker's customer asks where the indemnity bond is. The app shows the lease and the affidavit as ready for download from the app's own storage, and the bond as "in progress, usually within a few hours". At 1:10 in the afternoon the bond's certificate becomes available. The scheduled poll finds it, downloads it within the same call and stores it. The customer is notified once, with all three documents.
Throughout, the app never relied on an event for the truth, never kept a download URL beyond the function that used it, and never told the customer a stamp was ready before a stored, checked file existed.
Testing
| Test | What it proves |
|---|---|
available: false is handled as pending, not as an error | You do not alarm customers early |
available: true triggers an immediate fetch and store | The five-minute link is respected |
| An expired link leads to a fresh certificate call, not a retry of the old URL | You recover correctly |
A file that does not start with %PDF is quarantined | You never deliver garbage |
A null certificateNumber does not break storage | The field is optional |
| A duplicated event does not cause a second fetch | De-duplication works |
| A lost event is covered by the polling schedule | The backstop works |
CANCELLED stops polling and notifies | Terminal states are handled |
| Unknown status strings land in "needs attention" | A new status cannot crash the poller |
| Stored files can be restored from backup | The archive is real |
Common mistakes
- Treating
VERIFIEDas "the file exists". Onlyavailable: truesays so. - Keeping the
downloadUrl. It lives five minutes and is a bearer ticket. - Retrying an expired URL. Ask the certificate route for a new one.
- Treating
not_yet_availableas a failure. It is a normal HTTP 200 state. - Trusting an event over the route. Events are hints.
- Putting the API key in a browser to download. Stream through your own server.
- Storing only the link. Store the file.
- Making
certificateNumberrequired. It can be null. - Using replace for a wrong detail. Create a new order instead.
- Treating the sandbox certificate as the real one. It is the same watermarked sample PDF for every stamp, and it is not a valid stamp.
Where this fits in the flow
Order status and document access is step eight, the last of eight. Before it come the catalogue, the schema, the state, instrument and article lookup, the duty and value calculation, the parties, the order and the payment. The overview guide shows all eight with a rental example, the order flow guide goes deeper on webhooks, and the e-Stamp API reference lists the routes in tabular form.
StampMitra is a private LegalTech platform operated by Bani Global Industries LLP. It is not a government body or a law firm, and nothing here is legal advice. Whether and where your document must be executed or registered is for you or your counsel.
Sources
- StampMitra e-Stamp API reference, order status and document access, checked 2026-10-29.
- StampMitra webhooks reference, checked 2026-10-29.
- StampMitra authentication reference for keys, scopes and the error envelope, checked 2026-10-29.
- StampMitra Verification, e-Stamp and e-Sign Service Terms, sections 11 to 14, checked 2026-10-29.
- StampMitra developer data retention and deletion schedule, checked 2026-10-29.
Frequently asked questions
How do I download the e-stamp certificate through the API?
Call GET /v1/estamp/stamps/:stampId/certificate. When available is true it returns a downloadUrl, expiresAt and certificateNumber. Fetch the URL immediately, stream the PDF into your own storage, check it starts with %PDF and then mark the stamp delivered.
Why does the certificate route return 200 with available false?
The stamp exists but its certificate has not been delivered yet, so the route reports not_yet_available instead of an error. It never falls back to a live call upstream. Keep polling on a graduated schedule and do not alarm the customer.
How long is the certificate download link valid?
Five minutes. It is a presigned URL hosted by StampMitra, never a third-party link. If a download fails or the link expired, call the certificate route again for a fresh one, and never store or email the URL.
Does VERIFIED mean the certificate is ready?
Not by itself. VERIFIED means the stamp completed verification, and the certificate follows. Only available true on the certificate route proves that a file exists to fetch, so treat VERIFIED as very soon.
Can certificateNumber be null?
Yes, even when the certificate is available. Do not make it a required column. Store it when present, record the uin from the stamp as well, and show the certificate number to the customer only when you have it.
Should I use webhooks or polling for e-stamp certificates?
Both. Treat an order.document_ready event as a hint to look, verify its signature, de-duplicate on X-Webhook-Event-Id, then read the certificate route. Keep a graduated poll as a backstop, since events can be late, duplicated or missing for e-Stamp orders.
How often should I poll for a certificate?
Roughly every minute for the first ten minutes after placement, every five minutes up to two hours, every thirty minutes up to a day, then every two hours with an internal alert. Add jitter, back off on 429 and stop on CANCELLED or once stored.
Can I sandbox-test certificate download?
Yes. A sandbox order reaches ISSUED by itself in about thirty seconds, and the certificate route then returns a short-lived downloadUrl to one shared PDF watermarked SANDBOX SAMPLE, NOT A VALID STAMP. It is not a real certificate, so rehearse one low-value production order before launch.
How do I replace a defective e-stamp?
POST /v1/estamp/stamps/:stampId/replace requests a replacement for a defect such as a generation problem and returns the new stamp, which has its own id. A wrong party name or amount is not a defect: cancel and create a new order instead.
Can I cancel a stamp after it is verified?
No. A verified stamp cannot be cancelled and returns 409 INVALID_STATE. Cancellation works only while the stamp is in a cancellable state at the issuing side, and any credit appears in the wallet ledger rather than instantly.
Where should I store the certificate?
In durable, access-controlled object storage under your own naming, with the stamp id, certificate number, uin, hash and fetch time recorded in a table. Keep it immutable, encrypted and backed up, and serve it to customers from your own storage.
What are the generic order document routes?
GET /v1/orders/:id/documents and its download route belong to the platform-wide order resource and need documents.read. E-Stamp orders created through the e-Stamp routes use the stamp and certificate routes instead. Their download links are also short-lived and should be fetched immediately.