WorkflowsClient

Client for the Kibana Workflows API.

Workflows automate sequences of steps (connector calls, Elasticsearch requests, Kibana actions, …) defined in a YAML document. The Workflows APIs are generally available since Kibana 9.4.0.

Workflows are space-scoped resources: a workflow created in one space is not visible from another space. Every method accepts an optional space_id to target a specific space.

class kibana._sync.client.workflows.WorkflowsClient(client, default_space_id=None, validate_spaces=True)[source]

Bases: NamespaceClient

Client for the Kibana Workflows API.

Workflows automate sequences of steps (connector calls, Elasticsearch requests, Kibana actions, …) defined in a YAML document. The Workflows APIs are generally available since Kibana 9.4.0.

Workflows are space-scoped resources: a workflow created in one space is not visible from another space. Every method accepts an optional space_id to target a specific space (None targets the default space or the space the client is scoped to).

Example

>>> from kibana import Kibana
>>> client = Kibana("http://localhost:5601", api_key="...")
>>>
>>> yaml_definition = '''
... name: my-workflow
... enabled: true
... triggers:
...   - type: manual
... steps:
...   - name: log_step
...     type: console
...     with:
...       message: "hello world"
... '''
>>> created = client.workflows.create(yaml=yaml_definition)
>>> workflow_id = created.body["id"]
>>>
>>> run = client.workflows.run(id=workflow_id, inputs={})
>>> execution_id = run.body["workflowExecutionId"]
>>> execution = client.workflows.get_execution(execution_id=execution_id)
>>> client.workflows.delete(id=workflow_id)

Creating and Running Workflows

Workflows are defined in YAML:

from kibana import Kibana

client = Kibana("http://localhost:5601", api_key="your_api_key")

yaml_definition = """
name: my-workflow
enabled: true
triggers:
  - type: manual
steps:
  - name: log_step
    type: console
    with:
      message: "hello world"
"""

# Create the workflow
created = client.workflows.create(yaml=yaml_definition)
workflow_id = created.body["id"]

# Run it manually
run = client.workflows.run(id=workflow_id, inputs={})
execution_id = run.body["workflowExecutionId"]

Inspecting Executions

# Get a single execution
execution = client.workflows.get_execution(execution_id=execution_id)
print(execution.body["status"])

# List executions of a workflow
executions = client.workflows.get_executions(workflow_id=workflow_id)

# Step-level details and logs
steps = client.workflows.get_step_executions(workflow_id=workflow_id)
logs = client.workflows.get_execution_logs(execution_id=execution_id)

Searching and Managing Workflows

# Search workflows
found = client.workflows.get_all(query="my-workflow", size=10)
for workflow in found.body["results"]:
    print(workflow["id"], workflow["name"])

# Update the YAML definition
client.workflows.update(id=workflow_id, yaml=yaml_definition)

# Clone a workflow
clone = client.workflows.clone(id=workflow_id)

# Delete workflows
client.workflows.delete(id=workflow_id)

Testing Workflows

Test a workflow definition without persisting it:

test_run = client.workflows.test(
    workflow_yaml=yaml_definition, inputs={}
)
__init__(client, default_space_id=None, validate_spaces=True)[source]

Initialize the WorkflowsClient.

Parameters:
  • client (Kibana) – The parent Kibana client instance to delegate requests to.

  • default_space_id (str | None) – Optional default space ID for all operations.

  • validate_spaces (bool) – Whether to validate space existence before space-scoped operations (default: True).

Example

>>> workflows_client = WorkflowsClient(kibana_client)
create(*, yaml, id=None, space_id=None, validate_spaces=None)[source]

Create a workflow.

Creates a new workflow from a YAML definition. The definition describes the workflow name, enabled flag, triggers and steps (see get_schema() for the full JSON schema).

Parameters:
  • yaml (str) – The YAML definition of the workflow (max 1 MiB).

  • id (str | None) – Optional custom workflow ID (3-255 chars, lowercase alphanumerics and hyphens, e.g. "my-workflow-1"). If omitted, Kibana generates one.

  • space_id (str | None) – Optional space ID to create the workflow in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the created workflow, including id, name, enabled, yaml, the parsed definition, valid and audit fields (createdBy, createdAt, …).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> created = client.workflows.create(
...     id="my-workflow",
...     yaml="name: my-workflow\nenabled: true\n...",
... )
>>> print(created.body["valid"])
True
get(*, id, space_id=None, validate_spaces=None)[source]

Get a workflow.

Retrieves a single workflow by its ID, including its YAML source and parsed definition.

Parameters:
  • id (str) – The workflow ID.

  • space_id (str | None) – Optional space ID to get the workflow from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the workflow (id, name, description, enabled, yaml, definition, valid, audit fields).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> workflow = client.workflows.get(id="my-workflow")
>>> print(workflow.body["name"])
update(*, id, yaml=None, name=None, description=None, enabled=None, tags=None, space_id=None, validate_spaces=None)[source]

Update a workflow.

