ScalixScalix Docs
Sign up

Events

Pub/Sub event bus with topics, subscriptions, and webhook delivery

Overview

Scalix Events is a Pub/Sub system for event-driven architectures. Publish events to topics, subscribe with webhooks or functions, and track delivery with automatic retries.

CLI

bash
# Create a topic
scalix-cloud events topic create order-events
 
# Publish an event: <topic> <event_type> <json-data>
scalix-cloud events publish order-events order.created '{"order_id": "ord_123", "total": 99.99}'
 
# List topics
scalix-cloud events topics
 
# List subscriptions
scalix-cloud events subs

Subscriptions are created through the REST API (below) or the console; the CLI lists them.

REST API

Create a topic

bash
curl -X POST https://api.scalix.world/v1/events/topics \
  -H "Authorization: Bearer $SCALIX_API_KEY" \
  -d '{"name": "order-events"}'

Publish an event

bash
curl -X POST https://api.scalix.world/v1/events/topics/{topic_id}/publish \
  -H "Authorization: Bearer $SCALIX_API_KEY" \
  -d '{
    "event_type": "order.created",
    "data": {"order_id": "ord_123", "total": 99.99},
    "source": "checkout-service"
  }'

Subscribe

bash
curl -X POST https://api.scalix.world/v1/events/topics/{topic_id}/subscriptions \
  -H "Authorization: Bearer $SCALIX_API_KEY" \
  -d '{
    "sub_type": "webhook",
    "config": {"url": "https://myapp.com/webhooks/orders"},
    "filter": {"event_types": ["order.created"]},
    "max_retries": 5
  }'

Function subscriptions

Trigger a Scalix Function when an event is published:

bash
curl -X POST https://api.scalix.world/v1/events/topics/{topic_id}/subscriptions \
  -H "Authorization: Bearer $SCALIX_API_KEY" \
  -d '{
    "sub_type": "function",
    "config": {"function_id": "<function uuid>"},
    "filter": {"event_types": ["order.created"]}
  }'

The function is addressed by its id (config.function_id, the value the functions API/console reports), not by name.

Filter semantics

filter is matched per event:

  • event_types: [...]: an allowlist matched against the event's event_type (not against the data payload)
  • event_type: "...": a single event type, equality
  • any other key: an exact match against the event's data payload
  • absent, null, or {}: matches everything

Delivery payloads

Both subscriber types receive the same event envelope:

json
{
  "event_id": "<event uuid>",
  "event_type": "order.created",
  "data": { "order_id": "ord_123", "total": 99.99 },
  "project_id": "<project uuid>"
}

For a webhook subscription this JSON is the POST body. For a function subscription it arrives as the handler's first-argument payload (see Functions for the handler contract).

Delivery

Events are delivered to subscribers with automatic retries:

  • Retry strategy: Exponential backoff
  • Max retries: Configurable (default: 3)
  • Delivery tracking: View attempt history, status codes, and response times
bash
curl https://api.scalix.world/v1/events/subscriptions/{sub_id}/deliveries \
  -H "Authorization: Bearer $SCALIX_API_KEY"