post__workspace_{wksId}_users
POST /workspace/{id}/users
Add User to Workspace
Add a user to a workspace with a specified role. The authenticated user must have ADMIN access to the workspace to perform this operation.
TypeScript Client Library
public addUserToWorkspace = async (workspaceId: string, request: WorkspaceTypes.AddUserToWorkspaceRequest): Promise<WorkspaceTypes.AddUserToWorkspaceResponse> => {
return this.makeRequest<WorkspaceTypes.AddUserToWorkspaceResponse>(`workspace/${workspaceId}/users`, 'POST', request);
};Code Samples
# You can also use wget
curl -X POST https://backend.flashback.tech/workspace/123e4567-e89b-12d3-a456-426614174000/users \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access-token}' \
-d '{
"userId": "user-456",
"role": "WRITE"
}'POST https://backend.flashback.tech/workspace/123e4567-e89b-12d3-a456-426614174000/users HTTP/1.1
Host: backend.flashback.tech
Content-Type: application/json
Accept: application/json
Authorization: Bearer {access-token}
{
"userId": "user-456",
"role": "WRITE"
}const workspaceId = '123e4567-e89b-12d3-a456-426614174000';
const inputBody = '{
"userId": "user-456",
"role": "WRITE"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch(`https://backend.flashback.tech/workspace/${workspaceId}/users`,
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});require 'rest-client'
require 'json'
workspace_id = '123e4567-e89b-12d3-a456-426614174000'
headers = {
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}'
}
data = {
'userId' => 'user-456',
'role' => 'WRITE'
}
result = RestClient.post "https://backend.flashback.tech/workspace/#{workspace_id}/users",
data.to_json, headers: headers
p JSON.parse(result)import requests
import json
workspace_id = '123e4567-e89b-12d3-a456-426614174000'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {access-token}'
}
data = {
'userId': 'user-456',
'role': 'WRITE'
}
r = requests.post(f'https://backend.flashback.tech/workspace/{workspace_id}/users',
headers=headers,
json=data)
print(r.json())<?php
require 'vendor/autoload.php';
$workspace_id = '123e4567-e89b-12d3-a456-426614174000';
$headers = array(
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array(
'userId' => 'user-456',
'role' => 'WRITE'
);
try {
$response = $client->request('POST',"https://backend.flashback.tech/workspace/{$workspace_id}/users", array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}String workspaceId = "123e4567-e89b-12d3-a456-426614174000";
URL obj = new URL("https://backend.flashback.tech/workspace/" + workspaceId + "/users");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setRequestProperty("Authorization", "Bearer {access-token}");
String jsonInputString = "{\"userId\": \"user-456\", \"role\": \"WRITE\"}";
con.setDoOutput(true);
try(OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
"encoding/json"
"fmt"
)
func main() {
workspaceId := "123e4567-e89b-12d3-a456-426614174000"
data := map[string]string{
"userId": "user-456",
"role": "WRITE",
}
jsonData, _ := json.Marshal(data)
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Accept": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
}
req, err := http.NewRequest("POST", fmt.Sprintf("https://backend.flashback.tech/workspace/%s/users", workspaceId), bytes.NewBuffer(jsonData))
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}Body parameter
{
"userId": "user-456",
"role": "WRITE"
}Parameters
id
path
string
true
The unique identifier of the workspace
body
body
object
true
User addition data
Path Parameters
id
string
true
none
The unique identifier of the workspace
Request Body Schema
» userId
string
true
none
The unique identifier of the user to add
» role
string
true
none
The role to assign to the user (READ, WRITE, ADMIN)
Enumerated Values
» role
READ
» role
WRITE
» role
ADMIN
Example responses
200 Response
{
"success": true
}400 Response
{
"success": false,
"message": "User not found or account is not validated"
}403 Response
{
"success": false,
"message": "Insufficient permissions to manage workspace users"
}404 Response
{
"success": false,
"message": "Target user not found"
}500 Response
{
"success": false,
"message": "Failed to add user to workspace"
}Responses
Response Schema
Status Code 200
» success
boolean
true
none
Operation success status
Status Code 400
» success
boolean
true
none
Operation success status
» message
string
true
none
Error message
Status Code 403
» success
boolean
true
none
Operation success status
» message
string
true
none
Error message
Status Code 404
» success
boolean
true
none
Operation success status
» message
string
true
none
Error message
Status Code 500
» success
boolean
true
none
Operation success status
» message
string
true
none
Error message
Notes
Authentication Required: User must be authenticated with a valid Bearer token
Permissions: User must have ADMIN access to the workspace to add users
Account Validation: User account must be validated to perform this operation
User Organization: Target user must belong to the same organization as the workspace
Role Assignment: Users can be assigned READ, WRITE, or ADMIN roles
Duplicate Prevention: If the user already exists in the workspace, the role will be updated
Organization Scoped: Users can only be added to workspaces within their organization
Last updated
Was this helpful?