> 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/queues.md).

# Queues

The following parameters might be required as part of the request URL:

* **Organization ID.** Visible in Settings.
* **Queue ID.** Found in the URL when inside a queue.

A queue is denoted as an object with the following fields:

* `active_users`: A list with the names of the users currently assigned to at least one pending task in the queue.
* `created_at`: The queue's creation timestamp.
* `id`: The queue's identifier.
* `n_tasks`: The number of pending tasks in the queue, waiting to be completed.
* `name`: The queue title.
* `data`: The queue's data configuration, which consists of a list of Block objects. This field is only included when explicitly fetching a queue by its identifier.

Here is an example of how a queue object looks like:

```
{
    "active_users": [
        "Bernat"
    ],
    "created_at": "2020-10-23T11:03:48.542064Z",
    "data": [
        {
            "id": "paragraph",
            "name": "Paragraph",
            "text": {
                "placeholder": "What is going on?"
            },
            "type": "text"
        },
        {
            "id": "categories",
            "name": "Categories",
            "single_selection": {
                "is_required": true,
                "options": [
                    {
                        "id": "red",
                        "name": "Red"
                    },
                    {
                        "id": "blue",
                        "name": "Blue"
                    },
                    {
                        "id": "green",
                        "name": "Green"
                    }
                ]
            },
            "type": "single_selection"
        },
        {
            "id": "picture",
            "image": {
                "placeholder": "https://i.imgur.com/3FlrkQd.jpg"
            },
            "name": "Picture",
            "type": "image"
        }
    ],
    "description": "",
    "id": 169,
    "n_tasks": 2,
    "name": "Categorization"
}
```

## List all queues

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

Lists all queues that exist within the organization.

#### Path Parameters

| Name             | Type    | Description                  |
| ---------------- | ------- | ---------------------------- |
| ORGANIZATION\_ID | integer | The ID of your organization. |

#### Headers

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

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

```
[
    {
        "active_users": [
            "Bernat"
        ],
        "created_at": "2020-11-20T17:20:43.444360Z",
        "id": 213,
        "n_tasks": 2,
        "name": "Wikipedia"
    },
    {
        "active_users": [
            "Bernat"
        ],
        "created_at": "2020-10-23T11:03:48.542064Z",
        "id": 169,
        "n_tasks": 2,
        "name": "Categorization"
    },
    {
        "active_users": [],
        "created_at": "2020-11-24T10:56:13.779387Z",
        "id": 218,
        "n_tasks": 0,
        "name": "Lead Gen Requests"
    }
]
```

{% endtab %}
{% endtabs %}

Sample request:

```bash
curl https://api.humanlambdas.com/orgs/$ORG_ID/queues \
-H "Authorization: Token $API_KEY"
```

## Get queue by ID

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

Retrieves a queue's information given a queue identifier.

#### Path Parameters

| Name             | Type   | Description                  |
| ---------------- | ------ | ---------------------------- |
| ORGANIZATION\_ID | string | The ID of your organization. |
| QUEUE\_ID        | string | The ID of your queue.        |

#### Headers

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

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

```
{
    "active_users": [
        "Bernat"
    ],
    "created_at": "2020-10-23T11:03:48.542064Z",
    "data": [
        {
            "id": "paragraph",
            "name": "Paragraph",
            "text": {
                "placeholder": "What is going on?"
            },
            "type": "text"
        },
        {
            "id": "categories",
            "name": "Categories",
            "single_selection": {
                "is_required": true,
                "options": [
                    {
                        "id": "red",
                        "name": "Red"
                    },
                    {
                        "id": "blue",
                        "name": "Blue"
                    },
                    {
                        "id": "green",
                        "name": "Green"
                    }
                ]
            },
            "type": "single_selection"
        },
        {
            "id": "picture",
            "image": {
                "placeholder": "https://i.imgur.com/3FlrkQd.jpg"
            },
            "name": "Picture",
            "type": "image"
        }
    ],
    "id": 169,
    "n_tasks": 2,
    "name": "Categorization"
}
```

{% endtab %}
{% endtabs %}

## Flush a queue

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

Deletes all tasks in a queue whose status is not completed. Successful requests will result in an empty task queue.

#### Path Parameters

| Name             | Type    | Description                  |
| ---------------- | ------- | ---------------------------- |
| ORGANIZATION\_ID | integer | The ID of your organization. |
| QUEUE\_ID        | integer | The ID of your queue.        |

#### Headers

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

{% tabs %}
{% tab title="200 Tasks successfully flushed" %}

```
```

{% endtab %}
{% endtabs %}
