StampMitraDevelopers
Livee-Stamp Paper APIStep 6 of 8

e-Stamp order API: validate, create and track orders without creating two

Create an e-Stamp order using the generic orders API with an e-Stamp serviceCode.

POST/v1/ordersScope orders.createAPI fee ₹5 per call
curl -X POST "https://api-b2b.stampmitra.in/v1/orders" \
  -H "Authorization: Bearer $STAMPMITRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "externalOrderId": "ord_ext_123",
    "externalCustomerId": "cust_ext_456",
    "serviceCode": "estamp.instrument.rent_agreement",
    "details": {
      "state": "MH",
      "stampValue": 500,
      "note": "Shape not finalized - illustrative only"
    }
  }'
Example responseJSON
{
  "externalOrderId": "ord_ext_123",
  "createdAt": "2026-10-15T09:41:07.000Z",
  "serviceCode": "estamp.instrument.rent_agreement"
}

Creating an e-stamp order is the one step in the flow where a mistake costs real money and a retry can cost it twice. Everything before it was reading and pricing. Everything after it is waiting. This is the step that commits. It is also the step with the most misunderstandings, because "order created" does not mean what most developers expect: it means a request has been validated, paid for from your balances and put in front of a human reviewer, not that a stamp exists. This page walks through the whole order surface: validating before you create, creating safely with an idempotency key, reading and listing orders, cancelling, and the other order resource in the reference that you should probably not use for stamping. It is step six of the eight-step e-Stamp flow.

It is written for backend developers who will write the order worker, and for the product and operations people who will live with its output. Where behaviour is surprising it is stated plainly, with the reason.

The order routes at a glance

All of these are under the base URL https://api-b2b.stampmitra.in, authenticated with Authorization: Bearer <key> or x-api-key, and gated by the estamp.enabled entitlement.

RoutePurposeScopeRate limitMetered by StampMitra
POST /v1/estamp/orders/validateCheck an order without saving itestamp.orders.validate30 per 60 sNo
POST /v1/estamp/ordersCreate an order (needs Idempotency-Key)estamp.orders.create30 per 60 sPer order, where the per-order fee is enabled
GET /v1/estamp/ordersList your organisation's ordersestamp.orders.readDefaultNo
GET /v1/estamp/orders/:idRead one orderestamp.orders.readDefaultNo
POST /v1/estamp/orders/:id/cancelCancel an orderestamp.orders.cancel30 per 60 sNo
GET /v1/estamp/orders/:id/exportReconciliation exportestamp.orders.readDefaultNo
GET /v1/estamp/stamps/:stampIdRead one stampestamp.stamps.readDefaultNo
POST /v1/estamp/stamps/:stampId/cancel, .../replaceCancel or replace one stampestamp.stamps.cancel, estamp.stamps.replace30 per 60 sNo
GET /v1/estamp/stamps/:stampId/certificateCertificate status and download linkestamp.stamps.readDefaultNo

The stamp and certificate routes belong to the order status and document access page. This page covers the order itself.

POST/v1/orders

Create an order (generic - works for any entitled serviceCode, including e-Stamp)

Request parameters

Request parameters
FieldTypeDescription
AuthorizationrequiredheaderBearer <api-key> (e.g. sk_test_... in sandbox, sk_live_... in production). The x-api-key header is also accepted.
Idempotency-KeyheaderOptional 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).
externalOrderIdrequiredstringYour own reference for this order.
externalCustomerIdrequiredstringYour own reference for the customer.
serviceCoderequiredstringThe entitled service to order (e.g. an estamp.* code).
detailsobjectFree-form service-specific payload (e-Stamp field shape is not finalized).

Response fields

Response fields
FieldType
externalOrderIdstring
createdAtstring
serviceCodestring

GET/v1/orders/:id

Get an order

Request parameters

Request parameters
FieldTypeDescription
AuthorizationrequiredheaderBearer <api-key> (e.g. sk_test_... in sandbox, sk_live_... in production). The x-api-key header is also accepted.

GET/v1/orders/:id/status

Get order status

Request parameters

Request parameters
FieldTypeDescription
AuthorizationrequiredheaderBearer <api-key> (e.g. sk_test_... in sandbox, sk_live_... in production). The x-api-key header is also accepted.

What "created" means

When POST /v1/estamp/orders succeeds, the platform has done four things in order. It has validated your stamp lines against the issuing side's rules. It has priced each line afresh. It has debited the duty from your Stamp Duty Wallet and the service fee from your Service Fee Wallet. And it has written an order record that is waiting for review. It has not placed the order with the issuing vendor. A human operations reviewer confirms placement separately, outside this API, and only then does the order turn into stamps.

This design is deliberate. A silently duplicated or mistaken e-stamp order is a real-money mistake, and a human in the loop is the guard. It has consequences you should design for:

  • An order will sit in a pre-placement status for a while. Do not show it to a customer as "stamped".
  • The status vocabulary at this point is the platform's own: PENDING_REVIEW, READY_TO_PLACE, WARNINGS, NEEDS_INFORMATION, VALIDATION_FAILED and CANCELLED. The issuing vendor's own statuses appear later, on the stamps.
  • You cannot rush review by calling an API. Your product should communicate expected waiting time honestly, and track the actual elapsed time per order.

The request body

Both the validate and create routes take the same body: your own reference for the whole order, and a stamps array of one or more lines.

