Workspaces API

Workspaces are the top-level organizational unit in LVNG. They scope channels, agents, workflows, and team members. Each workspace has its own visibility settings, member roles (owner, admin, member), and configurable settings. Users can belong to multiple workspaces. All endpoints require JWT authentication and are rate-limited to 100 requests per minute.

Health Check

Service health endpoint. Placed before /:id routes to avoid parameter capture.

GET/api/v2/workspaces/healthAuthenticated

Returns service health status.

Request

cURL
curl -X GET "https://api.lvng.ai/api/v2/workspaces/health" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

{
  "status": "healthy",
  "service": "workspaces-api-v2"
}

Workspace CRUD

Create, retrieve, update, and delete workspaces. List returns only workspaces where the user is a member (via JOIN on workspace_members). The creator is automatically added as owner.

GET/api/v2/workspacesAuthenticated

List all workspaces the authenticated user belongs to. Returns workspaces joined via workspace_members table, including the user's role and ownership status.

Request

cURL
curl -X GET "https://api.lvng.ai/api/v2/workspaces" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

{
  "success": true,
  "workspaces": [
    {
      "id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
      "name": "LVNG Engineering",
      "slug": "lvng-engineering",
      "description": "Engineering team workspace for product development",
      "owner_id": "8f3a2b1c-4d5e-6f7a-8b9c-0d1e2f3a4b5c",
      "created_at": "2026-01-10T08:00:00.000Z",
      "updated_at": "2026-03-19T10:00:00.000Z",
      "settings": {},
      "my_role": "owner",
      "is_owner": true
    },
    {
      "id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
      "name": "Sales Operations",
      "slug": "sales-ops",
      "description": "Sales team workspace for CRM and reporting",
      "owner_id": "2a3b4c5d-6e7f-8901-abcd-ef2345678901",
      "created_at": "2026-02-01T09:00:00.000Z",
      "updated_at": "2026-03-18T14:00:00.000Z",
      "settings": {},
      "my_role": "admin",
      "is_owner": false
    }
  ],
  "count": 2
}
POST/api/v2/workspacesAuthenticated

Create a new workspace. The authenticated user is automatically added as the owner. Slug must be lowercase alphanumeric with hyphens only. Returns 409 if slug already exists.

Body Parameters

namestringrequired

Display name for the workspace.

slugstringrequired

URL-safe identifier. Must be lowercase alphanumeric with hyphens (e.g., "my-workspace").

descriptionstring

A brief description of the workspace purpose.

visibilitystring
Default: private

Workspace visibility: public, private, or invite-only.

discoverableboolean
Default: false

Whether the workspace appears in search/discovery.

settingsobject

Initial workspace settings object.

Request

cURL
curl -X POST "https://api.lvng.ai/api/v2/workspaces" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Response 201

{
  "success": true,
  "workspace": {
    "id": "d4e5f6a7-b8c9-0123-def4-567890123456",
    "name": "Marketing Hub",
    "slug": "marketing-hub",
    "description": "Central workspace for marketing campaigns and analytics",
    "owner_id": "8f3a2b1c-4d5e-6f7a-8b9c-0d1e2f3a4b5c",
    "visibility": "private",
    "discoverable": false,
    "settings": {},
    "created_at": "2026-03-19T18:30:00.000Z",
    "updated_at": "2026-03-19T18:30:00.000Z",
    "my_role": "owner",
    "is_owner": true
  }
}
GET/api/v2/workspaces/:idAuthenticated

Get detailed workspace information. Verifies the user is a member of the workspace. Includes member count and the user's role.

Path Parameters

iduuidrequired

The workspace ID.

Request

cURL
curl -X GET "https://api.lvng.ai/api/v2/workspaces/{id}" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

{
  "success": true,
  "workspace": {
    "id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
    "name": "LVNG Engineering",
    "slug": "lvng-engineering",
    "description": "Engineering team workspace for product development",
    "owner_id": "8f3a2b1c-4d5e-6f7a-8b9c-0d1e2f3a4b5c",
    "created_at": "2026-01-10T08:00:00.000Z",
    "updated_at": "2026-03-19T10:00:00.000Z",
    "settings": {},
    "member_count": 12,
    "my_role": "owner",
    "is_owner": true
  }
}
PUT/api/v2/workspaces/:idAuthenticated

Update workspace properties. Requires admin or owner role. Only the owner can change visibility to 'public' or set discoverable to true.

Path Parameters

iduuidrequired

The workspace ID.

Body Parameters

namestring

Updated workspace name.

descriptionstring

Updated description.

visibilitystring

Updated visibility: public, private, or invite-only.

discoverableboolean

Updated discoverability setting.

settingsobject

Updated settings object (replaces existing).

Request

