Ruby SDKFeature Clients

Runs Client

Runs client for interacting with Hatchet workflow run management API.

This class provides a high-level interface for creating and managing workflow runs in the Hatchet system. It wraps the generated REST API client with a more convenient Ruby interface.

response = hatchet.runs.create(
  name: "my-workflow",
  input: { key: "value" },
  additional_metadata: { source: "api" }
)

It is available on the main client as hatchet.runs.

Methods:

NameDescription
get_task_runGet task run details for a given task run ID.
getGet a workflow run by its ID.
get_detailsGet full workflow run details for a given workflow run ID.
get_statusGet workflow run status for a given workflow run ID.
list_with_paginationList task runs according to a set of filters, paginating through days.
listList task runs according to a set of filters.
createCreates a new workflow run in the Hatchet system.
replayReplay a task or workflow run.
bulk_replayReplay task or workflow runs in bulk, according to a set of filters.
cancelCancel a task or workflow run.
bulk_cancelCancel task or workflow runs in bulk, according to a set of filters.
get_resultGet the result of a workflow run by its external ID.
bulk_replay_by_filters_with_paginationReplay runs matching the specified filters in chunks.
bulk_cancel_by_filters_with_paginationCancel runs matching the specified filters in chunks.
get_run_refGet a reference to a workflow run.
pollPoll for workflow run completion with configurable interval and timeout.
subscribe_to_streamSubscribe to stream events for a workflow run.

Functions

get_task_run

Get task run details for a given task run ID.

Parameters:

NameTypeDescriptionDefault
task_run_idStringThe ID of the task run to retrieve details for.required

Returns:

TypeDescription
HatchetSdkRest::V1TaskSummaryTask run details for the specified task run ID.

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

get

Get a workflow run by its ID.

Returns the unwrapped V1WorkflowRun object directly (with status, output, etc.) Use get_details if you need the full details wrapper (task_events, shape, tasks, etc.)

Parameters:

NameTypeDescriptionDefault
workflow_run_idStringThe ID of the workflow run to retrieve.required

Returns:

TypeDescription
HatchetSdkRest::V1WorkflowRunThe workflow run.

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

get_details

Get full workflow run details for a given workflow run ID.

Returns the full V1WorkflowRunDetails including task_events, shape, tasks, and workflow_config.

Parameters:

NameTypeDescriptionDefault
workflow_run_idStringThe ID of the workflow run to retrieve details for.required

Returns:

TypeDescription
HatchetSdkRest::V1WorkflowRunDetailsFull workflow run details.

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

get_status

Get workflow run status for a given workflow run ID.

Parameters:

NameTypeDescriptionDefault
workflow_run_idStringThe ID of the workflow run to retrieve status for.required

Returns:

TypeDescription
HatchetSdkRest::V1TaskStatusThe task status.

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

list_with_pagination

List task runs according to a set of filters, paginating through days.

Parameters:

NameTypeDescriptionDefault
sinceTime | nilThe start time for filtering task runs.nil
only_tasksBooleanWhether to only list task runs.false
offsetInteger | nilThe offset for pagination.nil
limitInteger | nilThe maximum number of task runs to return.nil
statusesArray<HatchetSdkRest::V1TaskStatus> | nilThe statuses to filter task runs by.nil
until_timeTime | nilThe end time for filtering task runs.nil
additional_metadataHash<String, String> | nilAdditional metadata to filter task runs by.nil
workflow_idsArray<String> | nilThe workflow IDs to filter task runs by.nil
worker_idString | nilThe worker ID to filter task runs by.nil
parent_task_external_idString | nilThe parent task external ID to filter task runs by.nil
triggering_event_external_idString | nilThe event id that triggered the task run.nil
include_payloadsBooleanWhether to include payloads in the response (default: true)true

Returns:

TypeDescription
Array<HatchetSdkRest::V1TaskSummary>A list of task runs matching the specified filters.

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

list

List task runs according to a set of filters.

Parameters:

NameTypeDescriptionDefault
sinceTime | nilThe start time for filtering task runs.nil
only_tasksBooleanWhether to only list task runs.false
offsetInteger | nilThe offset for pagination.nil
limitInteger | nilThe maximum number of task runs to return.nil
statusesArray<HatchetSdkRest::V1TaskStatus> | nilThe statuses to filter task runs by.nil
until_timeTime | nilThe end time for filtering task runs.nil
additional_metadataHash<String, String> | nilAdditional metadata to filter task runs by.nil
workflow_idsArray<String> | nilThe workflow IDs to filter task runs by.nil
worker_idString | nilThe worker ID to filter task runs by.nil
parent_task_external_idString | nilThe parent task external ID to filter task runs by.nil
triggering_event_external_idString | nilThe event id that triggered the task run.nil
include_payloadsBooleanWhether to include payloads in the response (default: true)true

Returns:

TypeDescription
HatchetSdkRest::V1TaskSummaryListA list of task runs matching the specified filters.

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

create

Creates a new workflow run in the Hatchet system.

This method triggers a new workflow or task run for the specified workflow using the provided input data. The workflow run will be queued according to the workflow definition on an available worker.

IMPORTANT: It's preferable to use Workflow.run (and similar) to trigger workflows if possible. This method is intended to be an escape hatch.

response = hatchet.runs.create(
  name: "simple-workflow",
  input: { user_id: 123, action: "process_data" },
  additional_metadata: { source: "api", priority: "high" }
)