JSON
{
  "reference": "lease-2026-0412",
  "stamps": [
    {
      "clientReference": "line-001",
      "state": "MH",
      "category": "e_stamp",
      "articleCode": "ART1",
      "denomination": 1000,
      "firstParty": "Vikram Shetty",
      "secondParty": "Anita Rao",
      "purpose": "Leave and licence agreement",
      "district": "PUNE",
      "sro": "SRO-14",
      "propertyArea": "850 sq ft"
    }
  ]
}
FieldRequiredMeaning
referenceNoYour own reference for the whole order. Distinct from the Idempotency-Key header
stampsYesOne or more lines. All lines must share one state
clientReferenceNoYour own id for the line, echoed back on the created order's stamps[]
stateYesState the line is issued in
categoryNoe_stamp (default) or traditional_stamp
articleCodeYesArticle from the state's catalogue
denominationYesThe duty amount in rupees, a positive number
firstPartyYesFirst party to the instrument
secondPartyNoSecond party, where the article uses one
stampDutyPayer, payerPhone, payerGenderNoWho pays the duty, their phone, and MALE, FEMALE or OTHER
purposeNoNature of the instrument
district, sroNoWhen the state needs them
propertyAreaNoWhen the article needs an area
cessAmountNoWhen a cess applies
quantityNoIdentical stamps for the line, default 1
costCentre, businessUnit, linkedDocRefNoYour own tags and a linked document reference

One order is one state. A body whose lines name different states is rejected with a 400 that lists the distinct states found. If you need stamps in two states, create two orders, each with its own idempotency key.

A contract note on party and area fields. The public contract currently takes firstParty and secondParty as plain names and propertyArea as a string. The issuing side models a party as an object with a name and optional address, phone, fatherHusbandName and gender, and a property area as a unit and a value. When a state's flags ask for a first-party address or a father's or husband's name, those properties are where that data belongs. Run a sample through the validate route in sandbox, keep the shape that is accepted as a fixture, and ask developer support which form your account should use. This is the part of the contract most likely to be refined.

Validate first

POST /v1/estamp/orders/validate runs the same validation as creation without saving anything and without charging. It returns HTTP 200 whether the result is READY_TO_PLACE, WARNINGS or NEEDS_INFORMATION, and a 400 only for VALIDATION_FAILED, meaning input that cannot be fixed by adding information. The response has no id, since nothing was persisted.

JSON
{
  "valid": true,
  "reference": "lease-2026-0412",
  "state": "MH",
  "status": "READY_TO_PLACE",
  "isTest": false,
  "counts": { "total": 1, "e_stamp": 1, "traditional_stamp": 0 },
  "errors": [],
  "warnings": [],
  "quote": { "faceValueTotal": 1000, "serviceFeeTotal": 99, "gstOnFee": 17.82, "serviceWalletDebitTotal": 99 },
  "createdAt": "2026-10-29T09:12:03.000Z"
}

valid is false only when a detail is missing (NEEDS_INFORMATION); errors and warnings are lists of { index, message } where index is the zero-based stamp line. quote holds the priced totals in rupees: faceValueTotal is what the Stamp Duty Wallet pays, serviceWalletDebitTotal what the Service Fee Wallet pays (the fee before GST), gstOnFee the GST on the fee. It is null only if pricing was unavailable for that call. The sandbox and production answer with exactly this shape.

Validate resultHTTPWhat it meansWhat to do
READY_TO_PLACE200Nothing wrong foundProceed to create
WARNINGS200Passed with notes, often about pricing or complianceShow the warnings to the user and let them confirm
NEEDS_INFORMATION200A detail is missingCollect it, then validate again
VALIDATION_FAILED400Input is malformed or unfixableFix the input, using the message

Make validate the last step before the confirmation screen. It surfaces field-level problems while the user is still there, and it is free, so there is no reason to skip it.

cURL
curl -s -X POST "$BASE/v1/estamp/orders/validate" \
  -H "Authorization: Bearer $STAMPMITRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "reference": "lease-2026-0412", "stamps": [ { "state": "MH", "articleCode": "ART1", "denomination": 1000, "firstParty": "Vikram Shetty", "secondParty": "Anita Rao" } ] }'

Create, with a mandatory idempotency key

POST /v1/estamp/orders takes the same body plus a required Idempotency-Key header.

cURL
curl -s -X POST "$BASE/v1/estamp/orders" \
  -H "Authorization: Bearer $STAMPMITRA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: lease-2026-0412-v1" \
  -d '{ "reference": "lease-2026-0412", "stamps": [ { "clientReference": "line-001", "state": "MH", "articleCode": "ART1", "denomination": 1000, "firstParty": "Vikram Shetty", "secondParty": "Anita Rao", "purpose": "Leave and licence agreement" } ] }'

HTTP 201 means the order record exists. The header is mandatory on this route and only this route, because an order that spends money must never be retriable by accident.

Idempotency, precisely

The behaviour is simple to state and easy to get wrong.

SituationResult
First request with a new keyThe order is created, and the response is stored against the key
Same key, same body, againThe original response is replayed. No second order, no second debit
Same key, different body422 with the code IDEMPOTENCY_KEY_REUSED. The key was already used with a different request. Nothing is created
No Idempotency-Key header400 with the code IDEMPOTENCY_KEY_REQUIRED. Nothing is created
Same key while the first request is still being processed409 with the code IDEMPOTENCY_IN_PROGRESS and a Retry-After header. Wait that long and resend the identical request: you get the first request's response

A key is scoped to your organisation, to this route and to the environment, so a sandbox key never matches a production one and the same string on another route is a different key. A key is kept for 24 hours: inside that window it replays, after it a repeat runs as a new request. A key must be 1 to 255 printable characters, otherwise the answer is 400 IDEMPOTENCY_KEY_INVALID. A replay returns the same status and body as the first answer.

Four rules make this work in practice.

  1. Derive the key from something stable that you own. An agreement id plus a version works: lease-2026-0412-v1. A random value generated per attempt defeats the purpose, since a retry would generate a new one.
  2. Change the key when you change the body. If the user corrects a field and you resubmit, the body is different, so use -v2. Reusing the key gets a 422 IDEMPOTENCY_KEY_REUSED.
  3. Persist the key before you send. Write it to your database, send the request, then record the outcome. After a crash you can see what was in flight.
  4. Retry with the same key and the same body. After a timeout, send the identical request. You either get the original response or the order is created now, and either way you do not get two.

