{
  "schema_version": 2,
  "id": "commands/bf.insert",
  "title": "BF.INSERT",
  "url": "https://redis.io/docs/latest/commands/bf.insert/",
  "summary": "Adds one or more items to a Bloom Filter. A filter will be created if it does not exist",
  "since": "1.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:54+01:00",
  "page_type": "content",
  "content_hash": "970adad549b3f143437d2aa54719fe6024c627dd85271ba54be024463e7b7927",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Creates a new Bloom filter if the `key` does not exist using the specified error rate, capacity, and expansion, then adds all specified items to the Bloom Filter.\n\nThis command is similar to [`BF.MADD`](https://redis.io/docs/latest/commands/bf.madd), except that the error rate, capacity, and expansion can be specified. It is a sugarcoated combination of [`BF.RESERVE`](https://redis.io/docs/latest/commands/bf.reserve) and [`BF.MADD`](https://redis.io/docs/latest/commands/bf.madd)."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nis key name for a Bloom filter to add items to.\n\nIf `key` does not exist, a new Bloom filter is created.\n</details>\n\n<details open><summary><code>ITEMS item...</code></summary>\n\nOne or more items to add.\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>NOCREATE</code></summary>\n\nIndicates that the filter should not be created if it does not already exist.\nIf the filter does not yet exist, an error is returned rather than creating it automatically.\nThis may be used where a strict separation between filter creation and filter addition is desired.\nIt is an error to specify `NOCREATE` together with either `CAPACITY` or `ERROR`.\n</details>\n\n<details open><summary><code>CAPACITY capacity</code></summary>\n\nSpecifies the desired `capacity` for the filter to be created.\nThis parameter is ignored if the filter already exists.\nIf the filter is automatically created and this parameter is absent, then the module-level `capacity` is used.\nSee [`BF.RESERVE`](https://redis.io/docs/latest/commands/bf.reserve) for more information about the impact of this value.\n</details>\n\n<details open><summary><code>ERROR error</code></summary>\n    \nSpecifies the `error` ratio of the newly created filter if it does not yet exist.\nIf the filter is automatically created and `error` is not specified then the module-level error rate is used.\nSee [`BF.RESERVE`](https://redis.io/docs/latest/commands/bf.reserve) for more information about the format of this value.\n</details>\n\n<details open><summary><code>NONSCALING</code></summary>\n\nPrevents the filter from creating additional sub-filters if initial capacity is reached.\nNon-scaling filters require slightly less memory than their scaling counterparts. The filter returns an error when `capacity` is reached.\n</details>\n\n<details open><summary><code>EXPANSION expansion</code></summary>\n\nWhen `capacity` is reached, an additional sub-filter is created.\nThe size of the new sub-filter is the size of the last sub-filter multiplied by `expansion`, specified as a positive integer.\n\nIf the number of elements to be stored in the filter is unknown, use an `expansion` of `2` or more to reduce the number of sub-filters.\nOtherwise, use an `expansion` of `1` to reduce memory consumption. The default value is `2`.\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Add three items to a filter, then create the filter with default parameters if it does not already exist.\n\n\nredis> BF.INSERT filter ITEMS foo bar baz\n1) (integer) 1\n2) (integer) 1\n3) (integer) 1\n\n\nAdd one item to a filter, then create the filter with a capacity of 10000 if it does not already exist.\n\n\nredis> BF.INSERT filter CAPACITY 10000 ITEMS hello\n1) (integer) 1\n\n\nAdd two items to a filter, then return error if the filter does not already exist.\n\n\nredis> BF.INSERT filter NOCREATE ITEMS foo bar\n1) (integer) 0\n2) (integer) 0"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Supported</span><br /> | <span title=\"Supported\">&#x2705; Flexible & Annual</span><br /><span title=\"Supported\">&#x2705; Free & Fixed</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following: where each element is one of these options:\n* [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays), where each element is one of the following options:\n  * [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers) `1` for successfully adding an item, or `0` if there's a probability that the item was already added to the filter.\n  * [Simple string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-strings) when the item cannot be added because the filter is full.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) when the number of arguments or key type is wrong, and also when `NOCREATE` is specified and `key` does not exist.\n\n**RESP3:**\n\nOne of the following: where each element is one of these options:\n* [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays), where each element is one of the following options:\n  * [Boolean reply](https://redis.io/docs/latest/develop/reference/protocol-spec#booleans) `true` for successfully adding an item, or `false` if there's a probability that the item was already added to the filter.\n  * [Simple string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-strings) when the item cannot be added because the filter is full.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) when the number of arguments or key type is wrong, and also when `NOCREATE` is specified and `key` does not exist."
    }
  ],
  "examples": []
}
