{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/yelp/json-schema/yelp-get-events-response-schema.json",
  "title": "GetEventsResponse",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/yelp-leads-api-openapi.yml#/components/schemas/GetEventsResponse",
  "type": "object",
  "properties": {
    "events": {
      "description": "The events. Each event might be of a different type, which can be identified by the `event_type` field.\n\nAll events will have an attribute `fallback_text` inside the `event_content` object. The other attributes inside the object will be different depending on the actual `event_type`.\n",
      "type": "array",
      "items": {
        "$ref": "#/$defs/LeadEvent"
      }
    }
  },
  "required": [
    "events"
  ],
  "$defs": {
    "LeadEvent": {
      "type": "object",
      "anyOf": [
        {
          "$ref": "#/$defs/LeadEventTextMessage"
        },
        {
          "$ref": "#/$defs/LeadEventAttachments"
        },
        {
          "$ref": "#/$defs/LeadEventOther"
        }
      ]
    },
    "LeadEventAttachments": {
      "title": "Attachments",
      "type": "object",
      "description": "A lead event representing one or multiple attachments. Any attachment may also have a corresponding event with the same ID and the event_type `TEXT`.\n",
      "allOf": [
        {
          "$ref": "#/$defs/LeadEventBase"
        },
        {
          "type": "object",
          "properties": {
            "event_type": {
              "description": "The type of the event. The value will be `ATTACHMENT_GROUPING` for this event type",
              "type": "string",
              "enum": [
                "ATTACHMENT_GROUPING"
              ]
            },
            "event_content": {
              "title": "Event Content",
              "allOf": [
                {
                  "type": "object",
                  "properties": {
                    "attachments": {
                      "description": "An array of attachments",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "description": "The unique ID for this attachment",
                            "type": "string"
                          },
                          "url": {
                            "description": "A url to the attachment content. Accessible for up to 24 hours after querying this endpoint",
                            "type": "string"
                          },
                          "resource_name": {
                            "description": "The name of the resource",
                            "type": "string",
                            "x-nullable": true
                          },
                          "mime_type": {
                            "description": "The mime type of the file",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "url",
                          "resource_name",
                          "mime_type"
                        ]
                      }
                    }
                  }
                },
                {
                  "$ref": "#/$defs/LeadEventContentBase"
                }
              ]
            }
          },
          "required": [
            "event_type",
            "event_content"
          ]
        }
      ]
    },
    "LeadEventBase": {
      "type": "object",
      "description": "A lead event",
      "properties": {
        "id": {
          "description": "The unique ID for this event. *Note* Attachments with a text message will cause two events with the same ID, one with the event type `TEXT` and the other with the event type `ATTACHMENT_GROUPING`",
          "type": "string"
        },
        "cursor": {
          "description": "A cursor used for pagination. Not guaranteed to be unique or consistent over time",
          "type": "string"
        },
        "time_created": {
          "description": "The time when the event was created",
          "type": "string",
          "format": "date-time"
        },
        "user_type": {
          "description": "Whether the user that created this event is a consumer or biz user",
          "type": "string",
          "enum": [
            "CONSUMER",
            "BIZ"
          ]
        },
        "user_id": {
          "description": "The user's ID. *Note* This ID is only unique for the same user type.",
          "type": "string"
        },
        "user_display_name": {
          "description": "The user's display name. Typically the user's first name, and first initial of last name when present.",
          "type": "string"
        },
        "channel": {
          "description": "The channel through which a BIZ event was sent. Only present on events with `user_type` = `BIZ`.\nPlease contact Yelp if you want to receive this field in the response.\n\nPossible values:\n- `API-SELF` - The event was sent via the Leads API by the same OAuth client that is making the current request.\n- `SMS` - The event was sent via SMS.\n- `EMAIL` - The event was sent via email.\n- `YELP_CHAT` - The event was sent via Yelp Chat.\n\nIf this field is absent, the channel is unknown.\n",
          "type": "string",
          "enum": [
            "API-SELF",
            "SMS",
            "EMAIL",
            "YELP_CHAT"
          ]
        }
      },
      "required": [
        "id",
        "cursor",
        "time_created",
        "user_type",
        "user_id",
        "user_display_name"
      ]
    },
    "LeadEventContentBase": {
      "type": "object",
      "required": [
        "fallback_text"
      ],
      "properties": {
        "fallback_text": {
          "description": "A fallback text that can be used to display if the client doesn't support displaying the event type. Will always be set, but might be empty. For the event_type `OTHER` it is the only field.",
          "type": "string"
        }
      }
    },
    "LeadEventOther": {
      "title": "Other",
      "type": "object",
      "description": "A lead event representing an other message. Other might be any other event type that is not available as a structured response through this API, such as structured Request a Lead or Request Phone Call requests. In this case the API still returns a text that will contain all the important information of any such event. Yelp uses the `fallback_text` for older Clients.\n",
      "allOf": [
        {
          "$ref": "#/$defs/LeadEventBase"
        },
        {
          "type": "object",
          "properties": {
            "event_type": {
              "description": "The type of the event. The value will be `OTHER` for this event type",
              "type": "string",
              "enum": [
                "OTHER"
              ]
            },
            "event_content": {
              "description": "Event Content",
              "$ref": "#/$defs/LeadEventContentBase"
            }
          },
          "required": [
            "event_type",
            "event_content"
          ]
        }
      ]
    },
    "LeadEventTextMessage": {
      "title": "Text Message",
      "type": "object",
      "description": "A lead event representing a text message",
      "allOf": [
        {
          "$ref": "#/$defs/LeadEventBase"
        },
        {
          "type": "object",
          "properties": {
            "event_type": {
              "description": "The type of the event. The value will be `TEXT` for this event type",
              "type": "string",
              "enum": [
                "TEXT"
              ]
            },
            "event_content": {
              "type": "object",
              "title": "Event Content",
              "allOf": [
                {
                  "type": "object",
                  "properties": {
                    "text": {
                      "description": "The text of the message",
                      "type": "string"
                    }
                  },
                  "required": [
                    "text"
                  ]
                },
                {
                  "$ref": "#/$defs/LeadEventContentBase"
                }
              ]
            }
          },
          "required": [
            "event_type",
            "event_content"
          ]
        }
      ]
    }
  }
}