> For the complete documentation index, see [llms.txt](https://bernatf.gitbook.io/human-lambdas-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bernatf.gitbook.io/human-lambdas-documentation/api/webhooks.md).

# Webhooks

Webhooks are `POST` requests sent by the Human Lambdas API towards a callback URL of your choice, which you can register per queue in its corresponding [Connections](/human-lambdas-documentation/manual/queues/connections.md#destinations) screen.

Currently, Webhooks can only be enabled for completed tasks. The callback structure mimics the format of the task object.

Here's how you can replicate a sample Webhooks callback:

```bash
curl $CALLBACK_URL -H "Content-Type: application/json" -d '
{
  "id": 169578,
  "status": "completed",
  "completed_at": "2020-10-08T12:56:04.206Z",
  "created_at": "2020-10-08T12:55:08.546Z",
  "completed_by": "bernat@humanlambdas.com",
  "queue": "Example",
  "queue_id": 165,
  "data": {
    "text_test": "Some text"
  },
  "source": "manual"
}'
```

### Fetching and setting a queue's webhook

We currently only support setting one webhook per queue between the UI and the API. The webhook object is represented in the API as:

```bash
{
    "target": "https://webhook.site/6f768315-d21c-428f-9125-e7f467faecce"
}
```

With `target` being the URL that will receive a callback every time a task in a specific queue is completed.

## Get a queue's webhook

<mark style="color:blue;">`GET`</mark> `https://api.humanlambdas.com/orgs/$ORGANIZATION_ID/queues/$QUEUE_ID/webhook`

#### Path Parameters

| Name             | Type    | Description                   |
| ---------------- | ------- | ----------------------------- |
| ORGANIZATION\_ID | integer | The organization's identifier |
| QUEUE\_ID        | integer | The queue's identifier        |

#### Headers

| Name          | Type   | Description                                                      |
| ------------- | ------ | ---------------------------------------------------------------- |
| Authorization | string | `Token $API_KEY` or visit the Introduction page for more details |

{% tabs %}
{% tab title="200 " %}

```
{
    "target": "https://webhook.site/6f768315-d21c-428f-9125-e7f467faecce"
}
```

{% endtab %}
{% endtabs %}

## Set a queue's webhook

<mark style="color:orange;">`PUT`</mark> `https://api.humanlambdas.com/orgs/$ORGANIZATION_ID/queues/$QUEUE_ID/webhook`

#### Path Parameters

| Name             | Type    | Description                   |
| ---------------- | ------- | ----------------------------- |
| ORGANIZATION\_ID | integer | The organization's identifier |
| QUEUE\_ID        | integer | The queue's identifier        |

#### Headers

| Name          | Type   | Description                                                      |
| ------------- | ------ | ---------------------------------------------------------------- |
| Authorization | string | `Token $API_KEY` or visit the Introduction page for more details |
| Content-Type  | string | `application/json`                                               |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bernatf.gitbook.io/human-lambdas-documentation/api/webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
