> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set a key's value

> 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.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/edge-compute.yml put /storage/kvs/{id}/keys/{key}
openapi: 3.1.0
info:
  title: Telnyx Edge Compute API
  version: 2.0.0
  description: API for Edge Compute key-value storage (namespaces and keys).
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /storage/kvs/{id}/keys/{key}:
    put:
      tags:
        - kv keys
      summary: Set a key's value
      description: >-
        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.
      operationId: PutKvKey
      parameters:
        - description: KV namespace ID
          name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - description: >-
            Key name. Allowed characters: `a-z A-Z 0-9 - _ / = .`; maximum 256
            characters; names starting with `_` are reserved for system use. May
            contain `/`; URL-encode it so the whole string is treated as one key
            (for example `user/1` -> `user%2F1`).
          name: key
          in: path
          required: true
          schema:
            type: string
            maxLength: 256
            pattern: ^[-/_=.a-zA-Z0-9]+$
        - description: >-
            Time-to-live in seconds. When set, the key expires and is deleted
            after this duration. Requires a namespace provisioned with TTL
            support; namespaces without it return a `409`.
          name: ttl_secs
          in: query
          schema:
            type: integer
            format: int64
            minimum: 1
            maximum: 9223372036
      requestBody:
        content:
          '*/*':
            schema:
              type: string
              format: binary
              description: Raw value bytes, stored verbatim.
        description: >-
          The value to store, sent as the raw request body. Maximum size: 1 MiB
          (1048576 bytes).
        required: true
      responses:
        '200':
          description: Key updated
        '201':
          description: Key created
        '400':
          description: Bad request — invalid `id`, key name, or request body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/edge-compute_Errors'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/edge-compute_Errors'
        '404':
          description: KV namespace not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/edge-compute_Errors'
        '409':
          description: >-
            Conflict — the namespace is not ready (`status` is not
            `provision_ok`), or `ttl_secs` was set on a namespace without TTL
            support
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/edge-compute_Errors'
        '413':
          description: Payload too large — the value exceeds 1 MiB
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/edge-compute_Errors'
        '422':
          description: >-
            Unprocessable entity — `ttl_secs` is not a positive integer within
            range, or the unsupported `ttl` parameter was used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/edge-compute_Errors'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericErrorResponse'
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.storage.kvs.keys.update('id', 'key');

            console.log(response.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.storage.kvs.keys.update()
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tkey, err := client.Storage.Kvs.Keys.Update(\n\t\tcontext.TODO(),\n\t\ttelnyx.StorageKvsKeysUpdateParams{,\n\t\t\t\tID: \"id\",,\n\t\t\t\tKey: \"key\",,\n\t\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", key.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    Object response = client.storage()kvs()keys()update("id", "key");
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            response = telnyx.storage.kvs.keys.update

            puts(response)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $response = $client->storage->kvs->keys->update();

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx storage:kvs:keys update \
              --api-key 'My API Key' \
              --id id \
              --key key
components:
  schemas:
    edge-compute_Errors:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/edge-compute_Error'
    GenericErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/edge-compute_Error'
    edge-compute_Error:
      type: object
      properties:
        code:
          type: string
          example: '10005'
        detail:
          type: string
          example: The requested function does not exist or you don't have access to it
        meta:
          $ref: '#/components/schemas/ErrorMeta'
        source:
          $ref: '#/components/schemas/ErrorSource'
        title:
          type: string
          example: Function not found
    ErrorMeta:
      type: object
      properties:
        url:
          type: string
          example: https://docs.telnyx.com/api/errors/10005
    ErrorSource:
      type: object
      properties:
        parameter:
          type: string
          example: id
        pointer:
          type: string
          example: /id
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````