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

# Delete Run

> Soft-deletes a run that is no longer active. Allowed from DRAFT, COMPLETED and CANCELLED; SCHEDULED, RUNNING and PAUSED return 422 - cancel it first, because a delete must not silently terminate live phone calls. The conversations the run produced survive as separate resources, still readable with their runId intact. Deleting an already-deleted run is a 404, not an error state.

Soft-deletes a run that is no longer active.

## Only when the run is inert

| Status                            | Delete                                             |
| --------------------------------- | -------------------------------------------------- |
| `DRAFT`, `COMPLETED`, `CANCELLED` | Allowed                                            |
| `SCHEDULED`, `RUNNING`, `PAUSED`  | `422` — `"Cancel the flow run before deleting it"` |

An active run has queued calls that a delete would orphan. The alternative — letting `DELETE` cascade a cancel — was deliberately rejected: it makes an HTTP verb **silently terminate live phone calls**, which is not something a delete should do by implication. [Cancel](/api-reference/runs/cancel-run) first; that is the operation whose job is stopping the dialling.

## What happens to everything else

|                                    |                                                                                                           |
| ---------------------------------- | --------------------------------------------------------------------------------------------------------- |
| **Conversations the run produced** | **Survive.** They are separate resources, still readable at `/conversations/{id}` with `runId` populated. |
| **Webhooks**                       | Unaffected. `conversation.*` events belong to the conversation, not the run.                              |
| **Reads of the run**               | `GET /runs/{id}` returns `404`.                                                                           |
| **Deleting it again**              | `404`, not an error state to handle.                                                                      |

Deleting a run removes the grouping, not the history.

## Error Scenarios

* **404 Not Found**: the run does not exist, belongs to another company, or is already deleted
* **422 Unprocessable Entity**: the run is still active
* **403 Forbidden**: the API key does not hold `delete:runs`

## Related Resources

<CardGroup cols={2}>
  <Card title="Cancel Run" icon="ban" href="/api-reference/runs/cancel-run">
    Make an active run inert first
  </Card>

  <Card title="List Run Conversations" icon="list" href="/api-reference/runs/list-run-conversations">
    Read the results before you delete
  </Card>
</CardGroup>


## OpenAPI

````yaml DELETE /runs/{id}
openapi: 3.0.0
info:
  title: InstaView API
  description: |-
    InstaView API Documentation

    ## Authentication

    All endpoints require API key authentication using Bearer token:
    ```
    Authorization: Bearer sk_your_api_key_here
    ```

    ## API Key Management

    The API Key module provides comprehensive key management for:
    - **Direct Client Keys**: Company-scoped keys for your applications
    - **ATS Partner Keys**: Resource-scoped keys for ATS integrations

    ### Key Features
    - HMAC-SHA256 hashing for API key storage
    - Configurable rate limiting
    - Comprehensive audit logging
    - Company-level isolation
    - Resource scoping for ATS partners
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.instaview.sk
    description: Production API Gateway
security: []
tags: []
paths:
  /runs/{id}:
    delete:
      tags:
        - Runs
      summary: Delete run
      description: >-
        Soft-deletes a run that is no longer active. Allowed from DRAFT,
        COMPLETED and CANCELLED; SCHEDULED, RUNNING and PAUSED return 422 -
        cancel it first, because a delete must not silently terminate live phone
        calls. The conversations the run produced survive as separate resources,
        still readable with their runId intact. Deleting an already-deleted run
        is a 404, not an error state.
      operationId: PublicRunsController_deleteRun_v1
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
            format: uuid
        - name: companyId
          required: false
          in: query
          description: >-
            Required for ATS API keys to specify which company to access.
            Ignored for standard company API keys.
          schema:
            type: string
      responses:
        '200':
          description: Run deleted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicDeletedResponseDto'
        '422':
          description: >-
            Unprocessable Entity - the run is still active. Cancel the flow run
            before deleting it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearer: []
components:
  schemas:
    PublicDeletedResponseDto:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Id of the deleted resource
        deleted:
          type: boolean
          enum:
            - true
          example: true
          description: Always true; a failed delete answers with an error status
      required:
        - id
        - deleted
    ErrorResponse:
      type: object
      properties:
        statusCode:
          type: integer
          example: 400
        message:
          type: string
          example: Validation failed
        error:
          type: string
          example: Bad Request
      required:
        - statusCode
        - message
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: API key for authentication using Bearer scheme

````