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

# Fechar PostMortem

> Fecha um postmortem após revisao, marcando-o como finalizado e aceito pela equipe

<ParamField path="name" type="string" required>
  Unique postmortem name (e.g., `PM-20260319-001`)
</ParamField>

<ParamField query="namespace" type="string" default="default">
  Kubernetes namespace
</ParamField>

<ParamField body="reviewer" type="string">
  Identifier of the person closing the postmortem
</ParamField>

<ParamField body="notes" type="string">
  Final notes or summary of the review outcome
</ParamField>

## PostMortem Lifecycle

```
Auto-generated (on incident resolution)
      ↓
  State: Open
      ↓
  POST /review → State: InReview
      ↓
  POST /close → State: Closed (terminal)
```

A closed postmortem is immutable and serves as the permanent record for compliance and audit purposes.

<ResponseExample>
  ```json Response 200 theme={"system"}
  {
    "apiVersion": "v1",
    "kind": "PostMortem",
    "metadata": {
      "name": "PM-20260319-001",
      "namespace": "production"
    },
    "status": {
      "state": "Closed",
      "reviewer": "carlos.silva@empresa.com",
      "closedAt": "2026-03-19T18:00:00Z",
      "notes": "All action items assigned. Root cause verified. Approved for compliance archive."
    }
  }
  ```
</ResponseExample>