Idempotency also protects the money. The wallet debit is keyed to the order so that a duplicate submission cannot debit twice, and if a request failed after debiting, the debits are credited back. For the money rules, see the payment page.

JavaScript
// Node 18+; server side only
import { randomUUID } from "node:crypto";

const BASE = "https://api-b2b.stampmitra.in";
const headers = { Authorization: `Bearer ${process.env.STAMPMITRA_API_KEY}`, "Content-Type": "application/json" };
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

export async function createEstampOrder({ agreementId, version, reference, stamps }) {
  const key = `${agreementId}-v${version}`;               // stable, derived from our own ids
  const body = JSON.stringify({ reference, stamps });
  for (let attempt = 0; attempt < 4; attempt++) {
    let res;
    try {
      res = await fetch(`${BASE}/v1/estamp/orders`, { method: "POST", headers: { ...headers, "Idempotency-Key": key }, body });
    } catch (e) {                                          // transport failure: unknown outcome, same key, same body
      await sleep(1000 * 2 ** attempt); continue;
    }
    const out = await res.json();
    if (res.status === 201) return { ok: true, order: out };
    if (res.status === 409 && out.error?.code === "IDEMPOTENCY_IN_PROGRESS") { await sleep(1000 * Number(res.headers.get("retry-after") ?? 1)); continue; }  // first attempt still running
    if (res.status === 409 || res.status === 400 || res.status === 422) return { ok: false, status: res.status, message: out.error.message };  // do not retry
    if (res.status === 402) return { ok: false, status: 402, message: "check wallet balances" };
    if (res.status === 429 || res.status >= 500) { await sleep(1000 * 2 ** attempt); continue; }   // same key replays safely
    throw Object.assign(new Error(out.error?.message), { status: res.status, requestId: out.error?.requestId });
  }
  return { ok: false, status: 0, message: "unknown outcome: read the order list before retrying" };
}
Python
import os, time, requests

BASE = "https://api-b2b.stampmitra.in"
H = {"Authorization": f"Bearer {os.environ['STAMPMITRA_API_KEY']}"}

def create_estamp_order(agreement_id: str, version: int, reference: str, stamps: list) -> dict:
    key = f"{agreement_id}-v{version}"                       # stable, derived from our own ids
    body = {"reference": reference, "stamps": stamps}
    for attempt in range(4):
        try:
            r = requests.post(f"{BASE}/v1/estamp/orders", json=body,
                              headers={**H, "Idempotency-Key": key}, timeout=30)
        except (requests.ConnectionError, requests.Timeout):
            time.sleep(2 ** attempt); continue                # unknown outcome: same key, same body
        data = r.json()
        if r.status_code == 201:
            return {"ok": True, "order": data}
        if r.status_code == 409 and data["error"]["code"] == "IDEMPOTENCY_IN_PROGRESS":
            time.sleep(int(r.headers.get("Retry-After", 1))); continue   # first attempt still running
        if r.status_code in (400, 409, 422):
            return {"ok": False, "status": r.status_code, "message": data["error"]["message"]}
        if r.status_code == 402:
            return {"ok": False, "status": 402, "message": "check wallet balances"}
        if r.status_code == 429 or r.status_code >= 500:
            time.sleep(2 ** attempt); continue
        r.raise_for_status()
    return {"ok": False, "status": 0, "message": "unknown outcome: list orders by reference before retrying"}

After an unknown outcome, such as a timeout followed by repeated failures, do not guess. List your orders and look for your reference before you decide.

What the response contains

The create response is the order, with its stamps.

JSON
{
  "id": "estord_9c1f2a3b",
  "orderId": "6a0e2b9a-5f1d-4c63-9c2e-0d4e7b1f3a55",
  "reference": "lease-2026-0412",
  "state": "MH",
  "status": "PENDING_REVIEW",
  "isTest": false,
  "stampCount": 1,
  "stamps": [{ "id": "eststamp_4f21ab", "clientReference": "line-001" }],
  "errors": [],
  "warnings": [],
  "warningsAcknowledged": false,
  "createdAt": "2026-10-29T09:12:03.000Z",
  "updatedAt": "2026-10-29T09:12:03.000Z"
}
FieldWhat it tells you
idThe order id used in GET /v1/estamp/orders/:id and the cancel and export routes
orderIdThe Core order id. The parties route takes this one
referenceYour own order-level reference, echoed
stateThe state of the order
statusThe pre-placement status
isTestWhether the order was created in the sandbox environment
stampCount, stampsThe number of lines and, for each, a stamp id and your clientReference
errors, warnings, warningsAcknowledgedValidation findings on the order and whether warnings have been acknowledged
createdAt, updatedAtTimestamps

Store id, orderId, each stamp id, your reference and each clientReference together. They are the join keys between your records and the platform's. The stamps[].id values are what you use later to read a stamp and fetch its certificate.

The create response can carry errors and warnings arrays. A WARNINGS status means the order was created and is flagged for attention. The public contract does not document a request field for acknowledging warnings, so treat warnings as something the user reads at the validate step before creating. If a 400 about unacknowledged warnings ever appears, note the requestId and ask developer support how your account should proceed.

What happens to money at creation

Order creation is when the statutory duty and the service fees are paid for. Before any order record is written, the platform debits the duty from your Stamp Duty Wallet and the service fee, net of GST, from your Service Fee Wallet. If the second debit fails, the first is reversed. If the order cannot be created after the debits, they are credited back. A shortfall in either balance means the order is refused and nothing is created. In that case the answer is a 402 PAYMENT_REQUIRED whose message says which wallet is short, the Stamp Duty Wallet or the Service Fee Wallet, so you know which one to top up.

