Goal
Manage queues, consumers, messages, dead letters, tokens and sources from your own code.Prerequisites
- An API key. A pull token works only for pull and ack on its queue.
Workflow
1
Authenticate with Authorization: Bearer and your API key.
2
Pass {queue} as the queue name, or as its id or <project_id>:<name> when the name exists in more than one of your projects (otherwise 409 queue_name_ambiguous).
3
Send and read JSON. Times are RFC 3339 in UTC.
Queues
- GET /queues?project_id= lists queues.
- POST /queues creates one: project_id, name, retention_seconds, default_delay_seconds, accepts, consumer, dead_letter {mode: new | existing | none, queue_id}.
- GET /queues/{queue}; PATCH /queues/{queue} with retention_seconds, default_delay_seconds, accepts; DELETE /queues/{queue} with confirm_name.
- POST /queues/{queue}/pause and /resume; POST /queues/{queue}/purge with confirm_name returns purged_count.
- A queue has id, project_id, project_name, name, role (queue or dead_letter), dead_letter_for, state (active, paused or no_consumer), paused_at, paused_by, retention_seconds, default_delay_seconds, accepts, backlog_count, backlog_bytes, oldest_age_seconds, in_per_minute, out_per_minute, failed_24h, operations_month, consumer and created_at.
Consumer
- PUT /queues/{queue}/consumer with kind, function_path, function_project_id, url, batch_size, batch_wait_ms, max_retries, retry_delay_seconds, max_concurrency (0 = auto) and dead_letter {mode: new|existing|none, queue_id}.
- DELETE /queues/{queue}/consumer removes it.
- The consumer also reports running_batches, last_error and last_error_at.
Messages
- POST /queues/{queue}/messages with body, content_type, delay_seconds, idempotency_key returns id, sent_at, visible_at.
- POST /queues/{queue}/messages/batch with messages (up to 100, 256 KB) returns their ids.
- POST /queues/{queue}/messages/pull with batch_size and visibility_timeout_ms; POST /queues/{queue}/messages/ack with acks and retries.
- GET /queues/{queue}/messages?state=ready|delayed|leased&q=&limit=&cursor= lists messages oldest first with counts per state. Reading never leases.
- GET /queues/{queue}/messages/{id} returns one message with its body and its last retry.
- DELETE /queues/{queue}/messages with message_ids deletes them.
Health and failures
- GET /queues/{queue}/metrics?range=1h|24h|7d|14d returns points with waiting, in, out, acked, retried, dead_lettered and oldest_age_seconds.
- GET /queues/{queue}/failures?limit=20 lists dead-lettered messages and retried batches with their error.
- GET /queues/{queue}/dead-letters/groups and POST /queues/{queue}/redrive on a dead-letter queue.
Tokens, sources and usage
- GET, POST /queues/{queue}/tokens and DELETE /queues/{queue}/tokens/{id}. POST takes a name and returns the token once.
- GET, POST /queues/{queue}/sources and DELETE /queues/{queue}/sources/{id}. POST takes events and optional project_ids.
- GET /queues/usage?month=YYYY-MM.
SDKs and CLI
- JavaScript and Python: client.queues on the StackShift client. Go: client.Queues. PHP: new \StackShift\QueuesClient($token). Ruby: StackShift::QueuesClient.new(api_key:), or client.queues on AssetsClient and ComputersClient, with send_message and send_batch.
- CLI: stackshift queues create, list, get, delete, send, pull, ack, retry, tail, pause, resume, purge, redrive, and consumer set and consumer remove.
Expected result
Your code can do everything the Queues dashboard does.
Related guides
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.
Send messages
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.
Pull consumers
A worker anywhere pulls a batch over HTTP, leases the messages for a visibility timeout, then acks or retries each one by lease id.