{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/MetadataQuery",
  "title": "Metadata query search request",
  "type": "object",
  "description": "Create a search using SQL-like syntax to return items that match specific\nmetadata.",
  "required": [
    "from",
    "ancestor_folder_id"
  ],
  "properties": {
    "from": {
      "type": "string",
      "description": "Specifies the template used in the query. Must be in the form\n`scope.templateKey`. Not all templates can be used in this field,\nmost notably the built-in, Box-provided classification templates\ncan not be used in a query.",
      "example": "enterprise_123456.someTemplate"
    },
    "query": {
      "type": "string",
      "description": "The query to perform. A query is a logical expression that is very similar\nto a SQL `SELECT` statement. Values in the search query can be turned into\nparameters specified in the `query_param` arguments list to prevent having\nto manually insert search values into the query string.\n\nFor example, a value of `:amount` would represent the `amount` value in\n`query_params` object.",
      "example": "value >= :amount"
    },
    "query_params": {
      "type": "object",
      "description": "Set of arguments corresponding to the parameters specified in the\n`query`. The type of each parameter used in the `query_params` must match\nthe type of the corresponding metadata template field.",
      "example": {
        "amount": "100"
      },
      "additionalProperties": {
        "type": "string",
        "description": "The value for the argument being used in the metadata search.\n\nThe type of this parameter must match the type of the corresponding\nmetadata template field.",
        "example": "100",
        "x-box-example-key": "amount"
      }
    },
    "ancestor_folder_id": {
      "type": "string",
      "description": "The ID of the folder that you are restricting the query to. A\nvalue of zero will return results from all folders you have access\nto. A non-zero value will only return results found in the folder\ncorresponding to the ID or in any of its subfolders.",
      "example": "0"
    },
    "order_by": {
      "type": "array",
      "description": "A list of template fields and directions to sort the metadata query\nresults by.\n\nThe ordering `direction` must be the same for each item in the array.",
      "items": {
        "type": "object",
        "description": "An object representing one of the metadata template fields to sort the\nmetadata query results by.",
        "properties": {
          "field_key": {
            "type": "string",
            "description": "The metadata template field to order by.\n\nThe `field_key` represents the `key` value of a field from the\nmetadata template being searched for.",
            "example": "amount"
          },
          "direction": {
            "type": "string",
            "description": "The direction to order by, either ascending or descending.\n\nThe `ordering` direction must be the same for each item in the\narray.",
            "example": "asc",
            "enum": [
              "ASC",
              "DESC",
              "asc",
              "desc"
            ]
          }
        }
      }
    },
    "limit": {
      "type": "integer",
      "description": "A value between 0 and 100 that indicates the maximum number of results\nto return for a single request. This only specifies a maximum\nboundary and will not guarantee the minimum number of results\nreturned.",
      "default": 100,
      "minimum": 0,
      "maximum": 100,
      "example": 50
    },
    "marker": {
      "type": "string",
      "description": "Marker to use for requesting the next page.",
      "example": "AAAAAmVYB1FWec8GH6yWu2nwmanfMh07IyYInaa7DZDYjgO1H4KoLW29vPlLY173OKsci6h6xGh61gG73gnaxoS+o0BbI1/h6le6cikjlupVhASwJ2Cj0tOD9wlnrUMHHw3/ISf+uuACzrOMhN6d5fYrbidPzS6MdhJOejuYlvsg4tcBYzjauP3+VU51p77HFAIuObnJT0ff"
    },
    "fields": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "By default, this endpoint returns only the most basic info about the items for\nwhich the query matches. This attribute can be used to specify a list of\nadditional attributes to return for any item, including its metadata.\n\nThis attribute takes a list of item fields, metadata template identifiers,\nor metadata template field identifiers.\n\nFor example:\n\n* `created_by` will add the details of the user who created the item to\nthe response.\n* `metadata.<scope>.<templateKey>` will return the mini-representation\nof the metadata instance identified by the `scope` and `templateKey`.\n* `metadata.<scope>.<templateKey>.<field>` will return all the mini-representation\nof the metadata instance identified by the `scope` and `templateKey` plus\nthe field specified by the `field` name. Multiple fields for the same\n`scope` and `templateKey` can be defined.",
      "example": [
        "extension",
        "created_at",
        "item_status",
        "metadata.enterprise_1234.contracts",
        "metadata.enterprise_1234.regions.location"
      ]
    }
  }
}