After you top up, retry with the same key and body. Because nothing was created, the retry runs cleanly. The payment page covers the wallets, top-ups and ledgers.

Two other points. The price used is the one computed at creation, not the one from your earlier quote, so a catalogue or pricing change in between shows up in the order. And separately from the duty and fee wallets, a per-order StampMitra API fee can apply to order creation where it is enabled for your account, charged once per created order to your API credit wallet and never for a failed creation. Check your plan and the pricing page, where the API fee for the e-Stamp surface is ₹5 per charged call on pay-as-you-go before GST.

Sandbox

Free

Build and test with a sandbox key.

Production API fee

₹5 / call

Pay-as-you-go per successful call, lower on Growth and Scale. Excludes 18% GST. State procurement fee and stamp duty are quoted per order. Full pricing

Access scope

orders.create

Your API key needs this scope to call the endpoint.

Multi-line orders

An order can contain several lines, all in one state, which is how you buy a rental agreement stamp and an indemnity stamp in one go. Each line becomes its own stamp with its own id.

  • One idempotency key covers the whole order. The key protects the order, not each line.
  • Give every line a clientReference. It is echoed back in stamps[], which is how you match platform stamps to your documents.
  • Pricing is per line, with the whole order's paper count in mind. Where pricing depends on how many papers an order has, the total can differ from the sum of single-line quotes.
  • Lines are independent after placement. One stamp can be cancelled or replaced without touching the others.
  • Use quantity for identical stamps. If you need three identical stamps for one document type, set quantity: 3 on a line instead of repeating it.

If one line has a problem, the validate route reports it before you create. Prefer fixing the line over splitting the order, unless the lines belong to different states.

When one line of several is the problem

A multi-line body is validated as a whole. If a single line is missing a detail or fails a rule, the order's status reflects it, and the message names the line by its position or its clientReference, which is one more reason to set that field on every line. Your handling has three options. Fix the line and validate again before creating, which is the best case and the reason validate exists. If the order was already created and sits in NEEDS_INFORMATION, supply the missing detail where the route allows it and read the order again. Or, if the line is simply wrong, cancel the order before placement and recreate it with a corrected body and a new key. Avoid splitting a healthy multi-line order into several single-line orders just to isolate one bad line, unless the lines are in different states, since the whole-order paper count can affect pricing.

Statuses, and how to model them

Two vocabularies exist and they describe different moments. Store both and do not merge them.

WhereValueMeaning
OrderPENDING_REVIEWCreated, waiting for a reviewer
OrderREADY_TO_PLACEValidated, ready for placement
OrderWARNINGSCreated with warnings
OrderNEEDS_INFORMATIONMore detail needed
OrderVALIDATION_FAILEDCould not be validated
OrderCANCELLEDCancelled
StampPLACED, ASSIGNED, GENERATING, VERIFYING, VERIFIEDThe issuing side's progress, once placed
StampCANCELLEDCancelled at the issuing side

A sound internal model has your own states on top: draft, validated, submitted, in_review, needs_info, placed, stamped, failed and cancelled, derived from the platform's statuses. Map unknown strings to a "needs attention" state instead of throwing, and keep the raw platform value in a column, so an unexpected status is visible and does not break your poller.

Listing, reading and exporting

GET /v1/estamp/orders lists your organisation's orders, and only yours, newest first. The response has items, an array of orders, and nextCursor, a string to pass back as the cursor query parameter for the next page and null on the last page. Use limit (1 to 100, default 20) to size a page. For clients that read the earlier fields, data repeats items and pagination carries page, limit and total; total is exact on the last page and null while more pages follow, and page is honoured for the first 20 pages. The sandbox and production answer with exactly this shape.

JSON
{ "items": [ { "id": "estord_9c1f2a3b", "status": "PENDING_REVIEW" } ], "nextCursor": "estord_7d3e1c20", "data": [ { "id": "estord_9c1f2a3b", "status": "PENDING_REVIEW" } ], "pagination": { "page": 1, "limit": 20, "total": null } }
cURL
curl -s "$BASE/v1/estamp/orders?limit=20" -H "Authorization: Bearer $STAMPMITRA_API_KEY"
curl -s "$BASE/v1/estamp/orders?limit=20&cursor=estord_7d3e1c20" -H "Authorization: Bearer $STAMPMITRA_API_KEY"
curl -s "$BASE/v1/estamp/orders/estord_9c1f2a3b" -H "Authorization: Bearer $STAMPMITRA_API_KEY"
curl -s "$BASE/v1/estamp/orders/estord_9c1f2a3b/export" -H "Authorization: Bearer $STAMPMITRA_API_KEY"

The list is the tool for resolving unknown outcomes, since your reference appears on each order. GET /v1/estamp/orders/:id returns one order, with a 404 if it does not belong to your organisation. The export route returns a small CSV for reconciliation, as a filename and a csv string with the columns id, orderId, status, state, articleCode, denomination, providerRef, createdAt and updatedAt. It describes the order's first stamp line, so for a multi-line order use it as a status summary, not as a full ledger.

Cancelling

POST /v1/estamp/orders/:id/cancel behaves differently depending on how far the order has come.

Order situationWhat the call does
Not yet placedThe order is cancelled directly and returned as CANCELLED
Placed with the issuing sideA cancellation request is sent to the vendor, and the order changes when the vendor confirms. The immediate response may still show the old status
Completed, or already cancelled409 INVALID_STATE

So cancellation is clean before placement and asynchronous after it. Do not assume that a 200 means the money is back, and do not mark your own record as cancelled until the platform's record says so. Single stamps can be cancelled with POST /v1/estamp/stamps/:stampId/cancel while they are in a cancellable vendor state, and a defective stamp can be replaced with .../replace. A verified stamp cannot be cancelled.

Cancel and recreate, or correct?

