---
title: "Task webhooks"
description: Trigger a task from another system and verify that the results a task sends come from TukiAssistant.
---

A task can use webhooks in two ways: **receive** a call that triggers it and **send** its result to another system. This page is for whoever sets up the system on the other side; share it with your technical team.

:::note[Before you start]
You need the admin role in the workspace. Always use HTTPS addresses.
:::

## Trigger a task from another system

1. **Choose the webhook trigger**

    In the task's **When it runs** step, choose **When something happens** and **Another system triggers it**, and create the task.

2. **Generate the secret**

    In **Review**, under **Webhook secret**, click **Generate secret**. Copy the **Webhook URL** and the secret: the secret is shown only once.

3. **Turn the task on**

    Turn the task on. It cannot be turned on without a secret.

The other system sends a `POST` to that URL with a JSON object and the `Authorization: Bearer` header followed by the secret:

```sh
curl -X POST "https://app.tukiassistant.com/api/tasks/hook/<task-id>" \
  -H "Authorization: Bearer <secret>" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: applicant-1045" \
  -d '{"event": "postulant.created", "postulant": {"name": "Ana", "email": "ana@example.com"}}'
```

- The body can be up to 64 KB. The task receives it as data, never as instructions, and you can use its fields in the criterion (for example, `body.event`).
- With `Idempotency-Key`, a repeated call with the same key does not run the task again.
- Up to 60 calls per minute per task are accepted.
- The response confirms the run was queued; the task runs in the background.

:::warning
If you rotate the secret, the old one stops working right away. Update the other system at the same time.
:::

## Verify what a task sends

The **Send to another system** action signs every delivery with a secret of its own. To see it, click the task's card, which opens on **Review**, and, under **Signing secret**, click **Generate new secret**: it is shown only once and the previous one stops working.

Each delivery is a `POST` with the result as JSON and these headers:

- `x-tuki-timestamp`: when it was sent, in seconds.
- `x-tuki-signature`: HMAC-SHA256 of the secret over `timestamp.body` (the timestamp, a dot, and the body exactly as received), in hexadecimal.
- `idempotency-key`: the same across retries of one delivery; use it to avoid processing the same result twice.

Verification example in Node.js:

```js
import { createHmac, timingSafeEqual } from 'node:crypto';

function isFromTukiAssistant(rawBody, headers, secret) {
  const timestamp = headers['x-tuki-timestamp'];
  const expected = createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex');
  const received = Buffer.from(headers['x-tuki-signature'] ?? '');
  const ok = received.length === expected.length && timingSafeEqual(received, Buffer.from(expected));
  const fresh = Math.abs(Date.now() / 1000 - Number(timestamp)) < 300;
  return ok && fresh;
}
```

Answer with a 2xx code when you receive it. If your system answers with a 5xx or 429 error, or does not answer, TukiAssistant retries the delivery; with other 4xx errors it does not retry.

## Next steps

**[Create a task](/en/automated-tasks/create-automated-task)**

Set up a task's trigger and actions.

**[See the runs](/en/automated-tasks/task-runs)**

Check whether a delivery failed and when it is retried.
