# IRPCNamedValueStorage.SetNamedValues

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md) > [Named value storage](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNamedValueStorage/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNamedValueStorage/SetNamedValues/

Badges: `Vault API / standard` `write` `session` `idempotent` `returns metadata structure version`

Creates or replaces the given named values in one namespace, optionally only if the current
values are as expected.

- **Service:** [Named value storage](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNamedValueStorage/index.md) `MFiles.IRPCNamedValueStorage`
- **gRPC method:** `/MFiles.IRPCNamedValueStorage/SetNamedValues`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/set-named-values`
- **Request:** [`SetNamedValuesRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNamedValueStorage/SetNamedValues/index.md#request)
- **Response:** [`SetNamedValuesResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNamedValueStorage/SetNamedValues/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** write
- **Session:** Required: the session ID from LogIn in the mfiles-session-id-bin metadata.
- **Idempotent:** yes
- **Returns metadata structure version:** yes (in the mfiles-metadata-version-bin trailer)
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

- Requires a vault session; the write rights depend on `storage_type` (see the service
  overview). Anonymous sessions get "Access denied.".
- Only the keys in `values` are written; other keys in the namespace stay as they are. Each
  written key gets the new value as a whole.
- **Optimistic concurrency** with `required_existing_value`: every listed key must currently
  have exactly the listed value, or, if the listed value is empty, must have no value. If any of
  them differs, nothing is written and the call fails with "An SQL update statement yielded a
  probable lock conflict." (0x800403F9). Read the values again, merge and retry.
- If no value would change, nothing is written.
- With `NAMED_VALUE_TYPE_USER_SPECIFIC_VALUE` the values are stored for the calling user only.

<a id="request"></a>

## Request: SetNamedValuesRequest

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `storage_type` | [`NamedValueType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.NamedValueType/index.md) | The storage type to write. See the table in the service overview. Values: `NAMED_VALUE_TYPE_UNINITIALIZED` (0), `NAMED_VALUE_TYPE_PROPERTY_AUTOMATIC_NUMBERING` (1), `NAMED_VALUE_TYPE_VAULT_SHARED_VARIABLE` (2), `NAMED_VALUE_TYPE_METADATA_CONFIGURATION_VALUE` (3), `NAMED_VALUE_TYPE_USER_CONFIGURATION_VALUE` (4), `NAMED_VALUE_TYPE_REGISTRY_VALUE` (5), `NAMED_VALUE_TYPE_FOLDER_CONFIGURATION_VALUE` (6), `NAMED_VALUE_TYPE_ADMIN_CONFIGURATION_VALUE` (7), `NAMED_VALUE_TYPE_SYSTEM_CONFIGURATION_VALUE` (8), `NAMED_VALUE_TYPE_USER_SPECIFIC_VALUE` (9). |
| `namespace_name` | `string` | The namespace, at most 100 characters. |
| `values[]` | repeated [`NamedValue`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.NamedValue/index.md) | The values to create or replace. Keys are at most 100 characters. |
| `values[].key` | `string` | The name of the value. |
| `values[].value` | [`TypedValue`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TypedValue/index.md) | The value as a serialized bytearray. |
| `values[].value.is_null_value` | `bool` | True if the value is empty. `data` is then unset. |
| `values[].value.type` | [`Datatype`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.Datatype/index.md) | The data type of the value. |
| `values[].value.data` | [`TypedValueUnion`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TypedValueUnion/index.md) | The value, in the member that matches `type`. Unset for an empty value. |
| `required_existing_value[]` | repeated [`NamedValue`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.NamedValue/index.md) | Optional. Values that must be current before the write, typically the values you read with [GetNamedValues](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNamedValueStorage/GetNamedValues/index.md). A key with an empty value means "must not exist". On a mismatch the call fails with 0x800403F9 and nothing is written. |
| `required_existing_value[].key` | `string` | The name of the value. |
| `required_existing_value[].value` | [`TypedValue`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TypedValue/index.md) | The value as a serialized bytearray. |
| `required_existing_value[].value.is_null_value` | `bool` | True if the value is empty. `data` is then unset. |
| `required_existing_value[].value.type` | [`Datatype`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.Datatype/index.md) | The data type of the value. |
| `required_existing_value[].value.data` | [`TypedValueUnion`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TypedValueUnion/index.md) | The value, in the member that matches `type`. Unset for an empty value. |

<a id="response"></a>

## Response: SetNamedValuesResponse

No fields.
