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

# Delete Task

> Permanently delete a task.

**Required Role:** ADMIN or OWNER

**⚠️ WARNING: Tasks with execution history CANNOT be deleted!**

**Important:**
- Tasks with execution history return 400 Bad Request
- Use archive instead to preserve audit trail: `POST /tasks/{task_id}/archive`
- Only tasks with NO executions can be deleted
- Deletion cascades to remove notifications (if task never ran)

**Why this restriction:**
Execution history contains immutable audit records required for compliance.
Deleting executions would destroy historical usage metrics and transfer logs.

**Deleting a task:**
- Permanently removes the task definition
- Cascades to delete notifications (if any)
- CANNOT be undone

**Validation:**
- Task must exist and belong to the team
- Task must NOT have any execution history (enforced)

**Recommendation:** Use archive instead of delete to preserve history.



## OpenAPI

````yaml DELETE /v1/teams/{team_id}/tasks/{task_id}
openapi: 3.1.0
info:
  title: Data Raven API
  description: Cloud-to-cloud data transfer platform powered by RClone
  version: 0.5.0
servers: []
security: []
paths:
  /v1/teams/{team_id}/tasks/{task_id}:
    delete:
      tags:
        - Tasks
      summary: Delete Task
      description: >-
        Permanently delete a task.


        **Required Role:** ADMIN or OWNER


        **⚠️ WARNING: Tasks with execution history CANNOT be deleted!**


        **Important:**

        - Tasks with execution history return 400 Bad Request

        - Use archive instead to preserve audit trail: `POST
        /tasks/{task_id}/archive`

        - Only tasks with NO executions can be deleted

        - Deletion cascades to remove notifications (if task never ran)


        **Why this restriction:**

        Execution history contains immutable audit records required for
        compliance.

        Deleting executions would destroy historical usage metrics and transfer
        logs.


        **Deleting a task:**

        - Permanently removes the task definition

        - Cascades to delete notifications (if any)

        - CANNOT be undone


        **Validation:**

        - Task must exist and belong to the team

        - Task must NOT have any execution history (enforced)


        **Recommendation:** Use archive instead of delete to preserve history.
      operationId: delete_task_v1_teams__team_id__tasks__task_id__delete
      parameters:
        - name: task_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Task Id
        - name: team_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Team Id
      responses:
        '204':
          description: Successful Response
        '400':
          description: Cannot delete task with execution history
        '404':
          description: Task not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````