cURL
curl -X PUT "https://api.lvng.ai/api/v2/workspaces/{id}" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Response 200

{
  "success": true,
  "workspace": {
    "id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
    "name": "LVNG Engineering & Platform",
    "slug": "lvng-engineering",
    "description": "Engineering and platform team workspace",
    "owner_id": "8f3a2b1c-4d5e-6f7a-8b9c-0d1e2f3a4b5c",
    "visibility": "private",
    "discoverable": false,
    "settings": {},
    "created_at": "2026-01-10T08:00:00.000Z",
    "updated_at": "2026-03-19T18:40:00.000Z"
  }
}
DELETE/api/v2/workspaces/:idAuthenticated

Delete a workspace and all related data (CASCADE deletes members, channels, etc.). Only the workspace owner can delete.

Path Parameters

iduuidrequired

The workspace ID.

Request

cURL
curl -X DELETE "https://api.lvng.ai/api/v2/workspaces/{id}" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

{
  "success": true,
  "message": "Workspace deleted successfully"
}

Workspace Members

Manage team members within a workspace. Members have roles: owner (full control), admin (manage members and settings), or member (use resources). Profile data is fetched from the user_profiles table and presence status is enriched from the presence service when available.

GET/api/v2/workspaces/:id/membersAuthenticated

List all members of a workspace with their profile data and online status. Supports search by name/email and role filtering. Requires workspace membership.

Path Parameters

iduuidrequired

The workspace ID.

Query Parameters

searchstring

Filter members by name or email (case-insensitive).

rolestring

Filter by role: owner, admin, or member.

limitinteger
Default: 50

Maximum number of members to return.

offsetinteger
Default: 0

Pagination offset.

Request

cURL
curl -X GET "https://api.lvng.ai/api/v2/workspaces/{id}/members" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

{
  "success": true,
  "members": [
    {
      "id": "mem_1a2b3c4d-5e6f-7890-abcd-ef1234567890",
      "user_id": "8f3a2b1c-4d5e-6f7a-8b9c-0d1e2f3a4b5c",
      "role": "owner",
      "joined_at": "2026-01-10T08:00:00.000Z",
      "last_seen_at": "2026-03-19T17:30:00.000Z",
      "email": "sam@example.com",
      "display_name": "Sam Carter",
      "avatar_url": "https://cdn.lvng.ai/avatars/sam.jpg",
      "bio": "Founder & CEO",
      "job_title": "CEO",
      "online_status": "online"
    },
    {
      "id": "mem_2b3c4d5e-6f78-9012-bcde-f23456789012",
      "user_id": "2a3b4c5d-6e7f-8901-abcd-ef2345678901",
      "role": "admin",
      "joined_at": "2026-01-12T10:00:00.000Z",
      "last_seen_at": "2026-03-19T16:45:00.000Z",
      "email": "sarah@example.com",
      "display_name": "Sarah Chen",
      "avatar_url": null,
      "bio": null,
      "job_title": "Engineering Lead",
      "online_status": "offline"
    }
  ],
  "count": 2,
  "total": 12
}
GET/api/v2/workspaces/:id/members/:userIdAuthenticated

Get detailed member profile including shared channels, DM link, and online status. Requires workspace membership.

Path Parameters

iduuidrequired

The workspace ID.

userIduuidrequired

The user ID of the member.

Request

cURL
curl -X GET "https://api.lvng.ai/api/v2/workspaces/{id}/members/{userId}" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

{
  "success": true,
  "member": {
    "id": "mem_2b3c4d5e-6f78-9012-bcde-f23456789012",
    "user_id": "2a3b4c5d-6e7f-8901-abcd-ef2345678901",
    "role": "admin",
    "joined_at": "2026-01-12T10:00:00.000Z",
    "last_seen_at": "2026-03-19T16:45:00.000Z",
    "email": "sarah@example.com",
    "display_name": "Sarah Chen",
    "avatar_url": null,
    "bio": null,
    "job_title": "Engineering Lead",
    "online_status": "offline",
    "shared_channels": [
      { "id": "ch_1a2b3c4d", "name": "general", "is_private": false },
      { "id": "ch_2b3c4d5e", "name": "engineering", "is_private": true }
    ],
    "dm_id": "dm_3c4d5e6f-7890-1234-abcd-ef5678901234",
    "is_self": false
  }
}
POST/api/v2/workspaces/:id/membersAuthenticated

Add a user to the workspace. Owners and admins add people, with a role no higher than their own. Everyone else joins by invitation: a caller who is not an owner or admin gets 403 (code invitation_required). Returns 409 if the user is already a member.

Path Parameters

iduuidrequired

The workspace ID.

Body Parameters

user_iduuidrequired

The user ID to add.

