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

# Queue

> Send, lease, and acknowledge messages with standard and FIFO queues.

Queue holds messages until a consumer processes and acknowledges them. Use
standard queues for at-least-once delivery with best-effort ordering, or FIFO
queues for ordered processing within each message group.

The service is regional. The endpoint for São Paulo is
`https://queue.sa-saopaulo-1.basaltic.sh`. Calls use a bearer token and the
account handle in `X-Account-Id`; see [Authentication](/authentication).

## Receiving is a lease

Receiving hides a message for the visibility timeout and returns a receipt
handle. Delete the message with that handle when processing succeeds. If the
lease expires first, the message becomes available again. A new receive
returns a new handle; an expired handle cannot acknowledge another consumer's
lease.

Use the visibility endpoint to extend or shorten a current lease. The peek
endpoint is a separate operation and permission: it inspects messages without
leasing them.

## Queue contracts

| Contract | Behavior |
| - | - |
| Standard | At-least-once delivery and best-effort ordering. Consumers must tolerate redelivery. |
| FIFO | The name ends in `.fifo`; ordering is within `message_group_id`. The queue type is fixed at creation. |
| Long polling | `wait_time_seconds` waits up to 20 seconds for a message. |
| Acknowledgment | Delete with the receipt handle from the current lease. |
| Encryption | Message bodies are encrypted at rest. A customer KMS binding uses `kms_key`. |

Queue responses expose customer-managed encryption as a `kms_key` resource
reference with `id`, `crn`, and `name`. Platform encryption omits that field.
If the key's metadata is unavailable, its reference retains the stored ID and
CRN without a name. This does not switch the queue to platform encryption.

A queue's `redrive_policy.dead_letter_queue` is a resource reference with the
target queue's `id`, `crn`, and `name`. Create and update requests still accept
a UUID, name, or CRN string in that field. `max_receive_count` controls when a
message moves to the target.

On updates, omitting `kms_key` or `redrive_policy` preserves the current value.
Send `kms_key: null` to restore platform encryption for future messages, or
`redrive_policy: null` to remove the dead-letter policy. Existing messages
keep the encryption key that sealed them.

## Metrics

Open a queue's **Metrics** tab for queue depth, message traffic, oldest available
message age, and stored payload. Use the time-range controls to compare changes
over time. The same series are available through [Telemetry](/telemetry#metrics)
and can be used in metric alerts.

Series are sampled every 30 seconds and carry `queue_id` and `region` labels.
Reads require `telemetry:ReadMetrics` in the selected account and region.
On FIFO queues, an earlier message in the same group can still block receiving
a message counted as available.

| Metric | Type | Meaning |
| - | - | - |
| `basaltic_queue_messages_available` | Gauge | Unexpired messages whose visibility time has elapsed. |
| `basaltic_queue_messages_in_flight` | Gauge | Unexpired messages with an active visibility lease. |
| `basaltic_queue_messages_delayed` | Gauge | Unexpired messages whose initial delay has not elapsed. |
| `basaltic_queue_stored_bytes` | Gauge | Payload bytes in unexpired messages. |
| `basaltic_queue_oldest_available_message_age_seconds` | Gauge | Time since enqueue of the oldest available message; zero when empty. |
| `basaltic_queue_messages_enqueued_total` | Counter | Stored messages, including arrivals from redrive; deduplicated sends are excluded. |
| `basaltic_queue_messages_received_total` | Counter | Message leases, including redeliveries. |
| `basaltic_queue_messages_removed_total` | Counter | Removals through acknowledgement, expiry, purge, or redrive. |
| `basaltic_queue_bytes_enqueued_total` | Counter | Payload bytes accepted into the queue. |

Use `last` for current depth and `rate` for per-second traffic. Counters start
when this metrics feature is deployed and persist through message deletion and
worker restarts. Earlier traffic is not backfilled. An idle queue emits zero
gauges; a missing observation leaves a gap instead of reporting zero.

<CardGroup cols={2}>
  <Card title="Create a queue" href="/queue/creating">Choose type, timing, encryption, and a dead-letter destination.</Card>
  <Card title="Send and consume" href="/queue/messages">Lease messages, extend visibility, and acknowledge processing.</Card>
  <Card title="FIFO and dead-letter queues" href="/queue/fifo-and-dead-letter-queues">Control ordering and isolate repeated failures.</Card>
  <Card title="Permissions" href="/queue/permissions">Separate producers, consumers, and queue administrators.</Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.