Partially updates a workflow. Provide a new yaml definition to replace the whole workflow, or individual fields (name, description, enabled, tags) for targeted changes.

Parameters:
  • id (str) – The workflow ID.

  • yaml (str | None) – New YAML definition for the workflow.

  • name (str | None) – New workflow name.

  • description (str | None) – New workflow description.

  • enabled (bool | None) – Whether the workflow is enabled (it must be enabled to be run with run()).

  • tags (list[str] | None) – New list of tags.

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the update summary (id, enabled, valid, validationErrors, lastUpdatedAt, lastUpdatedBy).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> client.workflows.update(id="my-workflow", enabled=True)
delete(*, id, force=None, space_id=None, validate_spaces=None)[source]

Delete a workflow.

Deletes a single workflow by its ID.

Parameters:
  • id (str) – The workflow ID.

  • force (bool | None) – If True, force deletion even when the workflow has running executions (default: False).

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with an empty body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> client.workflows.delete(id="my-workflow")
clone(*, id, space_id=None, validate_spaces=None)[source]

Clone a workflow.

Creates a copy of an existing workflow. The clone gets a derived ID (e.g. "<id>-copy") and name ("<name> Copy").

Parameters:
  • id (str) – The ID of the workflow to clone.

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the cloned workflow (id, name, yaml, definition, …).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> cloned = client.workflows.clone(id="my-workflow")
>>> print(cloned.body["id"])
my-workflow-copy
run(*, id, inputs, metadata=None, space_id=None, validate_spaces=None)[source]

Run a workflow.

Triggers a production execution of an enabled workflow. Use test() to run a disabled workflow or an ad-hoc YAML definition.

Parameters:
  • id (str) – The workflow ID.

  • inputs (dict[str, Any]) – Key-value inputs for the workflow execution (pass {} when the workflow declares no inputs).

  • metadata (dict[str, Any] | None) – Optional metadata to attach to the execution.

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing workflowExecutionId, the ID of the started execution.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> run = client.workflows.run(id="my-workflow", inputs={})
>>> print(run.body["workflowExecutionId"])
get_all(*, query=None, size=None, page=None, enabled=None, created_by=None, tags=None, space_id=None, validate_spaces=None)[source]

Get (search) workflows.

Searches workflows with optional text query, filters and pagination.

Parameters:
  • query (str | None) – Text query matched against workflow names/descriptions.

  • size (int | None) – Number of workflows per page (minimum 1).

  • page (int | None) – Page number (minimum 1).

  • enabled (list[bool] | None) – Filter by enabled state; a list so both states can be requested, e.g. [True] or [True, False].

  • created_by (list[str] | None) – Filter by creator usernames.

  • tags (list[str] | None) – Filter by tags.

  • space_id (str | None) – Optional space ID to search in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing results (list of workflow summaries), total, page and size.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> found = client.workflows.get_all(query="my-workflow", size=10)
>>> print(found.body["total"])
bulk_create(*, workflows, overwrite=None, space_id=None, validate_spaces=None)[source]

Bulk create workflows.

Creates up to 500 workflows in one request.

Parameters:
  • workflows (list[dict[str, Any]]) – List of workflow objects, each with a required "yaml" key and an optional "id" key.

  • overwrite (bool | None) – If True, overwrite workflows that already exist with the given IDs (default: False).

  • space_id (str | None) – Optional space ID to create the workflows in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing created (list of created workflows) and per-entry errors for the ones that failed.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = client.workflows.bulk_create(
...     workflows=[{"id": "wf-1", "yaml": "name: wf-1\n..."}],
... )
>>> print(len(result.body["created"]))
1
bulk_delete(*, ids, force=None, space_id=None, validate_spaces=None)[source]

Bulk delete workflows.

Deletes up to 1000 workflows by ID in one request.

Parameters:
  • ids (list[str]) – List of workflow IDs to delete.

  • force (bool | None) – If True, force deletion even when workflows have running executions (default: False).

  • space_id (str | None) – Optional space ID the workflows live in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing total, deleted and failures.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = client.workflows.bulk_delete(ids=["wf-1", "wf-2"])
>>> print(result.body["deleted"])
2
mget(*, ids, source=None, space_id=None, validate_spaces=None)[source]

Get workflows by IDs (multi-get).

Looks up 1-500 workflows by ID in one request.

Parameters:
  • ids (list[str]) – List of workflow IDs to look up.

  • source (list[str] | None) – Optional list of source fields to include in each returned workflow (1-10 fields).

  • space_id (str | None) – Optional space ID the workflows live in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse whose body is the list of found workflows (a ListApiResponse at runtime).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> found = client.workflows.mget(ids=["wf-1", "wf-2"])
>>> print([wf["id"] for wf in found.body])
export(*, ids, space_id=None, validate_spaces=None)[source]

Export workflows.

Exports 1-500 workflows as normalized YAML documents suitable for re-import via bulk_create().

