Skip to main content

2 posts tagged with "integration"

View All Tags

· 3 min read

Building a great e-signing experience doesn’t stop at signing itself. Your system also needs to stay up to date as documents move through their lifecycle: created, sent, signed, cancelled. Polling for updates or relying on manual refreshes is slow and brittle.

In this short post, we’ll explore how Webhooks let you react to signing events instantly, so your workflows stay automatic and your users stay in the loop.

The Problem: Slow and Unreliable Polling

Imagine you have an internal dashboard showing the status of agreements your customers sign. Without Webhooks, you have to periodically fetch the agreement status from our API:

  1. Agreement created
    You store the agreement ID and show it as “Pending”.
  2. Polling begins
    Every minute you call the API to check if the agreement has been signed.
  3. Laggy updates
    The status might update minutes later, depending on when your polling job runs.
  4. Unnecessary load
    You’re wasting resources asking the API about agreements that haven’t changed.

Webhooks solve all of this by sending you a real-time notification as soon as something happens.

Getting started with Webhooks

Let’s walk through a minimal example of using Webhooks to update your system in real time when an agreement is signed:

  1. Create your webhook endpoint
  2. Register the webhook in Zigned
  3. Verify incoming webhook events
  4. Process the event and update your system

1. Create your webhook endpoint

You’ll need an HTTPS endpoint in your system that accepts POST requests with a JSON body. Here’s a minimal example using Express.js:

// Letss assume you have an Express.js app
const express = require('express')
const app = express()
app.use(express.json()) // Middleware to parse JSON bodies

app.post('/webhooks/zigned', (req, res) => {
const event = req.body

// Validate the event (more on this below)
console.log('Received webhook event:', event)

res.status(200).send('OK')
})

2. Register the webhook

Use our API to register your webhook URL. You can choose which events you want to subscribe to.

curl -X POST https://api.zigned.se/rest/v3/webhooks \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourapp.com/webhooks/zigned",
"events": ["agreement.lifecycle.finalized"]
}'

3. Verify the webhook event

Each webhook request includes a signature header you can use to verify authenticity. This helps you confirm the event really came from Zigned. You’ll find instructions and your secret in the developer dashboard.

Example Node.js verification snippet:

const crypto = require('crypto')

function verifySignature(rawBody, signature, secret) {
const expected = crypto.createHmac('sha256', secret).update(rawBody).digest('hex')
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))
}

4. Process the event

Once verified, you can safely update your system. For example, mark the agreement as signed in your database or trigger any follow-up workflows.


// Verify the webhook event. Assume your webhook secret is stored in an environment variable.
const data = verifySignature(req.body, req.headers['x-zigned-signature'], process.env.ZIGNED_WEBHOOK_SECRET)

switch(data.event) {
case 'agreement.lifecycle.finalized': {
// Update your agreement status in your system
// Assume you have a function updateAgreement that takes an ID and status
updateAgreement(data.data.agreement_id, 'signed')
break
}
case 'agreement.lifecycle.cancelled': { ... }
default: { ... }
}

And that’s it!

With Webhooks, you get real-time visibility into agreement status without any polling or delays. Whether you’re updating dashboards, sending notifications, or triggering workflows, Webhooks make sure your system stays perfectly in sync.

If you haven’t already, head over to your developer dashboard and register a webhook to see it in action. Happy building!

· 4 min read

Integrating e-signatures into your app or website often means sending users off to email invites, waiting for them to find the link, complete a signature in a separate interface, then hunt their way back to your service. All those context switches kill momentum and dent your conversion rates.

In this short post, we'll explore how we can utilize callback URLs to deliver a premium and seamless signing experience directly in your app.

The Problem: Context Switches and Drop-Offs

Let’s assume you have an onboarding process where the end-user needs to sign an agreement before gaining access to your service. Here’s a typical flow without callback URLs:

  1. Sign-up completes
    User finishes registration in your app and is told to check their email.
  2. Email invite
    They leave your app, open their inbox, locate the invite, and click the link.
  3. Detached signing room
    They visit the signing room and completes signing of the document.
  4. Manual return
    After signing, they have to manually return to your service, hopefully after you’ve had time to process everything.

Every app switch and manual step adds friction. Users get distracted, forget where they were, or simply bounce. With callback URLs you can collapse those four steps into a single, in-app experience.

Getting started with Callback URLs

Let's go ahead and see how easily we can resolve this issue with callback URLs. Below is a minimal example that collapses the entire flow into a single in-app experience. We’ll:

  1. Create the agreement (with email disabled and a callback URL)
  2. Add the signer
  3. Attach the document
  4. Move the agreement to “pending”
  5. Redirect the user straight into the signing room

In this example, we presume you already have uploaded the document to be signed in the /files endpoint. If not you can learn how to do so here


1. Create the agreement

First we create the agreement. We’ll disable email communication and add a callback URL. Disabling email communication is optional and requires you to handle all communication yourself, but provides a more integrated experience.

curl -X POST https://api.zigned.se/rest/v3/agreements \
-H "Content-Type: application/json" \
-d '{
"send_emails": false,
"success_callback_url": "https://yourapp.com/zigned/callback"
}'

2. Add the signer

Next, we add the signer for the document

curl -X POST https://api.zigned.se/rest/v3/agreements/<id>/participants \
-H "Content-Type: application/json" \
-d '{
"name": "Jane Doe"
}'

3. Attach the document

Now we add the document that will be signed.

curl -X POST https://api.zigned.se/agreements/agreement_123/documents/main \
-H "Content-Type: application/json" \
-d '{
"file_id": "<YOUR_FILE_ID>"
}'

4. Initiate the signing process

Lastly, we initiate the signing process but moving the lifecycle state of the agreement to “pending”

curl -X POST https://api.zigned.se/agreements/agreement_123/lifecycle \
-H "Content-Type: application/json" \
-d '{
"lifecycle_state": { "status": "pending" }
}'

5. Redirect your user

Grab the link for the signing room from the response in the previous step. Then either present the link for the user to click on or automatically redirect them. Below is an example in javascript:

// the “res” variable represents the response from the previous step in this case

const link = res.data.participants[0].signing_room_link
window.location.href = link

Once signing is complete, Zigned will automatically send the user back to https://yourapp.com/zigned/callback, where you can finalize onboarding or trigger any follow-up logic. If you supply a unique identifier from your system in the callback-url, we will send that too in order for you to more easily handle the rest on your end.

And that’s it!

With just a few lines of code, callback URLs let you collapse fragmented signing flows into a single, in-app experience—boosting completion rates and keeping users engaged. Give it a try in your next integration, and let us know how it goes. Happy signing!