- Qubitara eSign
- Developers
- Embedded signing
Embedded signing
This page is for developers who want signers to sign without leaving their application. It describes the planned rules for embedded signing and the security rules that come with it.
How it works#
Your server creates a signature request with the normal API. It marks one or more recipients as embedded. See Signature requests.
When the signer is in your app, your server asks the API for a signing URL for that recipient. The URL is valid for a short time and works once.
Your front end opens the URL in an iframe, or sends the browser to it.
The signer reads and signs. Your page receives
postMessageevents. In redirect mode, the signer goes back to yourreturn_url.Your server takes the final result from the webhook event
document.signedorsignature_request.finalized, or from aGETon the request. Never trust the browser alone.
Your server ──POST /signature-requests (embedded: true)──▶ eSign API
Your server ──POST /embedded/signing-url──────────────────▶ eSign API ──▶ { url, expires_at }
Your browser ─iframe src=url─────────────────────────────▶ eSign signer page
eSign ─postMessage { event: "signed" }───────────────────▶ Your browser
eSign ─webhook document.signed───────────────────────────▶ Your server (source of truth)Step 1: Mark a recipient as embedded#
curl -X POST "https://<org>.esign.qubitara.com/api/v1/signature-requests" \
-H "Authorization: Bearer $QUBITARA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Customer agreement",
"document_id": "doc_01J8Z0QWERTY",
"recipients": [
{ "role": "signer", "order": 1, "name": "Asha Rao", "email": "[email protected]",
"embedded": true, "client_user_id": "user-8842" }
],
"fields": [ { "type": "signature", "recipient": 0, "page": 2, "x": 72, "y": 600, "width": 180, "height": 60 } ],
"send": true
}'embedded: true and client_user_id are planned properties.
client_user_idis your own ID for the signer. Events return it, so you can match each event to your user.The plan is that an embedded recipient does not receive the request email. Your app shows the document.
The plan is that you set
"notify": trueon the recipient if you also want the email.
Step 2: Create a signing URL#
curl -X POST "https://<org>.esign.qubitara.com/api/v1/embedded/signing-url" \
-H "Authorization: Bearer $QUBITARA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"signature_request_id": "sr_01J8Z1ABCXYZ",
"recipient_id": "rcp_01J8Z2AAA",
"return_url": "https://app.example.com/contracts/8842/done",
"mode": "iframe"
}'{
"url": "https://<org>.esign.qubitara.com/sign/e/eyJhbGciOi...",
"expires_at": "2026-09-28T09:31:00Z",
"recipient_id": "rcp_01J8Z2AAA"
}The planned endpoint is POST /embedded/signing-url.
Property | Planned behavior |
|---|---|
Validity | 15 minutes from minting; expired URLs show an "expired link" page |
Single use | The URL is consumed on first load. Mint a new one if the signer reloads |
Regenerable |
|
|
|
| Must be HTTPS and on an allowed origin (see below) |
In this table, "mint" means "create a new signing URL".
Step 3: Embed in an iframe#
<iframe
id="esign-frame"
src="https://<org>.esign.qubitara.com/sign/e/eyJhbGciOi..."
width="100%" height="800"
allow="camera; clipboard-write"
sandbox="allow-scripts allow-forms allow-same-origin allow-popups">
</iframe>You need allow="camera" only if you turn on image flows or Aadhaar face-authentication flows. This is planned behavior.
The plan is that the signer page sets Content-Security-Policy: frame-ancestors to your allowed origins. If your origin is not allowed, the browser does not show the frame.
Allowed origins#
An origin is the scheme, host and port of a web page. Register the origins that can embed the signer page and receive postMessage events. The planned place is Settings → SYSTEM → Integrations.
The planned rules are:
Origins are exact
scheme://host[:port]values, for examplehttps://app.example.com.http://localhost:*may be allowed for development, in the sandbox only.Wildcards are not accepted.
return_urlmust match an allowed origin.
Step 4: Listen for postMessage events#
The signer page posts JSON messages to window.parent. Always check event.origin.
const ESIGN_ORIGIN = "https://<org>.esign.qubitara.com";
window.addEventListener("message", (e) => {
if (e.origin !== ESIGN_ORIGIN) return; // ignore anything else
const msg = e.data;
if (!msg || msg.source !== "qubitara-esign") return;
switch (msg.event) {
case "ready": /* frame loaded */ break;
case "viewed": /* signer opened the document */ break;
case "signed": showThankYou(); break; // UX only, confirm server-side
case "declined": showDeclined(msg.reason); break;
case "cancelled": closeFrame(); break;
case "expired": mintNewUrlAndReload(); break;
case "error": console.error(msg.code, msg.message); break;
}
});The planned message shape:
{
"source": "qubitara-esign",
"event": "signed",
"signature_request_id": "sr_01J8Z1ABCXYZ",
"recipient_id": "rcp_01J8Z2AAA",
"client_user_id": "user-8842",
"timestamp": "2026-09-28T09:20:31Z"
}
| When |
|---|---|
| Signer page has loaded inside the frame |
| Signer has opened the document |
| Signer completed all their fields |
| Signer declined, with |
| Signer closed without finishing |
| The signing URL or the request expired |
| An error page was shown, with |
All event names are planned and may change.
Redirect mode#
Redirect mode applies with "mode": "redirect", or when the signer opens the URL in a full window. The plan is that the signer goes to return_url with query parameters added:
https://app.example.com/contracts/8842/done?signature_request_id=sr_01J8Z1ABCXYZ&recipient_id=rcp_01J8Z2AAA&event=signedevent takes the same values as the postMessage events. Your return_url handler must do two things:
Show a result page.
Confirm the state with a
GETfrom your server, or wait for the webhook.
Anyone who knows the URL pattern can fake the query parameters. Never give access to anything because of event=signed alone.
Aadhaar eSign inside an embedded flow#
Some recipients have the signature_type aadhaar_otp. For them, the signer page sends the signer to the authentication page of the eSign Service Provider (ESP) and back. This redirect may not work inside a sandboxed iframe. It also may not work when the browser blocks third-party cookies.
Most Indian vendors need a redirect in the top-level window for the ESP authentication page. Plan for redirect mode with Aadhaar signers. See Aadhaar eSign API.
Security rules#
Keep the short expiry. A signing URL gives access as that signer. Create it only when the signer is present and ready to sign.
Do not email signing URLs yourself. Use the request email of the platform (leave
embeddedfalse). eSign then delivers and tracks the link.Sign the signer in to your app first. Embedded signing skips the email-link step, so your app session is the proof of identity. Keep a record of it. The plan is that the audit trail shows
authentication: embedded (client_user_id).Check
event.originand ignore messages from any other origin.Trust webhooks, not the browser. Update your database only from verified
document.signedorsignature_request.finalizedevents, or fromGET /signature-requests/{id}. See Webhooks for how to verify an event.Use HTTPS everywhere. Browsers block an HTTP iframe on an HTTPS page.
Testing#
These steps are planned. They need a sandbox, which is not decided yet.
Add
http://localhost:3000to the allowed origins in the sandbox.Create a request with
"test_mode": true, so that no credits are used.Create a URL, embed it, and watch the
postMessagelog in the browser console.Wait past
expires_atso that the URL expires. Check that your app handlesexpiredand creates a new URL.
Next steps#
Webhooks: the completion signal on the server that you should trust.
Signature requests: create the request that you embed.
Aadhaar eSign API: the redirect flow for Aadhaar signers.