Parameters:
  • ids (list[str]) – List of workflow IDs to export.

  • space_id (str | None) – Optional space ID the workflows live in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing entries (list of {"id", "yaml"} objects) and a manifest with export counts.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> exported = client.workflows.export(ids=["wf-1"])
>>> print(exported.body["entries"][0]["yaml"])
get_aggs(*, fields, space_id=None, validate_spaces=None)[source]

Get workflow aggregations.

Aggregates workflow field values (e.g. distinct tags or createdBy values with document counts), typically used to build filter UIs.

Parameters:
  • fields (list[str]) – Fields to aggregate on (1-25 fields, e.g. ["tags", "createdBy"]).

  • space_id (str | None) – Optional space ID to aggregate in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse mapping each requested field to a list of {"key", "doc_count"} buckets.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> aggs = client.workflows.get_aggs(fields=["createdBy"])
>>> print(aggs.body["createdBy"])
get_connectors(*, space_id=None, validate_spaces=None)[source]

Get available connectors.

Lists connector types (and existing connector instances) that can be used in workflow steps.

Parameters:
  • space_id (str | None) – Optional space ID to list connectors for.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing connectorTypes, a mapping of action type ID (e.g. ".slack") to its metadata and instances.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> connectors = client.workflows.get_connectors()
>>> print(sorted(connectors.body["connectorTypes"]))
get_schema(*, loose, space_id=None, validate_spaces=None)[source]

Get the workflow JSON schema.

Returns the JSON schema (draft-07) that workflow YAML definitions are validated against — useful for editor integration and client-side validation.

Parameters:
  • loose (bool) – Required. If True, return a loose variant of the schema (more permissive validation); if False, the strict schema.

  • space_id (str | None) – Optional space ID.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the JSON schema document.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> schema = client.workflows.get_schema(loose=False)
>>> print(schema.body["$schema"])
http://json-schema.org/draft-07/schema#
get_stats(*, space_id=None, validate_spaces=None)[source]

Get workflow statistics.

Returns aggregate statistics about workflows and their executions.

Parameters:
  • space_id (str | None) – Optional space ID to get statistics for.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing workflows (enabled / disabled counts) and executions statistics.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> stats = client.workflows.get_stats()
>>> print(stats.body["workflows"])
{'enabled': 1, 'disabled': 0}
test(*, inputs, workflow_id=None, workflow_yaml=None, space_id=None, validate_spaces=None)[source]

Test a workflow.

Starts a test execution of either an existing workflow (workflow_id) or an ad-hoc YAML definition (workflow_yaml). Test runs work even when the workflow is disabled.

Parameters:
  • inputs (dict[str, Any]) – Key-value inputs for the test execution (pass {} when the workflow declares no inputs).

  • workflow_id (str | None) – ID of an existing workflow to test.

  • workflow_yaml (str | None) – YAML definition to test (alternative to workflow_id).

  • space_id (str | None) – Optional space ID.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing workflowExecutionId, the ID of the started test execution.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> test_run = client.workflows.test(
...     workflow_id="my-workflow", inputs={}
... )
>>> print(test_run.body["workflowExecutionId"])
test_step(*, step_id, context_override, workflow_yaml, workflow_id=None, execution_context=None, space_id=None, validate_spaces=None)[source]

Test a single workflow step.

Starts a test execution of one step from a workflow YAML definition, with optional context overrides.

Parameters:
  • step_id (str) – ID (name) of the step to test.

  • context_override (dict[str, Any]) – Context overrides for the step execution (pass {} for none).

  • workflow_yaml (str) – YAML definition of the workflow containing the step.

  • workflow_id (str | None) – Optional ID of the workflow containing the step.

  • execution_context (dict[str, Any] | None) – Optional execution context for the step.

  • space_id (str | None) – Optional space ID.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing workflowExecutionId, the ID of the started step test execution.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> test_run = client.workflows.test_step(
...     step_id="log_step",
...     context_override={},
...     workflow_yaml="name: my-workflow\n...",
... )
>>> print(test_run.body["workflowExecutionId"])
get_executions(*, workflow_id, statuses=None, execution_types=None, executed_by=None, omit_step_runs=None, page=None, size=None, space_id=None, validate_spaces=None)[source]

Get workflow executions.

Lists the executions of a workflow, with optional filters and pagination.

Parameters:
  • workflow_id (str) – The workflow ID.

  • statuses (list[str] | None) – Filter by execution statuses ("pending", "waiting", "waiting_for_input", "running", "completed", "failed", "cancelled", "timed_out", "skipped").

  • execution_types (list[str] | None) – Filter by execution type ("test" and/or "production").

  • executed_by (list[str] | None) – Filter by usernames that triggered the executions.

  • omit_step_runs (bool | None) – If True, omit step run details from the results.

  • page (int | None) – Page number (minimum 1).

  • size (int | None) – Number of executions per page (1-100).

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing results (list of execution summaries with id, status, startedAt, …), total, page and size.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> executions = client.workflows.get_executions(
...     workflow_id="my-workflow", statuses=["completed"]
... )
>>> print(executions.body["total"])
get_step_executions(*, workflow_id, step_id=None, include_input=None, include_output=None, page=None, size=None, space_id=None, validate_spaces=None)[source]