Both paths exist, and the choice depends on what is wrong. A contact detail that sits on the party record, such as a mobile number, an email or an address, is corrected through the parties route, and no new order is needed. A fact on the stamp line itself, such as the second party's name, the article, the amount, the property area or the payer, cannot be edited in place. For those, cancel the order while it is still before placement and create a new one. Choose a new idempotency key for the new body, keep the old order's ids in your audit table, and tell the customer that the first request was withdrawn. If the order has already been placed, cancelling becomes a request to the issuing side that may not succeed, and a stamp that has been verified cannot be cancelled at all. Ask for a replacement only for a defect, not for a wrong detail.

Building the order worker as a small durable state machine

Order creation is a good place to be boring. The safest worker is a small state machine whose every step is written down before it happens, so that a crash at any point can be resumed without guessing.

Your stateEntered whenNext actionIf the process dies here
draftThe user is still editingNoneNothing was sent
validatedValidate returned READY_TO_PLACE or accepted WARNINGSWait for confirmationNothing was sent
submittingYou persisted the key and body and are about to sendSend the create requestResend the same key and body
submittedYou received a 201 and stored the idsPoll order statusRead the order by id
in_reviewThe order is in a pre-placement statusPoll with backoffPoll again
needs_infoThe status is NEEDS_INFORMATION or VALIDATION_FAILEDAsk the user, correct, or recreatePick up from the queue
placedStamps exist and are progressingPoll stampsPoll again
stampedA certificate is available and savedNotify the userNothing to repeat
cancelled, failedTerminalNoneNothing to repeat

The critical row is submitting. Persist the idempotency key and the exact body before you send, in the same transaction that moves the state. If the process dies after sending and before recording the response, the next run finds a record in submitting, resends the identical request, and gets either the original response or a fresh creation. No guesswork and no duplicate. This is the same outbox idea used for payments and emails, applied to stamps.

Run the worker with a small concurrency limit, since the create route allows 30 requests per 60 seconds and a burst is more likely to cause trouble than to save time. Process one order per key at a time, and keep the polling job separate from the submitting job so that a slow poll never delays a send. Make each handler safe to run twice, because at-least-once delivery from a queue will eventually run one twice.

Living with the review wait

Every order spends time in review, and your customers feel it. Treat the wait as a product feature to design, not as latency to hide.

  • Measure it. Record the time from submitted to placed for each order, and watch the median and the slow tail. Your own numbers are better than any catalogue estimate.
  • Say what you know. "Your stamp request is with our team and usually moves within about a working day" is honest. "Instant" is not.
  • Notify on change, not on a timer. Message the user when the order moves to needing information, when it is placed, and when the certificate is ready. Silence between those is fine.
  • Set an escalation threshold. If an order is still in review after several times your usual wait, create an internal task and, if needed, contact developer support with the order references.
  • Never promise a stamp time you cannot control. A stamp is needed before execution of the document, so tell the user to leave room, and show them where the order stands.

A status page for your own customers, driven by your stored platform status, answers most "where is my stamp" questions before they become tickets.

An audit trail for what you committed

Creating an order commits money and states, on a document that may matter for years. Record enough to reconstruct the decision.

  1. What the user confirmed: the state, the article, the amount, the parties, and the exact text of any warning they accepted.
  2. Who confirmed it, whether the customer or a member of your team, and when.
  3. What you sent: the idempotency key and a hash or copy of the body.
  4. What came back: the full response with its requestId, and every later status change with a timestamp.
  5. Which rules were in force: the article mapping version, the catalogue version and the pricing version where you have them.
  6. What changed afterwards: corrections, cancellations and replacements, each linked to the original order.

For higher-value or unusual documents, add a second approver before create. The article and the duty are decisions with legal weight, and a two-person rule is cheap. Restrict who can see party details, set a retention period that matches your own obligations, and keep the audit table append-only so that history cannot be edited. These records are what answer a question from a customer, an auditor or an authority months later, and what let you explain a cancelled order in one query.

Errors and how to react

All errors use { "error": { "code", "message", "requestId" } }. The code is derived from the HTTP status, with one exception noted in the table, and the message carries the detail.

StatusCodeWhenWhat to do
400IDEMPOTENCY_KEY_REQUIREDMissing Idempotency-Key on order creation. Nothing was createdSend a key and resend
400BAD_REQUESTValidation failure, lines in different states, or the organisation not entitledRead the message, fix and resend
401UNAUTHORIZEDMissing or invalid keyFix the key
402PAYMENT_REQUIREDThe Stamp Duty Wallet or the Service Fee Wallet cannot cover the order (the message names which), or, where the per-order API fee is enabled, the API credit wallet cannot cover it. Nothing was created and nothing was chargedTop up the wallet the message names and retry with the same key
403FORBIDDENValid key without the scopeAdd estamp.orders.create or the relevant scope
404NOT_FOUNDNo such order for your organisationCheck the id, and which key you used
409IDEMPOTENCY_IN_PROGRESSA request with this key is still being processed. Retry-After says when to retryResend the identical request after the delay
409CONFLICTThe action is not possible in the current state, for example cancelling an order that is already placedRead the status
422IDEMPOTENCY_KEY_REUSEDThe key was already used with a different request. Nothing was createdUse a new key for a new body
409SERVICE_UNAVAILABLEe-Stamp ordering is paused. The message is customer-facingRetry later with backoff and tell the user
429TOO_MANY_REQUESTSMore than 30 requests in 60 seconds. The response carries Retry-AfterBack off for that long
502INTERNAL_ERRORUpstream unreachable, or an unmapped upstream failureRetry with the same key
503INTERNAL_ERRORA dependency is temporarily unavailable. The response carries Retry-AfterRetry after that delay

Branch on the status first and use the message for display. Log the requestId on every failure.

The generic order route, and why not to use it

