{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "title": "User Created Webhook Schema",
  "description": "Sent whenever a new user is created in SaaSquatch program where the classic program is disabled.",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "title": "User Id",
      "description": "The user's unique identifier"
    },
    "accountId": {
      "type": "string",
      "title": "Account Id",
      "description": "The user's unique account identifier"
    },
    "email": {
      "type": [
        "string",
        "null"
      ],
      "title": "Email",
      "description": "The user's email address"
    },
    "firstName": {
      "type": [
        "string",
        "null"
      ],
      "title": "First Name",
      "description": "The user's first name"
    },
    "lastName": {
      "type": [
        "string",
        "null"
      ],
      "title": "Last Name",
      "description": "The user's last name"
    },
    "imageUrl": {
      "type": [
        "string",
        "null"
      ],
      "title": "Image Url",
      "description": "The URL to an image of this user"
    },
    "firstSeenIP": {
      "type": [
        "string",
        "null"
      ],
      "title": "First Seen IP",
      "description": "The IP address of this user when they were first seen by SaaSquatch"
    },
    "lastSeenIP": {
      "type": [
        "string",
        "null"
      ],
      "title": "Last Seen IP",
      "description": "The IP address of this user when they were most recently seen by SaaSquatch"
    },
    "dateCreated": {
      "type": "integer",
      "title": "Date Created",
      "description": "A timestamp of the date this user was created"
    },
    "locale": {
      "type": [
        "string",
        "null"
      ],
      "title": "Locale",
      "description": "This user's unique locale"
    },
    "countryCode": {
      "type": [
        "string",
        "null"
      ],
      "title": "Country Code",
      "description": "The user's country code"
    },
    "referralCodes": {
      "$schema": "http://json-schema.org/draft-06/schema#",
      "title": "Referral Codes",
      "description": "A map of programs to referral codes.",
      "type": "object",
      "patternProperties": {
        "^[a-zA-Z0-9-]{1,64}$": {
          "type": "string",
          "title": "Referral Code",
          "description": "The primary referral code associated with the programId key"
        }
      },
      "additionalProperties": false
    },
    "referable": {
      "type": "boolean",
      "title": "Referable",
      "description": "True if this user can be referred in a program by other users"
    },
    "referredByCodes": {
      "type": "array",
      "title": "Referred By Codes",
      "description": "Any codes used to refer this user",
      "items": {
        "type": "string"
      }
    },
    "cookieId": {
      "type": [
        "string",
        "null"
      ],
      "title": "Anonymous Cookie User Id",
      "description": "The anonymous cookie user identifier associated with this user if applicable (see anonymous users)"
    },
    "dateBlocked": {
      "type": [
        "string",
        "null"
      ],
      "title": "Date Blocked",
      "description": "The date the referral was blocked"
    },
    "customFields": {
      "title": "Custom Fields",
      "description": "Any custom fields set for this user",
      "$schema": "http://json-schema.org/draft-06/schema#",
      "type": "object",
      "patternProperties": {
        "^[a-zA-Z0-9_]{1,64}$": {
          "$schema": "http://json-schema.org/draft-06/schema#",
          "anyOf": [
            {
              "type": "string",
              "maxLength": 1024
            },
            {
              "type": "boolean"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "maxProperties": 100
    },
    "segments": {
      "type": "array",
      "title": "User Segments",
      "description": "Any segments this user belongs to",
      "items": {
        "type": "string"
      }
    },
    "programShareLinks": {
      "$schema": "http://json-schema.org/draft-06/schema#",
      "title": "Program Share Links",
      "description": "Links this user can share to make referrals",
      "type": "object",
      "patternProperties": {
        "^[a-zA-Z0-9-]{1,64}$": {
          "type": "object",
          "title": "Program Share Link",
          "description": "The primary share links available for this program",
          "properties": {
            "cleanShareLink": {
              "type": "string",
              "title": "Clean Link for Given Program",
              "description": "If the program's primary link is a vanity link then this will be the unencoded link, if not it is the UNKNOWN engagement medium and UNKOWN share medium link"
            },
            "MOBILE": {
              "title": "Mobile Share Links",
              "description": "Share links tracked with the MOBILE engagement medium",
              "$ref": "#/properties/programShareLinks/definitions/subShareLinks"
            },
            "EMAIL": {
              "title": "Email Share Links",
              "description": "Share links tracked with the EMAIL engagement medium",
              "$ref": "#/properties/programShareLinks/definitions/subShareLinks"
            },
            "UNKNOWN": {
              "title": "Share Links",
              "description": "Share links tracked with the UNKNOWN engagement medium",
              "$ref": "#/properties/programShareLinks/definitions/subShareLinks"
            }
          },
          "required": [
            "cleanShareLink",
            "MOBILE",
            "EMAIL",
            "UNKNOWN"
          ],
          "additionalProperties": false
        }
      },
      "definitions": {
        "subShareLinks": {
          "type": "object",
          "properties": {
            "DIRECT": {
              "type": "string",
              "title": "Direct Share Link",
              "description": "Share link associated with the DIRECT share medium"
            }
          },
          "required": [
            "DIRECT"
          ],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "id",
    "accountId",
    "dateCreated",
    "referable"
  ],
  "additionalProperties": false
}