Temporal Commands reference
A Command is an action a Worker requests from the Temporal Service when it completes a Workflow Task Execution. The SDK generates Commands from your Workflow code, such as a call to execute an Activity or start a Timer. The Temporal Service records an Event in the Event History for each Command.
Commands are defined in the CommandType enum and command messages of the Temporal gRPC API.
Each Command on this page lists the following:
- Awaitable: Whether the Workflow can wait on the result of the Command.
- Corresponding Event: The Event the Temporal Service records for the Command.
- Limit: The default maximum number of pending operations of this type per Workflow Execution, if one applies. When a Workflow Execution reaches the limit, the Workflow Task fails and is retried. See Workflow Execution limits.
Workflow Execution close Commands
Each of these Commands closes the Workflow Execution. Its corresponding Event is the last Event in the Event History.
CompleteWorkflowExecution
The Worker issues this Command when the Workflow Function returns.
- Awaitable: No
- Corresponding Event: WorkflowExecutionCompleted
ContinueAsNewWorkflowExecution
The Worker issues this Command when the Workflow calls Continue-As-New.
- Awaitable: No
- Corresponding Event: WorkflowExecutionContinuedAsNew
FailWorkflowExecution
The Worker issues this Command when the Workflow returns an error or throws an exception that fails the Workflow Execution.
- Awaitable: No
- Corresponding Event: WorkflowExecutionFailed
CancelWorkflowExecution
The Worker issues this Command when the Workflow finishes cleaning up after a Cancellation Request. The request appears in the Event History as a WorkflowExecutionCancelRequested Event.
- Awaitable: No
- Corresponding Event: WorkflowExecutionCanceled
Activity Commands
ScheduleActivityTask
The Worker issues this Command when the Workflow calls an Activity.
- Awaitable: Yes
- Corresponding Event: ActivityTaskScheduled
- Limit: 2,000 pending Activities
RequestCancelActivityTask
The Worker issues this Command when the Workflow requests cancellation of an Activity Task.
- Awaitable: No
- Corresponding Event: ActivityTaskCancelRequested
Timer Commands
StartTimer
The Worker issues this Command when the Workflow starts a Timer, such as a call to sleep.
- Awaitable: Yes
- Corresponding Event: TimerStarted
CancelTimer
The Worker issues this Command when the Workflow cancels a Timer.
- Awaitable: No
- Corresponding Event: TimerCanceled
Child and external Workflow Commands
StartChildWorkflowExecution
The Worker issues this Command when the Workflow starts a Child Workflow Execution.
- Awaitable: Yes
- Corresponding Event: StartChildWorkflowExecutionInitiated
- Limit: 2,000 pending Child Workflows
SignalExternalWorkflowExecution
The Worker issues this Command when the Workflow sends a Signal to another Workflow Execution.
- Awaitable: Yes
- Corresponding Event: SignalExternalWorkflowExecutionInitiated
- Limit: 2,000 pending Signals to other Workflows
RequestCancelExternalWorkflowExecution
The Worker issues this Command when the Workflow requests cancellation of another Workflow Execution.
- Awaitable: Yes
- Corresponding Event: RequestCancelExternalWorkflowExecutionInitiated
- Limit: 2,000 pending Cancellation Requests to other Workflows
Nexus Commands
ScheduleNexusOperation
The Worker issues this Command when the caller Workflow executes a Nexus Operation.
- Awaitable: Yes
- Corresponding Event: NexusOperationScheduled
- Limit: 30 pending Nexus Operations. See Nexus Operation limits.
RequestCancelNexusOperation
The Worker issues this Command when the caller Workflow requests cancellation of a Nexus Operation.
- Awaitable: No
- Corresponding Event: NexusOperationCancelRequested
Workflow metadata and SDK Commands
RecordMarker
The SDK issues this Command to record data it needs to replay the Workflow deterministically, such as the result of a Side Effect, a Local Activity, or a version check. Your Workflow code doesn't issue it directly.
- Awaitable: No
- Corresponding Event: MarkerRecorded
UpsertWorkflowSearchAttributes
The Worker issues this Command when the Workflow adds or updates its Search Attributes.
- Awaitable: No
- Corresponding Event: UpsertWorkflowSearchAttributes
ModifyWorkflowProperties
The Worker issues this Command when the Workflow adds or updates its Memo. The new values merge with the existing Memo.
- Awaitable: No
- Corresponding Event: WorkflowPropertiesModified
ProtocolMessage
The Worker issues this Command to keep protocol messages, such as responses to Updates, in order with the Workflow's other Commands.
The Command points to a protocol message, and the Temporal Service creates the Event from that message. The Command alone doesn't determine the resulting Event type. For Updates, the Events are WorkflowExecutionUpdateAccepted and WorkflowExecutionUpdateCompleted.