{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/postzen-dev/json-schema/postzen-dev-webhook-create-request-schema.json",
  "title": "WebhookCreateRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/postzen-dev-webhooks-api-openapi.yml#/components/schemas/WebhookCreateRequest",
  "type": "object",
  "required": [
    "name",
    "url",
    "events",
    "profileAccess"
  ],
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "Public HTTPS endpoint URL."
    },
    "events": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/WebhookEvent"
      }
    },
    "profileAccess": {
      "type": "string",
      "enum": [
        "all_profiles",
        "selected_profiles"
      ],
      "description": "all_profiles receives events for every profile. selected_profiles requires profileIds."
    },
    "profileIds": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Required for selected_profiles and omitted or empty for all_profiles."
    },
    "secret": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 256,
      "writeOnly": true,
      "description": "Optional HMAC signing secret. Omit or send null to create an unsigned endpoint."
    },
    "customHeaders": {
      "type": "array",
      "maxItems": 20,
      "items": {
        "$ref": "#/$defs/WebhookCustomHeader"
      }
    },
    "isActive": {
      "type": "boolean",
      "default": true
    }
  },
  "$defs": {
    "WebhookCustomHeader": {
      "type": "object",
      "required": [
        "name",
        "value"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "HTTP header name. Content-Type, transport headers, and X-PostZen-* names are reserved."
        },
        "value": {
          "type": "string",
          "maxLength": 4096,
          "writeOnly": true,
          "description": "Plaintext header value. PostZen encrypts it at rest and never returns it."
        }
      }
    },
    "WebhookEvent": {
      "type": "string",
      "enum": [
        "post.scheduled",
        "post.published",
        "post.partially_failed",
        "post.failed",
        "post.cancelled",
        "post.platform.published",
        "post.platform.failed",
        "post.external.created",
        "account.connected",
        "account.needs_reauth",
        "account.disconnected",
        "analytics.synced",
        "conversation.started",
        "message.received",
        "message.sent",
        "comment.received",
        "contact.tag_added",
        "contact.tag_removed",
        "contact.field_changed",
        "webhook.test"
      ],
      "description": "Webhook event type. See the Webhook Events section for each event's trigger and payload. Receivers should tolerate additional event types in future API versions."
    }
  }
}