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

# Delete a workspace

> Hard-delete a workspace and everything in it.

Requires ADMIN role in the workspace (the write service decides); a
workspace outside the caller's memberships is a 403, as on the update.
The cascade removes every project, its data references, access keys,
memberships and invites; the typed ``name`` must equal the workspace's
current name, and the caller's only workspace cannot be deleted.

Args:
    request (Request): Incoming request (rate-limit plumbing).
    response (Response): Outgoing response (rate-limit plumbing).
    auth (AccountStampedAuth): Account-scope user auth (session token or
        CLI access JWT); its resolved ``user_id`` becomes the actor.
    workspace_id (str): The workspace to delete.
    name (str): The workspace's current name, as a typed confirmation.
    reason (str): Why it is being deleted; recorded on the audit row.
    _live (None): Write-path liveness gate (blocks a revoked JWT session).

Returns:
    DeleteWorkspaceResponse: The removed workspace and the cascade counts.

Raises:
    HTTPException: The write service's 400/403/404/409 verbatim, or a
        503 when its response is ambiguous.



## OpenAPI

````yaml /api-reference/openapi.json delete /api/v1/public/workspaces/{workspace_id}
openapi: 3.1.0
info:
  title: TraceRoot Public API
  version: 0.1.0
servers:
  - description: TraceRoot Cloud
    url: https://app.traceroot.ai
  - description: Self-hosted
    url: '{baseUrl}'
    variables:
      baseUrl:
        default: http://localhost:8000
        description: Your TraceRoot backend URL
security: []
paths:
  /api/v1/public/workspaces/{workspace_id}:
    delete:
      tags:
        - Account
      summary: Delete a workspace
      description: |-
        Hard-delete a workspace and everything in it.

        Requires ADMIN role in the workspace (the write service decides); a
        workspace outside the caller's memberships is a 403, as on the update.
        The cascade removes every project, its data references, access keys,
        memberships and invites; the typed ``name`` must equal the workspace's
        current name, and the caller's only workspace cannot be deleted.

        Args:
            request (Request): Incoming request (rate-limit plumbing).
            response (Response): Outgoing response (rate-limit plumbing).
            auth (AccountStampedAuth): Account-scope user auth (session token or
                CLI access JWT); its resolved ``user_id`` becomes the actor.
            workspace_id (str): The workspace to delete.
            name (str): The workspace's current name, as a typed confirmation.
            reason (str): Why it is being deleted; recorded on the audit row.
            _live (None): Write-path liveness gate (blocks a revoked JWT session).

        Returns:
            DeleteWorkspaceResponse: The removed workspace and the cascade counts.

        Raises:
            HTTPException: The write service's 400/403/404/409 verbatim, or a
                503 when its response is ambiguous.
      operationId: delete_workspace
      parameters:
        - in: path
          name: workspace_id
          required: true
          schema:
            title: Workspace Id
            type: string
        - description: The workspace's current name, typed as confirmation
          in: query
          name: name
          required: true
          schema:
            description: The workspace's current name, typed as confirmation
            title: Name
            type: string
        - description: Why the resource is being deleted; recorded on the audit row
          in: query
          name: reason
          required: true
          schema:
            description: Why the resource is being deleted; recorded on the audit row
            maxLength: 500
            minLength: 3
            title: Reason
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteWorkspaceResponse'
          description: Successful Response
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication failed or session revoked
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Insufficient role or wrong credential kind
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Not found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: >-
            The typed name does not match, or this is the caller's only
            workspace
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Write service unavailable
      security:
        - BearerAuth: []
components:
  schemas:
    DeleteWorkspaceResponse:
      description: A hard-deleted workspace and the counts of what cascaded with it.
      properties:
        cascaded:
          anyOf:
            - additionalProperties:
                type: integer
              type: object
            - type: 'null'
          title: Cascaded
        deleted:
          title: Deleted
          type: boolean
        reason:
          title: Reason
          type: string
        workspace:
          $ref: '#/components/schemas/DeletedResource'
      required:
        - deleted
        - reason
        - workspace
      title: DeleteWorkspaceResponse
      type: object
    ErrorResponse:
      description: >-
        The canonical public error envelope (matches the gateway's normalized
        shape).
      properties:
        detail:
          title: Detail
          type: string
      required:
        - detail
      title: ErrorResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    DeletedResource:
      description: 'What a delete removed: the row''s id and name, for the receipt.'
      properties:
        id:
          title: Id
          type: string
        name:
          title: Name
          type: string
      required:
        - id
        - name
      title: DeletedResource
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    BearerAuth:
      scheme: bearer
      type: http

````

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