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

# Delete workflow nodes recursively

> Delete a node and its downstream subtree.

Delete a node and its downstream subtree.

Make a dry run request using `dryRun: true`.

If contacts are queued at any node that would be deleted, Loops returns with `"status": "queuedContactsFound"` instead of deleting. Retry with `queuedContactPolicy: "discard"` to delete the nodes and discard those queued contacts.


## OpenAPI

````yaml /openapi.json delete /v1/workflows/{workflowId}/nodes/{nodeId}/recursive
openapi: 3.1.0
info:
  title: Loops OpenAPI Spec
  description: This is the OpenAPI Spec for the [Loops API](https://loops.so/docs/api).
  version: 1.20.0
servers:
  - url: https://app.loops.so/api
security: []
tags:
  - name: API key
  - name: Audience segments
    description: View audience segments
  - name: Campaigns
    description: Create and manage email campaigns
  - name: Campaign groups
    description: Organize campaigns into groups
  - name: Components
    description: View email components
  - name: Configuration
    description: View configuration settings
  - name: Contacts
    description: Manage contacts in your audience
  - name: Contact properties
    description: Manage contact properties
  - name: Email messages
    description: Manage email message content for campaigns
  - name: Events
    description: Trigger workflows with events
  - name: Event patterns
    description: View workflow event patterns
  - name: Mailing lists
    description: View mailing lists
  - name: Themes
    description: View email themes
  - name: Transactional emails
    description: Create, manage, and send transactional emails
  - name: Transactional groups
    description: Organize transactional emails into groups
  - name: Uploads
    description: Upload image assets
  - name: Workflows
    description: View and mutate workflow graphs
  - name: Workflow nodes
    description: View and mutate workflow nodes
paths:
  /v1/workflows/{workflowId}/nodes/{nodeId}/recursive:
    parameters:
      - name: workflowId
        in: path
        required: true
        description: The ID of the workflow.
        schema:
          type: string
      - name: nodeId
        in: path
        required: true
        description: The root node ID of the subtree to delete.
        schema:
          type: string
    delete:
      tags:
        - Workflow nodes
      summary: Delete workflow nodes recursively
      description: >-
        Delete a node and its downstream subtree. If contacts are queued at any
        node that would be deleted, Loops returns with `"status":
        "queuedContactsFound"` instead of deleting. Retry with
        `queuedContactPolicy: "discard"` to delete the nodes and discard those
        queued contacts.
      operationId: deleteWorkflowNodeRecursively
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteWorkflowNodeRequest'
      responses:
        '200':
          description: Delete dry run, queued-contact warning, or deletion result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteWorkflowNodeResponse'
        '400':
          description: Invalid `workflowId`, `nodeId`, request body, or delete target.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowFailureResponse'
        '401':
          description: Invalid API key or workflow API not enabled for this team.
        '404':
          description: Workflow or workflow node not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowFailureResponse'
        '405':
          description: Wrong HTTP request method.
        '409':
          description: '`expectedRevisionId` is stale.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowFailureResponse'
      security:
        - apiKey: []
components:
  schemas:
    DeleteWorkflowNodeRequest:
      type: object
      properties:
        expectedRevisionId:
          $ref: '#/components/schemas/WorkflowExpectedRevisionId'
        dryRun:
          type: boolean
          description: >-
            If `true`, the request will be validated but the workflow will not
            be modified.
        queuedContactPolicy:
          $ref: '#/components/schemas/WorkflowQueuedContactPolicy'
      required:
        - expectedRevisionId
      additionalProperties: false
    DeleteWorkflowNodeResponse:
      oneOf:
        - $ref: '#/components/schemas/WorkflowQueuedContactDeletePreview'
        - $ref: '#/components/schemas/WorkflowDeletedResponse'
    WorkflowFailureResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
    WorkflowExpectedRevisionId:
      type: string
      description: >-
        The workflow revision token returned by the latest workflow read or
        mutation. Mutations reject stale values.
    WorkflowQueuedContactPolicy:
      type: string
      enum:
        - fail
        - discard
      default: fail
      description: >-
        `fail` returns queued-contact impact instead of mutating. `discard`
        confirms that matching queued contacts should be discarded. Defaults to
        `fail` when omitted.
    WorkflowQueuedContactDeletePreview:
      type: object
      properties:
        status:
          type: string
          enum:
            - dryRun
            - queuedContactsFound
        nodeIds:
          type: array
          items:
            type: string
          description: The IDs of the nodes that would be deleted.
        queuedContactCount:
          type: number
          description: >-
            The number of queued contacts that would be removed from the
            workflow due to the node deletion.
        queuedContactLimitReached:
          type: boolean
          description: >-
            Whether the queued contact limit would be reached if the nodes were
            deleted.
      required:
        - status
        - nodeIds
        - queuedContactCount
        - queuedContactLimitReached
    WorkflowDeletedResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - deleted
        nodeIds:
          type: array
          items:
            type: string
        workflowRevisionId:
          $ref: '#/components/schemas/WorkflowRevisionId'
        queuedContactCount:
          type: number
          description: >-
            The number of queued contacts that were removed from the workflow
            due to the node deletion.
        queuedContactLimitReached:
          type: boolean
          description: >-
            Whether the queued contact limit was reached due to the node
            deletion.
      required:
        - status
        - nodeIds
        - workflowRevisionId
        - queuedContactCount
        - queuedContactLimitReached
    WorkflowRevisionId:
      type:
        - string
      description: >-
        The current workflow revision token. Pass the latest value as
        `expectedRevisionId` on the next workflow mutation.
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````