<ResponseExample>
  ```json Response 409 theme={"system"}
  {
    "apiVersion": "v1",
    "kind": "Error",
    "error": {
      "code": 409,
      "message": "PostMortem already closed",
      "details": "The postmortem 'PM-20260319-001' was already closed at 2026-03-19T18:00:00Z"
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /postmortems/{name}/close
openapi: 3.1.0
info:
  title: ChatCLI AIOps Platform API
  description: >-
    REST API for the ChatCLI AIOps Platform — incidents, SLOs, runbooks,
    approvals, postmortems, analytics, audit, federation and health.


    The playground below uses **editable server variables** so you can point
    requests at your own self-hosted instance. Adjust `host`, `port` and
    `basePath` to match your deployment, then click **Try it**.
  version: 1.0.0
  contact:
    name: ChatCLI
    url: https://github.com/diillson/chatcli
  license:
    name: Apache-2.0
    identifier: Apache-2.0
servers:
  - url: http://{host}:{port}/{basePath}
    description: >-
      Self-hosted ChatCLI AIOps Platform — adjust host, port and basePath to
      match your deployment.
    variables:
      host:
        default: localhost
        description: >-
          Hostname or IP of your ChatCLI operator. For Kubernetes, use the
          Service DNS (e.g. chatcli-api.chatcli-system.svc) or your Ingress
          host.
      port:
        default: '8090'
        description: >-
          Port the API listens on. Default is 8090; configurable via Helm value
          `apiPort` or env var CHATCLI_API_PORT.
      basePath:
        default: api/v1
        description: >-
          API base path. Always `api/v1` unless you have a custom proxy rewrite
          in front of the operator.
security:
  - ApiKeyAuth: []
tags:
  - name: Incidents
    description: >-
      Incident lifecycle: list, fetch, acknowledge, resolve, snooze, timeline
      and remediation views.
  - name: Runbooks
    description: Remediation runbooks (list, create, update, delete).
  - name: SLOs
    description: Service Level Objectives and error budgets.
  - name: Approvals
    description: Approval workflow for risky remediations.
  - name: Postmortems
    description: Auto-generated postmortems with review, feedback and close.
  - name: Remediations
    description: Remediation plans and agentic execution history.
  - name: AI Insights
    description: AI root-cause analysis and recommendations per incident.
  - name: Analytics
    description: 'Operational analytics: MTTD, MTTR, trends, capacity, compliance.'
  - name: Audit
    description: Immutable audit log and exports.
  - name: Federation
    description: 'Multi-cluster federation: clusters, status and cross-cluster correlations.'
  - name: Health
    description: Liveness and readiness probes.
paths:
  /postmortems/{name}/close:
    post:
      tags:
        - Postmortems
      summary: Close Postmortem
      description: >-
        Closes a postmortem after review. Closed postmortems are immutable.


        Note (GAP-03 fix, schema corrected by GAP-07): when the PostMortem has
        status.requiresHumanAction=true, the PostMortemReconciler will REVERT
        premature closures back to Open until the
        aiops.chatcli.io/human-action-acknowledged annotation is set. Use POST
        /postmortems/{name}/ack-human-action before closing.
      operationId: closePostmortem
      parameters:
        - name: name
          in: path
          required: true
          description: Unique postmortem name.
          schema:
            type: string
            example: PM-20260319-001
        - name: namespace
          in: query
          required: false
          description: Kubernetes namespace.
          schema:
            type: string
            default: default
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                reviewer:
                  type: string
                  description: Identifier of the person closing the postmortem.
                  example: carlos.silva@empresa.com
                notes:
                  type: string
                  description: Final notes / summary of the review outcome.
                  example: All action items assigned. Approved for compliance archive.
            example:
              reviewer: carlos.silva@empresa.com
              notes: >-
                All action items assigned. Root cause verified. Approved for
                compliance archive.
      responses:
        '200':
          description: Postmortem closed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostMortem'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    PostMortem:
      type: object
      properties:
        apiVersion:
          type: string
          example: v1
        kind:
          type: string
          example: PostMortem
        metadata:
          type: object
          properties:
            name:
              type: string
            namespace:
              type: string
            incident:
              type: string
            createdAt:
              type: string
              format: date-time
            author:
              type: string
            reviewedBy:
              type: string
        resourceMeta:
          type: object
          description: Used by some endpoints in place of metadata.
          properties:
            name:
              type: string
            namespace:
              type: string
        report:
          type: object
          properties:
            title:
              type: string
            severity:
              type: string
            duration:
              type: string
            detectedAt:
              type: string
              format: date-time
            resolvedAt:
              type: string
              format: date-time
            summary:
              type: string
            impact:
              type: object
              additionalProperties: true
            rootCause:
              type: object
              properties:
                description:
                  type: string
                category:
                  type: string
                confidence:
                  type: number
            timeline:
              type: array
              items:
                type: object
                properties:
                  time:
                    type: string
                    format: date-time
                  event:
                    type: string
            remediationApplied:
              type: object
              additionalProperties: true
            actionItems:
              type: array
              items:
                type: object
                properties:
                  priority:
                    type: string
                  description:
                    type: string
                  assignee:
                    type: string
                  status:
                    type: string
                  dueDate:
                    type: string
                    format: date
            lessonsLearned:
              type: array
              items:
                type: string
            metricSnapshots:
              type: array
              items:
                type: object
                additionalProperties: true
            blastRadius:
              type: array
              items:
                type: object
                additionalProperties: true
            gitCorrelation:
              type: object
              additionalProperties: true
            trending:
              type: object
              additionalProperties: true
            gitOpsContext:
              type: string
            logAnalysisSummary:
              type: string
            cascadeChain:
              type: array
              items:
                type: string
            feedback:
              $ref: '#/components/schemas/PostMortemFeedback'
            chaosInduced:
              type: boolean
              description: >-
                True when this PostMortem belongs to a chaos drill (parent Issue
                carried platform.chatcli.io/source=chaos-experiment). GAP-04
                fix.
            chaosExperiment:
              type: string
              description: >-
                Name of the ChaosExperiment CR correlated with the incident.
                GAP-04 fix.
        status:
          type: object
          properties:
            state:
              type: string
              enum:
                - Open
                - InReview
                - Closed
            reviewer:
              type: string
            reviewStartedAt:
              type: string
              format: date-time
            closedAt:
              type: string
              format: date-time
            notes:
              type: string
            feedback:
              $ref: '#/components/schemas/PostMortemFeedback'
            requiresHumanAction:
              type: boolean
              description: >-
                True when the parent Issue was only Contained (workload
                silenced, root cause not fixed). PostMortemReconciler will not
                allow Closed transition while this is true and the
                human-action-acknowledged annotation is absent. GAP-07 fix moved
                this field from Spec to Status (correct K8s convention for
                controller-derived facts) — 1.122.x clients that wrote to Spec
                now read null until they upgrade.
            requiredAction:
              type: string
              description: >-
                Concrete follow-up action a human must take (e.g., 'restore
                deployment replicas after fixing root cause'). Set together with
                requiresHumanAction. GAP-07 fix moved this from Spec to Status.
    PostMortemFeedback:
      type: object
      properties:
        overrideRootCause:
          type: string
        remediationAccuracy:
          type: integer
          minimum: 1
          maximum: 5
        comments:
          type: string
        providedBy:
          type: string
        providedAt:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - apiVersion
        - kind
        - error
      properties:
        apiVersion:
          type: string
          example: v1
        kind:
          type: string
          example: Error
        error:
          oneOf:
            - type: object
              required:
                - code
                - message
              properties:
                code:
                  type: integer
                  example: 404
                message:
                  type: string
                  example: Resource not found
                details:
                  type: string
            - type: string
        code:
          type: integer
          description: Top-level code (only used by some endpoints).
          example: 400
  responses:
    Unauthorized:
      description: Missing or invalid API token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: Conflict with current state of the resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Rate limit exceeded for this token's role
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Bearer token issued by the operator. Format: `Authorization: Bearer
        <token>`.

````