---
title: "Set a secret by key"
method: PUT
path: "/functions/{id}/secrets/{key}"
tags: ["Functions"]
---

# Set a secret by key

`PUT /functions/{id}/secrets/{key}`

Path-keyed companion to `POST /functions/{id}/secrets`.
Idempotent: returns 201 the first time the key is set, 200 on
subsequent updates. Same validation rules and same write-only
guarantees as the POST verb; the new value lands in the running
handler on the next deploy.

## Request body

- object — Body for PUT /functions/{id}/secrets/{key}. Key comes from the path.
  - `value` string, required

## Response `200`

Secret updated

- object
  - `success` true, required
  - `data` object, required — Returned by POST and PUT secret routes.
    - `key` string, required
    - `created_at` string, date-time, required
    - `updated_at` string, date-time, required
    - `created` boolean, required — True if this call inserted a new row, false if it updated an existing one.

## Other responses

- `201` — Secret created
- `400` — Invalid request parameters
- `401` — Invalid or missing API key
- `404` — Resource not found

---

[API](https://skmtc.dev/primitive/apis/primitive-api.md) · [All operations](https://skmtc.dev/primitive/apis/primitive-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/primitive/primitive-api/revisions/c2299d28022c/schema)
