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

# Create a queue

> Create a queue from the dashboard, the CLI or the API, with its retention, default delay, accepted content types, consumer and dead-letter queue.

> [!TIP]
>
> **Live.** This area is documented as current, user-reliable behavior.

## Goal

Create a queue that is ready to receive and deliver messages.

## Prerequisites

* A StackShift project
* An API key for the CLI or API

## Workflow

**Step 1**

Open Queues and choose New queue.

**Step 2**

Pick the project and a name. Names are unique within the project.

**Step 3**

Set retention (1 hour to 14 days, default 4 days) and an optional default delay.

**Step 4**

Choose which content types the queue accepts: json, text and bytes.

**Step 5**

Choose a consumer: Function, HTTPS push or pull. You can add or change it later.

**Step 6**

Choose a dead-letter queue: make a new one, use an existing one, or none.

**Step 7**

Create the queue.

## Naming a queue in calls

Anywhere a call takes a queue, pass its name, for example orders. If you have queues with that name in more than one project, the API answers 409 queue\_name\_ambiguous; then pass the queue id or \<project\_id>:\<name>, for example p\_789:orders (the CLI also takes --project).

## CLI

```bash Create and list theme={null}
stackshift queues create orders --project checkout-api
stackshift queues create emails --project checkout-api --retention 2d --consumer pull --max-retries 5
stackshift queues list --project checkout-api
stackshift queues get checkout-api:orders
```

## API

* The response is the queue (201) with its id, state, backlog and consumer.
* dead\_letter.mode is new (StackShift creates a dead-letter queue for you), existing (pass queue\_id) or none (messages that run out of retries are deleted).
* Leave out consumer to create the queue first and add one later with PUT /queues/\{queue}/consumer.
* PATCH /queues/\{queue} changes retention, default delay and accepted types. Shortening retention deletes older messages straight away.
* DELETE /queues/\{queue} with \{"confirm\_name": "orders"} deletes the queue. In the dashboard you type the name to confirm; in the CLI, stackshift queues delete checkout-api:orders --confirm orders.

```bash POST /api/v1/queues theme={null}
curl -X POST https://api.stackshift.cloud/api/v1/queues \
  -H "Authorization: Bearer $STACKSHIFT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "p_789",
    "name": "orders",
    "retention_seconds": 345600,
    "default_delay_seconds": 0,
    "accepts": ["json", "text", "bytes"],
    "consumer": {
      "kind": "https",
      "url": "https://app.example.com/queues/orders",
      "batch_size": 10,
      "batch_wait_ms": 5000,
      "max_retries": 3,
      "retry_delay_seconds": 30,
      "max_concurrency": 0
    },
    "dead_letter": { "mode": "new" }
  }'
```

## Expected result

> [!TIP]
>
> The queue shows in the Queues list as Active, or No consumer if you have not chosen one yet.

## Common failures

> [!WARNING]
>
> * The name is already used by another queue in the project: pick another name.
> * The CLI's --dead-letter is new, none or an existing queue. It defaults to new when you set a consumer and none otherwise.
> * Retention outside 1 hour to 14 days is refused.

## Related guides

> [card] [Send messages](https://docs.stackshift.cloud/queues/send-messages.md)
>
> Send one message or a batch of up to 100 from the SDKs, the CLI or the API, as JSON, text or bytes, with an optional delay and idempotency key.

> [card] [Consumers and Function consumers](https://docs.stackshift.cloud/queues/consumers.md)
>
> Each queue has one consumer: a Function, an HTTPS endpoint, or pull. Function consumers are chosen in the dashboard or API, not in code.

> [card] [Dead letters, redrive, pause and purge](https://docs.stackshift.cloud/queues/dead-letters-pause-and-purge.md)
>
> Find messages that ran out of retries, group them by error, send them back once fixed, pause delivery, or purge a queue.


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