The reference also lists POST /v1/orders, the platform-wide order resource that works for any entitled service code, including e-Stamp ones. It takes externalOrderId, externalCustomerId, serviceCode and a free-form details object. For stamping it is a poor fit, for plain reasons. It has no typed state, article or denomination fields, so nothing validates what you put in details. It has no pre-creation validate route, no multi-line support and no stamp-level cancel or certificate routes. Its idempotency key is optional where the e-Stamp route's is mandatory. The e-Stamp order routes exist because stamping needs all of those. If you have a reason to use the generic route, for example an existing integration for another service code, ask developer support first and keep it out of your stamping path.

Sandbox and production

A sandbox key runs the order routes on a simulation. Nothing reaches the issuing side, no real wallet is touched and nothing is charged, so you can build and test the whole order path for free before you switch to a production key. This page covers the order. The order status and document access page covers stamps and the certificate, and the payment page covers the fake wallets that the simulation debits.

A lifecycle that moves by itself

A sandbox order advances with the time since it was created, so polling GET /v1/estamp/orders/:id shows progress with no action from you.

StatusDefault time after creationWhat it stands for
CREATED0 secondsThe order exists and the sandbox wallets have been debited
PAYMENT_PENDING5 secondsWaiting for the simulated payment
PROCESSING15 secondsThe simulated issuing service is generating the stamps
ISSUED30 secondsThe stamps are VERIFIED and the certificate can be fetched

Those are the defaults and an environment can shorten them, so read sandbox.nextStatusAt on the order instead of hard-coding the times. A sandbox order body has the same fields as a production one, plus a sandbox object with the scenario, statusChangedAt and nextStatusAt, and a failure object with a code and a message when the order ended badly. Ids look like estord_sbx_ and eststamp_sbx_ followed by ten characters, and isTest is true.

These statuses belong to the sandbox. A production order uses the platform's pre-placement vocabulary described earlier on this page, waits for a human reviewer and does not advance by itself. Write your status mapping so that it accepts both sets, and do not treat the sandbox timing as a promise about production.

Special test inputs

To force an outcome, put one of these markers in the order reference, or in the clientReference of any stamp line. Matching ignores case and surrounding spaces, and the whole value must be the marker.

MarkerWhat happens
SBX-PAYMENT-FAILEDThe order reaches PAYMENT_PENDING, then ends PAYMENT_FAILED when it would have started processing. The sandbox debit is credited back
SBX-ISSUANCE-FAILEDThe order reaches PROCESSING, then ends ISSUANCE_FAILED with the failure code ISSUANCE_FAILED, as if the issuing service had returned an error. Credited back
SBX-CANCELLEDA reviewer cancels the order when it would have started processing, so it ends CANCELLED. Credited back
SBX-EXPIREDThe order is never completed and ends EXPIRED. Credited back
SBX-DUPLICATEPOST /v1/estamp/orders answers 409 and creates nothing. The validate route answers WARNINGS instead
SBX-WARNINGThe validate route answers WARNINGS with a pricing note. Create proceeds normally

You also get these without any marker: a 400 for an amount the article does not allow, a 400 for a state that needs a district and an SRO (Karnataka, KA), a 400 for an unavailable state (UP), a 402 when a sandbox wallet is too low, a 422 IDEMPOTENCY_KEY_REUSED for a reused idempotency key with another body and a 429 at the open-order limit. The state, instrument and article page lists the sandbox catalogue.

What matches production and what does not

  • Validation. The body validators are the production ones, so a malformed body gets the same status and message in both environments. The catalogue checks (unknown state or article, denomination, district, SRO) use the production wording against the smaller sandbox catalogue.
  • Idempotency. The same key and the same body replays the original response, with no second order and no second debit. A different body under the same key is rejected with 422 and the code IDEMPOTENCY_KEY_REUSED, and a request that arrives while the first is still running with 409 and IDEMPOTENCY_IN_PROGRESS, exactly as in production. A sandbox key replays for as long as the sandbox order is stored.
  • Money. Creating an order debits the sandbox Stamp Duty Wallet and Service Fee Wallet, a failed or cancelled order credits them back once, and a short balance is a 402. See the payment page.
  • Events. Each change of status sends the matching order.* webhook to the organisation's sandbox endpoints only. See the order status and document access page.
  • Limits. An organisation can have 50 open sandbox orders at once. The next create answers 429 with the code SANDBOX_ESTAMP_ORDER_LIMIT and creates nothing. Open orders finish by themselves in about thirty seconds, or you can cancel them. Sandbox orders and their stamps are deleted after 30 days. Every sandbox request on the order routes also counts toward the sandbox call limits (10 requests a minute and 200 a day per organisation, and 50 a day per IP address, resetting at midnight IST): validate, create, list, get, cancel and export, and every poll.
  • The review step. Production orders wait for a person. The sandbox has none, which is the main reason its timing tells you nothing about how long a real order takes.

Moving to production

Production needs an approved production access request and funded wallets. Before launch, rehearse one low-value production order from end to end, because that is the only way to see the real review wait and the real certificate. The sandbox versus production guide covers the switch.

Reconciling orders with your records

Keep a table that ties your world to the platform's, and check it daily.

Your columnSourcePurpose
agreement_id, versionYour ownWhat you were stamping
idempotency_keyYour ownThe key sent for this attempt
platform_order_idResponse idReading, cancelling, exporting
core_order_idResponse orderIdThe parties route
stamp_id, client_referenceResponse stamps[]Reading stamps and certificates
platform_status, status_changed_atPollsYour own timeline
submitted_at, quote_total, quote_request_idYour ownWhat the user saw

A daily job lists orders for the last few days and compares them with this table. It flags orders the platform has and you do not (an unknown outcome you never resolved), orders you have and the platform does not (a failed create you marked as done), and statuses that have not moved for longer than your expectation. Most disputes end quickly when these three lists are empty.

