SDK Reference
Python SDK
REST API

API

The SDK exposes a rest client for interacting with the Hatchet REST API. This allows you to read, create, update, and delete workflows.

The admin client can be accessed via:

hatchet = Hatchet(debug=True)
 
list : WorkflowList = hatchet.client.rest().workflow_list()

Methods

put_workflow

put_workflow(name: str, workflow: CreateWorkflowVersionOpts | WorkflowMeta, overrides: CreateWorkflowVersionOpts | None = None): list

Creates or updates a workflow. This can use an existing workflow class to extend from and overwrite. For example:

@hatchet.workflow()
class BaseWorkflow:
    @hatchet.step()
    def step1(self, context: Context):
        return {
            "result": "success!"
        }
 
    @hatchet.step(parents=["step1"],timeout='4s')
    def step2(self, context):
        return {
            "result2": "success!"
        }
 
hatchet.client.admin.put_workflow(
    "workflow-copy",
    BaseWorkflow(),
    overrides=CreateWorkflowVersionOpts(
        cron_triggers=["*/15 * * * *"],
        cron_input=json.dumps({"test": "test"}),
    ),
)

workflow_list

workflow_list(): list

List all workflows for the tenant.

Returns

WorkflowList

A list of workflows.

workflow_get

workflow_get(workflow_id: str): dict

Get a workflow by its ID.

Parameters

NameTypeDescription
workflow_idstrThe workflow ID.

Returns

Workflow

The workflow details.

workflow_version_get

workflow_version_get(workflow_id: str, version: str | None = None): dict

Get a specific version of a workflow.

Parameters

NameTypeDescription
workflow_idstrThe workflow ID.
version`strNone`The version of the workflow. If None, the latest version is returned.

Returns

WorkflowVersion

The workflow version details.

workflow_run_list

workflow_run_list(workflow_id: str | None = None, offset: int | None = None, limit: int | None = None, event_id: str | None = None): list

List workflow runs, optionally filtered by parameters.

Parameters

NameTypeDescription
workflow_id`strNone`The workflow ID to filter by.
offset`intNone`Pagination offset.
limit`intNone`Pagination limit.
event_id`strNone`Event ID to filter by.

Returns

WorkflowRunList

A list of workflow runs.

workflow_run_get

workflow_run_get(workflow_run_id: str): dict

Get a specific workflow run.

Parameters

NameTypeDescription
workflow_run_idstrThe ID of the workflow run to get.

Returns

WorkflowRun

The workflow run details.

workflow_run_create

workflow_run_create(workflow_id: str, input: Dict[str, Any]): dict

Create and trigger a workflow run with specified input.

Parameters

NameTypeDescription
workflow_idstrThe ID of the workflow to run.
inputDict[str, Any]The input for the workflow run.

Returns

WorkflowRun

The details of the created workflow run.