Get workflow step executions.

Lists step-level executions across the runs of a workflow.

Parameters:
  • workflow_id (str) – The workflow ID.

  • step_id (str | None) – Filter by a specific step ID (name).

  • include_input (bool | None) – If True, include step input in the results.

  • include_output (bool | None) – If True, include step output in the results.

  • page (int | None) – Page number (minimum 1).

  • size (int | None) – Number of step executions per page (1-100).

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing results (list of step executions with id, stepId, status, …), total, page and size.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> steps = client.workflows.get_step_executions(
...     workflow_id="my-workflow", step_id="log_step"
... )
>>> print(steps.body["results"][0]["status"])
cancel_all_executions(*, workflow_id, space_id=None, validate_spaces=None)[source]

Cancel all active workflow executions.

Cancels every active (pending/waiting/running) execution of a workflow. Completed executions are unaffected.

Parameters:
  • workflow_id (str) – The workflow ID.

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with an empty body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> client.workflows.cancel_all_executions(
...     workflow_id="my-workflow"
... )
get_execution(*, execution_id, include_input=None, include_output=None, space_id=None, validate_spaces=None)[source]

Get a workflow execution.

Retrieves a single workflow execution by its ID, including status, timing, the workflow definition snapshot and step executions.

Parameters:
  • execution_id (str) – The execution ID (as returned by run() or test()).

  • include_input (bool | None) – If True, include execution input in the response.

  • include_output (bool | None) – If True, include execution output in the response.

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the execution (id, status, workflowId, isTestRun, startedAt, finishedAt, stepExecutions, …).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> execution = client.workflows.get_execution(
...     execution_id="be42ad95-..."
... )
>>> print(execution.body["status"])
completed
cancel_execution(*, execution_id, space_id=None, validate_spaces=None)[source]

Cancel a workflow execution.

Requests cancellation of a single workflow execution. Cancelling an already-finished execution is a no-op.

Parameters:
  • execution_id (str) – The execution ID.

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with an empty body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> client.workflows.cancel_execution(execution_id="be42ad95-...")
resume_execution(*, execution_id, input, space_id=None, validate_spaces=None)[source]

Resume a workflow execution.

Resumes an execution that is in the waiting_for_input status, providing the input it is waiting for.

Parameters:
  • execution_id (str) – The execution ID.

  • input (dict[str, Any]) – Input data to resume the execution with (pass {} for none).

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with the resume result.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> client.workflows.resume_execution(
...     execution_id="be42ad95-...", input={"approved": True}
... )
get_execution_children(*, execution_id, space_id=None, validate_spaces=None)[source]

Get child executions.

Lists the child executions spawned by a workflow execution (e.g. sub-workflow runs).

Parameters:
  • execution_id (str) – The parent execution ID.

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse whose body is the list of child executions (a ListApiResponse at runtime; empty when there are none).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> children = client.workflows.get_execution_children(
...     execution_id="be42ad95-..."
... )
>>> print(len(children.body))
get_execution_logs(*, execution_id, step_execution_id=None, size=None, page=None, sort_field=None, sort_order=None, space_id=None, validate_spaces=None)[source]

Get execution logs.

Retrieves the log entries produced by a workflow execution, with optional step filtering, sorting and pagination.

Parameters:
  • execution_id (str) – The execution ID.

  • step_execution_id (str | None) – Filter logs to a single step execution.

  • size (int | None) – Number of log entries per page (1-100, default 100).

  • page (int | None) – Page number (minimum 1, default 1).

  • sort_field (str | None) – Field to sort by (e.g. "timestamp").

  • sort_order (str | None) – Sort order, "asc" or "desc".

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing logs (list of entries with timestamp, level, message, …), total, page and size.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> logs = client.workflows.get_execution_logs(
...     execution_id="be42ad95-...", sort_order="asc"
... )
>>> for entry in logs.body["logs"]:
...     print(entry["level"], entry["message"])
get_step_execution(*, execution_id, step_execution_id, space_id=None, validate_spaces=None)[source]

Get a step execution.

Retrieves a single step execution from a workflow execution.

Parameters:
  • execution_id (str) – The workflow execution ID.

  • step_execution_id (str) – The step execution ID (as listed in get_step_executions() or in the execution’s stepExecutions).

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the step execution (id, stepId, stepType, status, startedAt, …).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> step = client.workflows.get_step_execution(
...     execution_id="be42ad95-...",
...     step_execution_id="27e59f68d0d8...",
... )
>>> print(step.body["stepId"], step.body["status"])
perform_request(method, path, *, params=None, headers=None, body=None)

Perform an HTTP request via the parent client with space context enhancement.

