---
title: "Upsert a KV entry by explicit namespace + key"
method: PUT
path: "/api/kv/_/{namespace}/{key}"
tags: ["KV"]
---

# Upsert a KV entry by explicit namespace + key

`PUT /api/kv/_/{namespace}/{key}`

## Path parameters

- `namespace` string, required
- `key` string, required

## Request body

- object
  - `value` unknown
  - `valueType` 'json' | 'string' | 'integer'
  - `expiresInSec` integer

## Response `200`

KV entry stored

- KvEntry
  - `namespace` string, required
  - `key` string, required
  - `value` unknown
  - `valueType` 'json' | 'string' | 'integer', required
  - `expiresAt` integer, nullable, required
  - `createdAt` integer, required
  - `updatedAt` integer, required

## Other responses

- `400` — Validation error
- `403` — Caller may not write this namespace
- `409` — INCR collision: existing value_type is not 'integer'
- `413` — Body exceeds 2 MiB

## Changes

- **2026-08-07** `06cac6a7c5bc` — 5 info
  - added the media type `application/json` for the response with the status `200`
  - added the media type `application/json` for the response with the status `400`
  - added the media type `application/json` for the response with the status `403`
  - added the media type `application/json` for the response with the status `409`
  - …1 more

[Change history](https://skmtc.dev/desplega-ai/apis/agent-swarm-api/changes/api/kv/_/:namespace/:key/put.md)

---

[API](https://skmtc.dev/desplega-ai/apis/agent-swarm-api.md) · [All operations](https://skmtc.dev/desplega-ai/apis/agent-swarm-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/desplega-ai/agent-swarm-api/revisions/8cde933218b5/schema)