rolestring
Default: member

Role to assign: owner, admin, or member.

Request

cURL
curl -X POST "https://api.lvng.ai/api/v2/workspaces/{id}/members" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Response 201

{
  "success": true,
  "member": {
    "id": "mem_4c5d6e7f-8091-0234-cdef-456789012345",
    "workspace_id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
    "user_id": "4c5d6e7f-8091-0234-cdef-456789012345",
    "role": "member",
    "invited_by": "8f3a2b1c-4d5e-6f7a-8b9c-0d1e2f3a4b5c",
    "joined_at": "2026-03-19T18:50:00.000Z"
  }
}
DELETE/api/v2/workspaces/:id/members/:userIdAuthenticated

Remove a member from the workspace. Admins and owners can remove others; users can remove themselves. The workspace owner cannot be removed. Returns 400 if attempting to remove the owner.

Path Parameters

iduuidrequired

The workspace ID.

userIduuidrequired

The user ID to remove.

Request

cURL
curl -X DELETE "https://api.lvng.ai/api/v2/workspaces/{id}/members/{userId}" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

{
  "success": true,
  "message": "Member removed successfully"
}
PATCH/api/v2/workspaces/:id/members/:userIdAuthenticated

Update a member's role. Requires admin or owner role. Only the owner can assign the 'owner' role (which also transfers workspace ownership). Cannot change the current owner's role.

Path Parameters

iduuidrequired

The workspace ID.

userIduuidrequired

The user ID to update.

Body Parameters

rolestringrequired

New role: owner, admin, or member.

Request

cURL
curl -X PATCH "https://api.lvng.ai/api/v2/workspaces/{id}/members/{userId}" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Response 200

{
  "success": true,
  "member": {
    "id": "mem_3b4c5d6e-7f80-9012-bcde-f34567890123",
    "workspace_id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
    "user_id": "3b4c5d6e-7f80-9012-bcde-f34567890123",
    "role": "admin",
    "joined_at": "2026-01-15T14:00:00.000Z"
  }
}

Settings & Permissions

Configure workspace-level settings and view effective permissions. Settings are stored in the workspace_settings table. If no settings exist on first access, defaults are auto-created. Organization admins can also manage workspace settings.

GET/api/v2/workspaces/:id/settingsAuthenticated

Get workspace settings. Creates default settings if none exist. Requires workspace membership or org admin role.

Path Parameters

iduuidrequired

The workspace ID.

Request

cURL
curl -X GET "https://api.lvng.ai/api/v2/workspaces/{id}/settings" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

{
  "success": true,
  "settings": {
    "workspace_id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
    "allow_member_invite": true,
    "allow_conversation_creation": true,
    "allow_result_sharing": true,
    "require_admin_approval": false,
    "default_twin_mode": "active",
    "join_mode": null,
    "created_at": "2026-01-10T08:00:00.000Z",
    "updated_at": "2026-03-15T10:00:00.000Z"
  }
}
PATCH/api/v2/workspaces/:id/settingsAuthenticated

Update workspace settings. Requires workspace admin/owner role or organization admin. Returns 400 if no valid settings fields are provided.

Path Parameters

iduuidrequired

The workspace ID.

Body Parameters

allow_member_inviteboolean

Whether members can invite others.

allow_conversation_creationboolean

Whether members can create conversations.

allow_result_sharingboolean

Whether members can share results externally.

require_admin_approvalboolean

Whether new member additions require admin approval.

default_twin_modestring

Default twin mode: active, observer, or on-demand.

join_modestring

How users can join: open, request, or invite-only.

Request

cURL
curl -X PATCH "https://api.lvng.ai/api/v2/workspaces/{id}/settings" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Response 200

{
  "success": true,
  "settings": {
    "workspace_id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
    "allow_member_invite": true,
    "allow_conversation_creation": true,
    "allow_result_sharing": true,
    "require_admin_approval": true,
    "default_twin_mode": "observer",
    "join_mode": "request",
    "updated_at": "2026-03-19T19:10:00.000Z"
  }
}
GET/api/v2/workspaces/:id/permissionsAuthenticated

Get the effective permissions for the authenticated user. Calculated from workspace member role and organization membership. Org admins receive elevated permissions even without workspace membership.

Path Parameters

iduuidrequired

The workspace ID.

Request

cURL
curl -X GET "https://api.lvng.ai/api/v2/workspaces/{id}/permissions" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

{
  "success": true,
  "permissions": {
    "role": "owner",
    "canViewSettings": true,
    "canEditSettings": true,
    "canManageMembers": true,
    "canInviteMembers": true,
    "canCreateConversations": true,
    "canDeleteWorkspace": true,
    "isOwner": true,
    "isOrgAdmin": false
  }
}