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

# Run a workflow and wait

> Run a workflow with typed inputs and get its outputs in the same call, or a run id if it takes longer than `wait` seconds.

A `200` holds the finished run with `outputs`. A `202` means the run is still going: poll [`GET /v1/workflow-runs/{run_id}`](/api-reference/workflows/get-run) at its `status_url`.


## OpenAPI

````yaml POST /v1/workflows/{slug}/run
openapi: 3.0.3
info:
  title: Valendata REST API
  version: 1.0.0
  description: >-
    Trigger Skills, manage Workflows, retrieve Runs, and stream structured
    results from any language using JSON over HTTPS.
servers:
  - url: https://api.valendata.com
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Skills
    description: Execute and inspect published Skills.
  - name: Workflows
    description: Trigger multi-step Workflows and list them.
  - name: Runs
    description: Start async Skill runs and read Skill and Workflow run results.
  - name: Skill creation
    description: Create a Skill from a plain-language task.
  - name: Skill improvement
    description: >-
      Fix a Skill, add fields to it or re-learn its detail steps, poll the
      result, and read its change history.
  - name: Versions
    description: List, diff, restore, and pin a Skill's recipe versions.
  - name: Webhooks
    description: Signed delivery of finished async runs.
paths:
  /v1/workflows/{slug}/run:
    post:
      tags:
        - Workflows
      summary: Run a Workflow and wait
      description: >-
        Checks the inputs against the workflow's declared inputs (a bad call is
        a 422 and costs nothing), runs it, and waits up to `wait` seconds
        (default 60, max 120). Finished in time → 200 with `outputs`. Still
        running → 202 with the run so far; poll its `status_url`. If your
        account is at its limit of runs in progress, the answer is 429 with
        `Retry-After` (use `/runs` to queue instead).
      operationId: runWorkflowSync
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            type: string
          description: The workflow's slug (shown on its API tab).
          example: test-workflow-api
        - name: wait
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            maximum: 120
          description: Overrides `wait` in the body.
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
          description: >-
            Retry-safe key. The same key from the same account returns the run
            it already started.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunWorkflowRequest'
            example:
              inputs:
                limit: 3
              wait: 60
      responses:
        '200':
          description: The finished run.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowRun'
        '202':
          description: Still running after `wait` seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowRun'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - ApiKeyAuth: []
        - SessionAuth: []
components:
  schemas:
    RunWorkflowRequest:
      type: object
      properties:
        inputs:
          type: object
          additionalProperties: true
          description: >-
            The workflow's inputs (see `input_schema`). Values are converted
            like skill inputs: `"5"` → 5 for an integer.
        wait:
          type: integer
          minimum: 0
          maximum: 120
          description: '`/run` only: seconds to wait (default 60).'
        webhook_url:
          type: string
          format: uri
          description: >-
            Receives the finished run as a signed POST
            (`X-Valendata-Signature`).
    WorkflowRun:
      type: object
      required:
        - run_id
        - status
      properties:
        run_id:
          type: string
        workflow_id:
          type: string
        workflow_slug:
          type: string
        status:
          type: string
          enum:
            - pending
            - running
            - completed
            - failed
            - cancelled
            - paused
            - waiting_for_human
        inputs:
          type: object
        outputs:
          type: object
          nullable: true
          additionalProperties: true
          description: >-
            `{rows, count}` from the final step. When several steps end the
            workflow: one `{rows, count}` per final step, keyed by step name.
            `null` while running.
        error:
          type: string
          nullable: true
        diagnosis:
          type: object
          nullable: true
        created_at:
          type: string
          format: date-time
        started_at:
          type: string
          format: date-time
          nullable: true
        finished_at:
          type: string
          format: date-time
          nullable: true
        execution_time_ms:
          type: integer
          nullable: true
        credits_charged:
          type: number
        cost_usd:
          type: number
        cost_final:
          type: boolean
        cost_estimate_credits:
          type: number
        steps:
          type: array
          items:
            type: object
            properties:
              step_id:
                type: string
              name:
                type: string
              type:
                type: string
              status:
                type: string
              count:
                type: integer
              error:
                type: string
                nullable: true
              execution_time_ms:
                type: integer
                nullable: true
        source:
          type: string
          enum:
            - api
            - mcp
          nullable: true
        status_url:
          type: string
    Error:
      type: object
      properties:
        detail:
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
          description: >-
            Error message. Usually a plain string; may be a structured object
            for some errors.
      example:
        detail: Invalid or expired API key
  responses:
    Unauthorized:
      description: >-
        Unauthorized. The Authorization header is missing, malformed, or the
        credential is invalid or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        Forbidden. You may not run or change this Skill, or it is not published
        or active.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found in your Workspace.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unprocessable:
      description: >-
        Invalid request. For bad inputs, `detail` is `{message, errors,
        allowed_inputs}`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: >-
        Too many requests for this API key, too many runs in progress, or too
        many recordings in progress. Check the `Retry-After` header when
        present.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: Internal server error on Valendata's side.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: vd_sk_...
      description: >-
        API key with the `vd_sk_` prefix. Create keys from Settings, API Keys in
        the dashboard.
    SessionAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Session token (JWT) obtained by calling `POST /api/auth/login` with your
        email and password.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.