curl --request POST \
--url https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"role_id": "00000000-0000-0000-0000-000000000020"
}
'import requests
url = "https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles"
payload = { "role_id": "00000000-0000-0000-0000-000000000020" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({role_id: '00000000-0000-0000-0000-000000000020'})
};
fetch('https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles', 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://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'role_id' => '00000000-0000-0000-0000-000000000020'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles"
payload := strings.NewReader("{\n \"role_id\": \"00000000-0000-0000-0000-000000000020\"\n}")
req, _ := http.NewRequest("POST", 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))
}HttpResponse<String> response = Unirest.post("https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"role_id\": \"00000000-0000-0000-0000-000000000020\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"role_id\": \"00000000-0000-0000-0000-000000000020\"\n}"
response = http.request(request)
puts response.read_body{
"id": "r3b4c5d6-e7f8-9012-abcd-ef1234567890",
"service_account_id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
"workspace_id": "w1b2c3d4-e5f6-7890-abcd-ef1234567890",
"role_id": "00000000-0000-0000-0000-000000000020",
"role_name": "workspace_admin",
"role_type": "system_role",
"granted_at": "2026-06-01T12:00:00Z",
"granted_by": "00000000-0000-0000-0000-000000000001"
}Assign Service Account Workspace Role
Assign a workspace-scoped role (system or custom access) to a service account. This is how workspace_admin and other workspace-scoped system roles are granted; only the account-wide admin role is assigned via POST /service-accounts/{id}/roles. The service account must be a direct member of the target workspace before this call.
curl --request POST \
--url https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"role_id": "00000000-0000-0000-0000-000000000020"
}
'import requests
url = "https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles"
payload = { "role_id": "00000000-0000-0000-0000-000000000020" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({role_id: '00000000-0000-0000-0000-000000000020'})
};
fetch('https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles', 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://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'role_id' => '00000000-0000-0000-0000-000000000020'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles"
payload := strings.NewReader("{\n \"role_id\": \"00000000-0000-0000-0000-000000000020\"\n}")
req, _ := http.NewRequest("POST", 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))
}HttpResponse<String> response = Unirest.post("https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"role_id\": \"00000000-0000-0000-0000-000000000020\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud.cdata.com/api/v1/admin/service-accounts/{id}/workspaces/{workspace_id}/roles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"role_id\": \"00000000-0000-0000-0000-000000000020\"\n}"
response = http.request(request)
puts response.read_body{
"id": "r3b4c5d6-e7f8-9012-abcd-ef1234567890",
"service_account_id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
"workspace_id": "w1b2c3d4-e5f6-7890-abcd-ef1234567890",
"role_id": "00000000-0000-0000-0000-000000000020",
"role_name": "workspace_admin",
"role_type": "system_role",
"granted_at": "2026-06-01T12:00:00Z",
"granted_by": "00000000-0000-0000-0000-000000000001"
}Authorizations
OAuth 2.0 client credentials. Alternatively, you can authenticate with a personal access token (PAT) by sending Authorization: Basic base64(email:PAT).
Scopes
Write access to service account resources.
Path Parameters
Service account identifier (UUID).
Workspace identifier (UUID).
Body
Role to assign. Must exist in the organization.
Response
Created. Returns the new workspace role assignment.
A workspace-scoped role assignment for a service account.
Assignment identifier.
The service account this workspace role is assigned to.
The workspace this role is assigned to.
The role identifier.
The name of the role.
The type of the role.
system_role, access_role ISO 8601 UTC.
The user who granted the workspace role.
Was this page helpful?