Worked example: three lines and a retry

A broker app stamps a leave and licence agreement together with an indemnity bond and an affidavit for one customer, all in one state. It sends three lines with clientReference values lease, indemnity and affidavit. The validate call returns WARNINGS with a note on one line, which the app shows to the customer, who confirms.

The app persists the key broker-7731-v1 and sends the create request. The connection drops before the response arrives, and the client sees a timeout. The app does not know whether the order exists. It retries with the same key and the same body. The platform replays the original response, which shows one order with three stamps. There is one order and one debit, not two.

Later the customer corrects the licensee's name on the lease line. The app has no way to edit the stamp line, and the order is still PENDING_REVIEW, so it cancels the order, which succeeds directly, builds a new body with the corrected line, and sends it with the key broker-7731-v2. The first order shows CANCELLED, the second is created, and the audit table lists both with their request ids. The clientReference values lease, indemnity and affidavit match the three stamps on the new order to the app's documents.

The daily reconciliation job finds the first order cancelled and the second in review, and nothing it cannot account for.

Testing

TestWhat it proves
Validate returns each of the four outcomes for crafted bodiesYour UI handles all of them
Create without the header returns 400 and sends nothing twiceYou never omit the key
Same key and body twice returns the same orderReplay works
Same key with a changed body returns 422 IDEMPOTENCY_KEY_REUSEDYou use a new key for a new body
Mixed-state lines are rejected before you sendYou prevent a predictable 400
A timeout then retry produces one orderRetries are safe
A short wallet returns 402 and the message names the walletYou top up the right wallet
Cancel before placement succeeds, after placement is treated as asynchronousYou handle both
Unknown status strings land in "needs attention"A new status cannot crash the poller

Common mistakes

  • Treating 201 as "stamped". It means the order is waiting for review.
  • Random idempotency keys. A retry then creates a second order.
  • Reusing a key after changing the body. You get a 422 IDEMPOTENCY_KEY_REUSED.
  • Concurrent requests with one key. The second gets a 409 IDEMPOTENCY_IN_PROGRESS with Retry-After. Wait, then resend the identical request.
  • Skipping validate. It is free and catches most problems.
  • Mixed states in one order. One order is one state.
  • Using the generic /v1/orders route for stamping. It lacks the typed fields and the safeguards.
  • Marking an order cancelled on a 200 after placement. The vendor confirms later.
  • Ignoring clientReference. It is how you match stamps to documents.

Where this fits in the flow

Order creation is step six of eight. Before it come the catalogue, the schema, the state, instrument and article lookup, the duty and value calculation and the parties. After it come the payment and the order status and document access. The overview guide shows all eight with a rental example, the order flow guide goes deeper on webhooks and retries, 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. The article, the duty and the document are your responsibility, as the service terms explain.

Sources

Frequently asked questions

What does the e-Stamp order API do when I create an order?

It validates your stamp lines, prices each line afresh, debits the duty from the Stamp Duty Wallet and the service fee from the Service Fee Wallet, and writes an order that waits for human review. It does not place the order with the issuing vendor by itself.

Is the Idempotency-Key header required?

Yes, on POST /v1/estamp/orders only. Without it you get a 400. The same key with the same body replays the original response, and the same key with a different body returns 422 IDEMPOTENCY_KEY_REUSED, so a retry can never create a second order. A missing header is 400 IDEMPOTENCY_KEY_REQUIRED, and a second request while the first is still running is 409 IDEMPOTENCY_IN_PROGRESS with Retry-After.

How should I build an idempotency key?

Derive it from stable ids you own, such as the agreement id plus a version. Persist it before sending, resend the identical request after a timeout, and use a new key when you change the body, since reusing it returns 422 IDEMPOTENCY_KEY_REUSED.

Why is my new order PENDING_REVIEW and not a certificate?

Order creation stops at validation and review. A human operations reviewer confirms placement with the issuing vendor separately, so a new order starts in a pre-placement status and stamps and certificates appear only after placement.

Should I call validate before create?

Yes. POST /v1/estamp/orders/validate runs the same checks without saving or charging, and returns 200 for READY_TO_PLACE, WARNINGS or NEEDS_INFORMATION and 400 only for VALIDATION_FAILED. Use it to show problems while the user is still on the form.

Can one order contain stamps for different states?

No. One order is one state, and a body with lines in different states is rejected with a 400 listing the states found. Create one order per state, each with its own idempotency key.

What is the difference between id and orderId in the response?

id identifies the order in the order routes such as get, cancel and export. orderId is the Core order id that the parties route takes. Store both along with each stamps[].id and your clientReference values.

How do I cancel an e-stamp order?

POST /v1/estamp/orders/:id/cancel cancels directly before placement. After placement it sends a cancellation request that the vendor confirms later, and a completed order returns 409 INVALID_STATE. Do not mark your record cancelled until the platform's record says so.

What if my create request times out?

Retry the identical request with the same Idempotency-Key. You either receive the original response or the order is created now, never two. If outcomes stay unknown, list your orders and look for your reference before deciding.

What do I get when my wallet is short?

A 402 PAYMENT_REQUIRED whose message says whether the Stamp Duty Wallet or the Service Fee Wallet is short. Nothing is created or charged. Top up that wallet and retry with the same key.

Should I use POST /v1/orders for stamping?

No. The generic order route has no typed state, article or denomination fields, no validate route, no multi-line support and an optional idempotency key. The e-Stamp order routes exist because stamping needs all of those.

Can a multi-line order cost more than the sum of its parts?

It can differ where pricing depends on the number of papers in an order, because each line is priced with the whole order's paper count in mind. Treat the sum of single quotes as an estimate and the order's pricing as the figure that counts.

Build with AI

Integrate e-Stamp Order Creation with one prompt.

Pick your AI tool and copy a prompt written for this API. It already has the endpoints, fields and errors.

