---
title: "Set one or more key-value pairs in key-value collection"
method: PUT
path: "/_fabric/{fabric}/_api/kv/{collection}/value"
tags: ["Key Value"]
---

# Set one or more key-value pairs in key-value collection

`PUT /_fabric/{fabric}/_api/kv/{collection}/value`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/macrometa/apis/macrometa-api-reference/docs/_fabric/:fabric/_api/kv/:collection/value/put.ts> (a function with typed inputs; its response is checked against the schema)

Set one or more key-value pairs in key-value collection.

If the input is an array of objects, then key-value pairs are created in a batch.

If the key does not exist, then the key-value pairs are created. Otherwise, the entry for the key is updated.

Specify expiration in UTC timestamp.

Note that you can use this API for both normal (text) and blob KV collections. When setting blob data in a blob collection, specify the multipart/form-data as the content type for the request body, and provide multi-part data in the request body.

## Path parameters

- `fabric` string, string, required
- `collection` string, string, required

## Request body

- KeyValue[]
  - `_key` string, required: Key
  - `value` string, required: Value
  - `groupID` string: Group ID
  - `expireAt` integer: Expiry time in UTC timestamp format.

## Response `202`

Successfully updated key-value pair.

- object[]
  - `_id` string: ID of the collection.
  - `_key` string: _key details of collection.
  - `_rev` string: updated _rev details of collection.
  - `_oldrev` string: prvious _rev details of collection.

## Other responses

- `404`: Failed to find specified collection.

---

[API](https://skmtc.dev/macrometa/apis/macrometa-api-reference.md) - [All operations](https://skmtc.dev/macrometa/apis/macrometa-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/macrometa/apis/macrometa-api-reference/revisions/2006b6d7f31d?raw)
