Upstash Documentation

context.invoke

2 min read

context.invoke() triggers another workflow run and pauses until the invoked workflow finishes.

The calling workflow resumes once the invoked workflow either succeeds, fails, or is canceled.

Note

Workflows can only invoke other workflows that were served together in the same serveMany route. For details, see Invoke other workflows.

Arguments#

workflowfunctionrequired#

The workflow definition to invoke. Must be a workflow exposed under the same serveMany.

bodyany#

The payload to send to the invoked workflow. This value will be set as context.requestPayload in the invoked workflow.

headersobject#

Optional HTTP headers to forward to the invoked workflow. This value will be set as context.headers in the invoked workflow.

workflowRunIdstring#

Override the workflow run ID for the invoked workflow. Defaults to a new ID if not specified.

retriesnumber#

Number of retry attempts configuration of the invoked workflow. Defaults to 3. Retries use exponential backoff.

retryDelaynumber|string#

Delay between retries of the invoked workflow.

flowControlobject#

Flow control configuration of the invoked workflow.

See Flow Control for details.

Show properties
keystring#

A logical grouping key that identifies which requests share the same flow control limits.

ratenumber#

The maximum number of allowed requests per second.

parallelismnumber#

The maximum number of concurrent requests allowed.

periodstring|number#

The time window used to enforce the defined rate limit. Default is 1s.

Response#

bodyany#

The response body returned by the invoked workflow.

isFailedboolean#

true if the invoked workflow completed with failure.

isCanceledboolean#

true if the invoked workflow was canceled before completion.

Usage#