---
title: "Create Postmortem Rule"
method: POST
path: "/ai-postmortem-rule"
tags: ["Postmortem Rule"]
---

# Create Postmortem Rule

`POST /ai-postmortem-rule`

## Request

- Base URL: `https://oneuptime.com/api`
- URL: `https://oneuptime.com/api/ai-postmortem-rule`
- Auth: API key in header `APIKey`
- TypeScript: <https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification/docs/ai-postmortem-rule/post.ts> (a function with typed inputs; its response is checked against the schema)

Endpoint to create a new Postmortem Rule

## Request body

- object
  - `data` AIPostmortemRuleCreateSchema, required: Create schema for AIPostmortemRule model. Create
    - `criteria` object: Versioned conditions that determine whether this rule matches a resource. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `projectId` string, uuid: ID of your OneUptime Project in which this object belongs. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [No access - you don't have permission for this operation]
    - `name` string, required: Name of this postmortem rule. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `description` string: Description of this postmortem rule. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `isEnabled` boolean: Whether this rule is enabled. A disabled rule is skipped, as if it were not there. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `order` number: Where this rule sits in the list. Rules are evaluated from the top of the list down, lowest number first, and the first one that matches wins. A new rule is added to the end of the list. Setting a number another one already has puts it in that place, and the ones in the way move one place along to make room. In the dashboard, drag the rows to reorder them. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `monitors` object[]: Match only incidents from these monitors. Leave empty to match any monitor. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `incidentSeverities` object[]: Match only incidents with these severities. Leave empty to match any severity. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `labels` object[]: Match only incidents that carry at least one of these labels. Leave empty to match any label. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `monitorLabels` object[]: Match only when one of the incident's monitors carries at least one of these labels - the natural way to scope rules to environments (e.g. staging vs production). Leave empty to match any monitor label. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `titlePattern` string: Case-insensitive regex matched against the incident's title. Leave empty to match any title. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `descriptionPattern` string: Case-insensitive regex matched against the incident's description. Leave empty to match any description. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `postmortemTemplates` object[]: The postmortem templates a draft for the incidents this rule matches may follow. Leave empty for OneUptime AI's standard outline. With more than one, OneUptime AI picks the one that fits the incident best. At most 10. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `llmProviderId` string, uuid: ID of the LLM provider OneUptime AI uses for everything this rule drafts. Empty: the project's default provider, else the global one. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]

## Response `201`

Created successfully

- object
  - `data` AIPostmortemRuleReadSchema: Read schema for AIPostmortemRule model. Read
    - `_id` string, uuid: ID of this object. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `createdAt` object: Date and Time when the object was created. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `updatedAt` object: Date and Time when the object was updated. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `deletedAt` object: Date and Time when the object was deleted. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `criteria` object: Versioned conditions that determine whether this rule matches a resource. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `projectId` string, uuid: ID of your OneUptime Project in which this object belongs. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [No access - you don't have permission for this operation]
    - `name` string, required: Name of this postmortem rule. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `description` string: Description of this postmortem rule. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `isEnabled` boolean: Whether this rule is enabled. A disabled rule is skipped, as if it were not there. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `order` number: Where this rule sits in the list. Rules are evaluated from the top of the list down, lowest number first, and the first one that matches wins. A new rule is added to the end of the list. Setting a number another one already has puts it in that place, and the ones in the way move one place along to make room. In the dashboard, drag the rows to reorder them. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `monitors` object[]: Match only incidents from these monitors. Leave empty to match any monitor. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `incidentSeverities` object[]: Match only incidents with these severities. Leave empty to match any severity. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `labels` object[]: Match only incidents that carry at least one of these labels. Leave empty to match any label. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `monitorLabels` object[]: Match only when one of the incident's monitors carries at least one of these labels - the natural way to scope rules to environments (e.g. staging vs production). Leave empty to match any monitor label. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `titlePattern` string: Case-insensitive regex matched against the incident's title. Leave empty to match any title. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `descriptionPattern` string: Case-insensitive regex matched against the incident's description. Leave empty to match any description. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `postmortemTemplates` object[]: The postmortem templates a draft for the incidents this rule matches may follow. Leave empty for OneUptime AI's standard outline. With more than one, OneUptime AI picks the one that fits the incident best. At most 10. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
      - `id` string
    - `llmProviderId` string, uuid: ID of the LLM provider OneUptime AI uses for everything this rule drafts. Empty: the project's default provider, else the global one. Permissions - Create: [Project Owner, Project Admin], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [Project Owner, Project Admin]
    - `createdByUserId` string, uuid: User ID who created this object. Permissions - Create: [No access - you don't have permission for this operation], Read: [Project Owner, Project Admin, Project Member, Viewer], Update: [No access - you don't have permission for this operation]

## Other responses

- `400`: Bad request. This response indicates that the request was malformed or contained invalid data.
- `401`: Unauthorized. This response indicates that the request requires user authentication.
- `402`: Payment Required. This response indicates that the request requires payment or a valid subscription.
- `403`: Forbidden. This response indicates that the server understood the request, but refuses to authorize it.
- `405`: Project not found. This response indicates that the requested project does not exist or is not accessible.
- `408`: Request Timeout. This response indicates that the server timed out waiting for the request.
- `415`: Unable to reach server. This response indicates that the server is currently unreachable or down.
- `422`: Not authorized. This response indicates that the user does not have permission to access the requested resource.
- `500`: Internal Server Error. This response indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

---

[API](https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification.md) - [All operations](https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification/llms.txt) - [OpenAPI document](https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification/revisions/ba3307d00304?raw)
