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

# Delete Project

> Delete a project, with safe and cascade-delete modes.

Accepts a :class:`DeleteProjectRequest` carrying a typed
``confirmation`` that must equal the project's current ``name`` and
an ``orphan_resources`` flag that selects between two explicit
semantics:

- Safe mode (``orphan_resources=false``, default): the endpoint
  refuses to delete a project that still owns resources and
  returns an HTTP 409 listing the blocking resource ids. Callers
  must deactivate each resource first via the regular
  ``DELETE /resources/...`` flow so the per-resource ``on_delete``
  lifecycle runs against provider infrastructure.
- Cascade mode (``orphan_resources=true``): the endpoint cascade-
  deletes every owned resource and the project row itself inside
  a single tenant-scoped transaction. No outbox events are
  emitted and no provider lifecycle is invoked, so the cloud
  infrastructure keeps running. This is the explicit opt-out for
  callers leaving pragma entirely.

Both paths run in a single ``BEGIN/COMMIT`` block. Because the
projects and resources tables live in the same tenant namespace,
the delete is atomic — either everything is removed or nothing is.

Raises:
    ProjectNotFoundError: If project not found in the caller's
        tenant namespace.
    ConfirmationMismatchError: If ``confirmation`` does not match the
        project's ``name``.
    PlatformResourceError: If the caller is not allowed to delete a
        platform-managed project.
    ProjectHasResourcesError: If ``orphan_resources`` is False and
        the project still owns resources.



## OpenAPI

````yaml https://api.pragmatiks.io/openapi.json delete /projects/{project_id}
openapi: 3.1.0
info:
  title: Pragma API
  version: 0.1.0
servers: []
security: []
paths:
  /projects/{project_id}:
    delete:
      tags:
        - projects
      summary: Delete Project
      description: |-
        Delete a project, with safe and cascade-delete modes.

        Accepts a :class:`DeleteProjectRequest` carrying a typed
        ``confirmation`` that must equal the project's current ``name`` and
        an ``orphan_resources`` flag that selects between two explicit
        semantics:

        - Safe mode (``orphan_resources=false``, default): the endpoint
          refuses to delete a project that still owns resources and
          returns an HTTP 409 listing the blocking resource ids. Callers
          must deactivate each resource first via the regular
          ``DELETE /resources/...`` flow so the per-resource ``on_delete``
          lifecycle runs against provider infrastructure.
        - Cascade mode (``orphan_resources=true``): the endpoint cascade-
          deletes every owned resource and the project row itself inside
          a single tenant-scoped transaction. No outbox events are
          emitted and no provider lifecycle is invoked, so the cloud
          infrastructure keeps running. This is the explicit opt-out for
          callers leaving pragma entirely.

        Both paths run in a single ``BEGIN/COMMIT`` block. Because the
        projects and resources tables live in the same tenant namespace,
        the delete is atomic — either everything is removed or nothing is.

        Raises:
            ProjectNotFoundError: If project not found in the caller's
                tenant namespace.
            ConfirmationMismatchError: If ``confirmation`` does not match the
                project's ``name``.
            PlatformResourceError: If the caller is not allowed to delete a
                platform-managed project.
            ProjectHasResourcesError: If ``orphan_resources`` is False and
                the project still owns resources.
      operationId: projects-delete_project
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: string
            title: Project Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteProjectRequest'
      responses:
        '204':
          description: Successful Response
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    DeleteProjectRequest:
      properties:
        confirmation:
          type: string
          maxLength: 200
          minLength: 1
          title: Confirmation
        orphan_resources:
          type: boolean
          title: Orphan Resources
          description: >-
            Opt in to cascade-wipe owned resources without running provider
            teardown. Defaults to False; non-empty projects are rejected unless
            this flag is True.
          default: false
      type: object
      required:
        - confirmation
      title: DeleteProjectRequest
      description: |-
        Request body for deleting a project.

        Project deletion requires the caller to echo the project's current
        ``name`` as a typed confirmation token. The field is required — there
        is no boolean shortcut — and the server rejects any mismatch with
        HTTP 400 so a stale scripted call cannot silently destroy the wrong
        project.

        Attributes:
            confirmation: Must equal the target project's ``name`` exactly.
            orphan_resources: When True, cascade-delete every resource in
                the project in the same transaction without invoking the
                per-resource ``on_delete`` provider lifecycle. Cloud
                infrastructure keeps running and pragma forgets it exists.
                When False (default), the endpoint refuses to delete a
                non-empty project and returns the list of blocking
                resources so the caller can deactivate them explicitly.
    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

````