Update a credential - Barndoor Documentation
Update a credential
cURL
curl --request PUT \
--url https://app.barndoor.ai/api/llm-gateway/admin/connections/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"base_url": "<string>",
"auth_type": "api_key",
"api_key": "<string>",
"credentials": {},
"settings": {}
}
'
Python
import requests
url = "https://app.barndoor.ai/api/llm-gateway/admin/connections/{id}"
payload = {
"name": "<string>",
"base_url": "<string>",
"auth_type": "api_key",
"api_key": "<string>",
"credentials": {},
"settings": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)
JavaScript
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
base_url: '<string>',
auth_type: 'api_key',
api_key: '<string>',
credentials: {},
settings: {}
})
};
fetch('https://app.barndoor.ai/api/llm-gateway/admin/connections/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [\
CURLOPT_URL => "https://app.barndoor.ai/api/llm-gateway/admin/connections/{id}",\
CURLOPT_RETURNTRANSFER => true,\
CURLOPT_ENCODING => "",\
CURLOPT_MAXREDIRS => 10,\
CURLOPT_TIMEOUT => 30,\
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
CURLOPT_CUSTOMREQUEST => "PUT",\
CURLOPT_POSTFIELDS => json_encode([\
'name' => '<string>',\
'base_url' => '<string>',\
'auth_type' => 'api_key',\
'api_key' => '<string>',\
'credentials' => [\
\
],\
'settings' => [\
\
]\
]),\
CURLOPT_HTTPHEADER => [\
"Authorization: Bearer <token>",\
"Content-Type: application/json"\
],\
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.barndoor.ai/api/llm-gateway/admin/connections/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"base_url\": \"<string>\",\n \"auth_type\": \"api_key\",\n \"api_key\": \"<string>\",\n \"credentials\": {},\n \"settings\": {}\n}")
req, _ := http.NewRequest("PUT", 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(string(body))
}
HTTP Response
200 OK
Response body:
{
"id": "4f8b2a3c-12ee-4d92-9c7b-e7d2f8b0a111",
"org_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "OpenAI Production",
"model_provider": "openai",
"auth_type": "api_key",
"base_url": "https://api.openai.com/v1",
"settings": {
"region": "us-east-1",
"model_api_family": "anthropic_messages"
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
400 Bad Request
Response body:
{
"error": "BadRequest",
"message": "request_timeout_secs must be between 1 and 3600"
}
Authorizations
Authorization
Type: string
Location: header
Required: true
JWT obtained through Barndoor's authentication flow. Pass the token verbatim in Authorization: Bearer <token>. Use the Barndoor SDK's loginInteractive() helper to obtain a token in scripts and notebooks.
Path Parameters
id(string, required): Credential UUID
Body
name(string)base_url(string) auth_type(string)api_key(string) credentials(object)settings(object)
Response
On Success (200)
A reusable upstream credential, called Credentials in the portal UI. One credential can back multiple providers (e.g. a single OpenAI key used by several routes).
Response includes fields:
id: stringorg_id: stringname: stringmodel_provider: enumauth_type: stringbase_url: stringsettings: objectcreated_at: stringupdated_at: string