---
title: "POST /settings/secrets"
method: POST
path: "/settings/secrets"
tags: ["Secrets"]
---

# POST /settings/secrets

`POST /settings/secrets`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/settings/secrets`
- Auth: HTTP bearer

## Request body

- UpsertSecretRequest
  - `description` string, nullable
  - `mount_path` string, nullable: Required for "file" type secrets — absolute path inside the sandbox
  - `name` string, required
  - `project_id` integer, nullable: Project whose agent runs receive the secret. Omit for an instance-wide secret, which is injected into every project's agent runs and so is readable by anyone who can run an agent in any project.
  - `secret_type` string: "env" (environment variable) or "file" (written to mount_path)
  - `value` string, required

## Response `201`

Secret created/updated

- SecretResponse
  - `created_at` string, required
  - `description` string, nullable
  - `id` integer, required
  - `mount_path` string, nullable
  - `name` string, required
  - `project_id` integer, nullable: Project the secret is scoped to; `null` means instance-wide.
  - `secret_type` string, required
  - `updated_at` string, required
  - `value` string, required: Always masked in responses

## Other responses

- `400`: Validation error
- `401`: Unauthorized
- `403`: Insufficient permissions
- `404`: Project not found

## Changes

- **2026-10-23** `fdfa2df06ae7`: 3 info
  - added the new optional request property `project_id`
  - added the non-success response with the status `404`
  - added the optional property `project_id` to the response with the `201` status
- **2026-10-23** `24af93ff5379`: 2 warning, 1 info
  - removed the request property `project_id`
  - removed the optional property `project_id` from the response with the `201` status
  - removed the non-success response with the status `404`
- **2026-10-22** `add7f7b41ae2`: 3 info
  - added the new optional request property `project_id`
  - added the non-success response with the status `404`
  - added the optional property `project_id` to the response with the `201` status
- **2026-04-25** `774be20905f2`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/settings/secrets/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
