> ## Documentation Index
> Fetch the complete documentation index at: https://docs.retab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Workflow Eval Run

> Create a workflow-scoped eval run.

`workflow_id` is the execution context. Optional `scope` narrows the
run to one saved eval or one block; omitted scope runs all workflow evals.

Create a workflow-eval run against the current workflow draft. A run can execute
one saved eval, every eval for one block, or every eval in the workflow.

The canonical route is flat: send `workflow_id` in the request body and
optionally narrow execution with `scope`. If `scope` is omitted, every saved
eval in the workflow runs.

The response is a run resource. Use its `id` with the run-id-first endpoints:
[Get Workflow Eval Run](/api-reference/workflows/evals/runs/get), [List Eval
Run Results](/api-reference/workflows/evals/results/list).

The request body has a workflow context and an optional scope:

* **omitted `scope`** - run every saved eval in the workflow.
* **`scope.type = "single"`** - run one saved eval by `eval_id`.
* **`scope.type = "block"`** - run every saved eval for one block by `block_id`.

<RequestExample>
  ```python Python theme={null}
  from retab import Retab

  client = Retab()

  run = client.workflows.evals.runs.create(
      workflow_id="wf_abc123xyz",
      scope={
          "type": "single",
          "eval_id": "wfnodeeval_hsLEQiM61ez9Piv147MWk",
      },
  )

  print(run.id, run.lifecycle.status)
  ```

  ```typescript TypeScript theme={null}
  import { Retab } from "@retab/node";

  const client = new Retab({ apiKey: process.env.RETAB_API_KEY });

  const run = await client.workflows.evals.runs.create("wf_abc123xyz", {
    type: "single",
    evalId: "wfnodeeval_hsLEQiM61ez9Piv147MWk",
  });

  console.log(run.id, run.lifecycle.status);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"

  	retab "github.com/retab-dev/retab/clients/go"
  )

  func ptr[T any](v T) *T { return &v }

  func main() {
  	ctx := context.Background()

  	client, err := retab.NewClient("")
  	if err != nil {
  		log.Fatal(err)
  	}

  	run, err := client.Workflows.Evals.Runs.Create(ctx, &retab.WorkflowEvalRunsCreateParams{
  		WorkflowID: "wf_abc123xyz",
  		Scope: &retab.WorkflowEvalRunScope{
  			Type:   retab.WorkflowEvalRunScopeTypeSingle,
  			EvalID: ptr("wfnodeeval_hsLEQiM61ez9Piv147MWk"),
  		},
  	})
  	if err != nil {
  		log.Fatal(err)
  	}

  	fmt.Println(run.ID, run.Lifecycle.Status())
  }
  ```

  ```ruby Ruby theme={null}
  require 'retab'

  client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])

  run = client.workflows.evals.runs.create(
    workflow_id: 'wf_abc123xyz',
    scope: {
      type: 'single',
      eval_id: 'wfnodeeval_hsLEQiM61ez9Piv147MWk',
    },
  )

  puts "#{run.id} #{run.lifecycle.status}"
  ```

  ```rust Rust theme={null}
  use retab::models::{CreateWorkflowEvalRunRequest, WorkflowEvalRunSingleScope};
  use retab::resources::workflow_eval_runs::CreateParams;
  use retab::Retab;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Retab::new(std::env::var("RETAB_API_KEY")?);

      let run = client
          .workflows().evals().runs()
          .create(CreateParams::new(CreateWorkflowEvalRunRequest {
              workflow_id: "wf_abc123xyz".into(),
              scope: Some(WorkflowEvalRunSingleScope {
                  type_: "single".into(),
                  eval_id: "wfnodeeval_hsLEQiM61ez9Piv147MWk".into(),
              }.into()),
          }))
          .await?;
      println!("{} {:?}", run.id, run.lifecycle);
      Ok(())
  }
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';

  use Retab\Client;

  $client = new Client(apiKey: getenv('RETAB_API_KEY'));

  $result = $client->workflows()->evals()->runs()->create();
  print_r($result);
  ```

  ```csharp C# theme={null}
  using Retab;
  using RetabClient = Retab.Retab;

  var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
  var client = new RetabClient(apiKey);

  var result = await client.Workflows.Evals.Runs.CreateAsync(
      new WorkflowEvalRunsCreateOptions
      {
          WorkflowId = "wf_abc123xyz",
          Scope = new WorkflowEvalRunSingleScope
          {
              EvalId = "wfnodeeval_hsLEQiM61ez9Piv147MWk",
          },
      }
  );
  Console.WriteLine(result);
  ```

  ```java Java theme={null}
  import com.retab.RetabClient;
  import com.retab.workflowevalruns.WorkflowEvalRunsApi;

  public final class Example {
    public static void main(String[] args) throws Exception {
      RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));

      var result = new WorkflowEvalRunsApi(client).create("wf_abc123", null);
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  # Single eval
  curl -X 'POST' \
    'https://api.retab.com/v1/workflows/evals/runs' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <your-api-key>' \
    -d '{
      "workflow_id": "wf_abc123xyz",
      "scope": {
        "type": "single",
        "eval_id": "wfnodeeval_hsLEQiM61ez9Piv147MWk"
      }
    }'

  # All evals for one block
  curl -X 'POST' \
    'https://api.retab.com/v1/workflows/evals/runs' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <your-api-key>' \
    -d '{
      "workflow_id": "wf_abc123xyz",
      "scope": { "type": "block", "block_id": "block_extract_invoice" }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 202 theme={null}
  {
    "id": "wfevalrun_q1z2",
    "workflow_id": "wf_abc123xyz",
    "workflow_version_id": "draft_2026_05_18",
    "trigger": { "type": "api" },
    "lifecycle": { "status": "pending" },
    "timing": {
      "created_at": "2026-05-18T10:00:00Z",
      "started_at": null,
      "completed_at": null,
      "duration_ms": null
    },
    "eval_id": "wfnodeeval_hsLEQiM61ez9Piv147MWk",
    "target": { "type": "block", "block_id": "block_extract_invoice" },
    "total_evals": 1,
    "counts": {
      "lifecycle_counts": {
        "pending": 1,
        "queued": 0,
        "running": 0,
        "completed": 0,
        "error": 0,
        "cancelled": 0
      },
      "outcome": {
        "passed": 0,
        "failed": 0,
        "blocked": 0
      }
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /v1/workflows/evals/runs
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/workflows/evals/runs:
    post:
      tags:
        - Workflows
        - Workflow Eval Runs
      summary: Create Workflow Eval Run
      description: >-
        Create a workflow-scoped eval run.


        `workflow_id` is the execution context. Optional `scope` narrows the

        run to one saved eval or one block; omitted scope runs all workflow
        evals.
      operationId: create_workflow_eval_run
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWorkflowEvalRunRequest'
        required: true
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowEvalRun'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    CreateWorkflowEvalRunRequest:
      properties:
        workflow_id:
          type: string
          title: Workflow Id
        scope:
          anyOf:
            - oneOf:
                - $ref: '#/components/schemas/WorkflowEvalRunSingleScope'
                - $ref: '#/components/schemas/WorkflowEvalRunWorkflowScope'
                - $ref: '#/components/schemas/WorkflowEvalRunBlockScope'
              discriminator:
                propertyName: type
                mapping:
                  block:
                    $ref: '#/components/schemas/WorkflowEvalRunBlockScope'
                  single:
                    $ref: '#/components/schemas/WorkflowEvalRunSingleScope'
                  workflow:
                    $ref: '#/components/schemas/WorkflowEvalRunWorkflowScope'
            - type: 'null'
          title: Scope
          description: >-
            Optional execution scope. Omit (or pass null) to run every saved
            eval in the workflow.
      additionalProperties: false
      type: object
      required:
        - workflow_id
      title: CreateWorkflowEvalRunRequest
      description: >-
        Create a workflow eval run. Provide a `workflow_id`, and optionally
        narrow execution with `scope` to a single eval or one block. Omit
        `scope` to run every saved workflow eval.
    WorkflowEvalRun:
      properties:
        id:
          type: string
          title: Id
        workflow_id:
          type: string
          title: Workflow Id
        workflow_version_id:
          type: string
          title: Workflow Version Id
        trigger:
          $ref: '#/components/schemas/EvalRunTrigger'
        lifecycle:
          oneOf:
            - $ref: '#/components/schemas/PendingWorkflowEvalRun'
            - $ref: '#/components/schemas/QueuedWorkflowEvalRun'
            - $ref: '#/components/schemas/RunningWorkflowEvalRun'
            - $ref: '#/components/schemas/CompletedWorkflowEvalRun'
            - $ref: '#/components/schemas/ErrorWorkflowEvalRun'
            - $ref: '#/components/schemas/CancelledWorkflowEvalRun'
          title: Lifecycle
          discriminator:
            propertyName: status
            mapping:
              cancelled:
                $ref: '#/components/schemas/CancelledWorkflowEvalRun'
              completed:
                $ref: '#/components/schemas/CompletedWorkflowEvalRun'
              error:
                $ref: '#/components/schemas/ErrorWorkflowEvalRun'
              pending:
                $ref: '#/components/schemas/PendingWorkflowEvalRun'
              queued:
                $ref: '#/components/schemas/QueuedWorkflowEvalRun'
              running:
                $ref: '#/components/schemas/RunningWorkflowEvalRun'
        timing:
          $ref: '#/components/schemas/WorkflowEvalRunTiming'
        target:
          anyOf:
            - $ref: '#/components/schemas/EvalRunBlockTarget'
            - type: 'null'
        eval_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Eval Id
        total_evals:
          type: integer
          title: Total Evals
        counts:
          $ref: '#/components/schemas/BlockEvalBatchExecutionCounts'
          default:
            lifecycle_counts:
              cancelled: 0
              completed: 0
              error: 0
              pending: 0
              queued: 0
              running: 0
            outcome:
              blocked: 0
              failed: 0
              passed: 0
        freshness:
          $ref: '#/components/schemas/EvalRunFreshness'
          description: >-
            Compatibility envelope only. WorkflowEval.freshness is the
            authoritative read-time staleness verdict for saved eval
            definitions.
      type: object
      required:
        - id
        - lifecycle
        - timing
        - total_evals
        - trigger
        - workflow_id
        - workflow_version_id
      title: WorkflowEvalRun
      description: >-
        A batch execution of a workflow's evals, with overall `lifecycle`,
        `timing`, and pass/fail `counts`.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    WorkflowEvalRunSingleScope:
      properties:
        type:
          type: string
          const: single
          title: Type
        eval_id:
          type: string
          title: Eval Id
      type: object
      required:
        - eval_id
        - type
      title: WorkflowEvalRunSingleScope
      description: Run one saved workflow eval in the workflow.
    WorkflowEvalRunWorkflowScope:
      properties:
        type:
          type: string
          const: workflow
          title: Type
      type: object
      required:
        - type
      title: WorkflowEvalRunWorkflowScope
      description: Run every saved eval in the workflow.
    WorkflowEvalRunBlockScope:
      properties:
        type:
          type: string
          const: block
          title: Type
        block_id:
          type: string
          title: Block Id
      type: object
      required:
        - block_id
        - type
      title: WorkflowEvalRunBlockScope
      description: Run every workflow eval for one block in the workflow.
    EvalRunTrigger:
      properties:
        type:
          type: string
          enum:
            - manual
            - api
            - schedule
            - webhook
            - email
            - custom
            - restart
          title: Type
      type: object
      required:
        - type
      title: EvalRunTrigger
    PendingWorkflowEvalRun:
      properties:
        status:
          type: string
          const: pending
          title: Status
          default: pending
      type: object
      title: PendingWorkflowEvalRun
      description: The eval run has been created but execution has not started.
    QueuedWorkflowEvalRun:
      properties:
        status:
          type: string
          const: queued
          title: Status
          default: queued
      type: object
      title: QueuedWorkflowEvalRun
      description: The eval run is enqueued and waiting for a worker.
    RunningWorkflowEvalRun:
      properties:
        status:
          type: string
          const: running
          title: Status
          default: running
      type: object
      title: RunningWorkflowEvalRun
      description: The eval run is executing assertions.
    CompletedWorkflowEvalRun:
      properties:
        status:
          type: string
          const: completed
          title: Status
          default: completed
      type: object
      title: CompletedWorkflowEvalRun
      description: The eval run finished. Per-eval verdicts live on each result row.
    ErrorWorkflowEvalRun:
      properties:
        status:
          type: string
          const: error
          title: Status
          default: error
        message:
          type: string
          title: Message
          description: Human-readable error message
          default: (no message)
        details:
          anyOf:
            - $ref: '#/components/schemas/ErrorDetails'
            - type: 'null'
          description: Structured error context including stack trace
      type: object
      title: ErrorWorkflowEvalRun
      description: |-
        The eval run failed. The error message lives on this variant.

        Carries the same structured `details` envelope as workflow runs so
        consumers can branch on `error_code` / `stage` rather than parsing
        a free-text message.
    CancelledWorkflowEvalRun:
      properties:
        status:
          type: string
          const: cancelled
          title: Status
          default: cancelled
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
          description: Human-readable reason, when known
      type: object
      title: CancelledWorkflowEvalRun
      description: The eval run was cancelled before reaching a natural terminal state.
    WorkflowEvalRunTiming:
      properties:
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the workflow-eval run was created.
        started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Started At
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
        duration_ms:
          anyOf:
            - type: integer
            - type: 'null'
          title: Duration Ms
      type: object
      title: WorkflowEvalRunTiming
    EvalRunBlockTarget:
      properties:
        type:
          type: string
          const: block
          title: Type
          default: block
        block_id:
          type: string
          title: Block Id
      type: object
      required:
        - block_id
      title: EvalRunBlockTarget
      description: >-
        Public workflow-eval target.


        The storage layer remains block-scoped today, but the API shape names
        the

        tested entity explicitly so workflow-level targets can be added later.
    BlockEvalBatchExecutionCounts:
      properties:
        lifecycle_counts:
          $ref: '#/components/schemas/BlockEvalLifecycleCounts'
          default:
            pending: 0
            queued: 0
            running: 0
            completed: 0
            error: 0
            cancelled: 0
        outcome:
          $ref: '#/components/schemas/BlockEvalOutcomeCounts'
          default:
            passed: 0
            failed: 0
            blocked: 0
      type: object
      title: BlockEvalBatchExecutionCounts
      description: |-
        Aggregate counts for a batch of block-eval runs.

        Each individual run contributes to exactly one `lifecycle_counts`
        bucket, and additionally to one `outcome` bucket when
        `lifecycle_counts.completed` is incremented.
    EvalRunFreshness:
      properties:
        status:
          type: string
          enum:
            - fresh
            - stale
            - unknown
          title: Status
          default: unknown
        reasons:
          items:
            type: string
            enum:
              - validity_changed
              - inputs_changed
              - engine_changed
              - metrics_engine_changed
              - no_baseline
          type: array
          title: Reasons
          default: []
        validity_fingerprint:
          anyOf:
            - type: string
            - type: 'null'
          title: Validity Fingerprint
        input_fingerprint:
          anyOf:
            - type: string
            - type: 'null'
          title: Input Fingerprint
        baseline_run_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Baseline Run Id
      type: object
      required:
        - baseline_run_id
        - input_fingerprint
        - validity_fingerprint
      title: EvalRunFreshness
      description: >-
        Compatibility envelope on WorkflowEvalRun. This is not the authoritative
        stale/fresh verdict for saved eval definitions; use
        WorkflowEval.freshness for current staleness presentation.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
          default: null
        ctx:
          type: object
          title: Context
          default: {}
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ErrorDetails:
      properties:
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
          description: >-
            Human-readable error message. Free-text; the structured fields below
            are the machine-readable counterpart.
        stack_trace:
          anyOf:
            - type: string
            - type: 'null'
          title: Stack Trace
          description: Full stack trace
        block_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Block Id
          description: ID of the block that failed
        block_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Block Name
          description: Name/label of the block that failed
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
          description: Error code if available
        context:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Context
          description: Additional context about the error
      type: object
      title: ErrorDetails
      description: |-
        Detailed error information for debugging.

        Captures stack traces and context about where and why an error occurred.
    BlockEvalLifecycleCounts:
      properties:
        pending:
          type: integer
          title: Pending
          default: 0
        queued:
          type: integer
          title: Queued
          default: 0
        running:
          type: integer
          title: Running
          default: 0
        completed:
          type: integer
          title: Completed
          default: 0
        error:
          type: integer
          title: Error
          default: 0
        cancelled:
          type: integer
          title: Cancelled
          default: 0
      type: object
      title: BlockEvalLifecycleCounts
      description: Per-lifecycle counts for a batch of block-eval runs.
    BlockEvalOutcomeCounts:
      properties:
        passed:
          type: integer
          title: Passed
          default: 0
        failed:
          type: integer
          title: Failed
          default: 0
        blocked:
          type: integer
          title: Blocked
          default: 0
      type: object
      title: BlockEvalOutcomeCounts
      description: Per-outcome counts. Only completed runs contribute to these buckets.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````