{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/reviewflowz-com/json-schema/reviewflowz-com-event-schema.json",
  "title": "Event",
  "description": "What your endpoint receives, plus where it was delivered (deliveries, here only).",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/reviewflowz-com-openapi.json#/components/schemas/Event",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "type": {
      "$ref": "#/$defs/EventType"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "description": "When it happened."
    },
    "data": {
      "type": "object",
      "description": "object: the subject as GET /v3/... returns it now (a review, reply, source, invitation, contact or campaign), or { id, deleted: true } when it's gone. The other keys are facts about this event: source, reason, previous, owner, tag...",
      "properties": {
        "object": {
          "type": "object"
        }
      },
      "additionalProperties": true
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "deliveries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Delivery"
      }
    }
  },
  "$defs": {
    "Delivery": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "endpoint": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "succeeded",
            "failed",
            "exhausted",
            "skipped"
          ],
          "description": "failed: the last try failed and another is scheduled. exhausted: all 8 tries failed. skipped: recorded while the endpoint was off, and not sent when it was turned back on."
        },
        "attempt_count": {
          "type": "integer"
        },
        "last_status_code": {
          "type": [
            "integer",
            "null"
          ]
        },
        "last_attempt_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "next_attempt_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "delivered_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "attempts": {
          "type": "array",
          "description": "On GET /v3/events/{id} only.",
          "items": {
            "type": "object",
            "properties": {
              "attempt": {
                "type": "integer"
              },
              "status_code": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "error": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "response_body": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The first KB of what your endpoint answered."
              },
              "duration_ms": {
                "type": "integer"
              },
              "at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      }
    },
    "EventType": {
      "type": "string",
      "enum": [
        "review.created",
        "review.updated",
        "review.removed",
        "review.reinstated",
        "review.deleted",
        "review.enriched",
        "review.tagged",
        "review.untagged",
        "review.owner_assigned",
        "review.owner_unassigned",
        "reply.drafted",
        "reply.submitted",
        "reply.published",
        "reply.updated",
        "reply.failed",
        "source.created",
        "source.synced",
        "source.access_lost",
        "source.access_restored",
        "source.decommissioned",
        "source.deleted",
        "rating.changed",
        "invitation.sent",
        "invitation.clicked",
        "invitation.skipped",
        "invitation.failed",
        "contact.reviewed",
        "contact.opted_out",
        "campaign.paused",
        "campaign.resumed"
      ]
    }
  }
}