Skip to main content
Live. This area is documented as current, user-reliable behavior.

Goal

Put messages on a queue from your app.

Prerequisites

  • A queue
  • An API key that can use the queue’s project

Workflow

1
Install the SDK for your language and create a client with your API key.
2
Call send for one message or sendBatch for up to 100.
3
Pass a delay when the message should wait before delivery.
4
Pass an idempotency key when a retry of your own code might send the same message twice.

Send one message

Send a batch

A batch takes up to 100 messages and 256 KB in total. Each message can set its own content type, delay and idempotency key. The reply lists the ids in the same order.

Content types

  • json (default): body is any JSON value and is delivered as the same value.
  • text: body is a string.
  • bytes: body is base64 in the API. The SDKs take raw bytes and encode them for you, and pulled messages have a bytes() helper (Bytes() in Go) that decodes them.
  • The SDKs check a batch holds at most 100 messages before sending anything.
  • A queue only accepts the content types chosen in its settings.

Delays and idempotency

  • delay_seconds holds a message back for up to 86,400 seconds (24 hours). Without it, the queue’s default delay applies.
  • idempotency_key makes a repeat send return the first message’s id with 200 instead of 201, and no second message is stored. Keys are remembered for the queue’s retention.

Expected result

Each send returns the message id (msg_ followed by 12 characters), when it was sent and when it becomes visible to the consumer.

Common failures

  • 413 message_too_large: a message is over 128 KB.
  • A batch over 100 messages or 256 KB is refused; split it.
  • 429 queue_rate_limited: the queue is taking more than 5,000 messages a second. Back off and try again.
  • 507 queue_full: the backlog has reached 25 GB. Fix or scale the consumer, or purge.

Consumers and Function consumers

Each queue has one consumer: a Function, an HTTPS endpoint, or pull. Function consumers are chosen in the dashboard or API, not in code.

Limits and error codes

Sizes, rates, retention and the error codes the Queues API returns when a limit is reached.

Laravel queue driver

Use StackShift Queues as a Laravel queue connection. dispatch() and php artisan queue:work keep working as they are.