# Queues & Cron

SQS-backed job queues that deliver HTTP requests to a consumer Worker with automatic retries, dead letters, and UTC cron schedules.

A **Queue** delivers messages to a consumer Worker in your organization. Delivery is at-least-once and unordered, backed by Amazon SQS.

## Creating a Queue & Sending Messages

:::tabs
::tab skopik
```bash
skopik create_queue --name jobs --worker api
skopik send_message --queue jobs --body '{"task":"reindex"}'
```
::tab curl
```bash
curl -X POST https://api.platform.skopik.com/v1/queues \
  -H "Authorization: Bearer $SKOPIK_API_KEY" \
  -H "content-type: application/json" \
  -d '{"name": "jobs", "worker": "api", "alias": "production"}'

curl -X POST https://api.platform.skopik.com/v1/queues/jobs/messages \
  -H "Authorization: Bearer $SKOPIK_API_KEY" \
  -H "content-type: application/json" \
  -d '{"task": "reindex"}'
```
::tab MCP
```json
{
  "tool": "send_message",
  "arguments": {
    "queue": "jobs",
    "body": "{\"task\":\"reindex\"}"
  }
}
```
:::

## Consumer Delivery Contract

When a message is ready, the platform sends an HTTP request to your consumer Worker:

- **Method & Path:** `POST /_mh/queues/<queue>` (or `POST <path>` for crons declared in a root `skopik.json`).
- **Headers:** `x-mh-queue` (`x-skopik-queue`), `x-mh-message-id`, `x-mh-attempt`, and `x-mh-schedule` (when triggered by a schedule).
- **Retries:** A `2xx` response within **30 seconds** marks the message done. Any other status or timeout retries after **10, 20, 40, and 80 seconds**.
- **Dead letters:** After **5 failed attempts**, the message moves to dead letters (`GET /v1/queues/{queue}/dead-letters` or MCP `list_dead_letters`).
- **Payload size:** 1 byte to **256 KiB** per message, or up to 10 messages (256 KiB combined) via `POST /v1/queues/{queue}/messages/batch`.

## Cron Schedules

Attach up to **10** five-field UTC cron schedules to any Queue (at most once per minute):

```bash
skopik create_schedule \
  --queue jobs \
  --name nightly-report \
  --cron "0 3 * * *" \
  --body '{"report":"daily"}'
```

If you deploy via [Git Integration](/docs/git-integration/), you can also declare `crons` directly under a service in your root `skopik.json`, and the platform automatically creates and reconciles a `<service>-cron` Queue on production pushes.
