---
title: "Set a key's value"
method: PUT
path: "/storage/kvs/{id}/keys/{key}"
tags: ["kv keys"]
---

# Set a key's value

`PUT /storage/kvs/{id}/keys/{key}`

Creates or replaces the value for a key. The request body is stored verbatim as the value — no base64, no JSON envelope — up to 1 MiB. The request's `Content-Type` header is stored with the value and echoed back on retrieval. Returns `201` when the key is created and `200` when an existing key is updated.

## Path parameters

- `id` string, uuid, required
- `key` string, required

## Query parameters

- `ttl_secs` integer

## Response `200`

Key updated

## Other responses

- `201` — Key created
- `400` — Bad request — invalid `id`, key name, or request body
- `401` — Unauthorized
- `404` — KV namespace not found
- `409` — Conflict — the namespace is not ready (`status` is not `provision_ok`), or `ttl_secs` was set on a namespace without TTL support
- `413` — Payload too large — the value exceeds 1 MiB
- `422` — Unprocessable entity — `ttl_secs` is not a positive integer within range, or the unsupported `ttl` parameter was used
- `500` — Internal server error

---

[API](https://skmtc.net/team-telnyx/apis/telnyx-api-2.md) · [All operations](https://skmtc.net/team-telnyx/apis/telnyx-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/team-telnyx/telnyx-api-2/versions/8f5f4e537994/schema)
