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

# Rerun a task run

> Creates a new task run for the same task using the original run's input. Tokenized fields are replayed from their stored tokens, so you never need to resupply the values. The new run executes asynchronously in a new session.



## OpenAPI

````yaml /api-reference/v2.json post /task-runs/{run_id}/rerun
openapi: 3.1.1
info:
  title: Deck API
  version: 2.0.0
servers:
  - url: https://api.deck.co/v2
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Agents
    description: >-
      Agents are the AI workers that execute tasks against sources. Create and
      manage the agents in your organization.
  - name: Components
    description: >-
      Embeddable UI components. Create short-lived session tokens for the Auth
      Component.
  - name: Credentials
    description: >-
      Credentials store the login details an agent uses at a source. Values are
      tokenized at rest and never returned in plaintext.
  - name: Event Destinations
    description: >-
      Where Deck delivers events: webhooks, SQS, Kinesis, S3, or EventBridge.
      Manage destinations and inspect delivery attempts.
  - name: Events
    description: >-
      Immutable records of things that happened in your organization, such as a
      task run completing or a credential being verified.
  - name: Sessions
    description: >-
      Sessions are agent sandbox lifetimes. A session is created for each task
      run (or explicitly) and counts toward your concurrency limit.
  - name: Sources
    description: >-
      Sources are the websites and portals agents work against. Register,
      inspect, reset, and delete them.
  - name: Storage
    description: >-
      Files produced by task runs: downloaded documents, exports, and extraction
      results.
  - name: Task Runs
    description: >-
      A task run is one execution of a task. Inspect status and output, retrieve
      files and screenshots, cancel runs, and answer interaction requests.
  - name: Tasks
    description: >-
      Tasks define reusable units of work for an agent: a goal, an input schema,
      and an output schema. Run them against sources with credentials.
  - name: Test
    description: Connectivity check for your API key.
  - name: Triggers
    description: Triggers run tasks automatically on a schedule or in response to events.
  - name: Workflows
  - name: Workflow Runs
