> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuro-tech.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Queue API

> Enqueue, peek, dequeue, batch, wait, and clear typed items over HTTP

The Queue API at `/Queues/{queueName}` provides authenticated FIFO queues with content decoding/encoding and delayed responses.

## Methods

| Method                  | Operation                             | Success                              |
| ----------------------- | ------------------------------------- | ------------------------------------ |
| `GET /Queues`           | API documentation                     | `200`                                |
| `PUT /Queues/{name}`    | Enqueue request body                  | `204`                                |
| `POST /Queues/{name}`   | Dequeue, or peek with query parameter | `200` with item, `204/404` when none |
| `DELETE /Queues/{name}` | Clear all items                       | `204`                                |

## Authorization

The account needs:

```text theme={null}
Admin.Queues.<QUEUE_NAME>.<OPERATION>
```

For example:

```text theme={null}
Admin.Queues.InvoiceEvents.Enqueue
Admin.Queues.InvoiceEvents.Dequeue
```

Supported authentication includes mTLS, JWT bearer, and configured HTTP authentication schemes. HTTPS with at least 128-bit security is required when encryption is enabled.

## Enqueue

```bash theme={null}
curl --fail -X PUT \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"invoiceId":"inv-123"}' \
  "https://neuron.example.com/Queues/InvoiceEvents?Timeout=30000"
```

The server first decodes the request by `Content-Type`, then serializes the resulting object for the queue. Expect `415` for an unsupported type and `422` when the decoded object cannot be serialized.

## Dequeue or peek

```bash theme={null}
curl --fail -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json" \
  "https://neuron.example.com/Queues/InvoiceEvents?Timeout=30000"
```

Use `Peek=1` to read without removal. Use `Count=N` for a batch; batches are returned as `multipart/mixed`, even when `N=1`. `MinTimeout` waits briefly for the remainder after the first item arrives.

| Query        | Applies to   | Range/default                     |
| ------------ | ------------ | --------------------------------- |
| `Timeout`    | PUT, POST    | 0–90000 ms; default 30000         |
| `Count`      | POST dequeue | 1+; default 1                     |
| `MinTimeout` | Batched POST | 0–`Timeout`                       |
| `Peek`       | Single POST  | 0 or 1; incompatible with `Count` |

Use HTTP/2 so many delayed dequeue requests can share a connection efficiently.

## Consumer design

Dequeue removes the item, so persist the business result before considering processing complete. Use an application idempotency key because a caller can fail after the server dequeues but before the caller records success.
