---
title: "Create a new secret"
method: POST
path: "/api/v1beta/secrets/default/keys"
tags: ["secrets"]
---

# Create a new secret

`POST /api/v1beta/secrets/default/keys`

Create a new secret in the default provider (encrypted provider only)

## Request body

- union
  - object
  - PkgApiV1CreateSecretRequest — Request to create a new secret
    - `key` string — Secret key name
    - `value` string — Secret value

## Response `201`

Created

- PkgApiV1CreateSecretResponse — Response after creating a secret
  - `key` string — Secret key that was created
  - `message` string — Success message

## Other responses

- `400` — Bad Request
- `404` — Not Found - Provider not setup
- `405` — Method Not Allowed - Provider doesn't support writing
- `409` — Conflict - Secret already exists
- `500` — Internal Server Error

## Changes

> 49 revisions in range; 6 could not be searched.

- **2026-03-17** `8ab2f5690c97` — 1 breaking, 1 info
  - removed `#/components/schemas/v1.createSecretRequest` from the request body `oneOf` list
  - added `#/components/schemas/pkg_api_v1.createSecretRequest` to the request body `oneOf` list
- **2026-01-29** `ff6ce8dd8f3a` — 1 breaking, 1 info
  - removed `#/components/schemas/pkg_api_v1.createSecretRequest` from the request body `oneOf` list
  - added `#/components/schemas/v1.createSecretRequest` to the request body `oneOf` list

[Change history](https://skmtc.dev/stacklok/apis/toolhive-api/changes/api/v1beta/secrets/default/keys/post.md)

---

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