@sajn/embed-js: a function API and a Web Component for any web page. See JavaScript.@sajn/embed-react: a React component for React 18 and later. See React.@sajn/embed-vue: a Vue component for Vue 3.3 and later. See Vue.
Before you begin
- Embedded signing is part of the Enterprise plan. If you build on sajn to send documents to your own customers, you also need a partner license. To get started, contact [email protected].
- Store your API key in the
SAJN_API_KEYenvironment variable on your server. To create a key, go to workspace settings in the sajn app, then Utvecklare (Developer) > API-nycklar (API keys).
Turn on embedding
After sajn turns on embedding for your organization, add the domains that can embed the signing page:- In the sajn app, go to workspace settings, then Utvecklare (Developer) > Inbäddning (Embedding).
- Enter your domains, separated by commas. A domain can start with a wildcard, such as
*.example.com.
localhost doesn’t work. To test from your computer, expose your local app on a public HTTPS domain, such as through a tunnel, and add that domain. To test before you go live, use the sandbox.
Embed the signing page
1
Create the document on your server
Create the document with the party’s The first request returns the document. Replace
deliveryMethod set to NONE, so sajn doesn’t also email an invitation, and send it:DOCUMENT_ID with its id, and note the party’s id in parties.2
Get the party's token on your server
PARTY_ID with the party’s id. The response has the party’s signingUrl, such as https://app.sajn.se/sign/DOCUMENT_ID?token=PARTY_TOKEN. Read the token from its token query parameter:3
Show the signing page
In your frontend, pass the document ID and the token to the embed:Replace
PARTY_TOKEN with the token from the previous step. For React and Vue, see the framework pages.4
Confirm the signature on your server
The
signer-completed event runs in the browser, so treat it as a signal to update the screen, not as proof. Confirm the signature with the document.party.signed or document.completed webhook event.Options
Every package takes the same options. The JavaScript package uses the names shown; the React package uses the same names as props, and the Vue package uses kebab-case attributes, such asdocument-id.
Theme colors
cssVars takes the following colors:
Events
Every package emits the following events:document-ready: the iframe loaded. No data.signer-completed: the party finished signing. Data:token,documentId,signerId(the party ID), andfailed, a reason, when signing failed.variables-submitted: the party submitted their form fields. The document isn’t signed yet: signing opens when every party with form fields has submitted. Data:token,documentId, andsignerId.signer-rejected: the party rejected the document, which needsallowDocumentRejection. Data:token,documentId,signerId, andreason.document-error: an error occurred. Data:codeandmessage.
signerId is the party’s id; the embed packages keep this name.
Security
- Only domains in the workspace’s allowlist can embed the signing page.
- The token is checked on the server before the page renders.
- If the party verifies with an eID or a camera-based check, the iframe needs the
allow="camera"attribute. - If the document has
accessVerification, the party passes that check inside the iframe before any content loads, the same as on the hosted page. Your application has usually signed the user in already, so consider leavingaccessVerificationoff for embedded documents. A party’s owntwoStepVerificationalways applies.
Handle errors
- A
document-errorevent: readcode. A missing or invalid token, or a domain that isn’t in the allowlist, stops the page from loading. - A blank iframe: check that your domain is in the allowlist and is served over HTTPS.
Next steps
JavaScript
Use the function API or the Web Component.
React
Use the React component.
Vue
Use the Vue component.

