> ## Documentation Index
> Fetch the complete documentation index at: https://idto.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Receive session and eSign completion events, verify their signatures, and handle retries.

idto sends two events to one HTTPS URL per account:

| Event | When | Page |
| - | - | - |
| Session completed | A verification session reaches `completed` | [session.completed](https://idto.mintlify.site/api-reference/webhooks/session-completed.md) |
| eSign completed | Every signer of an eSign document has signed | [esign.completed](https://idto.mintlify.site/api-reference/webhooks/esign-completed.md) |

## Route the two events

Both events arrive at the same URL, so your handler must tell them apart. The eSign body carries `"event": "esign.completed"`. The session body has no `event` field at all; it carries `session_id`, `status`, `outcome` and the step lists instead. Route on the presence of `event`, and treat any other `event` value as unknown: acknowledge it with a 2xx and ignore it, so a new event type never turns into a retry storm.

`event_id` is stable per event: `evt_<session_id>_completed` for a session, and a fixed id per signed document for eSign. idto never creates the same event twice, so a duplicate you see is always a retry of the same delivery.

## Set up

Webhook settings live in the dashboard, on the **Webhooks** page. There is no API for them. The page has no sidebar entry: open it from the **Set up a webhook** link the workflow builder shows when no URL is set. Only the Owner, Admin and Developer roles can change it.

**1. Add your URL**

Enter an `https://` endpoint. Plain `http` is refused.

**2. Generate a signing secret**

Click **Generate secret** to create the secret. It is shown once, so store it in your secret manager straight away. **Until a secret exists, idto does not send events**: each attempt fails and the event is dropped after 5 attempts.

**3. Verify every delivery**

Check the signature as below before trusting the body.

![Webhooks page in the idto dashboard with the URL field and the rotate secret button](https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/img/dashboard-webhooks.png)

## Verify the signature

Each delivery carries three headers:

| Header | Value |
| - | - |
| `X-Idto-Event-Id` | The event's `event_id` |
| `X-Idto-Timestamp` | Unix seconds when idto signed it |
| `X-Idto-Signature` | `sha256=` plus the hex HMAC-SHA256 of `<timestamp>.<raw body>`, keyed with your secret |

Compute the HMAC over the raw request bytes, not over re-serialised JSON, compare in constant time, and reject a timestamp more than 300 seconds from your clock. idto does not enforce that window for you, so the check on your side is what stops a replayed delivery.

```python theme={null}
import hashlib
import hmac
import time


def verify_idto_webhook(secret: str, raw_body: bytes, timestamp: str, signature: str, tolerance: int = 300) -> bool:
    if abs(time.time() - int(timestamp)) > tolerance:
        return False
    expected = hmac.new(secret.encode(), timestamp.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest("sha256=" + expected, signature)
```

Node, TypeScript, Go, PHP, Ruby and Java versions: [Verify webhook signatures](https://idto.mintlify.site/recipes/verify-webhook-signatures.md).

## Delivery and retries

* Return any 2xx within 10 seconds. Anything else, a timeout or a connection error counts as a failed attempt.
* idto makes up to 5 attempts. The first is sent as soon as the event is created. After failed attempt `n`, the next one is sent no earlier than `10 x 2^n` seconds later, capped at one hour: at least 20 s, 40 s, 80 s and 160 s. Retries are picked up by a periodic sweep, so the real gaps can be somewhat longer.
* The same event can arrive more than once. Deduplicate on `X-Idto-Event-Id`.
* Events are not ordered. Acknowledge first, then process asynchronously.
* Each retry goes to the URL that was set when the event was created. Changing the URL affects new events only.
* Clearing the URL turns delivery off. Events that happen while no URL is set are never created, so they are not sent later either.
* After the last failed attempt the event is not resent. Recover the state with [Get session state](https://idto.mintlify.site/api-reference/integration/session-state.md) or [Download the signed document](https://idto.mintlify.site/api-reference/esign/esign-document.md).

## Rotate the secret

Rotating creates a new secret and every later delivery is signed with it at once, including retries of events created before the rotation. idto signs with the current secret only. To rotate without dropping events, have your receiver accept either the old or the new secret, rotate, deploy the new secret, then remove the old one.

## Handle a delivery

**1. Read the raw body**

Take the bytes exactly as received. Parsing and re-serialising the JSON changes the bytes and breaks the signature.

**2. Verify, then check freshness**

Reject a bad signature or a stale timestamp with a 4xx. A failed check uses up one of the 5 attempts, so log it: a run of signature failures usually means a secret mismatch after a rotation.

**3. Deduplicate**

If you have already stored this `X-Idto-Event-Id`, return 2xx and stop.

**4. Store and acknowledge**

Save the event, return 2xx, and do the real work in a background job. Anything slow before the response risks the 10 second limit.

**5. Reconcile**

For a session, read the authoritative state from [Get session state](https://idto.mintlify.site/api-reference/integration/session-state.md) before you act on it. For eSign, download the signed document.

## Production checklist

* An `https` URL is saved and a signing secret is generated and stored in a secret manager.
* Signatures are checked over raw bytes in constant time, with a 300 second timestamp window.
* Duplicates are dropped on `X-Idto-Event-Id`.
* The handler answers within 10 seconds and processes asynchronously.
* Unknown `event` values are acknowledged and ignored.
* A scheduled job reconciles sessions and eSign documents through the API, so a missed event is recovered rather than lost.

***

Was this page helpful? Email us at [tech@idto.ai](mailto:tech@idto.ai?subject=Docs%20feedback%3A%20Webhooks) with the page link.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.