{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mandala-computer/json-schema/mandala-computer-webhook-schema.json",
  "title": "Webhook",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mandala-computer-openapi.json#/components/schemas/Webhook",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "`whk-` and sixteen hex characters."
    },
    "url": {
      "type": "string",
      "description": "Where deliveries are POSTed. `https://` only. The URL as the platform parsed it, which can differ in spelling from what you sent: the host lower-cased, a default port dropped, a bare origin ending in `/`."
    },
    "description": {
      "type": "string",
      "description": "Free text, for your listing. Empty when you gave none."
    },
    "events": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The event types this subscription receives. **Empty means every type.** The vocabulary is the event socket’s (the computer’s `events_url`) less `file.changed`: `window.opened`, `window.closed`, `window.focused`, `window.blurred`, `clipboard.changed`, `process.exited`, `computer.idle`, `computer.ready`, `computer.started`, `computer.stopped`, `computer.suspended`."
    },
    "computers": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The computer ids this subscription receives events for. **Empty means every computer in scope.** Not checked against your computers when you set it — a subscription may name a computer you are about to create."
    },
    "enabled": {
      "type": "boolean",
      "description": "Whether deliveries are made. Set `false` by the platform when an endpoint has failed for a day, when the account moves to a plan without webhooks, or when the person or key that created it loses access — see `disabled_reason`. Back to `true` by you with `PATCH`, which starts fresh, or, for `plan`, by the platform when you choose a plan again, which starts fresh too."
    },
    "disabled_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why `enabled` is false: `customer` when you disabled it, `failing` when the platform did — a delivery ran out of attempts and nothing had been accepted for 24 hours, counted from the later of the last 2xx and when the subscription was last enabled or its account reactivated — and `plan` when the account moved to a plan without webhooks. A `plan` subscription is enabled again, oldest first, as many as the plan allows, when the account chooses a plan that includes webhooks. `creator_removed` when the person behind `created_by` was removed from the account, left it, or was made a viewer; `key_revoked` when the API key in `created_by` was revoked as leaked from the dashboard. Neither comes back on its own: an owner or member enables it with `PATCH`. `null` while enabled.",
      "enum": [
        "customer",
        "failing",
        "plan",
        "creator_removed",
        "key_revoked",
        null
      ]
    },
    "disabled_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "RFC 3339 timestamp, or `null` while enabled."
    },
    "last_success_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When the endpoint last answered 2xx to any delivery. `null` until it has."
    },
    "last_failure_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When a delivery attempt last failed. `null` until one has."
    },
    "last_status": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The HTTP status of the newest attempt, whatever it was. `null` before any attempt, or when the newest got no answer."
    },
    "last_error": {
      "oneOf": [
        {
          "$ref": "#/$defs/WebhookLastError"
        },
        {
          "type": "null"
        }
      ],
      "description": "Why the newest attempt failed: when its failure was recorded, the status (or `null` for no answer), the one-line error and the delivery it was for. The newest by when the outcome was recorded, so a retry of an old delivery counts; an attempt still in flight does not, and nor does a delivery the platform dropped without sending. It stays until an attempt is accepted, whatever happens to the delivery row. `null` before any attempt has failed, and once the newest attempt was accepted. A failure recorded before this field existed is shown only when it is under six days old and its delivery is still kept, and may be `null` even then."
    },
    "workspace_id": {
      "type": "string",
      "description": "The workspace this subscription is confined to. Present only when it was created with a workspace-scoped API key; absent on an account-wide subscription."
    },
    "created_by": {
      "type": [
        "string",
        "null"
      ],
      "description": "Who created it, or last changed its `url`: the email of the person signed in to the dashboard, or `apikey:` and the `key-` id of the API key they used, as the audit log names them. This is whose removal, demotion to viewer or leaked key disables it (`disabled_reason`). `null` to a workspace-scoped key when it was a person, whose address such a key is not told."
    },
    "created_at": {
      "type": "string",
      "description": "RFC 3339 timestamp."
    },
    "updated_at": {
      "type": "string",
      "description": "RFC 3339 timestamp."
    }
  },
  "required": [
    "id",
    "url",
    "description",
    "events",
    "computers",
    "enabled",
    "disabled_reason",
    "disabled_at",
    "last_success_at",
    "last_failure_at",
    "last_status",
    "last_error",
    "created_by",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "WebhookLastError": {
      "type": "object",
      "properties": {
        "at": {
          "type": "string",
          "description": "When the failure was recorded, RFC 3339: the answer, or the 10-second cut for a timeout."
        },
        "status": {
          "type": [
            "integer",
            "null"
          ],
          "description": "The HTTP status the endpoint answered, or `null` when it gave no answer."
        },
        "error": {
          "type": "string",
          "description": "The one-line error, as on the delivery: `timeout`, `dns`, `refused`, `tls`, `redirect`, `status 503`, …"
        },
        "delivery": {
          "type": "string",
          "description": "The `whd-` id of the delivery the attempt was for. Its row is in `GET /webhooks/{id}/deliveries` until it is pruned, seven days after it was queued."
        }
      },
      "required": [
        "at",
        "status",
        "error",
        "delivery"
      ]
    }
  }
}