Skip to content

The Python Workers platform leverages FFI to access bindings to Cloudflare resources. Refer to the bindings documentation for more information.

From the configuration perspective, enabling Python Workflows requires adding the python_workflows compatibility flag to your Wrangler configuration file.

JSONC
{
"$schema": "./node_modules/wrangler/config-schema.json",
"name": "workflows-starter",
"main": "src/index.py",
// Set this to today's date
"compatibility_date": "2026-04-03",
"compatibility_flags": ["python_workflows", "python_workers"],
"workflows": [
{
// name of your workflow
"name": "workflows-starter",
// binding name env.MY_WORKFLOW
"binding": "MY_WORKFLOW",
// this is class that extends the Workflow class in src/index.py
"class_name": "MyWorkflow",
}
]
}

And this is how you use the payload in your workflow:

Python
from workers import WorkflowEntrypoint
class DemoWorkflowClass(WorkflowEntrypoint):
async def run(self, event, step):
@step.do('step-name')
async def first_step():
payload = event["payload"]
return payload

Workflow

The Workflow binding gives you access to the Workflow class. All its methods are available on the binding.

Under the hood, the Workflow binding is a Javascript object that is exposed to the Python script via JsProxy. This means that the values returned by its methods are also JsProxy objects, and need to be converted back into Python objects using python_from_rpc.

create

Create (trigger) a new instance of a given Workflow.

  • create(options=None)* options - an optional dictionary of options to pass to the workflow instance. Should contain the same keys as the WorkflowInstanceCreateOptions type.
Python
from js import Object
from pyodide.ffi import to_js
from workers import WorkerEntrypoint, Response