Replace who a workspace is shared with
curl --request PUT \
--url https://api.onecli.sh/v1/workspaces/{workspaceId}/access \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"users": [
{
"userId": "<string>"
}
],
"groupIds": [
"<string>"
]
}
'import requests
url = "https://api.onecli.sh/v1/workspaces/{workspaceId}/access"
payload = {
"users": [{ "userId": "<string>" }],
"groupIds": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({users: [{userId: '<string>'}], groupIds: ['<string>']})
};
fetch('https://api.onecli.sh/v1/workspaces/{workspaceId}/access', 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.onecli.sh/v1/workspaces/{workspaceId}/access",
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([
'users' => [
[
'userId' => '<string>'
]
],
'groupIds' => [
'<string>'
]
]),
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://api.onecli.sh/v1/workspaces/{workspaceId}/access"
payload := strings.NewReader("{\n \"users\": [\n {\n \"userId\": \"<string>\"\n }\n ],\n \"groupIds\": [\n \"<string>\"\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(string(body))
}HttpResponse<String> response = Unirest.put("https://api.onecli.sh/v1/workspaces/{workspaceId}/access")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"users\": [\n {\n \"userId\": \"<string>\"\n }\n ],\n \"groupIds\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onecli.sh/v1/workspaces/{workspaceId}/access")
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 \"users\": [\n {\n \"userId\": \"<string>\"\n }\n ],\n \"groupIds\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"added": 123,
"removed": 123,
"roleChanged": 123
}{
"error": "<string>"
}{
"error": "<string>"
}Workspace access
Replace who a workspace is shared with
Replaces the full set of workspace shares, adding, removing, or re-roling people and groups to match the request. On Cloud, plan limits apply to additions.
PUT
/
workspaces
/
{workspaceId}
/
access
Replace who a workspace is shared with
curl --request PUT \
--url https://api.onecli.sh/v1/workspaces/{workspaceId}/access \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"users": [
{
"userId": "<string>"
}
],
"groupIds": [
"<string>"
]
}
'import requests
url = "https://api.onecli.sh/v1/workspaces/{workspaceId}/access"
payload = {
"users": [{ "userId": "<string>" }],
"groupIds": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({users: [{userId: '<string>'}], groupIds: ['<string>']})
};
fetch('https://api.onecli.sh/v1/workspaces/{workspaceId}/access', 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.onecli.sh/v1/workspaces/{workspaceId}/access",
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([
'users' => [
[
'userId' => '<string>'
]
],
'groupIds' => [
'<string>'
]
]),
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://api.onecli.sh/v1/workspaces/{workspaceId}/access"
payload := strings.NewReader("{\n \"users\": [\n {\n \"userId\": \"<string>\"\n }\n ],\n \"groupIds\": [\n \"<string>\"\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(string(body))
}HttpResponse<String> response = Unirest.put("https://api.onecli.sh/v1/workspaces/{workspaceId}/access")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"users\": [\n {\n \"userId\": \"<string>\"\n }\n ],\n \"groupIds\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onecli.sh/v1/workspaces/{workspaceId}/access")
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 \"users\": [\n {\n \"userId\": \"<string>\"\n }\n ],\n \"groupIds\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"added": 123,
"removed": 123,
"roleChanged": 123
}{
"error": "<string>"
}{
"error": "<string>"
}Sends the complete desired share list, and OneCLI reconciles to it. On Cloud, sharing with people needs the Team plan and sharing with groups needs Enterprise, checked on additions only. See Editions and User provisioning.
Replaces the full set of shares. People are added, removed, or re-roled to match
users; groups to match groupIds. On Cloud, sharing with people needs the Team plan and sharing with groups needs the Enterprise plan; the check applies to additions only, so an existing binding never blocks an edit.
Availability: Cloud · Enterprise (self-hosted). Not available on the Community edition: a self-hosted deployment needs
ENTERPRISE_ENABLED=true, otherwise the endpoint answers 403 with error.type: "enterprise_license_required".Authorizations
A workspace API key (oc_…) or organization API key (oc_org_…). Workspace-scoped endpoints called with an organization key also need X-Workspace-Id.
Path Parameters
Body
application/json