Update Credentials
PUT https://api.coactive.ai/api/v1/auth-management/clients/{client_id}Content-Type: application/jsonUpdate system-level credentials.
This endpoint allows updating the name and roles of existing system-level credentials.
The access of the system-level credentials is scoped to its roles. If no roles are provided, the system-level credentials will have full access to all resources. If the credentials was previously assigned roles and no roles are provided in the update request, the credentials will gain full access to all resources.
Authentication
Section titled “Authentication”Authorizationheader (bearer token, required) — Bearer authentication of the formBearer <token>, where token is your auth token.
Request
Section titled “Request”Path parameters
Section titled “Path parameters”client_id(string, required) — The client ID of the system-level credentials
Body (application/json)
Section titled “Body (application/json)”This endpoint expects an object.
name(string, optional, nullable) — Display name for the system-level credentialsroles(list of object, optional, nullable) — List of roles to assign to the system-level credentials. This is only available to organizations that are RBAC-enabled. Please contact support if you would like to enable RBAC for your organization.role_id(string, required) — Name of the role (e.g., ‘admin’, ‘editor’, ‘viewer’)resource(string, optional, nullable) — Optional resource type the role applies to (e.g., ‘dataset’)resource_instance(string, optional, nullable) — Optional resource instance ID the role applies to
roles_context(string, optional, nullable) — Context for the roles to update. This can either be ‘system’ for system-level roles or ‘dataset:{dataset_id}’ for dataset-level roles.
Response
Section titled “Response”The updated system-level credentials details
client_id(string, required) — OAuth client IDclient_secret(string, required) — OAuth client secret (only returned on creation)name(string, required) — Display name for the OAuth clientroles(list of object, required) — List of roles assigned to the clientrole_id(string, required) — Name of the role (e.g., ‘admin’, ‘editor’, ‘viewer’)resource(string, optional, nullable) — Optional resource type the role applies to (e.g., ‘dataset’)resource_instance(string, optional, nullable) — Optional resource instance ID the role applies to
Errors
Section titled “Errors”422 Unprocessable Entity Error
Section titled “422 Unprocessable Entity Error”Validation Error
detail(list of object, optional)loc(list of string or integer, required)msg(string, required)type(string, required)
Examples
Section titled “Examples”Request
{ "name": "My OAuth Client", "roles": [ { "role_id": "admin" } ]}Response
{ "client_id": "client_123", "client_secret": "secret_123", "name": "My OAuth Client", "roles": [ { "role_id": "admin" }, { "role_id": "editor", "resource": "dataset", "resource_instance": "c1a7cb60-1731-4c0f-b966-165263c30896" } ]}SDK Code
import requests
url = "https://api.coactive.ai/api/v1/auth-management/clients/client_id"
payload = { "name": "My OAuth Client", "roles": [{ "role_id": "admin" }]}headers = { "Authorization": "Bearer <token>", "Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.json())const url = 'https://api.coactive.ai/api/v1/auth-management/clients/client_id';const options = { method: 'PUT', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"My OAuth Client","roles":[{"role_id":"admin"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.coactive.ai/api/v1/auth-management/clients/client_id"
payload := strings.NewReader("{\n \"name\": \"My OAuth Client\",\n \"roles\": [\n {\n \"role_id\": \"admin\"\n }\n ]\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(res) fmt.Println(string(body))
}require 'uri'require 'net/http'
url = URI("https://api.coactive.ai/api/v1/auth-management/clients/client_id")
http = Net::HTTP.new(url.host, url.port)http.use_ssl = true
request = Net::HTTP::Put.new(url)request["Authorization"] = 'Bearer <token>'request["Content-Type"] = 'application/json'request.body = "{\n \"name\": \"My OAuth Client\",\n \"roles\": [\n {\n \"role_id\": \"admin\"\n }\n ]\n}"
response = http.request(request)puts response.read_bodyimport com.mashape.unirest.http.HttpResponse;import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.put("https://api.coactive.ai/api/v1/auth-management/clients/client_id") .header("Authorization", "Bearer <token>") .header("Content-Type", "application/json") .body("{\n \"name\": \"My OAuth Client\",\n \"roles\": [\n {\n \"role_id\": \"admin\"\n }\n ]\n}") .asString();<?phprequire_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('PUT', 'https://api.coactive.ai/api/v1/auth-management/clients/client_id', [ 'body' => '{ "name": "My OAuth Client", "roles": [ { "role_id": "admin" } ]}', 'headers' => [ 'Authorization' => 'Bearer <token>', 'Content-Type' => 'application/json', ],]);
echo $response->getBody();using RestSharp;
var client = new RestClient("https://api.coactive.ai/api/v1/auth-management/clients/client_id");var request = new RestRequest(Method.PUT);request.AddHeader("Authorization", "Bearer <token>");request.AddHeader("Content-Type", "application/json");request.AddParameter("application/json", "{\n \"name\": \"My OAuth Client\",\n \"roles\": [\n {\n \"role_id\": \"admin\"\n }\n ]\n}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import Foundation
let headers = [ "Authorization": "Bearer <token>", "Content-Type": "application/json"]let parameters = [ "name": "My OAuth Client", "roles": [["role_id": "admin"]]] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.coactive.ai/api/v1/auth-management/clients/client_id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)request.httpMethod = "PUT"request.allHTTPHeaderFields = headersrequest.httpBody = postData as Data
let session = URLSession.sharedlet 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()