Get Workspace
Retrieve workspace details including RBAC status and configuration.
Endpoint
GET /v1/workspaces/{workspaceId}Authentication
This endpoint requires a Bearer token obtained through the two-step authentication flow:
- First, generate an access token using your API key
- Use that access token in the Authorization header
See Authentication for the complete authentication flow.
Request
# Step 1: Generate access token (do this once, reuse for multiple requests)
ACCESS_TOKEN=$(curl -s -X POST \
'https://api.sharely.ai/workspaces/{workspaceId}/generate-access-key-token' \
-H 'Content-Type: application/json' \
-H 'x-api-key: sk-sharely-your-api-key' \
-d '{}' | jq -r '.token')
# Step 2: Get workspace using the access token
curl -X GET \
'https://api.sharely.ai/v1/workspaces/{workspaceId}' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-H 'organizationid: your-organization-id'Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workspaceId | string (UUID) | Yes | The unique identifier of the workspace |
Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer token with access token |
organizationid | string (UUID) | Yes | Your organization ID |
Content-Type | string | Yes | Must be application/json |
Response
Success Response (200 OK)
{
"id": "264393d7-6379-453a-9535-e2452e972fdc",
"name": "My Workspace",
"organizationId": "org-uuid",
"rbacStatus": "ACTIVE",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-11-14T15:45:00Z",
"settings": {
"defaultLanguage": "en",
"features": ["rbac", "multilingual"]
}
}Response Fields
| Field | Type | Description |
|---|---|---|
id | string (UUID) | Workspace unique identifier |
name | string | Workspace name |
organizationId | string (UUID) | Parent organization ID |
rbacStatus | string | RBAC mode: ACTIVE or INACTIVE |
createdAt | string (ISO 8601) | Workspace creation timestamp |
updatedAt | string (ISO 8601) | Last update timestamp |
settings | object | Workspace configuration settings |
Error Responses
401 Unauthorized
{
"error": "Unauthorized",
"message": "Invalid or missing access token"
}403 Forbidden
{
"error": "Forbidden",
"message": "Insufficient permissions for this workspace"
}404 Not Found
{
"error": "Not Found",
"message": "Workspace not found"
}Example Usage
Node.js
const fetch = require('node-fetch');
const API_KEY = 'sk-sharely-your-api-key';
const WORKSPACE_ID = 'your-workspace-id';
const ORGANIZATION_ID = 'your-organization-id';
const API_BASE_URL = 'https://api.sharely.ai';
// Step 1: Generate access token
async function getAccessToken() {
const response = await fetch(
`${API_BASE_URL}/workspaces/${WORKSPACE_ID}/generate-access-key-token`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': API_KEY
},
body: JSON.stringify({})
}
);
const data = await response.json();
return data.token;
}
// Step 2: Get workspace
async function getWorkspace(accessToken) {
const response = await fetch(
`${API_BASE_URL}/v1/workspaces/${WORKSPACE_ID}`,
{
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'organizationid': ORGANIZATION_ID
}
}
);
if (!response.ok) {
throw new Error(`Failed to get workspace: ${response.status}`);
}
return await response.json();
}
// Usage
const accessToken = await getAccessToken();
const workspace = await getWorkspace(accessToken);
console.log('Workspace:', workspace.name);Python
import requests
API_KEY = 'sk-sharely-your-api-key'
WORKSPACE_ID = 'your-workspace-id'
ORGANIZATION_ID = 'your-organization-id'
API_BASE_URL = 'https://api.sharely.ai'
# Step 1: Generate access token
def get_access_token():
response = requests.post(
f'{API_BASE_URL}/workspaces/{WORKSPACE_ID}/generate-access-key-token',
headers={
'Content-Type': 'application/json',
'x-api-key': API_KEY
},
json={}
)
response.raise_for_status()
return response.json()['token']
# Step 2: Get workspace
def get_workspace(access_token):
response = requests.get(
f'{API_BASE_URL}/v1/workspaces/{WORKSPACE_ID}',
headers={
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json',
'organizationid': ORGANIZATION_ID
}
)
response.raise_for_status()
return response.json()
# Usage
access_token = get_access_token()
workspace = get_workspace(access_token)
print(f"Workspace: {workspace['name']}")Related Endpoints
- Update RBAC Status - Enable/disable RBAC
- Check Background Jobs - Monitor async operations