> ## Documentation Index
> Fetch the complete documentation index at: https://opensandbox-oc-s-762ac928075c46d2828bcb22.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Secret

Set or update a secret on an agent. The first call auto-creates a backing secret store. Values are AES-256-GCM encrypted at rest and never returned via API.

**CLI equivalent:** `oc agent create --secret KEY=VALUE` (at creation time only)

<ParamField path="agentId" type="string" required>
  Agent ID
</ParamField>

<ParamField path="key" type="string" required>
  Secret key name
</ParamField>

<ParamField body="value" type="string" required>
  Secret value
</ParamField>

<ParamField body="allowed_hosts" type="string[]">
  Restrict which outbound hosts can receive the decrypted value
</ParamField>

<ResponseExample>
  ```json 200 theme={null}
  {
    "key": "ANTHROPIC_API_KEY",
    "allowed_hosts": ["api.anthropic.com"],
    "set_at": "2026-04-09T10:30:00Z"
  }
  ```
</ResponseExample>
