getWorkflowMetadata
Access run IDs and timing information within workflow or step functions.
Returns metadata about the current workflow run. This function can be called from either a workflow function or a step function.
You may want to use this function when you need to:
- Log workflow run IDs
- Access timing information of a workflow
- Retrieve the workflow URL from within a step
If you need to access step-specific context, take a look at getStepMetadata.
import { getWorkflowMetadata } from "workflow"
async function testWorkflow() {
"use workflow"
const ctx = getWorkflowMetadata()
console.log(ctx.workflowRunId)
}API Signature
Parameters
This function does not accept any parameters.
Returns
Returns a WorkflowMetadata object with the following fields:
| Field | Type | Description |
|---|---|---|
workflowName | string | The name of the workflow. |
workflowRunId | string | Unique identifier for the workflow run. |
workflowStartedAt | Date | Timestamp when the workflow run started. |
url | string | The URL where the workflow can be triggered. |
| Name | Type | Description |
|---|---|---|
workflowName | string | The name of the workflow. |
workflowRunId | string | Unique identifier for the workflow run. |
workflowStartedAt | Date | Timestamp when the workflow run started. |
url | string | The URL where the workflow can be triggered. |