iframe Embedding
Embed Tencent eSign pages into the integrator’s own web page: ask Tencent eSign operations to allowlist your host domain first, then use the OpenAPI-returned URL as an iframe.
Prerequisite: Allowlist Your Host Domain
Send your OAuth app client_id and host domains (e.g. https://app.your-company.com, wildcard subdomains like https://*.your-company.com are supported) to your Tencent eSign operations / integration contact. The allowlist takes effect with the next release. An allowlisted host is required — otherwise the iframe stays blank.
Embeddable Pages
| Scenario | How to get the URL |
|---|---|
| Initiate signing / signature status list | Get Embedded View URL (request_signatures / signature_status) |
| Signing | Get Signing Link (embedded signing) |
Use the returned URL as-is: do not add or remove parameters, and do not change the domain. The client_id in the URL is what matches your allowlist.
Host Page
<iframe
src="URL returned by the OpenAPI"
style="width:100%;height:900px;border:0"
sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-downloads allow-modals"
></iframe>Keep allow-same-origin (without it API calls are sent with Origin: null and rejected). allow-top-navigation is not needed: the embedded page never navigates the host page.
Receiving the Result
Completion and decline are reported to the host via postMessage; validate the sender before acting:
window.addEventListener('message', (e) => {
if (e.origin !== 'https://www.tencent-esign.com') return; // validate against your environment domain
if (!e.data || e.data.source !== 'tencent-esign') return;
// e.data.type: embed.ready | signing.complete | signing.decline
// terminal messages also carry event / envelopeId / recipientId / returnUrl
});The message payload uses these exact fields:
| Field | Type | Description |
|---|---|---|
source | string | Always tencent-esign |
type | string | embed.ready, signing.complete, or signing.decline |
clientId | string | OAuth app client_id from the embedded URL when present |
envelopeId | string | Envelope ID on terminal messages |
recipientId | string | Signer recipient ID on terminal messages |
event | string | Terminal result: signing_complete or decline |
returnUrl | string | Validated return URL supplied by the integrator, when present |
type | event |
|---|---|
embed.ready | not set |
signing.complete | signing_complete |
signing.decline | decline |
The message is a UI signal only; the authoritative envelope status comes from webhooks or the envelope detail API.
FAQ
| Symptom | Fix |
|---|---|
| Blank iframe | The host domain is not allowlisted, or client_id was stripped/rewritten from the URL |
No postMessage received | Host does not validate the exact origin, the iframe has no height, or sandbox is missing allow-same-origin |
| Downloads / popups do nothing | sandbox is missing allow-downloads / allow-popups |
TOKEN_INVALID when opening the link | The link expired or was replaced by a newer link for the same signer; issue a new one |
| Signer is asked to log in | Expected for standard embedded signing (the sign-in card renders inside the iframe); contact operations if you need Trusted signing |