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

# Delete Workspace

> Soft-delete a workspace: stamp deleted_at, revoke its keys, audit it.

The row and everything under it survive for the purge job that still owes
the S3 payloads a delete (migration 0034). What makes the deletion real
immediately is the pair of auth chokepoints — `member_workspace` and
`resolve_workspace` both filter `deleted_at IS NULL` — plus revoking every
key, which is what actually stops an SDK mid-run from writing into a
workspace the customer just deleted.

Three GUCs are in play and none is optional. `member_workspace` sets
`app.current_user_id`; the UPDATE additionally needs `app.current_org_id`
(workspaces' only FOR ALL policy is `workspaces_org_isolation`, so without
it the statement matches zero rows and this endpoint 204s having done
nothing), and the audit INSERT needs `app.current_workspace_id` for
`audit_log_workspace_isolation`'s WITH CHECK. All three are SET LOCAL and
there is exactly one commit, at the end, so none of them is cleared
mid-handler. `workspace_api_keys` carries no RLS by design (0025).



## OpenAPI

````yaml /api-reference/openapi.json delete /v1/workspaces/{workspace_id}
openapi: 3.1.0
info:
  title: Visceral Backend
  version: 0.2.0
  description: >-
    The Visceral backend HTTP API. SDK and ingestion endpoints authenticate with
    a workspace API key; dashboard endpoints authenticate with a user session
    token. Both are sent as `Authorization: Bearer <token>`.
servers:
  - url: https://api.visceralai.dev
security: []
paths:
  /v1/workspaces/{workspace_id}:
    delete:
      tags:
        - keys
      summary: Delete Workspace
      description: >-
        Soft-delete a workspace: stamp deleted_at, revoke its keys, audit it.


        The row and everything under it survive for the purge job that still
        owes

        the S3 payloads a delete (migration 0034). What makes the deletion real

        immediately is the pair of auth chokepoints — `member_workspace` and

        `resolve_workspace` both filter `deleted_at IS NULL` — plus revoking
        every

        key, which is what actually stops an SDK mid-run from writing into a

        workspace the customer just deleted.


        Three GUCs are in play and none is optional. `member_workspace` sets

        `app.current_user_id`; the UPDATE additionally needs
        `app.current_org_id`

        (workspaces' only FOR ALL policy is `workspaces_org_isolation`, so
        without

        it the statement matches zero rows and this endpoint 204s having done

        nothing), and the audit INSERT needs `app.current_workspace_id` for

        `audit_log_workspace_isolation`'s WITH CHECK. All three are SET LOCAL
        and

        there is exactly one commit, at the end, so none of them is cleared

        mid-handler. `workspace_api_keys` carries no RLS by design (0025).
      operationId: delete_workspace_v1_workspaces__workspace_id__delete
      parameters:
        - name: workspace_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Workspace Id
      responses:
        '204':
          description: Successful Response
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - sessionToken: []
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:
    sessionToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Short-lived user access token (ES256 JWT) issued by `POST
        /v1/auth/login`.

````