<commit_before>---
layout: "docs"
page_title: "Commands: KV Put"
sidebar_current: "docs-commands-kv-put"
---

# Consul KV Put

Command: `consul kv put`

The `kv put` command writes the data to the given path in the key-value store.

## Usage

Usage: `consul kv put [options] KEY [DATA]`

#### API Options

<%= partial "docs/commands/http_api_options" %>

#### KV Put Options

* `-acquire` - Obtain a lock on the key. If the key does not exist, this
  operation will create the key and obtain the lock. The session must already
  exist and be specified via the -session flag. The default value is false.

* `-cas` - Perform a Check-And-Set operation. Specifying this value also
  requires the -modify-index flag to be set. The default value is false.

* `-flags=<int>` - Unsigned integer value to assign to this key-value pair. This
  value is not read by Consul, so clients can use this value however makes sense
  for their use case. The default value is 0 (no flags).

* `-modify-index=<int>` - Unsigned integer representing the ModifyIndex of the
  key. This is used in combination with the -cas flag.

* `-release` - Forfeit the lock on the key at the givne path. This requires the
  -session flag to be set. The key must be held by the session in order to be
  unlocked. The default value is false.

* `-session=<string>` - User-defined identifer for this session as a string.
  This is commonly used with the -acquire and -release operations to build
  robust locking, but it can be set on any key. The default value is empty (no
  session).

## Examples

To insert a value of "5" for the key named "redis/config/connections" in the<commit_msg>Fix typo in command/kv/put doc<commit_after>---
layout: "docs"
page_title: "Commands: KV Put"
sidebar_current: "docs-commands-kv-put"
---

# Consul KV Put

Command: `consul kv put`

The `kv put` command writes the data to the given path in the key-value store.

## Usage

Usage: `consul kv put [options] KEY [DATA]`

#### API Options

<%= partial "docs/commands/http_api_options" %>

#### KV Put Options

* `-acquire` - Obtain a lock on the key. If the key does not exist, this
  operation will create the key and obtain the lock. The session must already
  exist and be specified via the -session flag. The default value is false.

* `-cas` - Perform a Check-And-Set operation. Specifying this value also
  requires the -modify-index flag to be set. The default value is false.

* `-flags=<int>` - Unsigned integer value to assign to this key-value pair. This
  value is not read by Consul, so clients can use this value however makes sense
  for their use case. The default value is 0 (no flags).

* `-modify-index=<int>` - Unsigned integer representing the ModifyIndex of the
  key. This is used in combination with the -cas flag.

* `-release` - Forfeit the lock on the key at the given path. This requires the
  -session flag to be set. The key must be held by the session in order to be
  unlocked. The default value is false.

* `-session=<string>` - User-defined identifer for this session as a string.
  This is commonly used with the -acquire and -release operations to build
  robust locking, but it can be set on any key. The default value is empty (no
  session).

## Examples

To insert a value of "5" for the key named "redis/config/connections" in the
{'fraction_non_alphanumeric': 0.08561953572505276, 'fraction_numerical': 0.0012059089538739825, 'mean_word_length': 3.489851150202977, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7245142', 'n_tokens_mistral': 995, 'n_tokens_neox': 980, 'n_words': 505}