Parameters:
  • method (str) – HTTP method (GET, POST, PUT, DELETE, etc.)

  • path (str) – API endpoint path

  • params (dict[str, Any] | None) – Query parameters

  • headers (dict[str, str] | None) – Request headers

  • body (dict[str, Any] | None) – Request body

Returns:

API response

Raises:

ApiError – If the API returns an error response (enhanced with space context)

Return type:

ObjectApiResponse[Any]

AsyncWorkflowsClient

Asynchronous version of the WorkflowsClient for use with async/await syntax.

class kibana._async.client.workflows.AsyncWorkflowsClient(client, default_space_id=None, validate_spaces=True)[source]

Bases: AsyncNamespaceClient

Async client for the Kibana Workflows API.

Workflows automate sequences of steps (connector calls, Elasticsearch requests, Kibana actions, …) defined in a YAML document. The Workflows APIs are generally available since Kibana 9.4.0.

Workflows are space-scoped resources: a workflow created in one space is not visible from another space. Every method accepts an optional space_id to target a specific space (None targets the default space or the space the client is scoped to).

Example

>>> from kibana import AsyncKibana
>>> client = AsyncKibana("http://localhost:5601", api_key="...")
>>>
>>> yaml_definition = '''
... name: my-workflow
... enabled: true
... triggers:
...   - type: manual
... steps:
...   - name: log_step
...     type: console
...     with:
...       message: "hello world"
... '''
>>> created = await client.workflows.create(yaml=yaml_definition)
>>> workflow_id = created.body["id"]
>>>
>>> run = await client.workflows.run(id=workflow_id, inputs={})
>>> execution_id = run.body["workflowExecutionId"]
>>> execution = await client.workflows.get_execution(execution_id=execution_id)
>>> await client.workflows.delete(id=workflow_id)

Usage

The AsyncWorkflowsClient provides the same methods as WorkflowsClient but all methods are async and must be awaited:

from kibana import AsyncKibana
import asyncio

async def main():
    async with AsyncKibana("http://localhost:5601") as client:
        # Create and run a workflow (async)
        created = await client.workflows.create(
            yaml="""
            name: async-workflow
            enabled: true
            triggers:
              - type: manual
            steps:
              - name: log_step
                type: console
                with:
                  message: "hello from async"
            """
        )
        run = await client.workflows.run(
            id=created.body["id"], inputs={}
        )

        # Poll the execution (async)
        execution = await client.workflows.get_execution(
            execution_id=run.body["workflowExecutionId"]
        )

        # Delete (async)
        await client.workflows.delete(id=created.body["id"])

asyncio.run(main())
__init__(client, default_space_id=None, validate_spaces=True)[source]

Initialize the AsyncWorkflowsClient.

Parameters:
  • client (AsyncKibana) – The parent AsyncKibana client instance to delegate requests to.

  • default_space_id (str | None) – Optional default space ID for all operations.

  • validate_spaces (bool) – Whether to validate space existence before space-scoped operations (default: True).

Example

>>> workflows_client = AsyncWorkflowsClient(kibana_client)
async create(*, yaml, id=None, space_id=None, validate_spaces=None)[source]

Create a workflow.

Creates a new workflow from a YAML definition. The definition describes the workflow name, enabled flag, triggers and steps (see get_schema() for the full JSON schema).

Parameters:
  • yaml (str) – The YAML definition of the workflow (max 1 MiB).

  • id (str | None) – Optional custom workflow ID (3-255 chars, lowercase alphanumerics and hyphens, e.g. "my-workflow-1"). If omitted, Kibana generates one.

  • space_id (str | None) – Optional space ID to create the workflow in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the created workflow, including id, name, enabled, yaml, the parsed definition, valid and audit fields (createdBy, createdAt, …).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> created = await client.workflows.create(
...     id="my-workflow",
...     yaml="name: my-workflow\nenabled: true\n...",
... )
>>> print(created.body["valid"])
True
async get(*, id, space_id=None, validate_spaces=None)[source]

Get a workflow.

Retrieves a single workflow by its ID, including its YAML source and parsed definition.

Parameters:
  • id (str) – The workflow ID.

  • space_id (str | None) – Optional space ID to get the workflow from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the workflow (id, name, description, enabled, yaml, definition, valid, audit fields).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> workflow = await client.workflows.get(id="my-workflow")
>>> print(workflow.body["name"])
async update(*, id, yaml=None, name=None, description=None, enabled=None, tags=None, space_id=None, validate_spaces=None)[source]

Update a workflow.

Partially updates a workflow. Provide a new yaml definition to replace the whole workflow, or individual fields (name, description, enabled, tags) for targeted changes.

Parameters:
  • id (str) – The workflow ID.

  • yaml (str | None) – New YAML definition for the workflow.

  • name (str | None) – New workflow name.

  • description (str | None) – New workflow description.

  • enabled (bool | None) – Whether the workflow is enabled (it must be enabled to be run with run()).

  • tags (list[str] | None) – New list of tags.

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the update summary (id, enabled, valid, validationErrors, lastUpdatedAt, lastUpdatedBy).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> await client.workflows.update(id="my-workflow", enabled=True)
async delete(*, id, force=None, space_id=None, validate_spaces=None)[source]

