Skip to main content
In this guide, you configure a document so that each party lands on a page in your application after signing. The URL can carry the document ID and the party ID, so your page knows who signed.

Before you begin

  • Store your API key in the SAJN_API_KEY environment variable. To create a key, go to workspace settings in the sajn app, then Utvecklare (Developer) > API-nycklar (API keys).
  • Have a page in your application that can receive the redirect, such as https://app.example.com/signed.

How the redirect works

When a party finishes signing, the signing page counts down for five seconds and then opens the redirect URL in the same tab. The party can cancel the countdown. The redirect happens in the party’s browser, so it isn’t proof that the document was signed. To confirm a signature, use the document.party.signed and document.completed webhook events. The URL can contain the following placeholders. sajn replaces the first occurrence of each:
  • {documentId}: the document ID.
  • {signerId}: the ID of the party who signed, the same value as id in the document’s parties. The placeholder keeps this name in every API version.

Configure the redirect

1

Set the redirect URL on the document

Set documentMeta.redirectEnabled to true and documentMeta.redirectUrl to an http or https URL. You can send them when you create the document, or update a document you already have:
Replace DOCUMENT_ID with the document ID. The response is the document, with the URL in documentMeta.redirectUrl. You can change the redirect after sending, until the document is completed.After Alex signs, the browser opens a URL similar to the following:
2

Handle the redirect in your application

On the redirect page, read the IDs from the query string. To show the current state, get the document from your server, never from the browser, because the request needs your API key:
Treat the query string as untrusted input. Anyone can open the URL with other IDs, so check that the document belongs to the signed-in user before you show it.

Handle errors

  • 400 VALIDATION_FAILED: redirectUrl isn’t an http or https URL.
  • 409 INVALID_STATE after sending: the document is completed, cancelled, or rejected, and the redirect can no longer change.
For the error shape and every code, see Errors.

Next steps

Embedded signing

Show the signing page inside your application.

Webhooks

Confirm signatures server to server.