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

# Replay run

> Creates a new run with the same payload and options as the original run, in the same environment. Send a body to override the payload, metadata, or trigger options for the new run. The body is optional; an empty body replays the run unchanged.



## OpenAPI

````yaml v3-openapi POST /api/v1/runs/{runId}/replay
openapi: 3.1.0
info:
  title: Trigger.dev v3 REST API
  description: >-
    The REST API lets you trigger and manage runs on Trigger.dev. You can
    trigger a run, get the status of a run, and get the results of a run. 
  version: 2024-04
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://api.trigger.dev
    description: Trigger.dev API
security: []
paths:
  /api/v1/runs/{runId}/replay:
    parameters:
      - $ref: '#/components/parameters/runId'
    post:
      tags:
        - runs
      summary: Replay a run
      description: >-
        Creates a new run with the same payload and options as the original run,
        in the same environment. Send a body to override the payload, metadata,
        or trigger options for the new run. The body is optional; an empty body
        replays the run unchanged.
      operationId: replay_run_v1
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                payload:
                  description: >-
                    The payload for the new run. Omit it to reuse the original
                    run's payload.
                payloadType:
                  type: string
                  enum:
                    - application/json
                    - application/super+json
                  description: >-
                    How `payload` is encoded. Defaults to `application/json`.
                    With `application/super+json`, `payload` must be a SuperJSON
                    string, which keeps types like `Date` and `BigInt`. The SDK
                    sends this automatically.
                metadata:
                  type: object
                  additionalProperties: true
                  description: >-
                    Metadata for the new run. Omit it to reuse the original
                    run's metadata.
                tags:
                  allOf:
                    - $ref: '#/components/schemas/RunTags'
                  description: Tags for the new run. Replaces the original run's tags.
                queue:
                  type: string
                  description: The name of an existing queue in the environment to run on.
                concurrencyKey:
                  type: string
                  description: The concurrency key for the new run.
                machine:
                  type: string
                  enum:
                    - micro
                    - small-1x
                    - small-2x
                    - medium-1x
                    - medium-2x
                    - large-1x
                    - large-2x
                  example: small-2x
                  description: The machine preset for the new run.
                version:
                  type: string
                  description: >-
                    Lock the new run to this deployed version, for example
                    `20250101.1`. Defaults to the current version.
                region:
                  type: string
                  description: The region to run in. Defaults to the original run's region.
                delay:
                  type: string
                  description: >-
                    Delay the new run, as a duration (`1h30m`) or an ISO 8601
                    date.
                ttl:
                  oneOf:
                    - type: string
                    - type: integer
                  description: >-
                    How long the new run can stay queued before it expires, as a
                    duration string (`10m`) or a number of seconds.
                idempotencyKey:
                  type: string
                  maxLength: 2048
                  description: >-
                    An idempotency key for the new run. A repeated request with
                    the same key returns the same run.
                idempotencyKeyTTL:
                  type: string
                  description: How long the idempotency key is valid, as a duration (`1h`).
                maxAttempts:
                  type: integer
                  minimum: 1
                  description: The maximum number of attempts for the new run.
                maxDuration:
                  type: number
                  description: The maximum duration of the new run in seconds.
                priority:
                  type: number
                  description: >-
                    Priority offset in seconds. Higher values are dequeued
                    sooner.
            example:
              payload:
                userId: user_456
              tags:
                - replayed
              delay: 10m
      responses:
        '200':
          description: Successful request
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: The ID of the new run.
        '400':
          description: >-
            Invalid request, for example an unknown body field, an unknown
            queue, or a version that is not deployed to the environment.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: What was wrong with the request.
        '401':
          description: Unauthorized request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    enum:
                      - Invalid or Missing API key
        '403':
          description: >-
            The credentials can't trigger the run's task. A replay starts a new
            run, so it needs permission to trigger the task as well as write
            access to the run.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    enum:
                      - Run not found
        '413':
          description: The request body is larger than the maximum payload size.
      security:
        - secretKey: []
      x-codeSamples:
        - lang: typescript
          source: |-
            import { runs } from "@trigger.dev/sdk";

            const handle = await runs.replay("run_1234");

            const withOverrides = await runs.replay("run_1234", {
              payload: { userId: "user_456" },
              tags: ["replayed"],
              delay: "10m",
            });
components:
  parameters:
    runId:
      in: path
      name: runId
      required: true
      schema:
        type: string
      description: >
        The ID of an run, starts with `run_`. The run ID will be returned when
        you trigger a run on a task.
      example: run_1234
  schemas:
    RunTags:
      oneOf:
        - $ref: '#/components/schemas/RunTag'
        - type: array
          items:
            $ref: '#/components/schemas/RunTag'
          maxItems: 10
          uniqueItems: true
          example:
            - user_123456
            - product_4629101
      description: One or more tags to attach to a run. Runs can have a maximum of 10 tags.
    RunTag:
      type: string
      maxLength: 128
      description: A single run tag. Must be less than 128 characters.
      example: user_123456
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      description: >
        Use a named environment API key. It starts with `tr_dev_sk_`,
        `tr_prod_sk_`, `tr_stg_sk_`, etc.


        Create a named API key in the API Keys section of your Trigger.dev
        project dashboard. Choose the narrowest access preset that supports your
        integration.


        Our TypeScript SDK will default to using the value of the
        `TRIGGER_SECRET_KEY` environment variable if it is set. If you are using
        the SDK in a different environment, you can set the key using the
        `configure` function.


        ```typescript

        import { configure } from "@trigger.dev/sdk";


        configure({ accessToken: "tr_dev_sk_1234" });

        ```

````

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