Menu
Platform
AI
Alerts and status pages
App store purchases
Credits
Generated Assets
Knowledge
KV
Localization
Notifications
Organizations
Payments
Queues
Realtime
Sandboxes
Storage
Workflows
API reference
- Overview
- Access API keys
- Agent sessions API
- Agent versions API
- Agents API
- AI models API
- Artifact references API
- Artifacts API
- Assets API
- Auth configs API
- Bank receipts API
- Bank transfer accounts API
- Buckets API
- Builds API
- Catalogs API
- Chat profiles API
- Chat reports API
- Chat sticker packs API
- Checkout policies API
- Checkout sessions API
- Config changes API
- Config flags API
- Config segments API
- Connection providers API
- Connections API
- Connectors API
- Credit grants API
- Customer organizations API
- Customer subscriptions API
- Databases API
- Documents API
- Email domains API
- End users API
- Entities API
- Entitlement grants API
- Entries API
- Environments API
- Episodes API
- Error events API
- Error groups API
- Events API
- Exchange rates API
- Generations API
- Glossaries API
- Goals API
- Identities API
- Inbound emails API
- Inbound endpoints API
- Inbound messages API
- Inbound sms API
- Invitations API
- Job runs API
- Jobs API
- Knowledge schemas API
- KV API
- KV namespaces API
- Lease events API
- Leases API
- Licence keys API
- Licence tokens API
- Mail domains API
- Mail routes API
- Mailbox connect links API
- Mailbox OAUTH apps API
- Mailboxes API
- Memberships API
- Memories API
- Memory stores API
- Merchant accounts API
- Message topics API
- Messages API
- OAUTH clients API
- Objects API
- Organization roles API
- Orgs API
- Owner pools API
- Phone numbers API
- Portal sessions API
- Preferences API
- Price catalogs API
- Processor events API
- Projects API
- Queued executions API
- Queues API
- Realtime channels API
- Realtime members API
- Realtime messages API
- Recipients API
- Relations API
- Releases API
- Revenue API
- Revenue facts API
- Revenue sources API
- Runs API
- Sandbox shapes API
- Schedules API
- Scrubbing policies API
- Search API
- Search indexes API
- Secret versions API
- Secrets API
- Service enablements API
- Service observations API
- Services API
- Serving routes API
- Session events API
- Sessions API
- Signing key versions
- Signing keys
- Sms numbers API
- Source maps API
- Spaces API
- Store connections API
- Store consumption requests API
- Store purchases API
- Subscriptions API
- Suppressions API
- Tax threshold statuses API
- Templates API
- Test clocks API
- Token exchanges API
- Transfers API
- Trust policies API
- Trusted issuers API
- Uptime checks API
- Uptime manifests API
- Uptime sources API
- Usage events API
- Usage invoices API
- Usage meter prices API
- Usage meters API
- Usage reservations API
- Usage settings API
- Usage tiers API
- Volumes API
- Waits API
- Webhook deliveries API
- Webhook endpoints API
- Workflows API
Getting Started
Authentication
KV Store
Deploy & Infrastructure
Reference
Queues quickstart
A queue, a message sent, leased and acked, and a failure replayed
This takes you from nothing to a message that was sent, leased by a worker and
acked, and then a failing message brought back from the dead-letter set. It
uses only a key and curl; nothing is deployed.
The examples use the environment orgs/acme/projects/shop/envs/production;
use your own. sylphx access whoami prints the environment your key belongs
to, and a key only reaches its own environment.
export ENV=orgs/acme/projects/shop/envs/production#1. Create the queue
The queue id is the last segment of its name, and every producer and worker names it, so choose it. Here a lease hides a message for a minute, and a message dead-letters after three deliveries.
curl -sS -X POST "https://api.sylphx.com/v1/$ENV/queues?queue_id=emails" \
-H "Authorization: Bearer $SYLPHX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"spec": {"visibility_timeout": "60s", "max_deliveries": 3}}'#2. Send a message
A message is a CloudEvent. id and source identify it, type says what it
is, and data is the payload.
curl -sS -X POST "https://api.sylphx.com/v1/$ENV/queues/emails:send" \
-H "Authorization: Bearer $SYLPHX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"events": [{"id": "welcome-42", "source": "https://shop.example.com/signup", "type": "email.welcome", "data": {"user": "42"}}]}'The answer is the message ids, in the order you sent them.
#3. Lease it
This is the worker's call. wait keeps the call open up to 20 seconds when
the queue is empty, so a worker loop does not spin.
curl -sS -X POST "https://api.sylphx.com/v1/$ENV/queues/emails:lease" \
-H "Authorization: Bearer $SYLPHX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"max_messages": 10, "wait": "20s"}' > leased.json
jq '.messages[] | {message_id, delivery_count, type: .event.type}' leased.jsonEach leased message carries the event you sent, its delivery_count (1 the
first time) and a lease. For the next minute no other worker can lease it.
#4. Ack it
When the work is done, hand the leases back:
jq '{leases: [.messages[].lease]}' leased.json |
curl -sS -X POST "https://api.sylphx.com/v1/$ENV/queues/emails:ack" \
-H "Authorization: Bearer $SYLPHX_API_KEY" \
-H "Content-Type: application/json" \
-d @-An empty stale_leases means every ack was applied and the message is gone.
A lease that ran out before the ack, and was taken by another worker, comes
back in stale_leases instead: that worker now owns the message.
#5. Fail it, and replay it
Send a second message (step 2 with another id), then three times over lease
it (step 3) and nack it, as a worker would when the work keeps failing:
jq '{leases: [.messages[].lease]}' leased.json |
curl -sS -X POST "https://api.sylphx.com/v1/$ENV/queues/emails:nack" \
-H "Authorization: Bearer $SYLPHX_API_KEY" \
-H "Content-Type: application/json" \
-d @-After the third delivery the message is dead-lettered, and the queue's counts show it:
curl -sS "https://api.sylphx.com/v1/$ENV/queues/emails" \
-H "Authorization: Bearer $SYLPHX_API_KEY" | jq .statusdead_letter_count is 1 and ready_count is 0. Once the worker is fixed,
return it to the queue:
curl -sS -X POST "https://api.sylphx.com/v1/$ENV/queues/emails:replay" \
-H "Authorization: Bearer $SYLPHX_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'replayed_count is 1, and the next lease delivers the message again with
delivery_count back at 1.
At least once
A worker can finish the work and crash before its ack, so the same message can be delivered twice. Make the effect idempotent on the message id, which stays the same across deliveries.