SDK Reference
Python SDK
Event-Triggered Workflows

Running Workflows via Events

Pushing Single Events

For workflows with event triggers, you can push events to the Hatchet API with the client.event.push method:

from hatchet_sdk import Hatchet
 
hatchet = Hatchet()
 
hatchet.client.event.push(
    "user:create",
    {
        "test": "test"
    }
)

The event's input data will be passed to the workflow run as the input, and is retrievable via the context.workflow_input() method.

Pushing Multiple Events

Sometimes we would like to push many events at the same time. You can use the bulk_push client.event.bulk_push method:

from hatchet_sdk import Hatchet
 
hatchet = Hatchet()
 
events: List[BulkPushEventWithMetadata] = [
    {
        "key": "event1",
        "payload": {"message": "This is event 1"},
        "additional_metadata": {"source": "test", "user_id": "user123"},
    },
    {
        "key": "event2",
        "payload": {"message": "This is event 2"},
        "additional_metadata": {"source": "test", "user_id": "user456"},
    },
    {
        "key": "event3",
        "payload": {"message": "This is event 3"},
        "additional_metadata": {"source": "test", "user_id": "user789"},
    },
]
 
 
result =
hatchet.client.event.bulk_push(
    events
)