{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rizamo-com/json-schema/rizamo-com-webhook-endpoint-schema.json",
  "title": "WebhookEndpoint",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rizamo-com-openapi.json#/components/schemas/WebhookEndpoint",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "url": {
      "type": "string",
      "format": "uri"
    },
    "description": {
      "type": "string"
    },
    "events": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WebhookEventType"
          }
        },
        {
          "type": "null"
        }
      ],
      "description": "The event types it receives. Null: every type, those Rizamo adds later included. The inbox's (`comment.received`, `message.received`, `message.sent`) and comment automations' (`comment_automation.*`) carry what people wrote: an endpoint a key or agent made, or last pointed at its `url`, gets them only if it had `inbox:read` (`automations:read` for automations), whatever this lists."
    },
    "profileIds": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ],
      "description": "Only events of these profiles, and of those only the ones its person reaches now (`onBehalfOf`). Null: every profile's, and the events of no profile. Empty once every profile it was limited to is deleted: it is then disabled. Someone limited to some profiles only sees and makes endpoints within them."
    },
    "status": {
      "enum": [
        "active",
        "failing",
        "disabled"
      ],
      "type": "string",
      "description": "active: sends, and its last attempt was delivered (or none was made yet). failing: sends, but its last attempt failed; after 10 failures in a row its deliveries wait while one at a time tries it (`breaker`). disabled: sends nothing, see `disabledReason`."
    },
    "disabledReason": {
      "anyOf": [
        {
          "enum": [
            "by_request",
            "gone",
            "failing",
            "profile_deleted"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "by_request: someone set `enabled` to false. gone: the endpoint answered 410 Gone. failing: its breaker was open and nothing got through for 5 days; for these two Rizamo emails the team's owners and editors. profile_deleted: every profile it was limited to was deleted, which leaves `profileIds` empty; give it profiles to enable it again. Null while it sends."
    },
    "breaker": {
      "enum": [
        "closed",
        "open"
      ],
      "type": "string",
      "description": "open: it failed 10 times in a row, so its deliveries wait and one at a time tries it every 15 minutes; the first one delivered, or a test that gets through, sends the rest. closed: deliveries go as they come. A new `url` starts closed."
    },
    "failingSince": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "description": "Its first failed attempt of the failures in a row (failures hours apart, further than the retries' spacing, start anew). Null once an attempt is delivered."
    },
    "disablesAt": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "description": "When Rizamo disables it unless an attempt is delivered first: `failingSince` and 5 days, while its breaker is open. Null otherwise."
    },
    "successRate": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Of the attempts in the last 7 days, the percent delivered (a 2xx answer). Null with none."
    },
    "lastDeliveryAt": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "description": "When Rizamo last tried to deliver to it, whatever the answer."
    },
    "createdBy": {
      "anyOf": [
        {
          "$ref": "#/$defs/Actor"
        },
        {
          "type": "null"
        }
      ]
    },
    "onBehalfOf": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "userId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "userId",
            "name"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "The person it sends for: whoever made it or last pointed it at its `url`, or the person behind the API key or agent that did. It sends only events of the profiles they reach now (events of no profile only while they reach every profile), owners and they alone see and manage it, and it is deleted when they leave the team. Null once they are no longer on the team: it sends nothing until an owner changes it, which makes them its person."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "url",
    "description",
    "events",
    "profileIds",
    "status",
    "disabledReason",
    "breaker",
    "failingSince",
    "disablesAt",
    "successRate",
    "lastDeliveryAt",
    "createdBy",
    "onBehalfOf",
    "createdAt",
    "updatedAt"
  ],
  "$defs": {
    "Actor": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "agent"
            },
            "agent": {
              "anyOf": [
                {
                  "enum": [
                    "claude",
                    "chatgpt",
                    "claudecode",
                    "cursor",
                    "codex",
                    "gemini",
                    "perplexity",
                    "openclaw",
                    "n8n",
                    "make",
                    "zapier"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "name": {
              "type": "string"
            },
            "agentId": {
              "type": "string"
            },
            "onBehalfOf": {
              "type": "object",
              "properties": {
                "userId": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "userId",
                "name"
              ],
              "description": "The person whose agent it is, who connected it and whom it acts as, with their role: \"Ana via Claude Code\". Events from before 2026-11-02 have it too, with the person's name now. Left out of an agent with no person, and of other records from before. After the person's erasure, `name` is \"A former member\" and `userId` empty."
            }
          },
          "required": [
            "type",
            "agent",
            "name"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "user"
            },
            "userId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "initials": {
              "type": "string"
            }
          },
          "required": [
            "type",
            "userId",
            "name",
            "initials"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "api_key"
            },
            "keyId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "type",
            "keyId",
            "name"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "automation"
            },
            "automationId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "type",
            "automationId",
            "name"
          ]
        }
      ]
    },
    "WebhookEventType": {
      "enum": [
        "post.created",
        "post.updated",
        "post.scheduled",
        "post.unscheduled",
        "post.published",
        "post.failed",
        "post.deleted",
        "post.restored",
        "post.target.published",
        "post.target.failed",
        "post.target.updated",
        "post.target.deleted",
        "comment.received",
        "message.received",
        "message.sent",
        "comment_automation.sent",
        "comment_automation.failed",
        "comment_automation.paused",
        "account.connected",
        "account.disconnected",
        "account.updated",
        "account.removed"
      ],
      "type": "string"
    }
  }
}