{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codeqr-io/json-schema/codeqr-io-link-schema-schema.json",
  "title": "Link",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codeqr-io-openapi.yml#/components/schemas/LinkSchema",
  "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",
      "format": "uri",
      "description": "The destination URL of the short link."
    },
    "archived": {
      "type": "boolean",
      "default": false,
      "description": "Whether the short link is archived."
    },
    "expiresAt": {
      "type": [
        "string",
        "null"
      ],
      "description": "The date and time when the short link will expire in ISO-8601 format. Must be in the future."
    },
    "expiredUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "The URL to redirect to when the short link expires."
    },
    "trackConversion": {
      "type": "boolean",
      "default": false,
      "description": "[BETA] Whether to track conversions for the short link."
    },
    "flexible": {
      "type": "boolean",
      "default": false,
      "description": "Whether the short link is flexible."
    },
    "doIndex": {
      "type": "boolean",
      "default": false,
      "description": "Whether search engines can index the short link."
    },
    "password": {
      "type": [
        "string",
        "null"
      ],
      "description": "The password required to access the short link destination URL."
    },
    "externalId": {
      "type": [
        "string",
        "null"
      ],
      "description": "This is the ID of the link in your database."
    },
    "proxy": {
      "type": "boolean",
      "default": false,
      "description": "Whether the short link uses the custom link preview feature."
    },
    "title": {
      "type": [
        "string",
        "null"
      ],
      "description": "The title of the short link generated via `api.codeqr.io/metatags`. Will be used for custom link preview if `proxy` is true."
    },
    "description": {
      "type": [
        "string",
        "null"
      ],
      "description": "The description of the short link generated via `api.codeqr.io/metatags`. Will be used for custom link preview if `proxy` is true."
    },
    "image": {
      "type": [
        "string",
        "null"
      ],
      "description": "The image of the short link generated via `api.codeqr.io/metatags`. Will be used for custom link preview if `proxy` is true."
    },
    "video": {
      "type": [
        "string",
        "null"
      ],
      "description": "The video of the short link."
    },
    "rewrite": {
      "type": "boolean",
      "default": false,
      "description": "Whether the short link uses link cloaking."
    },
    "ios": {
      "type": [
        "string",
        "null"
      ],
      "description": "The iOS destination URL for the short link for iOS device targeting."
    },
    "android": {
      "type": [
        "string",
        "null"
      ],
      "description": "The Android destination URL for the short link for Android device targeting."
    },
    "geo": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string"
      },
      "description": "Geographic targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`. Learn more: https://codeqr.link/geo"
    },
    "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"
        ]
      },
      "description": "Smart rules for conditional destination routing by request attribute."
    },
    "publicStats": {
      "type": "boolean",
      "default": false,
      "description": "Whether the short link statistics are publicly accessible."
    },
    "tagId": {
      "type": [
        "string",
        "null"
      ],
      "description": "[DEPRECATED (use `tags` instead)]: The unique ID of the tag assigned to the short link.",
      "deprecated": true
    },
    "tags": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/TagSchema"
      },
      "description": "The tags assigned to the short link."
    },
    "folderId": {
      "type": [
        "string",
        "null"
      ],
      "description": "The unique ID of the folder assigned to the short link."
    },
    "comments": {
      "type": [
        "string",
        "null"
      ],
      "description": "The comments for the short link."
    },
    "notificationToken": {
      "type": [
        "string",
        "null"
      ],
      "description": "The notification token of the short link."
    },
    "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"
      ],
      "description": "The UTM source of the short link."
    },
    "utm_medium": {
      "type": [
        "string",
        "null"
      ],
      "description": "The UTM medium of the short link."
    },
    "utm_campaign": {
      "type": [
        "string",
        "null"
      ],
      "description": "The UTM campaign of the short link."
    },
    "utm_term": {
      "type": [
        "string",
        "null"
      ],
      "description": "The UTM term of the short link."
    },
    "utm_content": {
      "type": [
        "string",
        "null"
      ],
      "description": "The UTM content of the short link."
    },
    "userId": {
      "type": "string",
      "description": "The ID of the user who created the short link."
    },
    "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": {
      "type": [
        "string",
        "null"
      ],
      "description": "The date and time when the short link was last clicked."
    },
    "createdAt": {
      "type": "string",
      "description": "The date and time when the short link was created."
    },
    "updatedAt": {
      "type": "string",
      "description": "The date and time when the short link was last updated."
    },
    "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",
    "url",
    "archived",
    "expiresAt",
    "expiredUrl",
    "trackConversion",
    "flexible",
    "doIndex",
    "password",
    "externalId",
    "proxy",
    "title",
    "description",
    "image",
    "video",
    "rewrite",
    "ios",
    "android",
    "geo",
    "rules",
    "publicStats",
    "tagId",
    "tags",
    "folderId",
    "comments",
    "notificationToken",
    "utm_source",
    "utm_medium",
    "utm_campaign",
    "utm_term",
    "utm_content",
    "userId",
    "projectId",
    "clicks",
    "leads",
    "sales",
    "saleAmount",
    "lastClicked",
    "createdAt",
    "updatedAt",
    "preRedirection",
    "isFormMandatory",
    "filled",
    "useAsTemplate"
  ],
  "$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"
    }
  }
}