Workflow Protocol - Management API

Low-level description of the Workflow building block internals.

Workflow Management API

The Workflow Management API allows Dapr clients to control the lifecycle of workflow instances. These APIs are exposed via the standard Dapr gRPC endpoint and are typically made available via the SDKs.

gRPC Service Definition

The management APIs are part of the Dapr service in dapr.proto.runtime.v1. While multiple versions (Alpha1, Beta1) may exist, the following describes the current implementation logic.

StartWorkflow

Starts a new instance of a workflow.

Request (StartWorkflowRequest):

FieldTypeDescription
instance_idstringOptional. A unique identifier for the workflow instance. If not provided, Dapr will generate a random UUID.
workflow_componentstringThe name of the workflow component to use. Currently, Dapr uses the built-in engine.
workflow_namestringThe name of the workflow definition to execute.
optionsmap<string, string>Optional. Component-specific options.
inputbytesOptional. Input data for the workflow instance, typically a JSON-serialized string.

Response (StartWorkflowResponse):

FieldTypeDescription
instance_idstringThe ID of the started workflow instance.

GetWorkflow

Retrieves the current status and metadata of a workflow instance.

Request (GetWorkflowRequest):

FieldTypeDescription
instance_idstringThe ID of the workflow instance to query.
workflow_componentstringThe name of the workflow component.

Response (GetWorkflowResponse):

FieldTypeDescription
instance_idstringThe ID of the workflow instance.
workflow_namestringThe name of the workflow.
created_atTimestampThe time the instance was created.
last_updated_atTimestampThe time the instance was last updated.
runtime_statusstringThe status (e.g., RUNNING, COMPLETED, FAILED, TERMINATED, PENDING).
propertiesmap<string, string>Additional component-specific metadata.

TerminateWorkflow

Forcefully terminates a running workflow instance.

Request (TerminateWorkflowRequest):

FieldTypeDescription
instance_idstringThe ID of the workflow instance to terminate.
workflow_componentstringThe name of the workflow component.

RaiseEventWorkflow

Sends an event to a running workflow instance.

Request (RaiseEventWorkflowRequest):

FieldTypeDescription
instance_idstringThe ID of the workflow instance.
workflow_componentstringThe name of the workflow component.
event_namestringThe name of the event to raise.
event_databytesThe data associated with the event.

PauseWorkflow & ResumeWorkflow

Pauses or resumes a workflow instance.

Request (PauseWorkflowRequest / ResumeWorkflowRequest):

FieldTypeDescription
instance_idstringThe ID of the workflow instance.
workflow_componentstringThe name of the workflow component.

PurgeWorkflow

Removes all state and history associated with a workflow instance. This can usually only be done for completed, failed, or terminated instances.

Request (PurgeWorkflowRequest):

FieldTypeDescription
instance_idstringThe ID of the workflow instance.
workflow_componentstringThe name of the workflow component.

ListInstanceIDs (Task Hub Protocol Only)

Retrieves a list of workflow instance IDs, optionally filtered by status or name. This is currently part of the internal Task Hub protocol and used for pagination in management tools.

Request (ListInstanceIDsRequest):

FieldTypeDescription
page_sizeint32The maximum number of IDs to return.
continuation_tokenstringAn opaque token used to retrieve the next page of results.

Response (ListInstanceIDsResponse):

FieldTypeDescription
instance_idsrepeated stringThe list of instance IDs.
continuation_tokenstringA token for the next page of results.

Continuation Tokens and Pagination

The continuation_token is an opaque string generated by the Dapr runtime (and the underlying state store). Its purpose is to allow clients to reliably paginate through large sets of workflow instances without loading all IDs into memory at once.

SDK Requirements for Continuation Tokens:

  1. Opaqueness: The SDK MUST treat this token as a black box. It should not attempt to parse, modify, or construct its own tokens.
  2. State Management: When the SDK receives a ListInstanceIDsResponse, it should store the continuation_token if it intends to fetch more results.
  3. Request Propagation: To fetch the next page, the SDK MUST pass the exact continuation_token received from the previous response into the next ListInstanceIDsRequest.
  4. Termination: An empty or null continuation_token in the response indicates that there are no more pages to retrieve.

Runtime Behavior: The runtime derives this token from the state store’s KeysLike operation. Because it is tied to the underlying database’s pagination mechanism, the token may have an expiration or be tied to the specific query parameters (like page_size) used in the initial request.

Implementation Details

The sidecar receives these requests and translates them into operations on the underlying durabletask-go client. For example, StartWorkflow calls the backend to create a new orchestration instance and enqueue an ExecutionStarted event.