{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/clearstreet8e71/json-schema/clearstreet8e71-create-screener-request-schema.json",
  "title": "CreateScreenerRequest",
  "description": "Request body for creating or updating a saved screener configuration",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/clearstreet8e71-screener-api-openapi.yml#/components/schemas/CreateScreenerRequest",
  "type": "object",
  "properties": {
    "columns": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/FieldRef"
      },
      "description": "Structured field references to include when running this screener"
    },
    "filters": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/SearchFilter"
      },
      "description": "Structured search filter criteria"
    },
    "name": {
      "type": [
        "string",
        "null"
      ],
      "description": "The name for this screener configuration"
    },
    "shared": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Whether any user may fetch this screener by id. Omit to leave the\nexisting value unchanged (defaults to `false` when creating)."
    },
    "sorts": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/SortSpec"
      },
      "description": "Multi-field sort specifications"
    }
  },
  "$defs": {
    "FieldLookback": {
      "type": "string",
      "description": "Historical lookback window for price/change fields.",
      "enum": [
        "ONE_DAY",
        "ONE_WEEK",
        "ONE_MONTH",
        "THREE_MONTHS",
        "SIX_MONTHS",
        "YEAR_TO_DATE",
        "ONE_YEAR"
      ]
    },
    "FieldPeriod": {
      "type": "string",
      "description": "Reporting period for financial data fields.",
      "enum": [
        "QUARTER",
        "TRAILING_TWELVE_MONTHS",
        "ANNUAL"
      ]
    },
    "FieldRef": {
      "type": "object",
      "description": "A reference to a screener field.",
      "required": [
        "name"
      ],
      "properties": {
        "lookback": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/FieldLookback",
              "description": "Optional historical lookback window."
            }
          ]
        },
        "name": {
          "type": "string",
          "description": "The field name."
        },
        "period": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/FieldPeriod",
              "description": "Optional reporting period (e.g. quarter or TTM)."
            }
          ]
        },
        "value_type": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/FieldType",
              "description": "The data type of the field value. Present only in responses."
            }
          ]
        }
      }
    },
    "FieldType": {
      "type": "string",
      "description": "The data type of a screener field value.",
      "enum": [
        "DECIMAL",
        "INTEGER",
        "STRING",
        "ANALYST_RATING",
        "DATE"
      ]
    },
    "FilterOpSpec": {
      "type": "object",
      "description": "Operator specification with optional behavioral arguments.",
      "required": [
        "name"
      ],
      "properties": {
        "args": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/OperatorArg"
          },
          "description": "Optional arguments that modify operator behavior."
        },
        "name": {
          "$ref": "#/$defs/FilterOperator",
          "description": "The operator to apply."
        }
      }
    },
    "FilterOperator": {
      "type": "string",
      "description": "Filter operators supported by the screener.\n\nAbbreviated and lowercase forms are accepted as serde aliases for backward\ncompatibility with earlier API revisions; the canonical wire form is the\nSCREAMING_SNAKE_CASE rendering.",
      "enum": [
        "LESS_THAN",
        "LESS_OR_EQUAL",
        "GREATER_THAN",
        "GREATER_OR_EQUAL",
        "EQUAL",
        "BETWEEN",
        "NOT_BETWEEN",
        "ONE_OF",
        "REGEX",
        "BEGINS_WITH",
        "ENDS_WITH",
        "CONTAINS",
        "IS_NULL",
        "IS_NOT_NULL"
      ]
    },
    "FilterValue": {
      "type": "object",
      "description": "A filter value: either a literal or a variable reference.",
      "properties": {
        "value": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "variable": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/Variable",
              "description": "A variable reference."
            }
          ]
        }
      }
    },
    "Modifier": {
      "type": "object",
      "description": "Arithmetic modifier applied to a variable value.",
      "required": [
        "name",
        "args"
      ],
      "properties": {
        "args": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ]
          }
        },
        "name": {
          "$ref": "#/$defs/ModifierOp",
          "description": "The modifier operation."
        }
      }
    },
    "ModifierOp": {
      "type": "string",
      "description": "Modifier operation applied to a variable.",
      "enum": [
        "ADD",
        "SUBTRACT"
      ]
    },
    "OperatorArg": {
      "type": "string",
      "description": "Argument that modifies operator behavior.",
      "enum": [
        "LEFT_INCLUSIVE",
        "RIGHT_INCLUSIVE",
        "LEFT_EXCLUSIVE",
        "RIGHT_EXCLUSIVE",
        "CASE_INSENSITIVE"
      ]
    },
    "SearchFilter": {
      "type": "object",
      "description": "A single filter condition.\n\nWhen `op` and `right` are both absent, the filter is \"unenabled\":\nit persists a `left` field reference without applying any predicate.\nUnenabled filters are skipped during search execution but still\nround-trip through save/load so callers can preserve draft state.",
      "required": [
        "left"
      ],
      "properties": {
        "left": {
          "$ref": "#/$defs/FieldRef",
          "description": "The field to filter on."
        },
        "op": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/FilterOpSpec",
              "description": "The operator and optional arguments. Omit together with `right` for an unenabled filter."
            }
          ]
        },
        "right": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/FilterValue"
          },
          "description": "The value(s) to compare against. Omit together with `op` for an unenabled filter."
        }
      }
    },
    "SortDirection": {
      "type": "string",
      "description": "Sort direction for sorted results",
      "enum": [
        "ASC",
        "DESC"
      ]
    },
    "SortSpec": {
      "type": "object",
      "description": "A sort specification pairing a field with a direction.",
      "required": [
        "field"
      ],
      "properties": {
        "direction": {
          "$ref": "#/$defs/SortDirection",
          "description": "Sort direction (defaults to DESC)."
        },
        "field": {
          "$ref": "#/$defs/FieldRef",
          "description": "The field to sort by."
        }
      }
    },
    "Variable": {
      "type": "object",
      "description": "A variable reference (field or built-in like `today`).",
      "required": [
        "name"
      ],
      "properties": {
        "lookback": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/FieldLookback",
              "description": "Optional historical lookback window."
            }
          ]
        },
        "modifier": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/Modifier",
              "description": "Optional arithmetic modifier."
            }
          ]
        },
        "name": {
          "type": "string",
          "description": "The variable name."
        },
        "period": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/FieldPeriod",
              "description": "Optional reporting period."
            }
          ]
        }
      }
    }
  }
}