{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/0xinsider-com/json-schema/0xinsider-com-webhook-endpoint-schema.json",
  "title": "WebhookEndpoint",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/0xinsider-com-webhooks-api-openapi.yml#/components/schemas/WebhookEndpoint",
  "type": "object",
  "required": [
    "id",
    "object",
    "name",
    "url",
    "event_types",
    "trade_filters",
    "status",
    "verified_at",
    "verification_token_expires_at",
    "failure_count",
    "created_at",
    "updated_at",
    "retry_policy",
    "secret_rotation"
  ],
  "properties": {
    "id": {
      "type": "integer",
      "format": "int64"
    },
    "object": {
      "type": "string",
      "const": "webhook"
    },
    "name": {
      "type": "string"
    },
    "url": {
      "type": "string",
      "format": "uri"
    },
    "event_types": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/WebhookEventType"
      }
    },
    "trade_filters": {
      "$ref": "#/$defs/LargeTradeSubscriptionFilters"
    },
    "status": {
      "$ref": "#/$defs/WebhookStatus"
    },
    "verified_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "verification_token_expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "failure_count": {
      "type": "integer"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "retry_policy": {
      "$ref": "#/$defs/WebhookRetryPolicy"
    },
    "secret_rotation": {
      "$ref": "#/$defs/WebhookSecretRotation"
    },
    "signing_secret": {
      "type": "string",
      "description": "Returned only on create, immediate rotate-secret, staged rotate-secret/prepare, or staged rotate-secret/activate. Never returned by list, get, update, delete, verify, or retire."
    },
    "verification": {
      "$ref": "#/$defs/WebhookVerification"
    }
  },
  "$defs": {
    "LargeTradeSubscriptionFilters": {
      "type": "object",
      "additionalProperties": false,
      "description": "All present fields narrow large_trade_inserted_v2 delivery. Grade is observed at publication; ungraded trades do not match min_grade. An empty object matches every large trade.",
      "properties": {
        "condition_id": {
          "type": "string",
          "description": "Raw provider condition ID or mkt_-prefixed market ID."
        },
        "wallet": {
          "type": "string",
          "pattern": "^0x[a-fA-F0-9]{40}$",
          "description": "Polymarket wallet address; matching is case-insensitive."
        },
        "min_grade": {
          "type": "string",
          "enum": [
            "S",
            "A",
            "B",
            "C",
            "D",
            "F"
          ],
          "description": "S is best; ungraded trades do not match."
        },
        "min_size_usd": {
          "type": "string",
          "pattern": "^[0-9]+(\\.[0-9]{1,6})?$",
          "description": "Positive USD notional as an exact decimal string."
        }
      }
    },
    "WebhookEventType": {
      "type": "string",
      "enum": [
        "large_trade_inserted_v2",
        "large_trades_inserted",
        "whale_trades_inserted",
        "live_sports_updated",
        "trader_synced",
        "whale_trader_synced",
        "large_positions_updated",
        "wallet_grade_changed",
        "suspicious_trade_flagged",
        "insider_radar_flag_raised",
        "sharp_money_flow_detected",
        "smart_money_flow_detected",
        "export_job_ready",
        "export_job_failed",
        "export_job_expired",
        "export_job_cancelled"
      ]
    },
    "WebhookRetryPolicy": {
      "type": "object",
      "required": [
        "max_attempts",
        "terminal_status",
        "retry_horizon_seconds",
        "disable_after_consecutive_failures"
      ],
      "properties": {
        "max_attempts": {
          "type": "integer",
          "const": 8
        },
        "terminal_status": {
          "type": "string",
          "const": "dead_letter"
        },
        "retry_horizon_seconds": {
          "type": "integer",
          "const": 7380,
          "description": "Total wait from a delivery's first failed attempt to its last retry: 60, 120, 240, 480, 960, 1920 and 3600 seconds. A delivery still failing after that is dead_letter."
        },
        "disable_after_consecutive_failures": {
          "type": "integer",
          "const": 8,
          "description": "Consecutive failed attempts, across all of this endpoint's deliveries, after which the endpoint is disabled and its queued deliveries are dead-lettered. Any successful attempt resets the count."
        }
      }
    },
    "WebhookSecretRotation": {
      "type": "object",
      "required": [
        "status",
        "overlap_expires_at"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "idle",
            "pending",
            "overlap"
          ],
          "description": "idle when no staged rotation exists, pending after prepare, and overlap after activate while both signing secrets are accepted."
        },
        "overlap_expires_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When the previous signing secret stops being emitted and accepted. null outside the overlap phase."
        }
      }
    },
    "WebhookStatus": {
      "type": "string",
      "enum": [
        "pending_verification",
        "active",
        "disabled"
      ]
    },
    "WebhookVerification": {
      "type": "object",
      "required": [
        "token",
        "expires_at"
      ],
      "properties": {
        "token": {
          "type": "string",
          "description": "One-time verification token returned only on create or URL change. Pass it to POST /api/v1/webhooks/{id}/verify, which activates the endpoint only when the destination also answers the signed webhook.verification challenge with a 2xx."
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}