> For the complete documentation index, see [llms.txt](https://docs.groundcover.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.groundcover.com/reference/remote-access-and-apis/api-examples/secrets-api.md).

# Secrets API

Manage stored secrets referenced by integration configurations.

Manage stored secrets referenced by integration configurations.

## Authentication

Admin permissions are required for all operations on this page. Set `GC_API_KEY` to an API key with the required permissions and `GC_BACKEND_ID` to the backend ID. Every example sends both headers. For self-hosted deployments, replace `https://api.groundcover.com` with your API URL.

## Endpoints

| Method | Endpoint                | Response                         |
| ------ | ----------------------- | -------------------------------- |
| POST   | `/api/secret`           | `201`, secret metadata           |
| PUT    | `/api/secret/{id}`      | `200`, secret metadata           |
| GET    | `/api/secret/{id}/hash` | `200`, metadata and content hash |
| DELETE | `/api/secret/{id}`      | `204`, no body                   |

## Create

`type`, `name`, and `content` are required strings. Send the actual secret as `content`; the router stores the bytes of this string. Optional `managedByProvider` accepts `none` or `terraform`.

```bash
curl --request POST \
  --url "https://api.groundcover.com/api/secret" \
  --header "Authorization: Bearer $GC_API_KEY" \
  --header "X-Backend-Id: $GC_BACKEND_ID" \
  --header "Content-Type: application/json" \
  --data '{
  "type": "password",
  "name": "integration-password",
  "content": "<SECRET_VALUE>"
}'
```

The response contains `id`, `type`, and `name`. The ID is a complete reference such as `secretRef::store::<SECRET_UUID>`. Preserve that full reference in API paths and in integration fields that accept secret references. Secret content is not returned.

## Update

Supply the same required fields as create. Updating replaces the secret value while preserving its reference.

```bash
curl --request PUT \
  --url "https://api.groundcover.com/api/secret/secretRef::store::<SECRET_UUID>" \
  --header "Authorization: Bearer $GC_API_KEY" \
  --header "X-Backend-Id: $GC_BACKEND_ID" \
  --header "Content-Type: application/json" \
  --data '{
  "type": "password",
  "name": "integration-password",
  "content": "<REPLACEMENT_SECRET_VALUE>"
}'
```

## Detect changes

```bash
curl --request GET \
  --url "https://api.groundcover.com/api/secret/secretRef::store::<SECRET_UUID>/hash" \
  --header "Authorization: Bearer $GC_API_KEY" \
  --header "X-Backend-Id: $GC_BACKEND_ID"
```

The result contains `id`, `type`, `name`, `contentHash`, and optional `managedByProvider`. `contentHash` is a hexadecimal FNV-1a hash used for change detection, not the secret itself.

## Delete

Update configurations that reference the secret before deleting it.

```bash
curl --request DELETE \
  --url "https://api.groundcover.com/api/secret/secretRef::store::<SECRET_UUID>" \
  --header "Authorization: Bearer $GC_API_KEY" \
  --header "X-Backend-Id: $GC_BACKEND_ID"
```

Malformed or unsupported secret references return `400`. A missing stored secret returns `404` on get-hash, update, or delete.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.groundcover.com/reference/remote-access-and-apis/api-examples/secrets-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