paths:
  /task-runs/{run_id}/rerun:
    post:
      tags:
        - Task Runs
      summary: Rerun a task run
      description: >-
        Creates a new task run for the same task using the original run's input.
        Tokenized fields are replayed from their stored tokens, so you never
        need to resupply the values. The new run executes asynchronously in a
        new session.
      operationId: rerunTaskRun
      parameters:
        - name: run_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^trun_
            example: trun_AbC123xYz456
          description: Unique identifier for the task run (prefixed with `trun_`).
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            Optional key that makes the request idempotent. Retrying with the
            same key returns the original response instead of repeating the
            operation; keys expire after 24 hours. Any string up to 256
            characters. See [Idempotency](/api/idempotency).
          schema:
            type: string
            maxLength: 256
            example: 550e8400-e29b-41d4-a716-446655440000
      responses:
        '201':
          description: Created
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/GetTaskRunResponse'
            application/json:
              schema:
                $ref: '#/components/schemas/GetTaskRunResponse'
            text/json:
              schema:
                $ref: '#/components/schemas/GetTaskRunResponse'
        '400':
          description: Bad request — validation error or malformed input.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '401':
          description: Unauthorized.
        '403':
          description: Forbidden.
        '404':
          description: Not found — the task run does not exist (`resource_not_found`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >-
            Conflict — the original run has not reached a terminal state
            (`resource_not_ready`). Wait for it to complete, fail, or cancel
            before rerunning it. Also returned when an `Idempotency-Key` is
            reused with different request parameters (`idempotency_error`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: >-
            Unprocessable content — the task's input schema changed after the
            original run, so its stored input can no longer be replayed
            (`input_invalid`). Submit a new run instead.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >-
            Too many requests — the organization-wide API rate limit was
            exceeded (`rate_limit_exceeded`). Retry with exponential backoff.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    GetTaskRunResponse:
      required:
        - id
        - object
        - status
        - result
        - task_id
        - trigger_id
        - workflow_id
        - workflow_run_id
        - step
        - credential_id
        - session_id
        - agent_id
        - source_id
        - runtime_ms
        - output
        - errors
        - interaction
        - created_at
        - updated_at
        - request_id
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the task run, prefixed with `trun_`.
          pattern: ^trun_
          example: trun_AbC123xYz456
        object:
          type: string
          description: Always `task_run`.
        status:
          type: string
          description: >-
            Run status: `queued`, `running`, `canceling`,
            `interaction_required`, `review_required`, `completed`, `canceled`,
            or `failed`.
        result:
          type:
            - 'null'
            - string
          description: >-
            Run result after completion: `success`, `failure`, or `unknown`.
            Null while running.
        task_id:
          type: string
          description: The task that was executed. Prefixed with `task_`.
        trigger_id:
          type:
            - 'null'
            - string
          description: >-
            The trigger that created this run, if any. Prefixed with `trg_`.
            `null` for runs created directly through the API.
        workflow_id:
          type:
            - 'null'
            - string
          description: >-
            The workflow whose step dispatched this run. Prefixed with `wflo_`.
            `null` for a standalone run.
        workflow_run_id:
          type:
            - 'null'
            - string
          description: >-
            The workflow run this run is a step of. Prefixed with `wrun_`.
            `null` for a standalone run.
        step:
          type:
            - 'null'
            - string
          description: >-
            Name of the workflow step that dispatched this run. `null` for a
            standalone run.
        credential_id:
          type:
            - 'null'
            - string
          description: >-
            The credential used for authentication, if any. Prefixed with
            `cred_`.
        session_id:
          type:
            - 'null'
            - string
          description: The session this run executed within, if any. Prefixed with `sess_`.
        agent_id:
          type: string
          description: The agent that executed this run. Prefixed with `agt_`.
        source_id:
          type:
            - 'null'
            - string
          description: The source this run connected to, if any. Prefixed with `src_`.
        runtime_ms:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - 'null'
            - integer
            - string
          format: int32
          description: Execution time in milliseconds.
        input:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/JsonElement'
          description: Input data provided when the run was created.
        tokenized:
          type:
            - 'null'
            - array
          items:
            type: string
          description: >-
            Names of input fields whose values were tokenized when the run was
            created. The listed fields are removed from `input`. Returned
            alongside `input` (only when `include=input` is requested and one or
            more fields were vaulted); omitted otherwise.
        output:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/JsonElement'
          description: Output data produced by the task execution.
        storage:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/TaskRunStorageItem'
          description: >-
            Files captured during the run, each with inline extraction (if any).
            Returned only when `include=storage` is requested.
        storage_deduplicated:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/TaskRunDeduplicatedFile'
          description: >-
            Files skipped by deduplication during the run. Returned only when
            `include=storage_deduplicated` is requested and the run's task has
            `storage.deduplication` enabled; omitted otherwise. An empty array
            means deduplication ran and no files were skipped.
        artifacts:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TaskRunArtifactData'
          description: >-
            Run-level visibility artifacts (screenshots). Returned only when
            `include=artifacts` is requested.
        errors:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/TaskRunError'
          description: Error details if the run failed. Same structure as API-level errors.
        interaction:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/JsonElement'
          description: >-
            Interaction details when the run is paused waiting for user input
            (e.g. MFA code, security question).
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of when the resource was created.
          example: '2026-08-24T12:00:00Z'
        updated_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of when the resource was last updated.
          example: '2026-08-24T12:00:00Z'
        request_id:
          type: string
          description: >-
            Unique identifier for the API request. Include this when contacting
            support.
      description: A task run object representing a single execution of a task.
    ValidationErrorResponse:
      required:
        - errors
      type: object
      properties:
        type:
          type:
            - 'null'
            - string
          description: RFC 9110 problem type URI.
        title:
          type:
            - 'null'
            - string
          description: Short summary of the validation failure.
        status:
          type:
            - 'null'
            - integer
          description: HTTP status code.
          format: int32
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Validation errors grouped by field name.
        traceId:
          type:
            - 'null'
            - string
          description: Request trace identifier.
      description: Validation error returned for malformed requests (HTTP 400).
    ErrorResponse:
      required:
        - errors
        - request_id
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/TaskRunError'
          description: One or more errors that describe what went wrong.
        request_id:
          type: string
          description: Unique identifier for this request, useful for tracing.
      description: Standard error response.
    JsonElement:
      description: Arbitrary JSON value.
    TaskRunStorageItem:
      required:
        - id
        - object
        - file_name
        - file_type
        - file_size
        - purpose
        - created_at
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the storage item, prefixed with `stor_`.
          pattern: ^stor_
          example: stor_AbC123xYz456
        object:
          type: string
          description: Always `storage`.
        file_name:
          type: string
          description: Original file name.
        file_type:
          type: string
          description: MIME type of the file.
        file_size:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - integer
            - string
          format: int64
          description: Size of the file in bytes.
        url:
          type:
            - 'null'
            - string
          description: Signed URL to download the file. Time-limited.
        extraction:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/JsonElement'
          description: Extracted structured data from the file, if any.
        purpose:
          type: string
          enum:
            - attachment
            - extraction
            - output
          description: >-
            How the file relates to the run: `attachment` (a file you provided
            as task input for the agent to use), `extraction` (a file you
            provided as task input that Deck extracts data from directly,
            skipping the agent), or `output` (a file the agent captured during
            the run).
        created_at:
          type: string
          format: date-time
          description: When the storage item was created.
          example: '2026-08-24T12:00:00Z'
      description: >-
        A storage item embedded in the task run detail response when
        include=storage is requested. Includes the signed download URL and any
        inline extraction.
    TaskRunDeduplicatedFile:
      required:
        - file_name
        - duplicate_of
        - task_run_id
        - created_at
      type: object
      properties:
        file_name:
          type: string
          description: Name of the skipped file as the agent captured it.
        duplicate_of:
          type: string
          description: >-
            Storage ID of the surviving item this file matched, prefixed with
            `stor_`. Fetch `GET /v2/storage/{duplicate_of}` for the original's
            file name, extraction, and a fresh signed URL. The referenced item
            is deleted on the normal file retention schedule, after which the ID
            no longer resolves.
          pattern: ^stor_
          example: stor_AbC123xYz456
        task_run_id:
          type: string
          description: >-
            The task run that originally captured the matched file, prefixed
            with `trun_`. This is the earlier capture run, not the run this
            entry appears on.
          pattern: ^trun_
          example: trun_AbC123xYz456
        created_at:
          type: string
          format: date-time
          description: When the file was skipped.
          example: '2026-08-24T12:00:00Z'
      description: >-
        A file skipped by deduplication, embedded in the task run detail
        response when include=storage_deduplicated is requested and the task has
        deduplication enabled. Entries are inline values, not addressable
        resources: no id, no object type, and no query endpoint.
    TaskRunArtifactData:
      type: object
      properties:
        screenshots:
          type: array
          items:
            $ref: '#/components/schemas/TaskRunScreenshot'
          description: Screenshots captured during the run.
      description: >-
        Run-level visibility artifacts returned when include=artifacts is
        requested.
      required:
        - screenshots
    TaskRunError:
      required:
        - type
        - code
        - message
      type: object
      properties:
        type:
          type: string
          description: >-
            Error category (e.g. `source`, `auth`, `task`, `rate_limit`).
            Determines the class of failure.
        code:
          type: string
          description: Machine-readable error code. Use this for programmatic handling.
        message:
          type: string
          description: >-
            Human-readable explanation. Do not rely on this for logic — it may
            change.
        field:
          type:
            - 'null'
            - string
          description: The input field that caused the error, when applicable.
      description: Error details for a failed task run. Same structure as API-level errors.
    TaskRunScreenshot:
      required:
        - file_name
        - file_type
        - file_size
        - created_at
      type: object
      properties:
        file_name:
          type: string
          description: Original file name.
        file_type:
          type: string
          description: MIME type of the screenshot.
        file_size:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - integer
            - string
          format: int64
          description: Size of the file in bytes.
        url:
          type:
            - 'null'
            - string
          description: Signed URL to download the screenshot. Time-limited.
        reasoning:
          type:
            - 'null'
            - string
          description: AI reasoning at the time of capture, if recorded.
        created_at:
          type: string
          format: date-time
          description: When the screenshot was captured.
          example: '2026-08-24T12:00:00Z'
      description: A single screenshot captured during a task run.
  securitySchemes:
    BearerAuth:
      type: http
      description: Secret key (sk_live_...)
      scheme: bearer
      bearerFormat: JWT

````