{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://servicenow.com/schemas/servicenow/user.json",
  "title": "ServiceNow User",
  "description": "A ServiceNow user record from the sys_user table representing a person who can authenticate and interact with the platform.",
  "type": "object",
  "required": ["sys_id", "user_name"],
  "properties": {
    "sys_id": {
      "type": "string",
      "pattern": "^[a-f0-9]{32}$",
      "description": "The unique 32-character system identifier for the user."
    },
    "user_name": {
      "type": "string",
      "maxLength": 40,
      "description": "The login user name."
    },
    "first_name": {
      "type": ["string", "null"],
      "maxLength": 50,
      "description": "The user's first name."
    },
    "middle_name": {
      "type": ["string", "null"],
      "maxLength": 50,
      "description": "The user's middle name."
    },
    "last_name": {
      "type": ["string", "null"],
      "maxLength": 50,
      "description": "The user's last name."
    },
    "name": {
      "type": ["string", "null"],
      "maxLength": 151,
      "description": "The user's full display name."
    },
    "email": {
      "type": ["string", "null"],
      "format": "email",
      "description": "The user's email address."
    },
    "phone": {
      "type": ["string", "null"],
      "maxLength": 40,
      "description": "The user's business phone number."
    },
    "mobile_phone": {
      "type": ["string", "null"],
      "maxLength": 40,
      "description": "The user's mobile phone number."
    },
    "title": {
      "type": ["string", "null"],
      "maxLength": 60,
      "description": "The user's job title."
    },
    "employee_number": {
      "type": ["string", "null"],
      "description": "The employee number."
    },
    "department": {
      "$ref": "#/$defs/ReferenceField",
      "description": "The user's department."
    },
    "company": {
      "$ref": "#/$defs/ReferenceField",
      "description": "The user's company."
    },
    "manager": {
      "$ref": "#/$defs/ReferenceField",
      "description": "The user's direct manager."
    },
    "location": {
      "$ref": "#/$defs/ReferenceField",
      "description": "The user's primary location."
    },
    "building": {
      "$ref": "#/$defs/ReferenceField",
      "description": "The user's building."
    },
    "cost_center": {
      "$ref": "#/$defs/ReferenceField",
      "description": "The user's cost center."
    },
    "time_zone": {
      "type": ["string", "null"],
      "maxLength": 40,
      "description": "The user's time zone."
    },
    "active": {
      "type": "boolean",
      "description": "Whether the user account is active."
    },
    "locked_out": {
      "type": "boolean",
      "description": "Whether the user account is locked out."
    },
    "vip": {
      "type": "boolean",
      "description": "Whether the user has VIP status."
    },
    "roles": {
      "type": ["string", "null"],
      "description": "Comma-separated list of role names assigned to the user."
    },
    "source": {
      "type": ["string", "null"],
      "description": "The source from which the user record was created."
    },
    "last_login_time": {
      "type": ["string", "null"],
      "format": "date-time",
      "description": "The date and time of the user's last login."
    },
    "failed_attempts": {
      "type": ["integer", "null"],
      "minimum": 0,
      "description": "The number of failed login attempts."
    },
    "photo": {
      "type": ["string", "null"],
      "description": "The URL or reference to the user's photo."
    },
    "sys_created_on": {
      "type": "string",
      "format": "date-time",
      "description": "The date and time the record was created."
    },
    "sys_created_by": {
      "type": "string",
      "description": "The user who created the record."
    },
    "sys_updated_on": {
      "type": "string",
      "format": "date-time",
      "description": "The date and time the record was last updated."
    },
    "sys_updated_by": {
      "type": "string",
      "description": "The user who last updated the record."
    }
  },
  "$defs": {
    "ReferenceField": {
      "type": ["object", "string", "null"],
      "description": "A ServiceNow reference field that can be a sys_id string or an object containing a link and value.",
      "properties": {
        "link": {
          "type": "string",
          "format": "uri",
          "description": "The API URL to the referenced record."
        },
        "value": {
          "type": "string",
          "description": "The sys_id of the referenced record."
        },
        "display_value": {
          "type": "string",
          "description": "The display value of the referenced record."
        }
      }
    }
  }
}
