Skip to content
Docs
Qubitara eSign

Embedded signing

Updated Version 1ESIGN-50

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#

  1. Your server creates a signature request with the normal API. It marks one or more recipients as embedded. See Signature requests.

  2. 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.

  3. Your front end opens the URL in an iframe, or sends the browser to it.

  4. The signer reads and signs. Your page receives postMessage events. In redirect mode, the signer goes back to your return_url.

  5. Your server takes the final result from the webhook event document.signed or signature_request.finalized, or from a GET on the request. Never trust the browser alone.

text
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#

bash
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_id is 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": true on the recipient if you also want the email.

Step 2: Create a signing URL#

bash
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"
  }'
json
{
  "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

recipient_id is stable; you can mint as many URLs as needed while the recipient is action_required

mode

iframe (default) or redirect. In redirect mode the signer is sent to return_url when done

return_url

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#

html
<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 example https://app.example.com.

  • http://localhost:* may be allowed for development, in the sandbox only.

  • Wildcards are not accepted.

  • return_url must match an allowed origin.

Step 4: Listen for postMessage events#

The signer page posts JSON messages to window.parent. Always check event.origin.

js
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:

json
{
  "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"
}

event

When

ready

Signer page has loaded inside the frame

viewed

Signer has opened the document

signed

Signer completed all their fields

declined

Signer declined, with reason (only if declining is part of the release)

cancelled

Signer closed without finishing

expired

The signing URL or the request expired

error

An error page was shown, with code and message

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:

text
https://app.example.com/contracts/8842/done?signature_request_id=sr_01J8Z1ABCXYZ&recipient_id=rcp_01J8Z2AAA&event=signed

event takes the same values as the postMessage events. Your return_url handler must do two things:

  1. Show a result page.

  2. Confirm the state with a GET from 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 embedded false). 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.origin and ignore messages from any other origin.

  • Trust webhooks, not the browser. Update your database only from verified document.signed or signature_request.finalized events, or from GET /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.

  1. Add http://localhost:3000 to the allowed origins in the sandbox.

  2. Create a request with "test_mode": true, so that no credits are used.

  3. Create a URL, embed it, and watch the postMessage log in the browser console.

  4. Wait past expires_at so that the URL expires. Check that your app handles expired and creates a new URL.

Next steps#

Was this page helpful?