Delete a workflow.

Deletes a single workflow by its ID.

Parameters:
  • id (str) – The workflow ID.

  • force (bool | None) – If True, force deletion even when the workflow has running executions (default: False).

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with an empty body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> await client.workflows.delete(id="my-workflow")
async clone(*, id, space_id=None, validate_spaces=None)[source]

Clone a workflow.

Creates a copy of an existing workflow. The clone gets a derived ID (e.g. "<id>-copy") and name ("<name> Copy").

Parameters:
  • id (str) – The ID of the workflow to clone.

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the cloned workflow (id, name, yaml, definition, …).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> cloned = await client.workflows.clone(id="my-workflow")
>>> print(cloned.body["id"])
my-workflow-copy
async run(*, id, inputs, metadata=None, space_id=None, validate_spaces=None)[source]

Run a workflow.

Triggers a production execution of an enabled workflow. Use test() to run a disabled workflow or an ad-hoc YAML definition.

Parameters:
  • id (str) – The workflow ID.

  • inputs (dict[str, Any]) – Key-value inputs for the workflow execution (pass {} when the workflow declares no inputs).

  • metadata (dict[str, Any] | None) – Optional metadata to attach to the execution.

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing workflowExecutionId, the ID of the started execution.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> run = await client.workflows.run(id="my-workflow", inputs={})
>>> print(run.body["workflowExecutionId"])
async get_all(*, query=None, size=None, page=None, enabled=None, created_by=None, tags=None, space_id=None, validate_spaces=None)[source]

Get (search) workflows.

Searches workflows with optional text query, filters and pagination.

Parameters:
  • query (str | None) – Text query matched against workflow names/descriptions.

  • size (int | None) – Number of workflows per page (minimum 1).

  • page (int | None) – Page number (minimum 1).

  • enabled (list[bool] | None) – Filter by enabled state; a list so both states can be requested, e.g. [True] or [True, False].

  • created_by (list[str] | None) – Filter by creator usernames.

  • tags (list[str] | None) – Filter by tags.

  • space_id (str | None) – Optional space ID to search in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing results (list of workflow summaries), total, page and size.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> found = await client.workflows.get_all(query="my-workflow", size=10)
>>> print(found.body["total"])
async bulk_create(*, workflows, overwrite=None, space_id=None, validate_spaces=None)[source]

Bulk create workflows.

Creates up to 500 workflows in one request.

Parameters:
  • workflows (list[dict[str, Any]]) – List of workflow objects, each with a required "yaml" key and an optional "id" key.

  • overwrite (bool | None) – If True, overwrite workflows that already exist with the given IDs (default: False).

  • space_id (str | None) – Optional space ID to create the workflows in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing created (list of created workflows) and per-entry errors for the ones that failed.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = await client.workflows.bulk_create(
...     workflows=[{"id": "wf-1", "yaml": "name: wf-1\n..."}],
... )
>>> print(len(result.body["created"]))
1
async bulk_delete(*, ids, force=None, space_id=None, validate_spaces=None)[source]

Bulk delete workflows.

Deletes up to 1000 workflows by ID in one request.

Parameters:
  • ids (list[str]) – List of workflow IDs to delete.

  • force (bool | None) – If True, force deletion even when workflows have running executions (default: False).

  • space_id (str | None) – Optional space ID the workflows live in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing total, deleted and failures.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = await client.workflows.bulk_delete(ids=["wf-1", "wf-2"])
>>> print(result.body["deleted"])
2
async mget(*, ids, source=None, space_id=None, validate_spaces=None)[source]

Get workflows by IDs (multi-get).

Looks up 1-500 workflows by ID in one request.

Parameters:
  • ids (list[str]) – List of workflow IDs to look up.

  • source (list[str] | None) – Optional list of source fields to include in each returned workflow (1-10 fields).

  • space_id (str | None) – Optional space ID the workflows live in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse whose body is the list of found workflows (a ListApiResponse at runtime).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> found = await client.workflows.mget(ids=["wf-1", "wf-2"])
>>> print([wf["id"] for wf in found.body])
async export(*, ids, space_id=None, validate_spaces=None)[source]

Export workflows.

Exports 1-500 workflows as normalized YAML documents suitable for re-import via bulk_create().

Parameters:
  • ids (list[str]) – List of workflow IDs to export.

  • space_id (str | None) – Optional space ID the workflows live in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing entries (list of {"id", "yaml"} objects) and a manifest with export counts.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> exported = await client.workflows.export(ids=["wf-1"])
>>> print(exported.body["entries"][0]["yaml"])
async get_aggs(*, fields, space_id=None, validate_spaces=None)[source]

Get workflow aggregations.

Aggregates workflow field values (e.g. distinct tags or createdBy values with document counts), typically used to build filter UIs.

