{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lucca/json-schema/lucca-webhook-deliveries-read-schema.json",
  "title": "webhook-deliveries.read",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lucca-webhooks-api-openapi.yml#/components/schemas/webhook-deliveries.read",
  "allOf": [
    {
      "$ref": "#/$defs/webhook-deliveries"
    },
    {
      "$ref": "#/$defs/webhook-delivery.embedded"
    }
  ],
  "$defs": {
    "business-establishment-reference": {
      "title": "business-establishment-reference",
      "description": "Reference to a [business-establishment](../organization/business-establishment) resource.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "const": "business-establishment"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "collection.links": {
      "type": "object",
      "properties": {
        "links": {
          "title": "Links",
          "description": "Links to related resources",
          "type": [
            "object",
            "null"
          ],
          "required": [
            "prev",
            "next"
          ],
          "properties": {
            "prev": {
              "description": "Link to the previous page, or `null` when there is none.\nIt may be set on the first page, and then leads to an empty page.",
              "allOf": [
                {
                  "$ref": "#/$defs/page-link"
                }
              ]
            },
            "next": {
              "description": "Link to the next page, or `null` when there is none: stop paging when `next` is `null`.\nIt may be set on the last page when that page is full, and then leads to an empty page whose `next` is `null`.",
              "allOf": [
                {
                  "$ref": "#/$defs/page-link"
                }
              ]
            }
          }
        }
      }
    },
    "event": {
      "title": "event",
      "description": "Represents a change made to the state of a resource.",
      "x-tags": [
        "Events"
      ],
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique string identifier of this event."
        },
        "type": {
          "type": "string",
          "const": "event"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Absolute URL for the event resource."
        },
        "apiVersion": {
          "type": "string",
          "format": "date",
          "description": "API version of the resource representation contained in data. Not to be confused with the API version of the representation of this present event, which is indicated in the `Api-Version` HTTP header."
        },
        "topic": {
          "description": "Indicates which type of event occurred. Usually concatenates the name of the object type with the kind of change (\"created\", \"updated\" or \"deleted\").",
          "allOf": [
            {
              "$ref": "#/$defs/event.topic"
            }
          ]
        },
        "occurredAt": {
          "type": "string",
          "format": "date-time",
          "description": "Timezoned timestamp of the moment when this event occurred."
        },
        "source": {
          "type": "string",
          "format": "uri",
          "description": "URL of the tenant. Ensures unicity of {source} + {id}."
        },
        "data": {
          "type": "object",
          "description": "Representation of the resource whose change triggered the event. Please note that this is the representation of the resource just after the change, and it may have changed again since then.",
          "additionalProperties": true
        },
        "businessEstablishment": {
          "description": "Business Establishment of the Resource in the Event, if there is one.",
          "anyOf": [
            {
              "$ref": "#/$defs/business-establishment-reference"
            },
            {
              "type": "null"
            }
          ]
        },
        "previousAttributes": {
          "description": "Only sent on `*.updated` event topics. Keys are the list of modified attributes. Values are the values of these attributes before the change.\n\nThis is only available for some resources. If a value in the dictionary is NULL, then it can either mean that the original value was NULL or that we can't retrieve them for this Resource.",
          "type": "object",
          "additionalProperties": true
        },
        "links": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "retry": {
              "type": "object",
              "properties": {
                "href": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          }
        }
      }
    },
    "event-reference": {
      "title": "event-reference",
      "description": "Reference to an [(webhook-)event](../events/event) resource.",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "const": "event",
          "readOnly": true
        },
        "url": {
          "type": "string",
          "format": "uri",
          "readOnly": true
        }
      }
    },
    "event.topic": {
      "description": "List of topics",
      "oneOf": [
        {
          "type": "string",
          "title": "test.created",
          "const": "test.created"
        },
        {
          "type": "string",
          "title": "employee.created",
          "const": "employee.created"
        },
        {
          "type": "string",
          "title": "employee.updated",
          "const": "employee.updated"
        },
        {
          "type": "string",
          "title": "employment.created",
          "const": "employment.created"
        },
        {
          "type": "string",
          "title": "employment.updated",
          "const": "employment.updated"
        },
        {
          "type": "string",
          "title": "employment.deleted",
          "const": "employment.deleted"
        },
        {
          "type": "string",
          "title": "job-position.created",
          "const": "job-position.created"
        },
        {
          "type": "string",
          "title": "job-position.updated",
          "const": "job-position.updated"
        },
        {
          "type": "string",
          "title": "job-position.deleted",
          "const": "job-position.deleted"
        },
        {
          "type": "string",
          "title": "employee-attribute.created",
          "const": "employee-attribute.created"
        },
        {
          "type": "string",
          "title": "employee-attribute.updated",
          "const": "employee-attribute.updated"
        },
        {
          "type": "string",
          "title": "employee-attribute.deleted",
          "const": "employee-attribute.deleted"
        }
      ]
    },
    "page-link": {
      "title": "page-link",
      "description": "Link to another page of a collection.",
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "href": {
          "type": "string",
          "format": "uri",
          "description": "URL of the page."
        }
      },
      "required": [
        "href"
      ]
    },
    "webhook-deliveries": {
      "title": "webhook-deliveries",
      "description": "A collection of webhook-delivery objects.",
      "allOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "webhook-deliveries"
            },
            "url": {
              "type": "string",
              "format": "uri"
            },
            "totalCount": {
              "type": [
                "integer",
                "null"
              ],
              "format": "int64",
              "minimum": 0,
              "description": "Total number of webhook-delivery resources across all pages that satisfy query parameters."
            },
            "items": {
              "type": "array",
              "minItems": 0,
              "maxItems": 100,
              "description": "Paginated list of webhook-delivery resources.",
              "items": {
                "$ref": "#/$defs/webhook-delivery"
              }
            }
          }
        },
        {
          "$ref": "#/$defs/collection.links"
        }
      ]
    },
    "webhook-delivery": {
      "title": "webhook-delivery",
      "x-tags": [
        "Webhooks"
      ],
      "description": "A webhook-delivery is the object that represents the job to send an event to a [webhook-endpoint](./webhook-endpoint). It will lead to one or more [webhook-delivery-attempt](./webhook-delivery-attempt).",
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Uniquely identifies the webhook-delivery."
        },
        "type": {
          "type": "string",
          "const": "webhook-delivery"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "nextAttemptAt": {
          "description": "Timestamp of the next planned webhook-delivery-attempt (UTC).",
          "type": "string",
          "format": "date-time"
        },
        "attemptsCount": {
          "description": "Number of times this event has been attempted to be delivered.",
          "type": "integer",
          "format": "int32",
          "minimum": 0
        },
        "status": {
          "description": "Indicates whether the event has been delivered or not.",
          "type": "string",
          "enum": [
            "delivered",
            "undelivered",
            "failed"
          ],
          "x-enumDescriptions": {
            "delivered": "Webhook-delivery was successful.",
            "undelivered": "Webhook-delivery failed but a new\nwebhook-delivery-attempt is scheduled.",
            "failed": "Webhook-delivery failed and no new\nwebhook-delivery-attempt will be made."
          }
        },
        "event": {
          "$ref": "#/$defs/event-reference"
        },
        "webhookEndpoint": {
          "$ref": "#/$defs/webhook-endpoint-reference"
        },
        "links": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": false,
          "properties": {
            "attempts": {
              "type": "object",
              "properties": {
                "href": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          }
        }
      }
    },
    "webhook-delivery.embedded": {
      "type": "object",
      "properties": {
        "embedded": {
          "description": "Embeds the representation of resources related to the webhook-delivery(ies).\n\nOnly returned if requested by the API client: `?include=embedded`.",
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "event": {
              "description": "Webhook-event(s) that are the payload for these deliveries (cf. `webhookDeliveryAttempt.webhookDelivery.event`).\n\nStructured as a dictionary of [(webhook-)events](../events/event) indexed by their ID.",
              "type": [
                "object",
                "null"
              ],
              "additionalProperties": {
                "$ref": "#/$defs/event"
              }
            }
          }
        }
      }
    },
    "webhook-endpoint-reference": {
      "title": "webhook-endpoint-reference",
      "description": "Reference to a [webhook-endpoint](../webhooks/webhook-endpoint) resource.",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "const": "webhook-endpoint",
          "readOnly": true
        },
        "url": {
          "type": "string",
          "format": "uri",
          "readOnly": true
        }
      }
    }
  }
}