Upsert Workflows

async AsyncCogniteClient.workflows.upsert(
workflow: WorkflowUpsert | Sequence[WorkflowUpsert],
mode: Literal['replace'] = 'replace',
) Workflow | WorkflowList

Create one or more workflow(s).

Note this is an upsert endpoint, so workflows that already exist will be updated, and new ones will be created.

Parameters:
  • workflow (WorkflowUpsert | Sequence[WorkflowUpsert]) – The workflow(s) to upsert.

  • mode (Literal['replace']) – This is not an option for the API, but is included here to document that the upserts are always done in replace mode.

Returns:

The created workflow(s).

Return type:

Workflow | WorkflowList

Examples

Create one workflow with external id “my_workflow”:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import WorkflowUpsert
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> wf = WorkflowUpsert(external_id="my_workflow", description="my workflow description")
>>> res = client.workflows.upsert(wf)

Create multiple workflows:

>>> wf2 = WorkflowUpsert(external_id="other", data_set_id=123)
>>> res = client.workflows.upsert([wf, wf2])