Claude prompt · e-Stamp Order Creation · 6,316 charactersOpen Claude ↗
I'm using Claude to build this.

Integrate the StampMitra API (Indian identity verification and e-Stamp Paper) into my app.

API facts (source of truth: https://developer.stampmitra.in/llms.txt)
- Base URL: https://api-b2b.stampmitra.in
- Auth: send "Authorization: Bearer <key>" (or "x-api-key: <key>") on every request
- Requests and responses are JSON. Send Content-Type: application/json on POST.
- Use a SANDBOX key (sk_test_...) while building. Read it from the environment variable STAMPMITRA_API_KEY.
- Never hard-code the key, never expose it to the browser, never log it.
- Call StampMitra only from server-side code. The UI calls my own backend route.

How to build it
- First inspect my project: language, framework, package manager, HTTP client, test runner and folder conventions. Follow them. If the project is empty, ask which stack I want before writing code.
- The official StampMitra SDKs (Node.js, Python, PHP, Java, Go, .NET, Ruby) are pre-release 0.1.0 and not yet published to npm, PyPI, Packagist, Maven Central, the Go module proxy, NuGet or RubyGems, so do not run an install command for them. Call the REST API over HTTPS with the HTTP client my project already uses. Do not install or invent a StampMitra package.
- Put every StampMitra call in ONE small client module. It adds the auth header, applies a 15 second timeout and turns error responses into a typed error with status, code, message and requestId.
- Add STAMPMITRA_API_KEY to .env.example with a placeholder (sk_test_xxx). Fail fast at startup with a clear message if it is missing. Never commit real keys.

Error handling (every error body is { error: { code, message, requestId } })
- 400 BAD_REQUEST: invalid input. Show a field-level message. Do not retry.
- 401 UNAUTHORIZED: key missing or invalid. This is my configuration problem, not the end user's. Show a generic "service unavailable" message, log the requestId, do not retry.
- 402 PAYMENT_REQUIRED: not enough wallet balance (production). Surface it to me as an operational alert, not to the end user.
- 403 FORBIDDEN: the key lacks the required scope or the service is not enabled. Say which scope the endpoint needs.
- 404 NOT_FOUND: wrong id or path. Do not retry.
- 429 TOO_MANY_REQUESTS (or, on a sandbox key, SANDBOX_RATE_LIMIT, SANDBOX_DAILY_LIMIT, SANDBOX_IP_LIMIT): rate limit, or the sandbox limits of 10 requests a minute and 200 a day per organisation. Retry at most 3 times with exponential backoff and jitter (honour Retry-After if present), then show a friendly "try again shortly" message.
- 5xx / 502 / network timeout: retry reads (GET) up to 2 times. For POST calls retry at most once, then show a friendly message.
- Log requestId and referenceId with every failure. Never log the API key, a full PAN, bank account number or whole response bodies.

TASK: Integrate the StampMitra "e-Stamp Order Creation" API
Create an e-Stamp order using the generic orders API with an e-Stamp serviceCode.

ENDPOINT: POST /v1/orders
- Create an order (generic - works for any entitled serviceCode, including e-Stamp)
- Required scope: orders.create
- Parameters:
  - Idempotency-Key (header, optional): 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).
  - externalOrderId (string, required): Your own reference for this order.
  - externalCustomerId (string, required): Your own reference for the customer.
  - serviceCode (string, required): The entitled service to order (e.g. an estamp.* code).
  - details (object, optional): Free-form service-specific payload (e-Stamp field shape is not finalized).
- Example request body: {"externalOrderId":"ord_ext_123","externalCustomerId":"cust_ext_456","serviceCode":"estamp.instrument.rent_agreement","details":{"state":"MH","stampValue":500,"note":"Shape not finalized - illustrative only"}}
- Response fields: externalOrderId, createdAt, serviceCode
- Example response: {"externalOrderId":"ord_ext_123","createdAt":"2026-10-15T09:41:07.000Z","serviceCode":"estamp.instrument.rent_agreement"}

ENDPOINT: GET /v1/orders/:id
- Get an order
- Required scope: orders.read

ENDPOINT: GET /v1/orders/:id/status
- Get order status
- Required scope: orders.read

Rules for this e-Stamp step
- This is one step of the e-Stamp order flow: services -> state/instrument/article -> schema -> duty -> order -> parties -> payment -> status -> documents.
- Build the form from the schema endpoint and do not invent e-Stamp fields.
- Send an Idempotency-Key header on order creation, store the order id, and make the flow resumable.
- Poll order status with backoff until a final status. Download documents through my backend, never from the browser with the key.
- If an endpoint returns 404 or is not enabled for my key, stop and ask me rather than guessing.

Test in Sandbox
- A successful call, a validation failure (expect 400), a missing or wrong key (expect 401) and the 429 / 5xx retry path.

How I want you to work:
1. Before writing code, list the files you will create or change and the plan in 5-8 bullets. Then implement without pausing for approval.
2. If the StampMitra MCP server (@stampmitra/mcp-server) is connected, use it to run real sandbox calls and check the response shape before coding against it.
3. Write tests for the API client module and the validation (mock the HTTP layer).
4. At the end, summarise what you changed, how to run it and what I must do manually (add the key, restart the server).

Acceptance checklist:
- Works end to end in Sandbox with the real response fields (no mocked data in the final path)
- No secrets in client code, logs, URLs or git
- Clear loading, empty and error states, including 400, 401, 402, 403, 429 and 5xx
- referenceId (and requestId on failures) is stored or logged for audit
- Inputs are validated on client and server, and sensitive values are masked in the UI
- Tests cover the API client, validation and at least one error path
- A short note on how to run it and how to switch from Sandbox to production later
- If anything is missing (like my key), ask me. Do not guess endpoints, fields or values.

Start with a sandbox key.

Free to try. Make your first test call today.