Parameters:
  • fields (list[str]) – Fields to aggregate on (1-25 fields, e.g. ["tags", "createdBy"]).

  • space_id (str | None) – Optional space ID to aggregate in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse mapping each requested field to a list of {"key", "doc_count"} buckets.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> aggs = await client.workflows.get_aggs(fields=["createdBy"])
>>> print(aggs.body["createdBy"])
async get_connectors(*, space_id=None, validate_spaces=None)[source]

Get available connectors.

Lists connector types (and existing connector instances) that can be used in workflow steps.

Parameters:
  • space_id (str | None) – Optional space ID to list connectors for.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing connectorTypes, a mapping of action type ID (e.g. ".slack") to its metadata and instances.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> connectors = await client.workflows.get_connectors()
>>> print(sorted(connectors.body["connectorTypes"]))
async get_schema(*, loose, space_id=None, validate_spaces=None)[source]

Get the workflow JSON schema.

Returns the JSON schema (draft-07) that workflow YAML definitions are validated against — useful for editor integration and client-side validation.

Parameters:
  • loose (bool) – Required. If True, return a loose variant of the schema (more permissive validation); if False, the strict schema.

  • space_id (str | None) – Optional space ID.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the JSON schema document.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> schema = await client.workflows.get_schema(loose=False)
>>> print(schema.body["$schema"])
http://json-schema.org/draft-07/schema#
async get_stats(*, space_id=None, validate_spaces=None)[source]

Get workflow statistics.

Returns aggregate statistics about workflows and their executions.

Parameters:
  • space_id (str | None) – Optional space ID to get statistics for.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing workflows (enabled / disabled counts) and executions statistics.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> stats = await client.workflows.get_stats()
>>> print(stats.body["workflows"])
{'enabled': 1, 'disabled': 0}
async test(*, inputs, workflow_id=None, workflow_yaml=None, space_id=None, validate_spaces=None)[source]

Test a workflow.

Starts a test execution of either an existing workflow (workflow_id) or an ad-hoc YAML definition (workflow_yaml). Test runs work even when the workflow is disabled.

Parameters:
  • inputs (dict[str, Any]) – Key-value inputs for the test execution (pass {} when the workflow declares no inputs).

  • workflow_id (str | None) – ID of an existing workflow to test.

  • workflow_yaml (str | None) – YAML definition to test (alternative to workflow_id).

  • space_id (str | None) – Optional space ID.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing workflowExecutionId, the ID of the started test execution.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> test_run = await client.workflows.test(
...     workflow_id="my-workflow", inputs={}
... )
>>> print(test_run.body["workflowExecutionId"])
async test_step(*, step_id, context_override, workflow_yaml, workflow_id=None, execution_context=None, space_id=None, validate_spaces=None)[source]

Test a single workflow step.

Starts a test execution of one step from a workflow YAML definition, with optional context overrides.

Parameters:
  • step_id (str) – ID (name) of the step to test.

  • context_override (dict[str, Any]) – Context overrides for the step execution (pass {} for none).

  • workflow_yaml (str) – YAML definition of the workflow containing the step.

  • workflow_id (str | None) – Optional ID of the workflow containing the step.

  • execution_context (dict[str, Any] | None) – Optional execution context for the step.

  • space_id (str | None) – Optional space ID.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing workflowExecutionId, the ID of the started step test execution.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> test_run = await client.workflows.test_step(
...     step_id="log_step",
...     context_override={},
...     workflow_yaml="name: my-workflow\n...",
... )
>>> print(test_run.body["workflowExecutionId"])
async get_executions(*, workflow_id, statuses=None, execution_types=None, executed_by=None, omit_step_runs=None, page=None, size=None, space_id=None, validate_spaces=None)[source]

Get workflow executions.

Lists the executions of a workflow, with optional filters and pagination.

Parameters:
  • workflow_id (str) – The workflow ID.

  • statuses (list[str] | None) – Filter by execution statuses ("pending", "waiting", "waiting_for_input", "running", "completed", "failed", "cancelled", "timed_out", "skipped").

  • execution_types (list[str] | None) – Filter by execution type ("test" and/or "production").

  • executed_by (list[str] | None) – Filter by usernames that triggered the executions.

  • omit_step_runs (bool | None) – If True, omit step run details from the results.

  • page (int | None) – Page number (minimum 1).

  • size (int | None) – Number of executions per page (1-100).

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing results (list of execution summaries with id, status, startedAt, …), total, page and size.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> executions = await client.workflows.get_executions(
...     workflow_id="my-workflow", statuses=["completed"]
... )
>>> print(executions.body["total"])
async get_step_executions(*, workflow_id, step_id=None, include_input=None, include_output=None, page=None, size=None, space_id=None, validate_spaces=None)[source]

Get workflow step executions.

Lists step-level executions across the runs of a workflow.

