---
title: "Upsert a Secret"
method: POST
path: "/secrets"
tags: ["secrets"]
---

# Upsert a Secret

`POST /secrets`

Insert or Update a Secret by name for environment or space

## Headers

- `Authorization` string, required
- `X-Disable-Hooks` 'true', required

## Request body

- TypeSecretsWriteSecret — The properties required to write to a secret. Value is the only mutable property. Name, environmentId, spaceId (optional) are used for finding the secret.
  - `name` string, required — The name of a secret. Minimum 1 character, maximum 1024
  - `value` string, required — The value of a secret. Minimum 1 character, maximum 1024
  - `environmentId` string — Environment ID
  - `spaceId` string — Space ID
  - `actorId` union
    - string — User ID
    - string — Agent ID
    - string — Guest ID

## Response `200`

Response with status 200

- TypeSecretsSecretsResponse
  - `data` TypeSecretsSecret[], required
    - `name` string, required — The name of a secret. Minimum 1 character, maximum 1024
    - `value` string, required — The value of a secret. Minimum 1 character, maximum 1024
    - `environmentId` string — Environment ID
    - `spaceId` string — Space ID
    - `actorId` union
      - string — User ID
      - string — Agent ID
      - string — Guest ID
    - `id` string, required — Secret ID

## Other responses

- `400` — Error response with status 400
- `404` — Error response with status 404

---

[API](https://skmtc.net/flatfile/apis/api-reference.md) · [All operations](https://skmtc.net/flatfile/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/flatfile/api-reference/revisions/9d3a9979cd96/schema)
