{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tune.toys/schemas/platform/webhook.schema.json",
  "title": "Webhook",
  "description": "A pro-tier webhook endpoint. Deliveries are signed with TuneToys-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + body)>.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "id": { "$ref": "common.schema.json#/$defs/EntityId" },
    "appId": { "$ref": "common.schema.json#/$defs/EntityId" },
    "url": { "type": "string", "maxLength": 2048, "pattern": "^https://" },
    "events": {
      "type": "array",
      "minItems": 1,
      "maxItems": 5,
      "uniqueItems": true,
      "items": {
        "enum": [
          "version_published",
          "listing_updated",
          "review_created",
          "purchase_completed",
          "update_feed_changed"
        ]
      }
    },
    "state": { "enum": ["pending", "active", "paused", "disabled"] },
    "verifiedAt": {
      "anyOf": [
        { "$ref": "common.schema.json#/$defs/Timestamp" },
        { "type": "null" }
      ]
    },
    "createdAt": { "$ref": "common.schema.json#/$defs/Timestamp" },
    "updatedAt": { "$ref": "common.schema.json#/$defs/Timestamp" },
    "version": { "type": "integer", "minimum": 1 }
  },
  "required": [
    "id",
    "appId",
    "url",
    "events",
    "state",
    "verifiedAt",
    "createdAt",
    "updatedAt",
    "version"
  ]
}
