{
  "$id": "https://docs.honeybadger.io/guides/integrations/payloads/v2/occurred.schema.json",
  "title": "occurred webhook payload (v2)",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$ref": "#/$defs/WebhookV2OccurredEvent",
  "$defs": {
    "WebhookV2OccurredEvent": {
      "description": "An error occurred, or a fault passed its notification rate threshold.",
      "allOf": [
        {
          "$ref": "#/$defs/WebhookV2Event"
        },
        {
          "type": "object",
          "required": [
            "project",
            "fault",
            "notice"
          ],
          "properties": {
            "event": {
              "type": "string",
              "enum": [
                "occurred",
                "rate_exceeded"
              ]
            },
            "project": {
              "$ref": "#/$defs/WebhookV2Project"
            },
            "fault": {
              "$ref": "#/$defs/WebhookV2Fault"
            },
            "notice": {
              "$ref": "#/$defs/WebhookV2Notice"
            },
            "context": {
              "description": "The notice's request context, as the notifier sent it. Usually an object, but any JSON value. Moved here from `notice.request`.\n"
            },
            "custom_fields": {
              "description": "The integration's custom fields, when it has any."
            }
          }
        }
      ]
    },
    "WebhookV2Event": {
      "type": "object",
      "description": "The fields every v2 webhook body carries. Each event adds the records it's about. A v2 body has no `payload_version`; that's how it differs from the later versions.\n",
      "required": [
        "event",
        "message"
      ],
      "not": {
        "required": [
          "payload_version"
        ]
      },
      "properties": {
        "event": {
          "type": "string",
          "description": "The event's name, the same as its key under `webhooks`.",
          "examples": [
            "occurred"
          ]
        },
        "message": {
          "type": "string",
          "description": "A one-line summary of the event, as notifications show it."
        },
        "actor": {
          "allOf": [
            {
              "$ref": "#/$defs/WebhookV2User"
            }
          ],
          "description": "The person who caused the event. Absent when Honeybadger, or an API token with no user, did."
        }
      }
    },
    "WebhookV2User": {
      "type": "object",
      "description": "A Honeybadger user, or an account by its owner's details.",
      "required": [
        "id",
        "email",
        "name"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "examples": [
            4821
          ]
        },
        "email": {
          "type": "string",
          "examples": [
            "jane@example.com"
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "Jane Doe"
          ]
        }
      }
    },
    "WebhookV2Project": {
      "type": "object",
      "description": "The project the event belongs to.",
      "required": [
        "id",
        "name",
        "created_at",
        "disable_public_links",
        "pivotal_project_id",
        "asana_workspace_id",
        "token",
        "github_project",
        "environments",
        "owner",
        "last_notice_at",
        "earliest_notice_at",
        "unresolved_fault_count",
        "fault_count",
        "active",
        "users",
        "sites",
        "team_id"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "examples": [
            1234
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "Billing API"
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "disable_public_links": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "pivotal_project_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "asana_workspace_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "token": {
          "type": "string",
          "description": "The project's ingestion key, the one its notifiers report with."
        },
        "github_project": {
          "type": [
            "string",
            "null"
          ],
          "description": "The repository of the project's newest GitHub integration.",
          "examples": [
            "acme/billing"
          ]
        },
        "environments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WebhookV2Environment"
          }
        },
        "owner": {
          "allOf": [
            {
              "$ref": "#/$defs/WebhookV2User"
            }
          ],
          "description": "The account that owns the project."
        },
        "last_notice_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "earliest_notice_at": {
          "type": "string",
          "format": "date-time",
          "description": "The oldest notice the plan's retention keeps."
        },
        "unresolved_fault_count": {
          "type": "integer"
        },
        "fault_count": {
          "type": "integer"
        },
        "active": {
          "type": "boolean",
          "description": "Whether the account is active."
        },
        "users": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WebhookV2User"
          }
        },
        "sites": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WebhookV2ProjectSite"
          }
        },
        "team_id": {
          "type": [
            "integer",
            "null"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "The project's errors page. Sent on `volume_spike` only."
        }
      }
    },
    "WebhookV2Environment": {
      "type": "object",
      "description": "One of the project's environments.",
      "required": [
        "id",
        "project_id",
        "name",
        "notifications",
        "created_at",
        "updated_at"
      ],
      "properties": {
        "id": {
          "type": "integer"
        },
        "project_id": {
          "type": "integer"
        },
        "name": {
          "type": "string",
          "examples": [
            "production"
          ]
        },
        "notifications": {
          "type": "boolean",
          "description": "Whether errors in this environment send notifications."
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "WebhookV2ProjectSite": {
      "type": "object",
      "description": "One of the project's uptime sites, in brief.",
      "required": [
        "id",
        "active",
        "last_checked_at",
        "name",
        "state",
        "url"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "active": {
          "type": "boolean"
        },
        "last_checked_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "name": {
          "type": "string"
        },
        "state": {
          "type": "string",
          "examples": [
            "up"
          ]
        },
        "url": {
          "type": "string",
          "description": "The checked URL, as entered."
        }
      }
    },
    "WebhookV2Fault": {
      "type": "object",
      "description": "The fault (a unique error) the event is about. When the account is inactive, only `id`, `project_id`, `message` and `created_at` are sent.\n",
      "required": [
        "id",
        "project_id",
        "message",
        "created_at"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "examples": [
            12345
          ]
        },
        "project_id": {
          "type": "integer",
          "examples": [
            1234
          ]
        },
        "klass": {
          "type": [
            "string",
            "null"
          ],
          "description": "Error class name",
          "examples": [
            "NoMethodError"
          ]
        },
        "message": {
          "type": [
            "string",
            "null"
          ],
          "description": "The error message, without the class name.",
          "examples": [
            "undefined method 'foo' for nil"
          ]
        },
        "component": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "UsersController"
          ]
        },
        "action": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "show"
          ]
        },
        "environment": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "production"
          ]
        },
        "resolved": {
          "type": "boolean"
        },
        "ignored": {
          "type": "boolean"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "project_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "comments_count": {
          "type": "integer"
        },
        "notices_count": {
          "type": "integer"
        },
        "last_notice_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "tags": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        },
        "assignee": {
          "type": [
            "string",
            "null"
          ],
          "description": "The assignee's email address.",
          "examples": [
            "jane@example.com"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "deploy": {
          "anyOf": [
            {
              "$ref": "#/$defs/WebhookV2Deploy"
            },
            {
              "type": "null"
            }
          ],
          "description": "The latest deploy to the fault's environment."
        }
      }
    },
    "WebhookV2Deploy": {
      "type": "object",
      "description": "A deploy.",
      "required": [
        "environment",
        "revision",
        "repository",
        "local_username",
        "created_at",
        "changelog",
        "url"
      ],
      "properties": {
        "environment": {
          "type": "string",
          "examples": [
            "production"
          ]
        },
        "revision": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "850510ab072102729e6967cf89f28b740c61311b"
          ]
        },
        "repository": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "git@github.com:acme/billing.git"
          ]
        },
        "local_username": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "deploy-bot"
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "changelog": {
          "type": [
            "array",
            "null"
          ],
          "description": "Commits in the deploy, as the deploy notification sent them.",
          "items": {}
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "WebhookV2Notice": {
      "type": "object",
      "description": "The occurrence that triggered the event. When the account is inactive, only `id`, `fault_id` and `created_at` are sent. When the notice is older than the plan keeps, its request and environment data are sent empty.\n",
      "required": [
        "id",
        "fault_id",
        "created_at"
      ],
      "properties": {
        "id": {
          "type": "integer"
        },
        "fault_id": {
          "type": "integer"
        },
        "token": {
          "type": "string",
          "format": "uuid",
          "description": "The notice's UUID."
        },
        "message": {
          "type": [
            "string",
            "null"
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "environment": {
          "description": "The server environment the notifier reported (`environment-name`, hostname and the like). Defined by the notifier.\n"
        },
        "request": {
          "type": "object",
          "description": "The request the error happened in. `context` is moved to the body's top-level `context`.\n",
          "properties": {
            "url": {
              "type": [
                "string",
                "null"
              ]
            },
            "component": {
              "type": [
                "string",
                "null"
              ]
            },
            "action": {
              "type": [
                "string",
                "null"
              ]
            },
            "params": {
              "description": "Request parameters, as the notifier sent them. Usually an object, but any JSON value.\n"
            },
            "session": {
              "description": "Session data, as the notifier sent it. Usually an object, but any JSON value, including null.\n"
            }
          }
        },
        "backtrace": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WebhookV2BacktraceLine"
          }
        },
        "application_trace": {
          "type": "array",
          "description": "The frames of `backtrace` in the project's own code.",
          "items": {
            "$ref": "#/$defs/WebhookV2BacktraceLine"
          }
        },
        "web_environment": {
          "description": "CGI-style request environment, as the notifier sent it."
        },
        "deploy": {
          "anyOf": [
            {
              "$ref": "#/$defs/WebhookV2Deploy"
            },
            {
              "type": "null"
            }
          ]
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "WebhookV2BacktraceLine": {
      "type": "object",
      "description": "One backtrace frame, as the notifier reported it or a source map rewrote it. Notifiers can send keys beyond the ones listed here, such as `column`.\n",
      "additionalProperties": true,
      "properties": {
        "number": {
          "type": [
            "string",
            "integer",
            "null"
          ],
          "description": "The line number. Ruby notifiers send a string, PHP and JavaScript an integer.",
          "examples": [
            "42"
          ]
        },
        "file": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "[PROJECT_ROOT]/app/models/user.rb"
          ]
        },
        "method": {
          "type": [
            "string",
            "null"
          ],
          "examples": [
            "full_name"
          ]
        },
        "context": {
          "type": "string",
          "description": "`app` for a frame in the project's own code, otherwise `all`.",
          "enum": [
            "app",
            "all"
          ]
        },
        "application_file": {
          "type": "string",
          "description": "The file's path within the project. Sent for `app` frames."
        },
        "source": {
          "description": "Lines of source around the frame, usually an object keyed by line number. Null when a source map has no source for the frame, and notifiers can send other shapes.\n"
        }
      }
    }
  }
}