Parameters:

NameTypeDescriptionDefault
nameStringThe name of the workflow to trigger.required
inputHashThe input data for the workflow run.required
additional_metadataHash | nilAdditional metadata associated with the workflow run.nil
priorityInteger | nilThe priority of the workflow run.nil

Returns:

TypeDescription
HatchetSdkRest::V1WorkflowRunDetailsThe details of the triggered workflow run.

Raises:

TypeDescription
ArgumentErrorIf the workflow_name or input parameters are nil or invalid.
Hatchet::ErrorIf the API request fails or returns an error.

replay

Replay a task or workflow run.

Parameters:

NameTypeDescriptionDefault
run_idStringThe external ID of the task or workflow run to replay.required

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

bulk_replay

Replay task or workflow runs in bulk, according to a set of filters.

Parameters:

NameTypeDescriptionDefault
optsBulkCancelReplayOpts | nilOptions for bulk replay, including filters and IDs.nil
idsArray<String> | nilList of run IDs to replay.nil
filtersHash | nilFilter hash with :workflow_ids, :additional_metadata, :since, :until_time, :statuses.nil

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

cancel

Cancel a task or workflow run.

Parameters:

NameTypeDescriptionDefault
run_idStringThe external ID of the task or workflow run to cancel.required

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

bulk_cancel

Cancel task or workflow runs in bulk, according to a set of filters.

Parameters:

NameTypeDescriptionDefault
optsBulkCancelReplayOpts | nilOptions for bulk cancel, including filters and IDs.nil
idsArray<String> | nilList of run IDs to cancel.nil
filtersHash | nilFilter hash with :workflow_ids, :additional_metadata, :since, :until_time, :statuses.nil

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

get_result

Get the result of a workflow run by its external ID.

Parameters:

NameTypeDescriptionDefault
run_idStringThe external ID of the workflow run to retrieve the result for.required

Returns:

TypeDescription
HashThe result of the workflow run.

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

bulk_replay_by_filters_with_pagination

Replay runs matching the specified filters in chunks.

This method provides an easy way to perform bulk replay operations by filters over a larger number of runs than the API would normally handle, with automatic pagination and chunking to limit pressure on the API.

Parameters:

NameTypeDescriptionDefault
sleep_timeIntegerThe time to sleep between processing chunks, in seconds (default: 3)3
chunk_sizeIntegerThe maximum number of run IDs to process in each chunk (default: 500)500
sinceTime | nilThe start time for filtering runs.nil
until_timeTime | nilThe end time for filtering runs.nil
statusesArray | nilThe statuses to filter runs by (default: FAILED, CANCELLED)nil
additional_metadataHash | nilAdditional metadata to filter runs by.nil
workflow_idsArray<String> | nilThe workflow IDs to filter runs by.nil

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

bulk_cancel_by_filters_with_pagination

Cancel runs matching the specified filters in chunks.

This method provides an easy way to perform bulk cancel operations by filters over a larger number of runs than the API would normally handle, with automatic pagination and chunking to limit pressure on the API.

Parameters:

NameTypeDescriptionDefault
sleep_timeIntegerThe time to sleep between processing chunks, in seconds (default: 3)3
chunk_sizeIntegerThe maximum number of run IDs to process in each chunk (default: 500)500
sinceTime | nilThe start time for filtering runs.nil
until_timeTime | nilThe end time for filtering runs.nil
statusesArray | nilThe statuses to filter runs by (default: RUNNING, QUEUED)nil
additional_metadataHash | nilAdditional metadata to filter runs by.nil
workflow_idsArray<String> | nilThe workflow IDs to filter runs by.nil

Raises:

TypeDescription
Hatchet::ErrorIf the API request fails or returns an error.

get_run_ref

Get a reference to a workflow run.

Parameters:

NameTypeDescriptionDefault
workflow_run_idStringThe ID of the workflow run to get a reference to.required

Returns:

TypeDescription
Hatchet::WorkflowRunRefA reference to the specified workflow run.

poll

Poll for workflow run completion with configurable interval and timeout.

This method repeatedly calls get until the workflow run reaches a terminal state (succeeded, failed, or cancelled) or the timeout is reached.

result = hatchet.runs.poll("workflow-run-123")
result = hatchet.runs.poll("workflow-run-123", interval: 2.0, timeout: 30.0)

Parameters:

NameTypeDescriptionDefault
workflow_run_idStringThe ID of the workflow run to poll.required
intervalNumericThe polling interval in seconds (default: 1.0)1.0
timeoutNumeric | nilThe maximum time to poll in seconds (default: no timeout)nil

Returns:

TypeDescription
HatchetSdkRest::V1WorkflowRunDetailsThe final workflow run details.

Raises:

TypeDescription
Timeout::ErrorIf the timeout is reached before completion.
Hatchet::ErrorIf the API request fails or returns an error.

subscribe_to_stream

Subscribe to stream events for a workflow run.

Opens a gRPC server-streaming subscription to SubscribeToWorkflowEvents and yields each stream chunk payload to the given block.

Parameters:

NameTypeDescriptionDefault
workflow_run_idStringThe workflow run ID to subscribe to.required

Raises:

TypeDescription
Hatchet::ErrorIf the subscription fails.

Last updated on August 24, 2026

On this page