{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codeqr-io/json-schema/codeqr-io-click-event-schema.json",
  "title": "ClickEvent",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codeqr-io-openapi.yml#/components/schemas/ClickEvent",
  "type": "object",
  "properties": {
    "event": {
      "type": "string",
      "enum": [
        "click"
      ]
    },
    "timestamp": {
      "type": "string"
    },
    "click": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "continent": {
          "type": "string"
        },
        "country": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "device": {
          "type": "string"
        },
        "browser": {
          "type": "string"
        },
        "os": {
          "type": "string"
        },
        "referer": {
          "type": "string"
        },
        "refererUrl": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "ip": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "url",
        "continent",
        "country",
        "city",
        "device",
        "browser",
        "os",
        "referer",
        "refererUrl",
        "type",
        "ip"
      ]
    },
    "link": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The unique ID of the short link."
        },
        "domain": {
          "type": "string",
          "description": "The domain of the short link. If not provided, the main domain of the project will be used (or `codeqr.link` if the project has no domains)."
        },
        "key": {
          "type": "string",
          "description": "The slug of the short link. If not provided, a random 7-character slug will be generated."
        },
        "url": {
          "type": "string"
        },
        "archived": {
          "type": "boolean"
        },
        "expiresAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "expiredUrl": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "default": null
        },
        "trackConversion": {
          "type": "boolean"
        },
        "flexible": {
          "type": "boolean",
          "default": false,
          "description": "Whether the short link is flexible."
        },
        "doIndex": {
          "type": "boolean"
        },
        "password": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "externalId": {
          "type": [
            "string",
            "null"
          ]
        },
        "proxy": {
          "type": "boolean"
        },
        "title": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "description": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "image": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "video": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "rewrite": {
          "type": "boolean"
        },
        "ios": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "android": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "geo": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": {
            "type": "string"
          },
          "default": null
        },
        "rules": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object",
            "properties": {
              "attribute": {
                "type": "string",
                "enum": [
                  "device",
                  "country",
                  "utm_source",
                  "utm_medium",
                  "utm_campaign",
                  "referrer",
                  "language",
                  "city",
                  "region",
                  "continent",
                  "utm_term",
                  "utm_content"
                ]
              },
              "operator": {
                "type": "string",
                "enum": [
                  "equals",
                  "not_equals"
                ]
              },
              "value": {
                "type": "string"
              },
              "url": {
                "type": "string"
              }
            },
            "required": [
              "attribute",
              "operator",
              "value",
              "url"
            ]
          }
        },
        "publicStats": {
          "type": "boolean"
        },
        "tagId": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "tags": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/TagSchema"
          },
          "default": null
        },
        "folderId": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "comments": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "notificationToken": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "shortLink": {
          "type": "string",
          "format": "uri",
          "description": "The complete URL of the short link, including the https protocol (for example, `https://codeqr.link/try`)."
        },
        "qrCode": {
          "type": "string",
          "format": "uri",
          "description": "The complete QR code URL for the short link (for example, `https://api.codeqr.io/qr?url=https://codeqr.link/try`)."
        },
        "utm_source": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "utm_medium": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "utm_campaign": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "utm_term": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "utm_content": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "userId": {
          "type": [
            "string",
            "null"
          ]
        },
        "projectId": {
          "type": "string",
          "description": "The ID of the project of the short link."
        },
        "clicks": {
          "type": "number",
          "default": 0,
          "description": "The number of clicks on the short link."
        },
        "leads": {
          "type": "number",
          "default": 0,
          "description": "The number of leads generated by the short link."
        },
        "sales": {
          "type": "number",
          "default": 0,
          "description": "The number of sales generated by the short link."
        },
        "saleAmount": {
          "type": "number",
          "default": 0,
          "description": "The amount of the sale generated by the link."
        },
        "lastClicked": {
          "nullable": true,
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "string"
            }
          ]
        },
        "createdAt": {
          "type": "string"
        },
        "updatedAt": {
          "type": "string"
        },
        "preRedirection": {
          "type": "boolean",
          "default": false,
          "description": "Whether the short link has pre-redirection."
        },
        "pageId": {
          "type": [
            "string",
            "null"
          ],
          "description": "The ID of the page to redirect to before the link destination."
        },
        "pageUrl": {
          "type": [
            "string",
            "null"
          ],
          "description": "The URL of the page to redirect to before the link destination."
        },
        "isFormMandatory": {
          "type": "boolean",
          "default": false,
          "description": "If the form is mandatory for the page."
        },
        "filled": {
          "type": "boolean",
          "default": false,
          "description": "Whether the link is filled or not."
        },
        "useAsTemplate": {
          "type": "boolean",
          "default": false,
          "description": "Whether this link should be used as a reusable template."
        }
      },
      "required": [
        "id",
        "domain",
        "key",
        "expiredUrl",
        "flexible",
        "password",
        "title",
        "description",
        "image",
        "video",
        "ios",
        "android",
        "geo",
        "tagId",
        "tags",
        "folderId",
        "comments",
        "notificationToken",
        "utm_source",
        "utm_medium",
        "utm_campaign",
        "utm_term",
        "utm_content",
        "projectId",
        "clicks",
        "leads",
        "sales",
        "saleAmount",
        "createdAt",
        "updatedAt",
        "preRedirection",
        "isFormMandatory",
        "filled",
        "useAsTemplate"
      ]
    },
    "click_id": {
      "type": "string",
      "description": "Deprecated. Use `click.id` instead.",
      "deprecated": true
    },
    "link_id": {
      "type": "string",
      "description": "Deprecated. Use `link.id` instead.",
      "deprecated": true
    },
    "domain": {
      "type": "string",
      "description": "Deprecated. Use `link.domain` instead.",
      "deprecated": true
    },
    "key": {
      "type": "string",
      "description": "Deprecated. Use `link.key` instead.",
      "deprecated": true
    },
    "url": {
      "type": "string",
      "description": "Deprecated. Use `click.url` instead.",
      "deprecated": true
    },
    "continent": {
      "type": "string",
      "description": "Deprecated. Use `click.continent` instead.",
      "deprecated": true
    },
    "country": {
      "type": "string",
      "description": "Deprecated. Use `click.country` instead.",
      "deprecated": true
    },
    "city": {
      "type": "string",
      "description": "Deprecated. Use `click.city` instead.",
      "deprecated": true
    },
    "device": {
      "type": "string",
      "description": "Deprecated. Use `click.device` instead.",
      "deprecated": true
    },
    "browser": {
      "type": "string",
      "description": "Deprecated. Use `click.browser` instead.",
      "deprecated": true
    },
    "os": {
      "type": "string",
      "description": "Deprecated. Use `click.os` instead.",
      "deprecated": true
    },
    "type": {
      "type": "string",
      "description": "Deprecated. Use `click.qr` instead.",
      "deprecated": true
    },
    "ip": {
      "type": "string",
      "description": "Deprecated. Use `click.ip` instead.",
      "deprecated": true
    }
  },
  "required": [
    "event",
    "click",
    "link",
    "click_id",
    "link_id",
    "domain",
    "key",
    "url",
    "continent",
    "country",
    "city",
    "device",
    "browser",
    "os",
    "type",
    "ip"
  ],
  "$defs": {
    "TagSchema": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The unique ID of the tag."
        },
        "name": {
          "type": "string",
          "description": "The name of the tag."
        },
        "color": {
          "type": "string",
          "enum": [
            "red",
            "yellow",
            "green",
            "blue",
            "purple",
            "pink",
            "brown"
          ],
          "description": "The color of the tag."
        }
      },
      "required": [
        "id",
        "name",
        "color"
      ],
      "title": "Tag"
    }
  }
}