Skip to content

Example: CLI demo

Context

  • Runtime: macOS/Linux shell
  • Permissions: messages:write, messages:read, messages:ack

What it does

Publishes one message, polls for it, then acknowledges it.

Run it

export IRON_API_KEY='YOUR_SANDBOX_KEY'
export IRON_BASE_URL='https://sandbox.api.iron.example'

MESSAGE_ID=$(curl -sS -X POST "$IRON_BASE_URL/v1/messages" \
  -H "Authorization: Bearer $IRON_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: example-cli-1" \
  -d '{"type":"demo","data":{"n":1}}' | \
  python -c 'import sys, json; print(json.load(sys.stdin)["id"])')

echo "published: $MESSAGE_ID"

curl -sS "$IRON_BASE_URL/v1/messages:poll?max=1&visibility_timeout_seconds=30" \
  -H "Authorization: Bearer $IRON_API_KEY"

echo

curl -sS -X POST "$IRON_BASE_URL/v1/messages/$MESSAGE_ID:ack" \
  -H "Authorization: Bearer $IRON_API_KEY"

echo

Expected result

  • Prints published: msg_...
  • Poll response includes your message
  • Ack returns { "status": "acked" }

Common failure modes


Next: Getting Started · Reference · Changelog · Support