---
title: "attachSecret"
---

> Documentation Index
> Fetch the complete documentation index at: https://agenthold.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# attachSecret

Path: agenthold API › secrets

`PUT /agents/{agentId}/secrets/{secretId}`

URL: `/api/v1/agents/{agentId}/secrets/{secretId}`

Attach a secret (agent admin; the secret's owner or a workspace admin).
Injection works immediately; a changed environment variable needs a rebuild.

## Authentication

Requires one of the following:

- `session`, apiKey, in cookie
- `token`, http bearer, header `Authorization`

## Path parameters

- `agentId` (`attachSecret.path.agentId`; string, required)
- `secretId` (`attachSecret.path.secretId`; string, required)

## Request body

_Required._

- `envVar` (`attachSecret.envVar`; string, optional) — Variable that holds the placeholder in the sandbox.

## Example request

```json
{
  "envVar": "string"
}
```

## Code samples

### cURL

```bash
curl --request PUT \
  --url '<base-url>/api/v1/agents/<agentId>/secrets/<secretId>' \
  --header 'Content-Type: application/json' \
  --cookie 'agenthold_session=<agenthold_session>' \
  --data '
{
  "envVar": "string"
}
'
```

### TypeScript

```typescript
const url = '<base-url>/api/v1/agents/<agentId>/secrets/<secretId>';
const options = {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
    cookie: 'agenthold_session=<agenthold_session>'
  },
  body: JSON.stringify({envVar: 'string'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/api/v1/agents/<agentId>/secrets/<secretId>"

payload = { "envVar": "string" }
headers = {
    "cookie": "agenthold_session=<agenthold_session>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Attached.

#### Example

```json
{
  "secret": {
    "id": "string",
    "workspaceId": "string",
    "name": "string",
    "rule": {
      "hosts": [
        "string"
      ],
      "header": "string",
      "template": "string"
    },
    "placeholder": "string",
    "owner": {
      "id": "string",
      "email": "string",
      "name": "string",
      "avatarUrl": "string"
    },
    "canManage": true,
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  },
  "envVar": "string"
}
```

- `secret` (`attachSecret.response.200.secret`; object, required)
  - `id` (`attachSecret.response.200.secret.id`; string, required)
  - `workspaceId` (`attachSecret.response.200.secret.workspaceId`; string, required)
  - `name` (`attachSecret.response.200.secret.name`; string, required)
  - `rule` (`attachSecret.response.200.secret.rule`; object, required)
    - `hosts` (`attachSecret.response.200.secret.rule.hosts`; array of string, required) — Exact host names or "*.example.com".
    - `header` (`attachSecret.response.200.secret.rule.header`; string, required)
    - `template` (`attachSecret.response.200.secret.rule.template`; string, required) — Header value; {{.Value}} is the secret. Function: base64.
  - `placeholder` (`attachSecret.response.200.secret.placeholder`; string, required) — What sandboxes see instead of the value.
  - `owner` (`attachSecret.response.200.secret.owner`; object, required)
    - `id` (`attachSecret.response.200.secret.owner.id`; string, required)
    - `email` (`attachSecret.response.200.secret.owner.email`; string, required)
    - `name` (`attachSecret.response.200.secret.owner.name`; string, required)
    - `avatarUrl` (`attachSecret.response.200.secret.owner.avatarUrl`; string, required)
  - `canManage` (`attachSecret.response.200.secret.canManage`; boolean, required)
  - `createdAt` (`attachSecret.response.200.secret.createdAt`; string, required)
    - format: `date-time`
  - `updatedAt` (`attachSecret.response.200.secret.updatedAt`; string, required)
    - format: `date-time`
- `envVar` (`attachSecret.response.200.envVar`; string, required)

### 400

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`attachSecret.response.400.error`; string, required)

### 403

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`attachSecret.response.403.error`; string, required)

### 404

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`attachSecret.response.404.error`; string, required)


Source: https://agenthold.dev/api/attach-secret/index.md
