{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lucca/json-schema/lucca-events-read-schema.json",
  "title": "events.read",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lucca-events-api-openapi.yml#/components/schemas/events.read",
  "allOf": [
    {
      "$ref": "#/$defs/events"
    },
    {
      "$ref": "#/$defs/event.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.embedded": {
      "type": "object",
      "properties": {
        "embedded": {
          "description": "No embedded resources on a event(s) response. Expect an empty object if embedded are requested.",
          "type": [
            "object",
            "null"
          ]
        }
      }
    },
    "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"
        }
      ]
    },
    "events": {
      "title": "events",
      "description": "A collection of [event](./event) objects.",
      "allOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "events"
            },
            "url": {
              "type": "string",
              "format": "uri"
            },
            "totalCount": {
              "type": [
                "integer",
                "null"
              ],
              "format": "int64",
              "minimum": 0,
              "description": "Total number of event resources across all pages that satisfy query parameters."
            },
            "items": {
              "type": "array",
              "minItems": 0,
              "maxItems": 100,
              "description": "Paginated list of event resources.",
              "items": {
                "$ref": "#/$defs/event"
              }
            }
          }
        },
        {
          "$ref": "#/$defs/collection.links"
        }
      ]
    },
    "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"
      ]
    }
  }
}