{
  "openapi": "3.1.0",
  "info": {
    "title": "treason.app API",
    "version": "1.0.0",
    "description": "On-call paging as a primitive. Create alerts, wait for a human, watch heartbeats, read who is on call. Everything is JSON over HTTPS."
  },
  "servers": [
    {
      "url": "https://api.treason.app"
    }
  ],
  "tags": [
    {
      "name": "Alerts"
    },
    {
      "name": "Approvals"
    },
    {
      "name": "Noise control"
    },
    {
      "name": "Reports"
    },
    {
      "name": "Reachability"
    },
    {
      "name": "Heartbeats"
    },
    {
      "name": "On call"
    },
    {
      "name": "Schedules"
    },
    {
      "name": "Escalation"
    },
    {
      "name": "People"
    },
    {
      "name": "Integrations"
    },
    {
      "name": "Webhooks"
    },
    {
      "name": "Keys and organization"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/v1/alerts": {
      "post": {
        "tags": [
          "Alerts"
        ],
        "summary": "Create an alert",
        "description": "Accepts an alert, stores it, and starts paging whoever is on call for the team. Answers `202` once the alert is durably stored in two places. A repeat with the same `alias` while the alert is not closed is de-duplicated: it bumps `dedupCount` and does not page again. Send an `Idempotency-Key` header and a retried request returns the original result.",
        "operationId": "post_alerts",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retried request return the original result."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAlert"
              },
              "example": {
                "message": "API error rate above 5%",
                "alias": "api-errors",
                "priority": "P1",
                "tags": [
                  "prod"
                ],
                "source": "grafana"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requestId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "deduplicated": {
                      "type": "boolean"
                    },
                    "alert": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/Alert"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "requestId",
                    "deduplicated",
                    "alert"
                  ]
                },
                "example": {
                  "requestId": "a3c1f7e0-0a0d-5b3c-8b43-0a1d3d9c4c2e",
                  "deduplicated": false,
                  "alert": {
                    "id": "5b0f0c5e-6c6e-5a3e-9f2b-0f6d6a2c9d11",
                    "alias": "api-errors",
                    "tinyId": 4821,
                    "status": "open",
                    "priority": "P1",
                    "message": "API error rate above 5%",
                    "description": null,
                    "entity": null,
                    "source": "grafana",
                    "tags": [
                      "prod"
                    ],
                    "details": {},
                    "dedupCount": 1,
                    "createdAt": "2026-10-11T20:50:04.000Z",
                    "acknowledgedAt": null,
                    "closedAt": null,
                    "acknowledgedVia": null,
                    "acknowledgedBy": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Retry after the `retry-after` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Alerts"
        ],
        "summary": "List alerts",
        "description": "Newest first. Page with `before` set to the previous response's `next`.",
        "operationId": "get_alerts",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "acknowledged",
                "exhausted",
                "closed",
                "suppressed"
              ]
            }
          },
          {
            "name": "alias",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Only alerts created before this time.",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of alerts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "alerts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Alert"
                      }
                    },
                    "next": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `before` for the next page; null on the last page."
                    }
                  },
                  "required": [
                    "alerts",
                    "next"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/alerts/summary": {
      "get": {
        "tags": [
          "Alerts"
        ],
        "summary": "Count alerts by status",
        "operationId": "get_alerts_summary",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Counts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "counts": {
                      "type": "object",
                      "properties": {
                        "open": {
                          "type": "integer"
                        },
                        "acknowledged": {
                          "type": "integer"
                        },
                        "exhausted": {
                          "type": "integer"
                        },
                        "closed": {
                          "type": "integer"
                        },
                        "suppressed": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "open",
                        "acknowledged",
                        "exhausted",
                        "closed",
                        "suppressed"
                      ]
                    }
                  },
                  "required": [
                    "counts"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/alerts/{id}": {
      "get": {
        "tags": [
          "Alerts"
        ],
        "summary": "Get an alert, its events and every notification attempt",
        "description": "The event log is append-only. `attempts` lists every push, text and call we made, with the carrier's answer: the answer to \"why did nobody get paged?\"",
        "operationId": "get_alerts_by_id",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The alert.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "alert": {
                      "$ref": "#/components/schemas/Alert"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AlertEvent"
                      }
                    },
                    "attempts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/NotificationAttempt"
                      }
                    }
                  },
                  "required": [
                    "alert",
                    "events",
                    "attempts"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/alerts/{id}/ack": {
      "post": {
        "tags": [
          "Alerts"
        ],
        "summary": "Acknowledge an alert",
        "description": "Stops escalation. A late acknowledgement of an exhausted alert still works.",
        "operationId": "post_alerts_ack",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user": {
                    "type": "string",
                    "description": "Who is acknowledging."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Done.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "outcome": {
                      "type": "string",
                      "enum": [
                        "acknowledged",
                        "already_acknowledged"
                      ]
                    }
                  },
                  "required": [
                    "outcome"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/alerts/{id}/close": {
      "post": {
        "tags": [
          "Alerts"
        ],
        "summary": "Close an alert",
        "operationId": "post_alerts_close",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Done.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "outcome": {
                      "type": "string",
                      "enum": [
                        "closed",
                        "already_closed"
                      ]
                    }
                  },
                  "required": [
                    "outcome"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/alerts/{id}/notes": {
      "post": {
        "tags": [
          "Alerts"
        ],
        "summary": "Add a note to an alert",
        "operationId": "post_alerts_notes",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "note": {
                    "type": "string",
                    "maxLength": 25000
                  },
                  "user": {
                    "type": "string"
                  }
                },
                "required": [
                  "note"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Added.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/alerts/{id}/snooze": {
      "post": {
        "tags": [
          "Noise control"
        ],
        "summary": "Snooze an alert",
        "description": "Acknowledges now and pages again, from the first step of the policy, if the alert is still open after `minutes`. Closing the alert cancels the snooze.",
        "operationId": "post_alerts_snooze",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10080
                  },
                  "user": {
                    "type": "string"
                  }
                },
                "required": [
                  "minutes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Snoozed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "outcome": {
                      "type": "string",
                      "enum": [
                        "snoozed"
                      ]
                    },
                    "until": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "outcome",
                    "until"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/maintenance-windows": {
      "post": {
        "tags": [
          "Noise control"
        ],
        "summary": "Create a maintenance window",
        "description": "Alerts that arrive while a window is in effect are recorded and de-duplicated but do not page, are not billed, and do not fire webhooks. When it ends, those still open page (or are dropped, with `onEnd: discard`). A window covers everything, or just a team, an integration, or alerts matching `conditions`. It is one-off (`startsAt`, `endsAt`) or recurring (`recurrence`).",
        "operationId": "post_maintenance_windows",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MaintenanceWindowInput"
              },
              "example": {
                "name": "Weekly deploy",
                "recurrence": {
                  "days": [
                    2
                  ],
                  "time": "14:00",
                  "durationMinutes": 60,
                  "timezone": "America/New_York"
                },
                "conditions": [
                  {
                    "field": "tag",
                    "op": "is",
                    "value": "env:staging"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "window": {
                      "$ref": "#/components/schemas/MaintenanceWindow"
                    }
                  },
                  "required": [
                    "window"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Noise control"
        ],
        "summary": "List maintenance windows",
        "operationId": "get_maintenance_windows",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "true"
              ]
            },
            "description": "Only windows in effect now."
          }
        ],
        "responses": {
          "200": {
            "description": "Recurring windows and one-off windows that have not ended (or ended in the last week).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "windows": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MaintenanceWindow"
                      }
                    }
                  },
                  "required": [
                    "windows"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/maintenance-windows/{id}": {
      "get": {
        "tags": [
          "Noise control"
        ],
        "summary": "Get a maintenance window",
        "operationId": "get_maintenance_windows_by_id",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The window.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "window": {
                      "$ref": "#/components/schemas/MaintenanceWindow"
                    }
                  },
                  "required": [
                    "window"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Noise control"
        ],
        "summary": "Replace a maintenance window",
        "description": "Shortening a window to the past releases what it was holding.",
        "operationId": "put_maintenance_windows_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MaintenanceWindowInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "window": {
                      "$ref": "#/components/schemas/MaintenanceWindow"
                    }
                  },
                  "required": [
                    "window"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Noise control"
        ],
        "summary": "Delete a maintenance window",
        "description": "Ending maintenance early means the problem is real again: alerts the window was holding page now.",
        "operationId": "delete_maintenance_windows_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/routing-rules": {
      "post": {
        "tags": [
          "Noise control"
        ],
        "summary": "Create a routing rule",
        "description": "Rules run on every new alert, in order. Each rule whose conditions match applies its actions, and later rules see the effect of earlier ones. Use them to re-prioritise, re-route to another team, tag, group related alerts into one page, or silence an alert by policy.",
        "operationId": "post_routing_rules",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RoutingRuleInput"
              },
              "example": {
                "name": "Staging is never urgent",
                "conditions": [
                  {
                    "field": "tag",
                    "op": "is",
                    "value": "env:staging"
                  }
                ],
                "actions": {
                  "setPriority": "P5"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created, last in order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rule": {
                      "$ref": "#/components/schemas/RoutingRule"
                    }
                  },
                  "required": [
                    "rule"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Noise control"
        ],
        "summary": "List routing rules, in order",
        "operationId": "get_routing_rules",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Rules.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RoutingRule"
                      }
                    }
                  },
                  "required": [
                    "rules"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/routing-rules/order": {
      "put": {
        "tags": [
          "Noise control"
        ],
        "summary": "Reorder routing rules",
        "description": "`ids` must list every rule exactly once.",
        "operationId": "put_routing_rules_order",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                },
                "required": [
                  "ids"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rules in their new order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RoutingRule"
                      }
                    }
                  },
                  "required": [
                    "rules"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/routing-rules/{id}": {
      "put": {
        "tags": [
          "Noise control"
        ],
        "summary": "Replace a routing rule",
        "operationId": "put_routing_rules_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RoutingRuleInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rule": {
                      "$ref": "#/components/schemas/RoutingRule"
                    }
                  },
                  "required": [
                    "rule"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Noise control"
        ],
        "summary": "Delete a routing rule",
        "operationId": "delete_routing_rules_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/readiness": {
      "get": {
        "tags": [
          "Reachability"
        ],
        "summary": "Can the people who get paged be reached?",
        "description": "Per person: a verified phone, the app installed and allowed to ring through Do Not Disturb, notification rules that actually escalate, a recent test page. For the organization: who is on call right now and whether they can be paged, schedules with nobody on call in the next 14 days, empty policies and steps, and teams that receive alerts but have no policy.",
        "operationId": "get_readiness",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Readiness.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrgReadiness"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}/readiness": {
      "get": {
        "tags": [
          "Reachability"
        ],
        "summary": "Can this person be reached?",
        "operationId": "get_users_readiness",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Checks, each with how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "readiness": {
                      "$ref": "#/components/schemas/Readiness"
                    }
                  },
                  "required": [
                    "readiness"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}/test-page": {
      "post": {
        "tags": [
          "Reachability"
        ],
        "summary": "Send a test page",
        "description": "A real page, along the real path, to one person. Without `channels` it uses their own notification rules and passes when they acknowledge it; with `channels` it tries each now and passes when each is delivered. A test is hidden from alert lists, counts, reports and billing, fires no webhook, and does not page admins if nobody answers. Carrier costs still apply.",
        "operationId": "post_users_test_page",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channels": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "push",
                        "sms",
                        "voice"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "alertId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "channels": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "string",
                          "enum": [
                            "rules"
                          ]
                        }
                      ]
                    }
                  },
                  "required": [
                    "alertId",
                    "channels"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}/test-pages": {
      "get": {
        "tags": [
          "Reachability"
        ],
        "summary": "Recent test pages and how they went",
        "operationId": "get_users_test_pages",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "testPages": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TestResult"
                      }
                    }
                  },
                  "required": [
                    "testPages"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/approvals": {
      "post": {
        "tags": [
          "Approvals"
        ],
        "summary": "Ask a human to approve something",
        "description": "Pages the people who can answer (the team's policy, or `userIds`) along the real path, with escalation, retries and failover, and records the answer. They reply by text (`Y4821` / `N4821`), press 1 or 9 on a call, or decide in the dashboard or app. **Software asks; only a human answers**: the key that creates an approval cannot decide it. Send an `Idempotency-Key` so a retry is the same question.",
        "operationId": "post_approvals",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApprovalInput"
              },
              "example": {
                "title": "Deploy v42 to production",
                "context": {
                  "commit": "9f31c2a",
                  "diff": "+42 -7"
                },
                "timeoutSeconds": 900,
                "priority": "P2"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Asked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approval": {
                      "$ref": "#/components/schemas/Approval"
                    }
                  },
                  "required": [
                    "approval"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Approvals"
        ],
        "summary": "List approvals",
        "operationId": "get_approvals",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "approved",
                "denied",
                "expired",
                "cancelled"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approvals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Approval"
                      }
                    }
                  },
                  "required": [
                    "approvals"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/approvals/{id}": {
      "get": {
        "tags": [
          "Approvals"
        ],
        "summary": "Get an approval",
        "operationId": "get_approvals_by_id",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The approval, with its votes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approval": {
                      "$ref": "#/components/schemas/Approval"
                    }
                  },
                  "required": [
                    "approval"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/approvals/{id}/decision": {
      "post": {
        "tags": [
          "Approvals"
        ],
        "summary": "Decide an approval",
        "description": "Needs an **admin** key, which belongs to a person or the dashboard and not to the software that asked. The first denial denies; enough approvals approve. Deciding closes the alert, so paging stops.",
        "operationId": "post_approvals_decision",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "decision": {
                    "type": "string",
                    "enum": [
                      "approve",
                      "deny"
                    ]
                  },
                  "user": {
                    "type": "string",
                    "description": "Who is deciding, for the record."
                  },
                  "note": {
                    "type": "string"
                  }
                },
                "required": [
                  "decision"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "outcome": {
                      "type": "string",
                      "enum": [
                        "decided",
                        "recorded"
                      ]
                    },
                    "approval": {
                      "$ref": "#/components/schemas/Approval"
                    }
                  },
                  "required": [
                    "outcome",
                    "approval"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/approvals/{id}/cancel": {
      "post": {
        "tags": [
          "Approvals"
        ],
        "summary": "Withdraw an approval",
        "description": "The requester no longer needs the answer. Only while pending.",
        "operationId": "post_approvals_cancel",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "outcome": {
                      "type": "string",
                      "enum": [
                        "cancelled"
                      ]
                    },
                    "approval": {
                      "$ref": "#/components/schemas/Approval"
                    }
                  },
                  "required": [
                    "outcome",
                    "approval"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/schedules/{id}/coverage": {
      "post": {
        "tags": [
          "Schedules"
        ],
        "summary": "Ask for cover",
        "description": "\"I am ill on Thursday, can someone take my shift?\" Names a stretch of the requester's on-call time. When someone eligible (a member of the schedule's team) accepts, overrides are created for them covering exactly the minutes the requester was on call inside that stretch. The rotation itself is untouched.",
        "operationId": "post_schedules_coverage",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CoverageInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Open.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "coverage": {
                      "$ref": "#/components/schemas/Coverage"
                    }
                  },
                  "required": [
                    "coverage"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/coverage": {
      "get": {
        "tags": [
          "Schedules"
        ],
        "summary": "List cover requests",
        "operationId": "get_coverage",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "accepted",
                "declined",
                "cancelled",
                "expired"
              ]
            }
          },
          {
            "name": "scheduleId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Newest shifts first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "coverage": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Coverage"
                      }
                    }
                  },
                  "required": [
                    "coverage"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/coverage/{id}/accept": {
      "post": {
        "tags": [
          "Schedules"
        ],
        "summary": "Take a shift",
        "description": "Creates the overrides. The taker must be on the schedule's team, and the request open and not yet over.",
        "operationId": "post_coverage_accept",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "userId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Taken.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "coverage": {
                      "$ref": "#/components/schemas/Coverage"
                    },
                    "covered": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "from": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "to": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "from",
                          "to"
                        ]
                      }
                    }
                  },
                  "required": [
                    "coverage",
                    "covered"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/coverage/{id}/decline": {
      "post": {
        "tags": [
          "Schedules"
        ],
        "summary": "Decline an offered shift",
        "description": "Only the person it was offered to.",
        "operationId": "post_coverage_decline",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "userId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Declined.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "coverage": {
                      "$ref": "#/components/schemas/Coverage"
                    }
                  },
                  "required": [
                    "coverage"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/coverage/{id}/cancel": {
      "post": {
        "tags": [
          "Schedules"
        ],
        "summary": "Withdraw a cover request",
        "description": "If it was already taken, the cover is undone and its overrides removed.",
        "operationId": "post_coverage_cancel",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "coverage": {
                      "$ref": "#/components/schemas/Coverage"
                    }
                  },
                  "required": [
                    "coverage"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/teams/{id}/handoff-notes": {
      "post": {
        "tags": [
          "On call"
        ],
        "summary": "Leave a handoff note",
        "description": "What the person going off call wants the next person to know. Shown by `GET /v1/oncall` as `handoff`, in the dashboard, and sent as a `handoff.note` webhook.",
        "operationId": "post_teams_handoff_notes",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "userId": {
                    "type": "string",
                    "description": "Who is writing, for the byline.",
                    "format": "uuid"
                  }
                },
                "required": [
                  "body"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "note": {
                      "$ref": "#/components/schemas/HandoffNote"
                    }
                  },
                  "required": [
                    "note"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "On call"
        ],
        "summary": "Handoff notes",
        "operationId": "get_teams_handoff_notes",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "notes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/HandoffNote"
                      }
                    }
                  },
                  "required": [
                    "notes"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/calendar-feeds": {
      "post": {
        "tags": [
          "Schedules"
        ],
        "summary": "Create a calendar feed",
        "description": "A secret URL that Google Calendar, Apple Calendar or Outlook subscribes to, showing a schedule, a team, or one person's shifts (a week back to four months ahead, overrides included). The token is shown once; delete the feed to revoke it.",
        "operationId": "post_calendar_feeds",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scheduleId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "teamId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "userId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "label": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "feed": {
                      "$ref": "#/components/schemas/CalendarFeed"
                    },
                    "token": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string",
                      "description": "Subscribe to this."
                    }
                  },
                  "required": [
                    "feed",
                    "token",
                    "url"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Schedules"
        ],
        "summary": "List calendar feeds",
        "operationId": "get_calendar_feeds",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Feeds, without their tokens.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "feeds": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CalendarFeed"
                      }
                    }
                  },
                  "required": [
                    "feeds"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/calendar-feeds/{id}": {
      "delete": {
        "tags": [
          "Schedules"
        ],
        "summary": "Delete a calendar feed",
        "description": "Calendar apps subscribed to it stop updating.",
        "operationId": "delete_calendar_feeds_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reports/load": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Who is carrying the pager",
        "description": "Per person over a period: hours on call (to the minute, overrides included), the share at night and at weekends by the clock where they live, pages received, pages at night, and how fast they answer. With suggestions where the load is lopsided.",
        "operationId": "get_reports_load",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 90,
              "default": 30
            }
          },
          {
            "name": "team",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoadReport"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reports/noise": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Which alerts are noise",
        "description": "From what people actually did with alerts: how many were acknowledged, which resolved themselves, which repeat, and which source is loudest. `suggestions` are ranked, and many carry a ready-to-create routing rule or the organization setting that would apply them.",
        "operationId": "get_reports_noise",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 90,
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoiseReport"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/heartbeats/{name}": {
      "put": {
        "tags": [
          "Heartbeats"
        ],
        "summary": "Create or update a heartbeat",
        "description": "Idempotent, so it can run on every deploy. A heartbeat expects a ping every `intervalSeconds` (plus `graceSeconds`). If one is missed, an alert opens with alias `heartbeat:<name>` and pages the team's escalation policy; the next ping closes it.",
        "operationId": "put_heartbeats_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Letters, digits, dot, dash, underscore."
            },
            "example": "nightly-backup"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HeartbeatInput"
              },
              "example": {
                "intervalSeconds": 86400,
                "graceSeconds": 600,
                "priority": "P1",
                "message": "The nightly backup did not report in"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The heartbeat.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "heartbeat": {
                      "$ref": "#/components/schemas/Heartbeat"
                    }
                  },
                  "required": [
                    "heartbeat"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Heartbeats"
        ],
        "summary": "Get a heartbeat",
        "operationId": "get_heartbeats_by_id",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Letters, digits, dot, dash, underscore."
            },
            "example": "nightly-backup"
          }
        ],
        "responses": {
          "200": {
            "description": "The heartbeat.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "heartbeat": {
                      "$ref": "#/components/schemas/Heartbeat"
                    }
                  },
                  "required": [
                    "heartbeat"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Heartbeats"
        ],
        "summary": "Delete a heartbeat",
        "operationId": "delete_heartbeats_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Letters, digits, dot, dash, underscore."
            },
            "example": "nightly-backup"
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/heartbeats": {
      "get": {
        "tags": [
          "Heartbeats"
        ],
        "summary": "List heartbeats",
        "operationId": "get_heartbeats",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "All heartbeats.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "heartbeats": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Heartbeat"
                      }
                    }
                  },
                  "required": [
                    "heartbeats"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/heartbeats/{name}/ping": {
      "post": {
        "tags": [
          "Heartbeats"
        ],
        "summary": "Ping a heartbeat",
        "description": "Records that the job is alive and moves the due time forward. If the heartbeat was down, its alert is closed and `recovered` is true. Any key that can create alerts can ping.",
        "operationId": "post_heartbeats_ping",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Letters, digits, dot, dash, underscore."
            },
            "example": "nightly-backup"
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "heartbeat": {
                      "$ref": "#/components/schemas/Heartbeat"
                    },
                    "recovered": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "heartbeat",
                    "recovered"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Retry after the `retry-after` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/oncall": {
      "get": {
        "tags": [
          "On call"
        ],
        "summary": "Who is on call",
        "description": "For a team, the person on call right now (or at `at`) for each of its schedules. Overrides win over rotations.",
        "operationId": "get_oncall",
        "x-scope": "alert",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "A team id or exact name."
            }
          },
          {
            "name": "at",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Defaults to now.",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "On-call by schedule.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "team": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "name": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name"
                      ]
                    },
                    "at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "schedules": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "scheduleId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "scheduleName": {
                            "type": "string"
                          },
                          "onCall": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "scheduleId",
                          "scheduleName",
                          "onCall"
                        ]
                      }
                    },
                    "handoff": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/HandoffNote"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The latest handoff note for the team."
                    }
                  },
                  "required": [
                    "team",
                    "at",
                    "schedules",
                    "handoff"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/schedules/preview": {
      "post": {
        "tags": [
          "Schedules"
        ],
        "summary": "Preview a schedule",
        "description": "Who would be on call at each of the given times if this schedule were saved. Saves nothing. Pass `scheduleId` to include that schedule's existing overrides (a replacement keeps them). This is what `treason plan` uses to show a rotation change as \"Thursday 09:00 is Bo, not Ana\".",
        "operationId": "post_schedules_preview",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "layers": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "rotationStart": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "rotationLength": {
                          "type": "object",
                          "properties": {
                            "days": {
                              "type": "integer"
                            },
                            "hours": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "days",
                            "hours"
                          ]
                        },
                        "handoffTime": {
                          "type": "string"
                        },
                        "members": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "format": "uuid"
                          }
                        }
                      },
                      "required": [
                        "rotationStart",
                        "rotationLength",
                        "handoffTime",
                        "members"
                      ]
                    }
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "scheduleId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "at": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "required": [
                  "layers",
                  "at"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "On call at each time.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "onCall": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "user": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "at",
                          "user"
                        ]
                      }
                    }
                  },
                  "required": [
                    "onCall"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/schedules": {
      "post": {
        "tags": [
          "Schedules"
        ],
        "summary": "Create a schedule",
        "operationId": "post_schedules",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduleInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schedule": {
                      "$ref": "#/components/schemas/Schedule"
                    }
                  },
                  "required": [
                    "schedule"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Schedules"
        ],
        "summary": "List schedules",
        "operationId": "get_schedules",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "All schedules, with who is on call now.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schedules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Schedule"
                      }
                    }
                  },
                  "required": [
                    "schedules"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/schedules/{id}": {
      "get": {
        "tags": [
          "Schedules"
        ],
        "summary": "Get a schedule",
        "operationId": "get_schedules_by_id",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "at",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Evaluate `onCall` at this time. Overrides ending in the last 90 days are included.",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The schedule.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schedule": {
                      "$ref": "#/components/schemas/Schedule"
                    }
                  },
                  "required": [
                    "schedule"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Schedules"
        ],
        "summary": "Replace a schedule",
        "operationId": "put_schedules_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduleInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schedule": {
                      "$ref": "#/components/schemas/Schedule"
                    }
                  },
                  "required": [
                    "schedule"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Schedules"
        ],
        "summary": "Delete a schedule",
        "description": "Refused while an escalation policy still points at it, because that would page nobody.",
        "operationId": "delete_schedules_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/schedules/{id}/overrides": {
      "post": {
        "tags": [
          "Schedules"
        ],
        "summary": "Add an override",
        "description": "Puts someone on call for a time range instead of the rotation.",
        "operationId": "post_schedules_overrides",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "startsAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endsAt": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "userId",
                  "startsAt",
                  "endsAt"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "override": {
                      "$ref": "#/components/schemas/Override"
                    }
                  },
                  "required": [
                    "override"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/schedules/{id}/overrides/{oid}": {
      "delete": {
        "tags": [
          "Schedules"
        ],
        "summary": "Remove an override",
        "operationId": "delete_schedules_overrides_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "oid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/escalation-policies": {
      "post": {
        "tags": [
          "Escalation"
        ],
        "summary": "Create an escalation policy",
        "description": "Each team has one policy.",
        "operationId": "post_escalation_policies",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EscalationPolicyInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "policy": {
                      "$ref": "#/components/schemas/EscalationPolicy"
                    }
                  },
                  "required": [
                    "policy"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Escalation"
        ],
        "summary": "List escalation policies",
        "operationId": "get_escalation_policies",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "All policies.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "policies": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/EscalationPolicy"
                      }
                    }
                  },
                  "required": [
                    "policies"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/escalation-policies/{id}": {
      "get": {
        "tags": [
          "Escalation"
        ],
        "summary": "Get an escalation policy",
        "operationId": "get_escalation_policies_by_id",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The policy.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "policy": {
                      "$ref": "#/components/schemas/EscalationPolicy"
                    }
                  },
                  "required": [
                    "policy"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Escalation"
        ],
        "summary": "Replace an escalation policy",
        "operationId": "put_escalation_policies_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EscalationPolicyInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "policy": {
                      "$ref": "#/components/schemas/EscalationPolicy"
                    }
                  },
                  "required": [
                    "policy"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Escalation"
        ],
        "summary": "Delete an escalation policy",
        "operationId": "delete_escalation_policies_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users": {
      "post": {
        "tags": [
          "People"
        ],
        "summary": "Create a person",
        "operationId": "post_users",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "responder",
                      "admin"
                    ]
                  },
                  "access": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "invited": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/User"
                    }
                  },
                  "required": [
                    "user"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "People"
        ],
        "summary": "List people",
        "operationId": "get_users",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "archived",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "true"
              ]
            },
            "description": "Include people who were removed."
          }
        ],
        "responses": {
          "200": {
            "description": "People.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "users": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    }
                  },
                  "required": [
                    "users"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}": {
      "get": {
        "tags": [
          "People"
        ],
        "summary": "Get a person with contacts, rules and teams",
        "operationId": "get_users_by_id",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The person.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/User"
                    },
                    "contacts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "rules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Rule"
                      }
                    },
                    "teams": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name"
                        ]
                      }
                    }
                  },
                  "required": [
                    "user",
                    "contacts",
                    "rules",
                    "teams"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "People"
        ],
        "summary": "Update a person",
        "operationId": "patch_users_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "responder",
                      "admin"
                    ]
                  },
                  "access": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "invited": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/User"
                    }
                  },
                  "required": [
                    "user"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "People"
        ],
        "summary": "Remove a person",
        "description": "Stops all paging for them and removes them from teams and schedules. History is kept.",
        "operationId": "delete_users_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}/contacts": {
      "post": {
        "tags": [
          "People"
        ],
        "summary": "Add a phone number or Slack member",
        "description": "A phone number gets a verification code by text first; alerts are never sent to an unverified number.",
        "operationId": "post_users_contacts",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "phone"
                      },
                      "number": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "number"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "slack"
                      },
                      "slackUserId": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "slackUserId"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Added.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contacts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    }
                  },
                  "required": [
                    "contacts"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}/contacts/{cid}/verify": {
      "post": {
        "tags": [
          "People"
        ],
        "summary": "Verify a phone number",
        "operationId": "post_users_contacts_verify",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "pattern": "^\\d{6}$"
                  }
                },
                "required": [
                  "code"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verified.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "verified": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "verified"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}/contacts/{cid}/resend": {
      "post": {
        "tags": [
          "People"
        ],
        "summary": "Send a new verification code",
        "operationId": "post_users_contacts_resend",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sent": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "sent"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Retry after the `retry-after` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}/contacts/{cid}": {
      "delete": {
        "tags": [
          "People"
        ],
        "summary": "Remove a contact",
        "operationId": "delete_users_contacts_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}/rules": {
      "get": {
        "tags": [
          "People"
        ],
        "summary": "Get how a person is paged",
        "operationId": "get_users_rules",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rules.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Rule"
                      }
                    }
                  },
                  "required": [
                    "rules"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "People"
        ],
        "summary": "Set how a person is paged",
        "description": "The order and timing of push, text and call for P1 to P3 alerts. Without rules the default is push now, text after 2 minutes, call after 5.",
        "operationId": "put_users_rules",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rules": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "channel": {
                          "type": "string",
                          "enum": [
                            "push",
                            "sms",
                            "voice"
                          ]
                        },
                        "delaySeconds": {
                          "type": "integer"
                        },
                        "priority": {
                          "type": "string",
                          "enum": [
                            "urgent",
                            "low"
                          ]
                        }
                      },
                      "required": [
                        "channel",
                        "delaySeconds"
                      ]
                    }
                  }
                },
                "required": [
                  "rules"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Rule"
                      }
                    }
                  },
                  "required": [
                    "rules"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users/{id}/pairing-codes": {
      "post": {
        "tags": [
          "People"
        ],
        "summary": "Create a code to pair the mobile app",
        "operationId": "post_users_pairing_codes",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "A short-lived code.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "code",
                    "expiresAt"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/teams": {
      "post": {
        "tags": [
          "People"
        ],
        "summary": "Create a team",
        "operationId": "post_teams",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "team": {
                      "$ref": "#/components/schemas/Team"
                    }
                  },
                  "required": [
                    "team"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "People"
        ],
        "summary": "List teams",
        "operationId": "get_teams",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Teams.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "teams": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Team"
                      }
                    }
                  },
                  "required": [
                    "teams"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/teams/{id}": {
      "patch": {
        "tags": [
          "People"
        ],
        "summary": "Rename a team",
        "operationId": "patch_teams_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Renamed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "team": {
                      "$ref": "#/components/schemas/Team"
                    }
                  },
                  "required": [
                    "team"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "People"
        ],
        "summary": "Delete a team",
        "description": "Refused while integrations, schedules or a policy still use it.",
        "operationId": "delete_teams_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/teams/{id}/members": {
      "put": {
        "tags": [
          "People"
        ],
        "summary": "Set a team's members",
        "operationId": "put_teams_members",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "userIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                },
                "required": [
                  "userIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "memberIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid"
                      }
                    }
                  },
                  "required": [
                    "memberIds"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/integrations": {
      "post": {
        "tags": [
          "Integrations"
        ],
        "summary": "Create an alert source",
        "description": "`inbound` is the native endpoint for a monitoring tool (set `source`): it posts its own payload to `/inbound/<source>?key=<key>` and nothing needs translating. `opsgenie_compat` keys work with anything that speaks Opsgenie's API; `email` gives an address that turns mail into alerts. The key is shown once.",
        "operationId": "post_integrations",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "opsgenie_compat",
                      "webhook",
                      "email",
                      "inbound"
                    ]
                  },
                  "teamId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "source": {
                    "$ref": "#/components/schemas/InboundSource"
                  },
                  "config": {
                    "$ref": "#/components/schemas/SourceConfig"
                  }
                },
                "required": [
                  "name",
                  "kind"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. `key` is shown once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "integration": {
                      "$ref": "#/components/schemas/Integration"
                    },
                    "key": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "integration",
                    "key"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List alert sources",
        "operationId": "get_integrations",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Sources.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "integrations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Integration"
                      }
                    }
                  },
                  "required": [
                    "integrations"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/integrations/{id}": {
      "patch": {
        "tags": [
          "Integrations"
        ],
        "summary": "Update an alert source",
        "operationId": "patch_integrations_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "teamId": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid"
                  },
                  "config": {
                    "$ref": "#/components/schemas/SourceConfig"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "integration": {
                      "$ref": "#/components/schemas/Integration"
                    }
                  },
                  "required": [
                    "integration"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Integrations"
        ],
        "summary": "Delete an alert source",
        "operationId": "delete_integrations_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict with the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/integrations/{id}/rotate-key": {
      "post": {
        "tags": [
          "Integrations"
        ],
        "summary": "Replace an alert source's key",
        "operationId": "post_integrations_rotate_key",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The new key, shown once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "integration": {
                      "$ref": "#/components/schemas/Integration"
                    },
                    "key": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "integration",
                    "key"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/inbound/preview": {
      "post": {
        "tags": [
          "Integrations"
        ],
        "summary": "Preview what a payload would do",
        "description": "Reads a sample payload the way an `inbound` integration would, and returns the alerts it would open or close, without creating anything. Use it to check a generic mapping or a Datadog template before pointing a tool at the endpoint.",
        "operationId": "post_inbound_preview",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "$ref": "#/components/schemas/InboundSource"
                  },
                  "payload": {
                    "description": "The JSON the tool would send."
                  },
                  "headers": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    },
                    "description": "Headers that matter to the source, such as `Sentry-Hook-Resource`."
                  },
                  "config": {
                    "$ref": "#/components/schemas/SourceConfig"
                  }
                },
                "required": [
                  "source",
                  "payload"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What would happen.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboundPreview"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Create a webhook endpoint",
        "description": "We POST each event to your https URL, signed with the returned `secret` (shown once). See the Webhooks guide for verification.",
        "operationId": "post_webhooks",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. `secret` is shown once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook": {
                      "$ref": "#/components/schemas/Webhook"
                    },
                    "secret": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "webhook",
                    "secret"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhook endpoints",
        "operationId": "get_webhooks",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhooks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    }
                  },
                  "required": [
                    "webhooks"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/{id}": {
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Update a webhook endpoint",
        "operationId": "patch_webhooks_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook": {
                      "$ref": "#/components/schemas/Webhook"
                    }
                  },
                  "required": [
                    "webhook"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete a webhook endpoint",
        "operationId": "delete_webhooks_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/api-keys": {
      "post": {
        "tags": [
          "Keys and organization"
        ],
        "summary": "Create an API key",
        "description": "Scopes are not a ladder: `alert` creates, acknowledges, closes and reads alerts and pings heartbeats; `read` reads everything; `admin` does everything. The key is shown once.",
        "operationId": "post_api_keys",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "read",
                      "alert",
                      "admin"
                    ]
                  }
                },
                "required": [
                  "name",
                  "scope"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. `key` is shown once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apiKey": {
                      "$ref": "#/components/schemas/ApiKey"
                    },
                    "key": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "apiKey",
                    "key"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Keys and organization"
        ],
        "summary": "List API keys",
        "operationId": "get_api_keys",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Keys, by prefix only.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apiKeys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  },
                  "required": [
                    "apiKeys"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/api-keys/{id}": {
      "delete": {
        "tags": [
          "Keys and organization"
        ],
        "summary": "Revoke an API key",
        "operationId": "delete_api_keys_by_id",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No body."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/org": {
      "get": {
        "tags": [
          "Keys and organization"
        ],
        "summary": "Get the organization",
        "operationId": "get_org",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "The organization.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "org": {
                      "$ref": "#/components/schemas/Org"
                    }
                  },
                  "required": [
                    "org"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Keys and organization"
        ],
        "summary": "Update the organization",
        "operationId": "patch_org",
        "x-scope": "admin",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "allowInternational": {
                    "type": "boolean"
                  },
                  "flapThreshold": {
                    "type": "integer"
                  },
                  "flapWindowMinutes": {
                    "type": "integer"
                  },
                  "flapHoldMinutes": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "org": {
                      "$ref": "#/components/schemas/Org"
                    }
                  },
                  "required": [
                    "org"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "tags": [
          "Keys and organization"
        ],
        "summary": "Usage for a month",
        "operationId": "get_usage",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "`YYYY-MM`. Defaults to this month.",
              "pattern": "^\\d{4}-\\d{2}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Billable usage.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "period": {
                      "type": "string"
                    },
                    "units": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "unit": {
                            "type": "string"
                          },
                          "quantity": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "unit",
                          "quantity"
                        ]
                      }
                    },
                    "carrierCostMicros": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "period",
                    "units",
                    "carrierCostMicros"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/audit": {
      "get": {
        "tags": [
          "Keys and organization"
        ],
        "summary": "Recent configuration changes",
        "operationId": "get_audit",
        "x-scope": "read",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Audit events, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "actor": {
                            "type": "string"
                          },
                          "action": {
                            "type": "string"
                          },
                          "entity": {
                            "type": "string"
                          },
                          "entityId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "payload": {
                            "type": "object"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "actor",
                          "action",
                          "entity",
                          "entityId",
                          "payload",
                          "createdAt"
                        ]
                      }
                    }
                  },
                  "required": [
                    "events"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key's scope cannot do this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "An organization API key (`trk_...`) or an integration key. Create keys in the dashboard under Integrations, or with `POST /v1/api-keys`."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "A stable, machine-readable code, such as `validation_failed`."
              },
              "message": {
                "type": "string",
                "description": "A human-readable explanation."
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "Alert": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "alias": {
            "type": "string",
            "description": "De-duplication key. A repeat with the same alias bumps `dedupCount` instead of paging again."
          },
          "tinyId": {
            "type": "integer",
            "description": "The short number people say out loud, such as 4821."
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "acknowledged",
              "exhausted",
              "closed",
              "suppressed"
            ]
          },
          "priority": {
            "type": "string",
            "enum": [
              "P1",
              "P2",
              "P3",
              "P4",
              "P5"
            ],
            "description": "P1 pages now; P4 and P5 only push."
          },
          "message": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "entity": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "details": {
            "type": "object",
            "additionalProperties": true
          },
          "dedupCount": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "acknowledgedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "closedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "acknowledgedVia": {
            "type": [
              "string",
              "null"
            ],
            "description": "`api`, `sms`, `voice`, `app`, `slack` or `snooze`."
          },
          "acknowledgedBy": {
            "$ref": "#/components/schemas/AcknowledgedBy",
            "description": "Who acknowledged it. Null until someone does."
          },
          "teamId": {
            "type": "string",
            "format": "uuid"
          },
          "isTest": {
            "type": "boolean",
            "description": "A test page. These are left out of lists, counts, reports and billing."
          },
          "suppressedBy": {
            "type": [
              "string",
              "null"
            ],
            "description": "Set while `status` is `suppressed`: `maintenance:<id>`, `rule:<id>`, `group:<alert id>` or `flapping`. A held alert is recorded but pages nobody."
          },
          "snoozedUntil": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Set while an acknowledged alert is snoozed: it pages again at this time if it is still open."
          }
        },
        "required": [
          "id",
          "alias",
          "tinyId",
          "status",
          "priority",
          "message",
          "description",
          "entity",
          "source",
          "tags",
          "details",
          "dedupCount",
          "createdAt",
          "acknowledgedAt",
          "closedAt",
          "acknowledgedVia",
          "acknowledgedBy",
          "suppressedBy",
          "snoozedUntil"
        ]
      },
      "AcknowledgedBy": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "actor": {
            "type": "string",
            "description": "Who did it, as recorded: `sms:<user id>`, `app:<user id>`, `dashboard:<sign-in>`, `api_key:<id>` and so on."
          },
          "userId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The person, when it was one (a phone, the app, Slack, a signed-in dashboard user, or the API naming a user). Null for an API key or an integration."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That person's name."
          }
        },
        "required": [
          "actor",
          "userId",
          "name"
        ]
      },
      "AlertEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "type": {
            "type": "string",
            "description": "`created`, `deduped`, `escalated`, `notified`, `delivered`, `acknowledged`, `closed`, `noted`, `suppressed`, `released`, `routed`, `grouped`, `snoozed`, `approval_requested`, `approval_vote`, `approval_decided`."
          },
          "actor": {
            "type": "string"
          },
          "payload": {
            "type": "object",
            "additionalProperties": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "type",
          "actor",
          "payload",
          "createdAt"
        ]
      },
      "NotificationAttempt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "step": {
            "type": "integer"
          },
          "channel": {
            "type": "string",
            "enum": [
              "push",
              "sms",
              "voice",
              "slack"
            ]
          },
          "carrier": {
            "type": [
              "string",
              "null"
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "page",
              "summary"
            ]
          },
          "status": {
            "type": "string",
            "description": "`queued`, `sent`, `delivered`, `answered`, `failed`, `no_receipt`, `no_answer`, `collapsed`."
          },
          "attemptNo": {
            "type": "integer"
          },
          "costMicros": {
            "type": [
              "integer",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "sentAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "deliveredAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "why": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Why"
              },
              {
                "type": "null"
              }
            ],
            "description": "Why this person was notified this way. Null for notifications sent before this was recorded."
          }
        },
        "required": [
          "id",
          "userId",
          "step",
          "channel",
          "carrier",
          "kind",
          "status",
          "attemptNo",
          "costMicros",
          "error",
          "sentAt",
          "deliveredAt",
          "createdAt",
          "why"
        ]
      },
      "Why": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "schedule",
              "user",
              "team",
              "responder",
              "admin_notice",
              "test",
              "heartbeat"
            ]
          },
          "policy": {
            "type": "string",
            "description": "The escalation policy that paged them."
          },
          "step": {
            "type": "integer",
            "description": "1-based."
          },
          "round": {
            "type": "integer",
            "description": "0 on the first pass of the policy."
          },
          "scheduleId": {
            "type": "string",
            "format": "uuid"
          },
          "scheduleName": {
            "type": "string"
          },
          "via": {
            "type": "string",
            "enum": [
              "override",
              "rotation"
            ],
            "description": "For `schedule`: what made them the person on call."
          },
          "teamName": {
            "type": "string"
          },
          "routedByRule": {
            "type": "boolean",
            "description": "A routing rule sent the alert to this team's policy."
          },
          "rule": {
            "type": "object",
            "properties": {
              "channel": {
                "type": "string",
                "enum": [
                  "push",
                  "sms",
                  "voice",
                  "slack"
                ]
              },
              "delaySeconds": {
                "type": "integer"
              },
              "custom": {
                "type": "boolean",
                "description": "False when they have no notification rules and the default applied."
              }
            },
            "required": [
              "channel",
              "delaySeconds",
              "custom"
            ]
          },
          "text": {
            "type": "string",
            "description": "The whole answer as a sentence."
          }
        },
        "required": [
          "kind",
          "text"
        ]
      },
      "CreateAlert": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "What happened, in a sentence. Kept to 130 characters; longer text is not lost, it is kept in full in the description."
          },
          "alias": {
            "type": "string",
            "description": "De-duplication key. Without one, every request is a new alert."
          },
          "description": {
            "type": "string",
            "description": "Up to 15,000 characters."
          },
          "entity": {
            "type": "string",
            "description": "What it is about: a host, a service, a job."
          },
          "source": {
            "type": "string",
            "description": "Where it came from."
          },
          "priority": {
            "type": "string",
            "enum": [
              "P1",
              "P2",
              "P3",
              "P4",
              "P5"
            ],
            "description": "P1 pages now; P4 and P5 only push.",
            "default": "P3"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 50
            }
          },
          "details": {
            "type": "object",
            "additionalProperties": true,
            "description": "Free-form key/value context."
          },
          "note": {
            "type": "string",
            "description": "Added as a note on the alert."
          },
          "user": {
            "type": "string",
            "description": "Who to record as the actor."
          },
          "teamId": {
            "type": "string",
            "description": "Which team to page. Optional when the organization has exactly one team.",
            "format": "uuid"
          }
        },
        "required": [
          "message"
        ]
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "timezone": {
            "type": "string",
            "description": "An IANA zone, like `America/New_York`."
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "role": {
            "type": "string",
            "enum": [
              "responder",
              "admin"
            ]
          },
          "archived": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sign-in account linked to this person, once they have joined."
          },
          "invitedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "pendingAccess": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "What they may do once they accept their invitation."
          }
        },
        "required": [
          "id",
          "name",
          "timezone",
          "email",
          "role",
          "archived",
          "createdAt",
          "externalId",
          "invitedAt",
          "pendingAccess"
        ]
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "enum": [
              "sms",
              "voice",
              "push",
              "slack"
            ]
          },
          "address": {
            "type": "string",
            "description": "Masked for phones."
          },
          "verified": {
            "type": "boolean"
          },
          "lastSeenAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "type",
          "address",
          "verified",
          "lastSeenAt"
        ]
      },
      "Rule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "channel": {
            "type": "string",
            "enum": [
              "push",
              "sms",
              "voice"
            ]
          },
          "delaySeconds": {
            "type": "integer"
          },
          "priority": {
            "type": "string",
            "enum": [
              "urgent",
              "low"
            ]
          }
        },
        "required": [
          "id",
          "channel",
          "delaySeconds",
          "priority"
        ]
      },
      "Team": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "memberIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        },
        "required": [
          "id",
          "name",
          "memberIds"
        ]
      },
      "RotationLayer": {
        "type": "object",
        "properties": {
          "order": {
            "type": "integer"
          },
          "rotationStart": {
            "type": "string",
            "description": "When the first shift begins, at the handoff time.",
            "format": "date-time"
          },
          "handoffTime": {
            "type": "string",
            "description": "`HH:MM` in the schedule's time zone.",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
          },
          "rotationLength": {
            "type": "object",
            "properties": {
              "days": {
                "type": "integer"
              },
              "hours": {
                "type": "integer"
              }
            },
            "required": [
              "days",
              "hours"
            ]
          },
          "members": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        },
        "required": [
          "order",
          "rotationStart",
          "handoffTime",
          "rotationLength",
          "members"
        ]
      },
      "Override": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "startsAt": {
            "type": "string",
            "format": "date-time"
          },
          "endsAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "userId",
          "startsAt",
          "endsAt"
        ]
      },
      "Schedule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "teamId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "timezone": {
            "type": "string"
          },
          "layers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RotationLayer"
            }
          },
          "overrides": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Override"
            }
          },
          "onCall": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Who is on call right now (or at `at`)."
          }
        },
        "required": [
          "id",
          "name",
          "teamId",
          "timezone",
          "layers",
          "overrides",
          "onCall"
        ]
      },
      "ScheduleInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "teamId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "timezone": {
            "type": "string",
            "description": "Default `UTC`."
          },
          "layers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "rotationStart": {
                  "type": "string",
                  "format": "date-time"
                },
                "rotationLength": {
                  "type": "object",
                  "properties": {
                    "days": {
                      "type": "integer"
                    },
                    "hours": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "days",
                    "hours"
                  ]
                },
                "handoffTime": {
                  "type": "string"
                },
                "members": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              },
              "required": [
                "rotationStart",
                "rotationLength",
                "handoffTime",
                "members"
              ]
            }
          }
        },
        "required": [
          "name",
          "layers"
        ]
      },
      "PolicyStep": {
        "type": "object",
        "properties": {
          "delayMinutes": {
            "type": "integer",
            "description": "Wait this long for an acknowledgement, then go to the next step."
          },
          "targets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "user",
                    "schedule",
                    "team"
                  ]
                },
                "id": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "required": [
                "type",
                "id"
              ]
            }
          }
        },
        "required": [
          "delayMinutes",
          "targets"
        ]
      },
      "EscalationPolicyInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "teamId": {
            "type": "string",
            "format": "uuid"
          },
          "repeatCount": {
            "type": "integer",
            "description": "How many times to start over if nobody answers (default 0: tell admins and stop)."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PolicyStep"
            }
          }
        },
        "required": [
          "name",
          "teamId",
          "steps"
        ]
      },
      "EscalationPolicy": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "teamId": {
            "type": "string",
            "format": "uuid"
          },
          "repeatCount": {
            "type": "integer"
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PolicyStep"
            }
          }
        },
        "required": [
          "id",
          "name",
          "teamId",
          "repeatCount",
          "steps"
        ]
      },
      "InboundSource": {
        "type": "string",
        "enum": [
          "alertmanager",
          "grafana",
          "datadog",
          "sentry",
          "cloudwatch",
          "gcp",
          "azure",
          "generic"
        ],
        "description": "Which tool an `inbound` integration is the endpoint for."
      },
      "SourceConfig": {
        "type": "object",
        "properties": {
          "defaultPriority": {
            "type": "string",
            "enum": [
              "P1",
              "P2",
              "P3",
              "P4",
              "P5"
            ],
            "description": "P1 pages now; P4 and P5 only push."
          },
          "priorityMap": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "enum": [
                "P1",
                "P2",
                "P3",
                "P4",
                "P5"
              ],
              "description": "P1 pages now; P4 and P5 only push."
            },
            "description": "Maps the tool's own severity words (`critical`, `Sev1`...) to a priority. Wins over the built-in map."
          },
          "insufficientData": {
            "type": "string",
            "enum": [
              "ignore",
              "trigger"
            ],
            "description": "CloudWatch only: what to do with INSUFFICIENT_DATA. Default `ignore`."
          },
          "mapping": {
            "$ref": "#/components/schemas/GenericMapping"
          }
        }
      },
      "GenericMapping": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "A JSON path (`$.alert.title`), a template (`{{ $.name }} is {{ $.status }}`) or literal text."
          },
          "alias": {
            "type": "string",
            "description": "Same alert, same alias. Defaults to a digest of the message."
          },
          "description": {
            "type": "string"
          },
          "entity": {
            "type": "string"
          },
          "priority": {
            "type": "string",
            "description": "What to read; mapped through `priorityMap`, or understood as P1-P5 or a severity word."
          },
          "tags": {
            "type": "string",
            "description": "A path to an array of strings or a comma-separated string."
          },
          "each": {
            "type": "string",
            "description": "A path to an array holding one alert per element; other paths are then relative to each element."
          },
          "resolveWhen": {
            "type": "object",
            "properties": {
              "path": {
                "type": "string"
              },
              "values": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "path",
              "values"
            ]
          },
          "priorityMap": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "enum": [
                "P1",
                "P2",
                "P3",
                "P4",
                "P5"
              ],
              "description": "P1 pages now; P4 and P5 only push."
            }
          },
          "details": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Extra fields to keep on the alert: `{ name: path }`."
          }
        },
        "required": [
          "message"
        ]
      },
      "Integration": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "opsgenie_compat",
              "webhook",
              "email",
              "inbound"
            ]
          },
          "teamId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "enabled": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "emailAddress": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/InboundSource"
          },
          "config": {
            "$ref": "#/components/schemas/SourceConfig"
          }
        },
        "required": [
          "id",
          "name",
          "kind",
          "teamId",
          "enabled",
          "createdAt"
        ]
      },
      "InboundPreview": {
        "type": "object",
        "properties": {
          "outcome": {
            "type": "string",
            "enum": [
              "events",
              "ignored",
              "confirm"
            ]
          },
          "reason": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "action": {
                  "type": "string",
                  "enum": [
                    "trigger",
                    "resolve"
                  ]
                },
                "alias": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "priority": {
                  "type": "string",
                  "enum": [
                    "P1",
                    "P2",
                    "P3",
                    "P4",
                    "P5"
                  ],
                  "description": "P1 pages now; P4 and P5 only push."
                },
                "description": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "entity": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "details": {
                  "type": "object"
                }
              },
              "required": [
                "action",
                "alias",
                "message",
                "priority",
                "description",
                "tags",
                "entity",
                "details"
              ]
            }
          }
        },
        "required": [
          "outcome",
          "events"
        ]
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "alert.created",
                "alert.acknowledged",
                "alert.closed",
                "alert.exhausted",
                "notification.failed",
                "approval.requested",
                "approval.decided",
                "coverage.requested",
                "coverage.accepted",
                "coverage.cancelled",
                "handoff.note"
              ]
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "url",
          "events",
          "enabled",
          "createdAt"
        ]
      },
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "scope": {
            "type": "string",
            "enum": [
              "read",
              "alert",
              "admin"
            ]
          },
          "prefix": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "scope",
          "prefix",
          "createdAt",
          "revokedAt"
        ]
      },
      "Org": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "plan": {
            "type": "string"
          },
          "allowInternational": {
            "type": "boolean"
          },
          "flapThreshold": {
            "type": "integer",
            "description": "0 turns flapping control off. Otherwise: an alias that opens this many times within `flapWindowMinutes` is held."
          },
          "flapWindowMinutes": {
            "type": "integer"
          },
          "flapHoldMinutes": {
            "type": "integer",
            "description": "How long a flapping alert is held before it pages if it is still open."
          },
          "preshiftTestHours": {
            "type": "integer",
            "description": "0 is off. Otherwise someone about to go on call within this many hours gets a quiet push test (daytime only, at most weekly)."
          }
        },
        "required": [
          "id",
          "name",
          "plan",
          "allowInternational",
          "flapThreshold",
          "flapWindowMinutes",
          "flapHoldMinutes",
          "preshiftTestHours"
        ]
      },
      "ApprovalInput": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "The question, in a sentence."
          },
          "description": {
            "type": "string"
          },
          "context": {
            "type": "object",
            "additionalProperties": true,
            "description": "What the human should see before deciding: the diff, the command, the amount. Up to 8 KB."
          },
          "teamId": {
            "type": "string",
            "description": "Page this team's escalation policy. Optional with a single team, or with `relatedAlertId`.",
            "format": "uuid"
          },
          "userIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "relatedAlertId": {
            "type": "string",
            "description": "The alert this question is about. The request and the answer go into its timeline; the approval is filed under its team and pages whoever acknowledged it first, unless `teamId` or `userIds` say otherwise.",
            "format": "uuid"
          },
          "priority": {
            "type": "string",
            "enum": [
              "P1",
              "P2",
              "P3",
              "P4",
              "P5"
            ],
            "description": "P1 pages now; P4 and P5 only push."
          },
          "timeoutSeconds": {
            "type": "integer",
            "description": "30 to 604800. Default 3600.",
            "minimum": 30,
            "maximum": 604800
          },
          "onTimeout": {
            "type": "string",
            "enum": [
              "deny",
              "approve"
            ],
            "description": "What a timeout means. `deny` is the safe default."
          },
          "required": {
            "type": "integer",
            "description": "Approvals needed. Any denial denies at once. Default 1.",
            "minimum": 1,
            "maximum": 5
          },
          "deciders": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Who may answer by text, call or app. Default: whoever was paged."
          }
        },
        "required": [
          "title"
        ]
      },
      "Approval": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "context": {
            "type": "object",
            "additionalProperties": true
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "approved",
              "denied",
              "expired",
              "cancelled"
            ]
          },
          "decision": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "approve",
              "deny",
              null
            ],
            "description": "The effective answer: the human's, or for `expired` what `onTimeout` says. Null while pending or cancelled."
          },
          "requiredApprovals": {
            "type": "integer"
          },
          "approvals": {
            "type": "integer"
          },
          "votes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "by": {
                  "type": "string"
                },
                "decision": {
                  "type": "string",
                  "enum": [
                    "approve",
                    "deny"
                  ]
                },
                "note": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "via": {
                  "type": "string"
                },
                "at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "by",
                "decision",
                "note",
                "via",
                "at"
              ]
            }
          },
          "deciders": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "onTimeout": {
            "type": "string",
            "enum": [
              "deny",
              "approve"
            ]
          },
          "timeoutAt": {
            "type": "string",
            "format": "date-time"
          },
          "alertId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The page that asks the question."
          },
          "alertNumber": {
            "type": [
              "integer",
              "null"
            ]
          },
          "relatedAlertId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The alert the question is about, if the request named one."
          },
          "relatedAlertNumber": {
            "type": [
              "integer",
              "null"
            ]
          },
          "requester": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "decidedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "decidedBy": {
            "type": [
              "string",
              "null"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "title",
          "description",
          "context",
          "status",
          "decision",
          "requiredApprovals",
          "approvals",
          "votes",
          "deciders",
          "onTimeout",
          "timeoutAt",
          "alertId",
          "alertNumber",
          "relatedAlertId",
          "relatedAlertNumber",
          "requester",
          "createdAt",
          "decidedAt",
          "decidedBy",
          "note"
        ]
      },
      "CoverageInput": {
        "type": "object",
        "properties": {
          "requesterId": {
            "type": "string",
            "description": "Whose on-call time this is. They must be on call at some point in the window.",
            "format": "uuid"
          },
          "startsAt": {
            "type": "string",
            "format": "date-time"
          },
          "endsAt": {
            "type": "string",
            "format": "date-time"
          },
          "note": {
            "type": "string",
            "description": "Why, for whoever sees the request."
          },
          "offeredTo": {
            "type": "string",
            "description": "Ask one person (they accept or decline). Omit to ask anyone on the schedule's team.",
            "format": "uuid"
          }
        },
        "required": [
          "requesterId",
          "startsAt",
          "endsAt"
        ]
      },
      "Coverage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "scheduleId": {
            "type": "string",
            "format": "uuid"
          },
          "scheduleName": {
            "type": [
              "string",
              "null"
            ]
          },
          "requester": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "name"
            ]
          },
          "startsAt": {
            "type": "string",
            "format": "date-time"
          },
          "endsAt": {
            "type": "string",
            "format": "date-time"
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "offeredTo": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "accepted",
              "declined",
              "cancelled",
              "expired"
            ]
          },
          "takenBy": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "resolvedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "scheduleId",
          "scheduleName",
          "requester",
          "startsAt",
          "endsAt",
          "note",
          "offeredTo",
          "status",
          "takenBy",
          "createdAt",
          "resolvedAt"
        ]
      },
      "HandoffNote": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "teamId": {
            "type": "string",
            "format": "uuid"
          },
          "author": {
            "type": "string"
          },
          "authorId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "body": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "teamId",
          "author",
          "authorId",
          "body",
          "createdAt"
        ]
      },
      "CalendarFeed": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "label": {
            "type": "string"
          },
          "scheduleId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "teamId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "userId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastReadAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "label",
          "scheduleId",
          "teamId",
          "userId",
          "createdAt",
          "lastReadAt"
        ]
      },
      "LoadReport": {
        "type": "object",
        "properties": {
          "period": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string",
                "format": "date-time"
              },
              "to": {
                "type": "string",
                "format": "date-time"
              },
              "days": {
                "type": "integer"
              }
            },
            "required": [
              "from",
              "to",
              "days"
            ]
          },
          "totals": {
            "type": "object",
            "properties": {
              "onCallHours": {
                "type": "number"
              },
              "pages": {
                "type": "integer"
              },
              "nightPages": {
                "type": "integer"
              }
            },
            "required": [
              "onCallHours",
              "pages",
              "nightPages"
            ]
          },
          "people": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "userId": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "timezone": {
                  "type": "string"
                },
                "onCallHours": {
                  "type": "number"
                },
                "nightHours": {
                  "type": "number",
                  "description": "22:00 to 07:00 where they live."
                },
                "weekendHours": {
                  "type": "number"
                },
                "pages": {
                  "type": "integer",
                  "description": "Alerts that paged them (not test pages or admin notices)."
                },
                "nightPages": {
                  "type": "integer"
                },
                "acknowledged": {
                  "type": "integer"
                },
                "medianMinutesToAck": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "shareOfHours": {
                  "type": "number",
                  "description": "Percent of everyone's on-call hours."
                },
                "shareOfPages": {
                  "type": "number"
                }
              },
              "required": [
                "userId",
                "name",
                "timezone",
                "onCallHours",
                "nightHours",
                "weekendHours",
                "pages",
                "nightPages",
                "acknowledged",
                "medianMinutesToAck",
                "shareOfHours",
                "shareOfPages"
              ]
            }
          },
          "suggestions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "heavy_load",
                    "night_pages",
                    "idle"
                  ]
                },
                "userId": {
                  "type": "string",
                  "format": "uuid"
                },
                "title": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "userId",
                "title",
                "detail"
              ]
            }
          }
        },
        "required": [
          "period",
          "totals",
          "people",
          "suggestions"
        ]
      },
      "Check": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "info",
              "warn",
              "fail"
            ]
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "fix": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "status",
          "title",
          "detail"
        ]
      },
      "TestResult": {
        "type": "object",
        "properties": {
          "alertId": {
            "type": "string",
            "format": "uuid"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "outcome": {
            "type": "string",
            "enum": [
              "pending",
              "passed",
              "failed"
            ]
          },
          "acknowledged": {
            "type": "boolean"
          },
          "acknowledgedAfterSeconds": {
            "type": [
              "integer",
              "null"
            ]
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "channel": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "error": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "seconds": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "description": "Send to delivery."
                }
              },
              "required": [
                "channel",
                "status",
                "error",
                "seconds"
              ]
            }
          }
        },
        "required": [
          "alertId",
          "at",
          "outcome",
          "acknowledged",
          "acknowledgedAfterSeconds",
          "channels"
        ]
      },
      "Readiness": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "level": {
            "type": "string",
            "enum": [
              "ready",
              "warnings",
              "at_risk",
              "unreachable"
            ],
            "description": "`unreachable`: nothing verified to reach them by. `at_risk`: a check failed. `warnings`: reachable, but fragile."
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            }
          },
          "lastTest": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "alertId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "passed",
                      "failed"
                    ]
                  },
                  "acknowledged": {
                    "type": "boolean"
                  },
                  "channels": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "channel": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "error": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "channel",
                        "status",
                        "error"
                      ]
                    }
                  }
                },
                "required": [
                  "alertId",
                  "at",
                  "status",
                  "acknowledged",
                  "channels"
                ]
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "userId",
          "name",
          "level",
          "checks",
          "lastTest"
        ]
      },
      "OrgReadiness": {
        "type": "object",
        "properties": {
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "summary": {
            "type": "object",
            "properties": {
              "people": {
                "type": "integer"
              },
              "ready": {
                "type": "integer"
              },
              "warnings": {
                "type": "integer"
              },
              "atRisk": {
                "type": "integer"
              },
              "unreachable": {
                "type": "integer"
              },
              "onCallReachable": {
                "type": "boolean",
                "description": "Everyone on call right now can be paged."
              },
              "gaps": {
                "type": "integer"
              }
            },
            "required": [
              "people",
              "ready",
              "warnings",
              "atRisk",
              "unreachable",
              "onCallReachable",
              "gaps"
            ]
          },
          "onCallNow": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "scheduleId": {
                  "type": "string",
                  "format": "uuid"
                },
                "scheduleName": {
                  "type": "string"
                },
                "user": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "name": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "level": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "issues": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "scheduleId",
                "scheduleName",
                "user",
                "level",
                "issues"
              ]
            }
          },
          "people": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "userId": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "level": {
                  "type": "string",
                  "enum": [
                    "ready",
                    "warnings",
                    "at_risk",
                    "unreachable"
                  ]
                },
                "issues": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "status",
                      "title"
                    ]
                  }
                },
                "lastTest": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "alertId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "status": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "alertId",
                        "at",
                        "status"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "userId",
                "name",
                "level",
                "issues",
                "lastTest"
              ]
            }
          },
          "gaps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "no_one_on_call",
                    "coverage_gap",
                    "empty_policy",
                    "empty_step",
                    "team_without_policy"
                  ]
                },
                "title": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                },
                "scheduleId": {
                  "type": "string",
                  "format": "uuid"
                },
                "from": {
                  "type": "string",
                  "format": "date-time"
                },
                "to": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "kind",
                "title",
                "detail"
              ]
            }
          }
        },
        "required": [
          "generatedAt",
          "summary",
          "onCallNow",
          "people",
          "gaps"
        ]
      },
      "NoiseReport": {
        "type": "object",
        "properties": {
          "period": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string",
                "format": "date-time"
              },
              "to": {
                "type": "string",
                "format": "date-time"
              },
              "days": {
                "type": "integer"
              }
            },
            "required": [
              "from",
              "to",
              "days"
            ]
          },
          "totals": {
            "type": "object",
            "properties": {
              "alerts": {
                "type": "integer"
              },
              "acknowledged": {
                "type": "integer"
              },
              "ackRate": {
                "type": "number",
                "description": "Percent of alerts somebody acknowledged."
              },
              "selfResolved": {
                "type": "integer",
                "description": "Closed without ever being acknowledged."
              },
              "suppressed": {
                "type": "integer"
              },
              "repeats": {
                "type": "integer",
                "description": "Repeats that de-duplicated into an open alert."
              },
              "urgent": {
                "type": "integer",
                "description": "P1-P3 alerts that were not held."
              },
              "urgentUnacknowledged": {
                "type": "integer"
              }
            },
            "required": [
              "alerts",
              "acknowledged",
              "ackRate",
              "selfResolved",
              "suppressed",
              "repeats",
              "urgent",
              "urgentUnacknowledged"
            ]
          },
          "integrations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "kind": {
                  "type": "string"
                },
                "source": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "alerts": {
                  "type": "integer"
                },
                "acknowledged": {
                  "type": "integer"
                },
                "ackRate": {
                  "type": "number"
                },
                "selfResolved": {
                  "type": "integer"
                },
                "suppressed": {
                  "type": "integer"
                },
                "repeats": {
                  "type": "integer"
                },
                "medianMinutesToAck": {
                  "type": [
                    "number",
                    "null"
                  ]
                }
              },
              "required": [
                "id",
                "name",
                "kind",
                "source",
                "alerts",
                "acknowledged",
                "ackRate",
                "selfResolved",
                "suppressed",
                "repeats",
                "medianMinutesToAck"
              ]
            }
          },
          "topAliases": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "alias": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "integrationId": {
                  "type": "string",
                  "format": "uuid"
                },
                "integrationName": {
                  "type": "string"
                },
                "priority": {
                  "type": "string"
                },
                "opened": {
                  "type": "integer"
                },
                "occurrences": {
                  "type": "integer"
                },
                "acknowledged": {
                  "type": "integer"
                },
                "selfResolved": {
                  "type": "integer"
                },
                "medianMinutesOpen": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "lastAt": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "alias",
                "message",
                "integrationId",
                "integrationName",
                "priority",
                "opened",
                "occurrences",
                "acknowledged",
                "selfResolved",
                "medianMinutesOpen",
                "lastAt"
              ]
            }
          },
          "suggestions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "never_acknowledged",
                    "flapping",
                    "storm",
                    "repeats",
                    "low_acted_rate"
                  ]
                },
                "severity": {
                  "type": "string",
                  "enum": [
                    "high",
                    "medium",
                    "low"
                  ]
                },
                "title": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                },
                "rule": {
                  "$ref": "#/components/schemas/RoutingRuleInput",
                  "description": "Create it with `POST /v1/routing-rules` to apply the suggestion."
                },
                "org": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "number"
                  },
                  "description": "Organization settings that would apply it, for `PATCH /v1/org`."
                },
                "alias": {
                  "type": "string"
                },
                "integrationId": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "required": [
                "kind",
                "severity",
                "title",
                "detail"
              ]
            }
          }
        },
        "required": [
          "period",
          "totals",
          "integrations",
          "topAliases",
          "suggestions"
        ]
      },
      "Condition": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string",
            "enum": [
              "message",
              "description",
              "alias",
              "source",
              "entity",
              "priority",
              "integration",
              "team",
              "tag",
              "detail",
              "time"
            ]
          },
          "key": {
            "type": "string",
            "description": "For `detail`: which detail."
          },
          "op": {
            "type": "string",
            "enum": [
              "is",
              "is_not",
              "contains",
              "not_contains",
              "glob",
              "in",
              "exists",
              "not_exists"
            ],
            "description": "Case-insensitive. `glob` supports `*` and `?`. `exists` and `not_exists` are for tags and details."
          },
          "value": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ],
            "description": "Text, or a list for `in`. `integration` and `team` conditions take ids."
          },
          "timezone": {
            "type": "string",
            "description": "For `time`."
          },
          "days": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "For `time`: 0 is Sunday. Omit for every day."
          },
          "from": {
            "type": "string",
            "description": "For `time`: `HH:MM`."
          },
          "to": {
            "type": "string",
            "description": "For `time`: `HH:MM`. Earlier than `from` runs past midnight."
          }
        },
        "required": [
          "field"
        ]
      },
      "Recurrence": {
        "type": "object",
        "properties": {
          "days": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "time": {
            "type": "string",
            "description": "`HH:MM` in `timezone`."
          },
          "durationMinutes": {
            "type": "integer"
          },
          "timezone": {
            "type": "string"
          }
        },
        "required": [
          "time",
          "durationMinutes",
          "timezone"
        ]
      },
      "MaintenanceWindowInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "startsAt": {
            "type": "string",
            "description": "A one-off window: start...",
            "format": "date-time"
          },
          "endsAt": {
            "type": "string",
            "description": "...and end.",
            "format": "date-time"
          },
          "recurrence": {
            "$ref": "#/components/schemas/Recurrence"
          },
          "teamId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "integrationId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Condition"
            },
            "description": "All must match. Empty: every alert in scope."
          },
          "onEnd": {
            "type": "string",
            "enum": [
              "release",
              "discard"
            ],
            "description": "What happens to alerts still firing when the window ends: page for them (default) or drop them."
          }
        },
        "required": [
          "name"
        ]
      },
      "MaintenanceWindow": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "startsAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "endsAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "recurrence": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Recurrence"
              },
              {
                "type": "null"
              }
            ]
          },
          "teamId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "integrationId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Condition"
            }
          },
          "onEnd": {
            "type": "string",
            "enum": [
              "release",
              "discard"
            ]
          },
          "active": {
            "type": "boolean",
            "description": "In effect right now."
          },
          "activeUntil": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdBy": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "startsAt",
          "endsAt",
          "recurrence",
          "teamId",
          "integrationId",
          "conditions",
          "onEnd",
          "active",
          "activeUntil",
          "createdBy",
          "createdAt"
        ]
      },
      "RuleActions": {
        "type": "object",
        "properties": {
          "routeToTeamId": {
            "type": "string",
            "description": "Page this team's escalation policy instead of the integration's.",
            "format": "uuid"
          },
          "setPriority": {
            "type": "string",
            "enum": [
              "P1",
              "P2",
              "P3",
              "P4",
              "P5"
            ],
            "description": "P1 pages now; P4 and P5 only push."
          },
          "suppress": {
            "type": "boolean",
            "description": "Record the alert but never page for it."
          },
          "addTags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "groupBy": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "One page per group: the first alert pages, later ones attach to it until it closes. Fields: `message`, `alias`, `source`, `entity`, `priority`, `integration`, `team`, `tag:<name>`, `detail:<key>`."
          },
          "groupWindowMinutes": {
            "type": "integer",
            "description": "How long after the first alert others join its group. Default 10."
          }
        }
      },
      "RoutingRuleInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "integrationId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Condition"
            }
          },
          "actions": {
            "$ref": "#/components/schemas/RuleActions"
          },
          "stop": {
            "type": "boolean",
            "description": "Stop evaluating later rules after this one matches."
          },
          "enabled": {
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "actions"
        ]
      },
      "RoutingRule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "position": {
            "type": "integer"
          },
          "enabled": {
            "type": "boolean"
          },
          "integrationId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Condition"
            }
          },
          "actions": {
            "$ref": "#/components/schemas/RuleActions"
          },
          "stop": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "position",
          "enabled",
          "integrationId",
          "conditions",
          "actions",
          "stop",
          "createdAt"
        ]
      },
      "Heartbeat": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "teamId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "intervalSeconds": {
            "type": "integer",
            "description": "How often a ping is expected."
          },
          "graceSeconds": {
            "type": "integer",
            "description": "Extra time allowed before it counts as missed."
          },
          "priority": {
            "type": "string",
            "enum": [
              "P1",
              "P2",
              "P3",
              "P4",
              "P5"
            ],
            "description": "P1 pages now; P4 and P5 only push."
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "description": "Custom alert text."
          },
          "enabled": {
            "type": "boolean"
          },
          "state": {
            "type": "string",
            "enum": [
              "new",
              "up",
              "down"
            ],
            "description": "`new` until the first ping; `down` while its alert is open."
          },
          "lastPingAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "downSince": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "dueAt": {
            "type": "string",
            "description": "When the next ping must arrive by.",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "name",
          "teamId",
          "intervalSeconds",
          "graceSeconds",
          "priority",
          "message",
          "enabled",
          "state",
          "lastPingAt",
          "downSince",
          "dueAt",
          "createdAt"
        ]
      },
      "HeartbeatInput": {
        "type": "object",
        "properties": {
          "intervalSeconds": {
            "type": "integer",
            "description": "Between 10 seconds and one year.",
            "minimum": 10
          },
          "graceSeconds": {
            "type": "integer",
            "default": 0
          },
          "priority": {
            "type": "string",
            "enum": [
              "P1",
              "P2",
              "P3",
              "P4",
              "P5"
            ],
            "description": "P1 pages now; P4 and P5 only push.",
            "default": "P2"
          },
          "message": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": "boolean",
            "default": true
          },
          "teamId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        },
        "required": [
          "intervalSeconds"
        ]
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique per delivery attempt group: use it to de-duplicate.",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "enum": [
              "alert.created",
              "alert.acknowledged",
              "alert.closed",
              "alert.exhausted",
              "notification.failed",
              "approval.requested",
              "approval.decided",
              "coverage.requested",
              "coverage.accepted",
              "coverage.cancelled",
              "handoff.note"
            ]
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "properties": {
              "alert": {
                "$ref": "#/components/schemas/Alert"
              },
              "approval": {
                "$ref": "#/components/schemas/Approval"
              },
              "acknowledgedBy": {
                "$ref": "#/components/schemas/AcknowledgedBy",
                "description": "On `alert.acknowledged`: who acknowledged, as of that moment."
              },
              "coverage": {
                "$ref": "#/components/schemas/Coverage"
              },
              "handoff": {
                "$ref": "#/components/schemas/HandoffNote"
              }
            }
          }
        },
        "required": [
          "id",
          "type",
          "occurredAt",
          "data"
        ]
      }
    }
  },
  "webhooks": {
    "alert": {
      "post": {
        "summary": "An alert event",
        "description": "Sent to your webhook endpoints. Verify `X-Treason-Signature` before trusting it. `data.alert` is present for alert and approval events; approvals add `data.approval`, cover requests `data.coverage`, handoff notes `data.handoff`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx acknowledges. Anything else is retried with backoff."
          }
        }
      }
    }
  }
}
