> For the complete documentation index, see [llms.txt](https://docs.transactionlink.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.transactionlink.io/docs/workflows/webhooks.md). Agents can also search and read this documentation through its [MCP server](https://docs.transactionlink.io/docs/~gitbook/mcp).

# Webhooks

Get notified on your server when the status of a workflow changes.

A webhook is an HTTP request that TransactionLink sends to your server when something happens in a workflow. Use webhooks to react to workflow results without polling the API.

TransactionLink sends a webhook when:

* **A workflow is completed.** The data collected in the workflow is ready to download through the API.
* **A workflow is awaiting.** The user finished their part in the widget, and some tasks are still processing in the background. A completion webhook follows when they finish.
* **A workflow changes status.** This is useful for long-running workflows that need no user input.

## Set up a webhook endpoint

1. Create an endpoint on your server that accepts `POST` requests with a JSON body.
2. Open the **Settings** page in the [TransactionLink dashboard](https://dashboard.transactionlink.io/) and set the webhook URL to the address of your endpoint.
3. Return a `2xx` response within ten seconds of receiving the webhook.

{% hint style="info" %}
To test webhooks on your machine, expose your local server with a tunneling tool such as [ngrok](https://ngrok.com/).
{% endhint %}

## Webhook payload

The body of the request identifies the workflow execution and its status. Use `workflowId` to get the result from [`GET /workflows/{workflowId}/result`](https://docs.transactionlink.io/docs/transactionlink-api/api-reference/workflows.md).

```json
{
  "workflowId": "cd1c4384-bb5b-4483-8974-d8b3ef935843",
  "workflowName": "70953b16-704a-43a7-b9d0-6cb7d63e491c",
  "workflowDefinitionId": "a16bc61f-b7ab-4a1d-8301-71740fe6b3a2",
  "workflowStatus": "COMPLETED",
  "workspaceId": "aebf8333-5b3e-4840-92dc-f4c8c2c56051"
}
```

## Retries

TransactionLink treats a webhook as failed when your endpoint does not respond within ten seconds or responds with a status outside `2xx`. A failed webhook is retried up to five times, with a five-second interval.

## Verify the signature

TransactionLink signs every webhook. Verify the signature before you trust the payload.

The signature is in the `JWS-SIGNATURE` header, as a JSON Web Signature (JWS) in detached format: `<header>..<signature>`, with an empty payload part.

{% stepper %}
{% step %}

### Read the key ID

Take the part of the signature before the first dot and decode it from base64url. The result is the JOSE header:

```json
{
  "alg": "RS256",
  "kid": "070725bf-7dac-4712-b61a-420ba3701263",
  "typ": "JWT"
}
```

`kid` is the ID of the key that signed the webhook. `alg` is the signing algorithm, RSA with SHA-256 (`RS256`) by default.
{% endstep %}

{% step %}

### Get the public key

Call the [public key endpoint](#get-public-key) with the `kid` value. The key is returned in PEM format by default.

The signing key pair is rotated every 24 hours. A public key stays available from the API for 24 hours after its expiration, so you can cache each key locally for a day to reduce the number of calls.
{% endstep %}

{% step %}

### Validate the signature

1. Remove all whitespace from the payload you received. TransactionLink signs the payload without whitespace.
2. Encode the result in base64url.
3. Put the encoded payload between the two dots of the detached signature. This gives the compact format: `<header>.<payload>.<signature>`.
4. Validate the compact JWS with the public key, using the JWT or JWS library of your choice.
   {% endstep %}
   {% endstepper %}

## Public key endpoint

### `GET` Public key

{% openapi src="/files/TuX298475JdERUrKxf2o" path="/auth/webhooks/key/{keyId}" method="get" %}
[webhooks.yml](https://4264774896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTuZUhAUswS7SDAPD9DAo%2Fuploads%2Fgit-blob-93767deb49976a0b8853d7246f2e5de3bc2651ff%2Fwebhooks.yml?alt=media)
{% endopenapi %}