Parameters:
  • workflow_id (str) – The workflow ID.

  • step_id (str | None) – Filter by a specific step ID (name).

  • include_input (bool | None) – If True, include step input in the results.

  • include_output (bool | None) – If True, include step output in the results.

  • page (int | None) – Page number (minimum 1).

  • size (int | None) – Number of step executions per page (1-100).

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing results (list of step executions with id, stepId, status, …), total, page and size.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> steps = await client.workflows.get_step_executions(
...     workflow_id="my-workflow", step_id="log_step"
... )
>>> print(steps.body["results"][0]["status"])
async cancel_all_executions(*, workflow_id, space_id=None, validate_spaces=None)[source]

Cancel all active workflow executions.

Cancels every active (pending/waiting/running) execution of a workflow. Completed executions are unaffected.

Parameters:
  • workflow_id (str) – The workflow ID.

  • space_id (str | None) – Optional space ID the workflow lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with an empty body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> await client.workflows.cancel_all_executions(
...     workflow_id="my-workflow"
... )
async get_execution(*, execution_id, include_input=None, include_output=None, space_id=None, validate_spaces=None)[source]

Get a workflow execution.

Retrieves a single workflow execution by its ID, including status, timing, the workflow definition snapshot and step executions.

Parameters:
  • execution_id (str) – The execution ID (as returned by run() or test()).

  • include_input (bool | None) – If True, include execution input in the response.

  • include_output (bool | None) – If True, include execution output in the response.

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the execution (id, status, workflowId, isTestRun, startedAt, finishedAt, stepExecutions, …).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> execution = await client.workflows.get_execution(
...     execution_id="be42ad95-..."
... )
>>> print(execution.body["status"])
completed
async cancel_execution(*, execution_id, space_id=None, validate_spaces=None)[source]

Cancel a workflow execution.

Requests cancellation of a single workflow execution. Cancelling an already-finished execution is a no-op.

Parameters:
  • execution_id (str) – The execution ID.

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with an empty body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> await client.workflows.cancel_execution(execution_id="be42ad95-...")
async resume_execution(*, execution_id, input, space_id=None, validate_spaces=None)[source]

Resume a workflow execution.

Resumes an execution that is in the waiting_for_input status, providing the input it is waiting for.

Parameters:
  • execution_id (str) – The execution ID.

  • input (dict[str, Any]) – Input data to resume the execution with (pass {} for none).

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with the resume result.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> await client.workflows.resume_execution(
...     execution_id="be42ad95-...", input={"approved": True}
... )
async get_execution_children(*, execution_id, space_id=None, validate_spaces=None)[source]

Get child executions.

Lists the child executions spawned by a workflow execution (e.g. sub-workflow runs).

Parameters:
  • execution_id (str) – The parent execution ID.

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse whose body is the list of child executions (a ListApiResponse at runtime; empty when there are none).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> children = await client.workflows.get_execution_children(
...     execution_id="be42ad95-..."
... )
>>> print(len(children.body))
async get_execution_logs(*, execution_id, step_execution_id=None, size=None, page=None, sort_field=None, sort_order=None, space_id=None, validate_spaces=None)[source]

Get execution logs.

Retrieves the log entries produced by a workflow execution, with optional step filtering, sorting and pagination.

Parameters:
  • execution_id (str) – The execution ID.

  • step_execution_id (str | None) – Filter logs to a single step execution.

  • size (int | None) – Number of log entries per page (1-100, default 100).

  • page (int | None) – Page number (minimum 1, default 1).

  • sort_field (str | None) – Field to sort by (e.g. "timestamp").

  • sort_order (str | None) – Sort order, "asc" or "desc".

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing logs (list of entries with timestamp, level, message, …), total, page and size.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> logs = await client.workflows.get_execution_logs(
...     execution_id="be42ad95-...", sort_order="asc"
... )
>>> for entry in logs.body["logs"]:
...     print(entry["level"], entry["message"])
async get_step_execution(*, execution_id, step_execution_id, space_id=None, validate_spaces=None)[source]

Get a step execution.

Retrieves a single step execution from a workflow execution.

Parameters:
  • execution_id (str) – The workflow execution ID.

  • step_execution_id (str) – The step execution ID (as listed in get_step_executions() or in the execution’s stepExecutions).

  • space_id (str | None) – Optional space ID the execution lives in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the step execution (id, stepId, stepType, status, startedAt, …).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> step = await client.workflows.get_step_execution(
...     execution_id="be42ad95-...",
...     step_execution_id="27e59f68d0d8...",
... )
>>> print(step.body["stepId"], step.body["status"])
async perform_request(method, path, *, params=None, headers=None, body=None)

Perform an async HTTP request via the parent client with space context enhancement.

Parameters:
  • method (str) – HTTP method (GET, POST, PUT, DELETE, etc.)

  • path (str) – API endpoint path

  • params (dict[str, Any] | None) – Query parameters

  • headers (dict[str, str] | None) – Request headers

  • body (dict[str, Any] | None) – Request body

Returns:

API response

Raises:

ApiError – If the API returns an error response (enhanced with space context)

Return type:

ObjectApiResponse[Any]