# Secrets

4 endpoints at `https://api.kosa8.com`, sent with `Authorization: Bearer $KOSA8_API_KEY`. Generated from the API's own [OpenAPI description](https://api.kosa8.com/openapi.json), which a test holds to the router.

## The organization's secrets: names and where each goes, never values[#]

GET`/v1/secrets`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/secrets \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Store (or replace) a secret, encrypted; sandboxes created with it hold only a placeholder[#]

PUT`/v1/secrets/{name}`scope admin

Answers 200 when it replaces one. Sandboxes already running keep the value they were created with.

Parameters

`name`requiredpath · string

Secret name: 1-32 of a-z, 0-9 and -

JSON body

`value`requiredstring

The real key or token. Stored encrypted; never returned Max length 8192.

`upstream`requiredstring

https://host[:port], no path

`header`string

Header that carries it upstream (default Authorization)

`scheme`string

Written before the value (default "Bearer " for Authorization, else none)

`methods`array of string

HTTP methods it may be used with; empty: any but TRACE

`paths`array of string

Upstream path prefixes it may be used on; empty: any

`env`object

Default {NAME_API_KEY: "{{placeholder}}", NAME_BASE_URL: "{{url}}"}

`pipelines`boolean

Default false. true: a pipeline run that names it gets the value itself, as an environment variable of its jobs (npm-token is NPM_TOKEN), as CI secrets are; never in a sandbox otherwise

Responses

201400401403409

```
curl -s -X PUT https://api.kosa8.com/v1/secrets/$NAME \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Delete a secret; sandboxes holding it keep it until they are deleted[#]

DELETE`/v1/secrets/{name}`scope admin

Parameters

`name`requiredpath · string

Secret name: 1-32 of a-z, 0-9 and -

Responses

200401403404

```
curl -s -X DELETE https://api.kosa8.com/v1/secrets/$NAME \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Which secrets the sandbox was created with[#]

GET`/v1/sandboxes/{id}/secrets`scope sandboxes:read

Parameters

`id`requiredpath · string

Sandbox id (sbx_…)

Responses

200401403404

```
curl -s -X GET https://api.kosa8.com/v1/sandboxes/$SBX/secrets \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

---
Source: https://docs.kosa8.com/api/secrets/
