> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.instabase.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.instabase.com/_mcp/server.

# Update secret

PATCH https://aihub.instabase.com/api/v2/aihub/secrets
Content-Type: application/json

Update the description, value, or allowed workspaces for a secret. If a value for a parameter is not specified, it will remain the same.Only organization admins can update secrets.

Reference: https://docs.instabase.com/api-sdk/api-reference/secrets/update-secret

## Authentication

- `Authorization` header (bearer token, required) — Bearer HTTP authentication.

## Request

### Headers

- `IB-Context` (string, optional) — Typically your organization ID. See [Authorization and context identification](/api-sdk/authorization#ib-context-header) for details.

### Body (application/json)

This endpoint expects an object.

- `alias` (string, required) — Name of the secret to update.
- `description` (string, optional) — New description of the secret.
- `value` (string, optional) — New content of the secret.
- `allowed_workspaces_type` (enum, optional) — New designation of which workspaces in this organization are allowed to use this secret in custom functions.
  - Allowed values: `ALL`, `SOME`, `NONE`
- `allowed_workspaces` (list of string, optional) — New designation of which workspaces are allowed to use this secret, if only some are.

## Response

### 200

Secret updated successfully.

## Examples

**Request**

```json
{
  "alias": "database_password"
}
```

**Response**

```json
{}
```

**SDK Code**

```python Simple request with SDK
from aihub import AIHub

client = AIHub(
    api_root="https://aihub.instabase.com/api",
    api_key="abcdefghijklmnopqrst1234567890",
    ib_context="john.doe_acme.com"
)

# returns None
client.secrets.update(alias="password", value="abc123")

```

```python Simple request without SDK
import requests

url = "https://aihub.instabase.com/api/v2/aihub/secrets"

headers = {
    "Authorization": "Bearer abcdefghijklmnopqrst1234567890",
    "IB-Context": "john.doe_acme.com"
}

# create the request payload
data = {
    "alias": "password",
    "value": "abc123"
}

# make the PATCH request
response = requests.patch(url, headers=headers, json=data)

# handle the response
if response.status_code == 200:
    print("Secret updated successfully")
else:
    print(f"Error: {response.status_code} - {response.text}")

```

```python Advanced request with SDK
from aihub import AIHub

client = AIHub(
    api_root="https://aihub.instabase.com/api",
    api_key="abcdefghijklmnopqrst1234567890",
    ib_context="john.doe_acme.com")

# returns None
client.secrets.update(
    alias="password",
    description="password",
    value="abc123",
    allowed_workspaces_type="SOME",
    allowed_workspaces=["WorkspaceA", "WorkspaceB"]
)

```

```python Advanced request without SDK
import requests

url = "https://aihub.instabase.com/api/v2/aihub/secrets"

headers = {
    "Authorization": "Bearer abcdefghijklmnopqrst1234567890",
    "IB-Context": "john.doe_acme.com"
}

# create the request payload
data = {
    "alias": "password",
    "value": "abc123",
    "allowed_workspaces_type": "SOME",
    "allowed_workspaces": ["WorkspaceA", "WorkspaceB"]
}

# make the PATCH request
response = requests.patch(url, headers=headers, json=data)

# handle the response
if response.status_code == 200:
    print("Secret updated successfully")
else:
    print(f"Error: {response.status_code} - {response.text}")

```

```javascript
const url = 'https://aihub.instabase.com/api/v2/aihub/secrets';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"alias":"database_password"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://aihub.instabase.com/api/v2/aihub/secrets"

	payload := strings.NewReader("{\n  \"alias\": \"database_password\"\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://aihub.instabase.com/api/v2/aihub/secrets")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"alias\": \"database_password\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://aihub.instabase.com/api/v2/aihub/secrets")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"alias\": \"database_password\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://aihub.instabase.com/api/v2/aihub/secrets', [
  'body' => '{
  "alias": "database_password"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://aihub.instabase.com/api/v2/aihub/secrets");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"alias\": \"database_password\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["alias": "database_password"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://aihub.instabase.com/api/v2/aihub/secrets")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```