> ## 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.

# Create bulk action

> Create an asynchronous bulk action to cancel or replay runs selected by run IDs or filters.



## OpenAPI

````yaml v3-openapi POST /api/v1/bulk-actions
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/bulk-actions:
    post:
      tags:
        - bulk-actions
      summary: Create bulk action
      description: >-
        Create an asynchronous bulk action to cancel or replay runs selected by
        run IDs or filters.
      operationId: create_bulk_action_v1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBulkActionRequestBody'
      responses:
        '202':
          description: Bulk action accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateBulkActionResponse'
        '400':
          description: Invalid request parameters or body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized request
        '422':
          description: Unprocessable entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too many concurrent bulk replays
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - secretKey: []
      x-codeSamples:
        - lang: typescript
          label: Replay matching runs
          source: |-
            import { runs } from "@trigger.dev/sdk";

            const action = await runs.bulk.replay({
              filter: {
                status: "FAILED",
                taskIdentifier: "sync-customer",
                period: "24h",
              },
              name: "Replay failed customer syncs",
            });

            console.log(action.id);
        - lang: typescript
          label: Cancel selected runs
          source: |-
            import { runs } from "@trigger.dev/sdk";

            const action = await runs.bulk.cancel({
              runIds: ["run_1234", "run_5678"],
              name: "Cancel selected runs",
            });

            console.log(action.id);
components:
  schemas:
    CreateBulkActionRequestBody:
      oneOf:
        - title: Cancel by filter
          type: object
          required:
            - action
            - filter
          properties:
            action:
              type: string
              enum:
                - cancel
            filter:
              $ref: '#/components/schemas/BulkActionFilter'
            name:
              type: string
              maxLength: 255
        - title: Cancel by run IDs
          type: object
          required:
            - action
            - runIds
          properties:
            action:
              type: string
              enum:
                - cancel
            runIds:
              type: array
              minItems: 1
              maxItems: 500
              items:
                type: string
            name:
              type: string
              maxLength: 255
        - title: Replay by filter
          type: object
          required:
            - action
            - filter
          properties:
            action:
              type: string
              enum:
                - replay
            filter:
              $ref: '#/components/schemas/BulkActionFilter'
            name:
              type: string
              maxLength: 255
            targetRegion:
              type: string
              description: >-
                Region identifier to replay runs in. When omitted, each replay
                keeps the original run's region.
        - title: Replay by run IDs
          type: object
          required:
            - action
            - runIds
          properties:
            action:
              type: string
              enum:
                - replay
            runIds:
              type: array
              minItems: 1
              maxItems: 500
              items:
                type: string
            name:
              type: string
              maxLength: 255
            targetRegion:
              type: string
              description: >-
                Region identifier to replay runs in. When omitted, each replay
                keeps the original run's region.
    CreateBulkActionResponse:
      type: object
      required:
        - id
      properties:
        id:
          type: string
          example: bulk_1234
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: Something went wrong
      required:
        - error
    BulkActionFilter:
      type: object
      description: >-
        Selects runs using SDK-style run-list filter fields, excluding
        pagination fields. In HTTP requests these fields are sent as JSON body
        properties, so time fields are top-level (`from`, `to`, `period`)
        instead of nested under `createdAt`. Provide at least one property.
      minProperties: 1
      properties:
        status:
          oneOf:
            - type: string
              enum:
                - PENDING_VERSION
                - QUEUED
                - EXECUTING
                - REATTEMPTING
                - FROZEN
                - COMPLETED
                - CANCELED
                - FAILED
                - CRASHED
                - INTERRUPTED
                - SYSTEM_FAILURE
            - type: array
              items:
                type: string
                enum:
                  - PENDING_VERSION
                  - QUEUED
                  - EXECUTING
                  - REATTEMPTING
                  - FROZEN
                  - COMPLETED
                  - CANCELED
                  - FAILED
                  - CRASHED
                  - INTERRUPTED
                  - SYSTEM_FAILURE
        taskIdentifier:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: The identifier of the task that was run.
        version:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: The worker version that executed the run.
        from:
          oneOf:
            - type: string
              format: date-time
            - type: number
          description: >-
            Start of the time range as an ISO date string or Unix timestamp in
            milliseconds.
        to:
          oneOf:
            - type: string
              format: date-time
            - type: number
          description: >-
            End of the time range as an ISO date string or Unix timestamp in
            milliseconds.
        period:
          type: string
          description: Relative time period to select, such as `24h` or `30d`.
          example: 24h
        bulkAction:
          type: string
          description: Select runs that were processed by another bulk action.
          example: bulk_1234
        tag:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: Select runs with one or more tags.
        schedule:
          type: string
          description: Select runs created by a schedule.
          example: sched_1234
        isTest:
          type: boolean
          description: Select test or non-test runs.
        batch:
          type: string
          description: Select runs in a batch.
          example: batch_1234
        queue:
          oneOf:
            - $ref: '#/components/schemas/QueueTypeName'
            - type: array
              items:
                $ref: '#/components/schemas/QueueTypeName'
        machine:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: Select runs by machine preset.
        region:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: Select runs by region.
    QueueTypeName:
      type: object
      required:
        - type
        - name
      properties:
        type:
          type: string
          enum:
            - task
            - custom
        name:
          type: string
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      description: >
        Use your project-specific Secret API key. Will start with `tr_dev_`,
        `tr_prod`, `tr_stg`, etc.


        You can find your Secret API key in the API Keys section of your
        Trigger.dev project dashboard.


        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_1234" });

        ```

````