{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/peeve-ai/json-schema/peeve-ai-webhook-endpoint-with-secret-schema.json",
  "title": "WebhookEndpointWithSecret",
  "x-generated": "2026-11-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/peeve-ai-openapi.yml#/components/schemas/WebhookEndpointWithSecret",
  "allOf": [
    {
      "$ref": "#/$defs/ObjectEnvelope"
    },
    {
      "type": "object",
      "properties": {
        "data": {
          "allOf": [
            {
              "$ref": "#/$defs/WebhookEndpoint"
            },
            {
              "type": "object",
              "properties": {
                "secret": {
                  "type": "string",
                  "description": "The signing secret (`whsec_…`). **Returned only here and on rotate-secret. It cannot be recovered later.**"
                }
              }
            }
          ]
        }
      }
    }
  ],
  "$defs": {
    "ObjectEnvelope": {
      "type": "object",
      "required": [
        "object",
        "data",
        "request_id"
      ],
      "properties": {
        "object": {
          "type": "string",
          "description": "The resource type, e.g. `lead`."
        },
        "data": {
          "type": "object",
          "additionalProperties": true
        },
        "request_id": {
          "type": "string",
          "description": "Echoed in the `X-Request-Id` header. Quote it to support."
        }
      }
    },
    "WebhookEndpoint": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "object": {
          "type": "string",
          "const": "webhook_endpoint"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "label": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 80
        },
        "events": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "session.started",
              "session.resolved",
              "handoff.created",
              "handoff.message.created",
              "handoff.status.changed",
              "lead.created",
              "lead.status.changed",
              "meeting.booked",
              "meeting.status.changed",
              "billing.payment_failed",
              "billing.subscription.changed",
              "billing.credits_low",
              "billing.credits_expiring",
              "*"
            ]
          }
        },
        "channels": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string",
            "enum": [
              "human",
              "agent",
              "whatsapp",
              "messenger",
              "instagram",
              "email"
            ]
          },
          "description": "`null` means every channel."
        },
        "enabled": {
          "type": "boolean",
          "description": "`false` is paused — reversible, keeps the secret and delivery history."
        },
        "secret_hint": {
          "type": [
            "string",
            "null"
          ],
          "description": "Last 4 characters of the signing secret, so a rotation can be confirmed without exposing it."
        },
        "secret_set_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "last_delivery_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "last_status": {
          "type": [
            "string",
            "null"
          ]
        },
        "last_response_code": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    }
  }
}