Create a dedicated API-key credential for a workspace agent
The key is stored under the workspace owner’s account and used only by this agent. Callable by a user or by an account API key with integrations write scope; a key can only connect credentials to agents it installed itself, under its own account.
With replace, every live grant on the agent for the integration that serves every member is revoked in the same transaction, whoever made it. Under per-member resolution a member’s grant of their own credential serves only them, so it stays.
curl --request POST \
--url https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Basic <encoded-value>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"auth_config_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_by_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"target_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "CONNECTED",
"credentials_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"integration": "<unknown>",
"member_owned": "<unknown>",
"owner": "<unknown>",
"runs_as": "<unknown>",
"workspace": "<unknown>",
"workspace_agent_id": "<unknown>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Authorizations
API key: key id as the username, secret as the password. An account API key carries the same scopes as an OAuth token and is checked against the scopes listed under oauth2 on each operation. A trigger API key is limited to its trigger's workspace and reaches only the session operations that list this scheme alongside the oauth2 scopes.
Path Parameters
Query Parameters
When true, revokes the existing bindings that would block this credential and creates the new one in the same transaction. Either everything commits or nothing changes, enabling atomic credential swaps.
Revoke the bindings that would block this one, in the same transaction: either everything commits or nothing changes. A dedicated key and a grant serving every member exclude each other.
Response
Successful response
Integration auth config this row applies to
The user or API key that granted this credential to the agent.
Workspace agent install receiving the credential; the association is scoped to this install's workspace. Account-wide availability is plain credential ownership with no association row.
GRANTED = existing credential shared with the agent; CONNECTED = credential created for the agent (connect flow).
CONNECTED, GRANTED Linked credential row; null while OAuth connect is pending.
curl --request POST \
--url https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Basic <encoded-value>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.guild.ai/v1/workspace_agents/{workspace_agent_id}/credentials/api-key")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"auth_config_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_by_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"target_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "CONNECTED",
"credentials_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"integration": "<unknown>",
"member_owned": "<unknown>",
"owner": "<unknown>",
"runs_as": "<unknown>",
"workspace": "<unknown>",
"workspace_agent_id": "<unknown>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}