# Workspace Sharing

## Invite a user to a workspace

> Send an invitation to a user to join a workspace with specified permissions. Only workspace owners can send invitations.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-JSMON-KEY","description":"API Key to access the Jsmon API. Example: \"X-JSMON-KEY: your_api_key_here\""}}},"paths":{"/api/v2/workspaces/{workspaceId}/invite":{"post":{"summary":"Invite a user to a workspace","description":"Send an invitation to a user to join a workspace with specified permissions. Only workspace owners can send invitations.","tags":["Workspace Sharing"],"parameters":[{"in":"path","name":"workspaceId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The workspace ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["invitedEmail"],"properties":{"invitedEmail":{"type":"string","format":"email","description":"Email address of the user to invite"},"permissions":{"type":"string","enum":["read","write","admin"],"default":"read","description":"Permission level for the invited user"}}}}}},"responses":{"200":{"description":"Invitation sent successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"invitationId":{"type":"string","format":"uuid"},"invitedEmail":{"type":"string","format":"email"}}}}}},"400":{"description":"Bad Request - Invalid input, disposable email, or user already has access","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"403":{"description":"Forbidden - Only workspace owner can invite users"},"404":{"description":"Workspace not found"},"500":{"description":"Internal server error"}}}}}}
```

## Accept or reject a workspace invitation

> Accept or reject a pending workspace invitation. The invitation must be for the authenticated user.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-JSMON-KEY","description":"API Key to access the Jsmon API. Example: \"X-JSMON-KEY: your_api_key_here\""}}},"paths":{"/api/v2/workspaceInvitations/{invitationId}":{"post":{"summary":"Accept or reject a workspace invitation","description":"Accept or reject a pending workspace invitation. The invitation must be for the authenticated user.","tags":["Workspace Sharing"],"parameters":[{"in":"path","name":"invitationId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The invitation ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status","userEmail"],"properties":{"status":{"type":"string","enum":["accepted","rejected"],"description":"Whether to accept or reject the invitation"},"userEmail":{"type":"string","format":"email","description":"Email address of the user responding to the invitation"}}}}}},"responses":{"200":{"description":"Invitation response processed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"400":{"description":"Bad Request - Invitation expired, already processed, or invalid status"},"403":{"description":"Forbidden - Invitation is not for this user"},"404":{"description":"Invitation not found"},"500":{"description":"Internal server error"}}}}}}
```

## Update invitation expiration date

> Update the expiration date of a pending workspace invitation. Only the inviter or workspace owner can update expiration.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-JSMON-KEY","description":"API Key to access the Jsmon API. Example: \"X-JSMON-KEY: your_api_key_here\""}}},"paths":{"/api/v2/workspaceInvitations/{invitationId}/expiration":{"post":{"summary":"Update invitation expiration date","description":"Update the expiration date of a pending workspace invitation. Only the inviter or workspace owner can update expiration.","tags":["Workspace Sharing"],"parameters":[{"in":"path","name":"invitationId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The invitation ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["expirationDate"],"properties":{"expirationDate":{"type":"string","format":"date-time","description":"New expiration date for the invitation"}}}}}},"responses":{"200":{"description":"Invitation expiration updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"invitationId":{"type":"string","format":"uuid"},"expiresAt":{"type":"string","format":"date-time"}}}}}},"400":{"description":"Bad Request - Invalid date format"},"403":{"description":"Forbidden - Only inviter or workspace owner can update expiration"},"404":{"description":"Invitation or workspace not found"},"500":{"description":"Internal server error"}}}}}}
```

## Remove a user from workspace

> Remove a shared user's access to a workspace. Only workspace owners can remove users.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-JSMON-KEY","description":"API Key to access the Jsmon API. Example: \"X-JSMON-KEY: your_api_key_here\""}}},"paths":{"/api/v2/workspaces/{workspaceId}/sharedUsers/{userId}/remove":{"post":{"summary":"Remove a user from workspace","description":"Remove a shared user's access to a workspace. Only workspace owners can remove users.","tags":["Workspace Sharing"],"parameters":[{"in":"path","name":"workspaceId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The workspace ID"},{"in":"path","name":"userId","required":true,"schema":{"type":"string"},"description":"The user ID to remove from workspace"}],"responses":{"200":{"description":"User removed from workspace successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"userId":{"type":"string"},"workspace":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Forbidden - Only workspace owner can remove users"},"404":{"description":"Workspace not found or user already removed"},"500":{"description":"Internal server error"}}}}}}
```

## Update user permissions in workspace

> Update the permission level of a shared user in a workspace. Only workspace owners can update permissions.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-JSMON-KEY","description":"API Key to access the Jsmon API. Example: \"X-JSMON-KEY: your_api_key_here\""}}},"paths":{"/api/v2/workspaces/{workspaceId}/sharedUsers/{userId}":{"post":{"summary":"Update user permissions in workspace","description":"Update the permission level of a shared user in a workspace. Only workspace owners can update permissions.","tags":["Workspace Sharing"],"parameters":[{"in":"path","name":"workspaceId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The workspace ID"},{"in":"path","name":"userId","required":true,"schema":{"type":"string"},"description":"The user ID whose permissions to update"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["permissions"],"properties":{"permissions":{"type":"string","enum":["read","write","admin"],"description":"New permission level for the user"}}}}}},"responses":{"200":{"description":"Permissions updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"userId":{"type":"string"},"workspace":{"type":"string","format":"uuid"},"permissions":{"type":"string","enum":["read","write","admin"]}}}}}},"400":{"description":"Bad Request - Invalid permissions"},"403":{"description":"Forbidden - Only workspace owner can update permissions"},"404":{"description":"Workspace not found or user does not have access"},"500":{"description":"Internal server error"}}}}}}
```

## List all shared users in workspace

> Get a list of all users who have access to the workspace along with their permissions.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-JSMON-KEY","description":"API Key to access the Jsmon API. Example: \"X-JSMON-KEY: your_api_key_here\""}}},"paths":{"/api/v2/workspaces/{workspaceId}/sharedUsers":{"get":{"summary":"List all shared users in workspace","description":"Get a list of all users who have access to the workspace along with their permissions.","tags":["Workspace Sharing"],"parameters":[{"in":"path","name":"workspaceId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The workspace ID"}],"responses":{"200":{"description":"Successfully retrieved shared users list","content":{"application/json":{"schema":{"type":"object","properties":{"workspaceId":{"type":"string","format":"uuid"},"sharedUsers":{"type":"array","items":{"type":"object","properties":{"userId":{"type":"string","description":"User ID"},"name":{"type":"string","description":"User's full name"},"email":{"type":"string","format":"email","description":"User's email address"},"permissions":{"type":"string","enum":["read","write","admin"],"description":"User's permission level"},"addedAt":{"type":"string","format":"date-time","description":"Date when user was added to workspace"}}}}}}}}},"403":{"description":"Forbidden - No access to this workspace"},"404":{"description":"Workspace not found"},"500":{"description":"Internal server error"}}}}}}
```

## List pending invitations for workspace

> Get a list of all pending invitations for a workspace. Workspace owners can see all invitations, other users can only see invitations they sent.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-JSMON-KEY","description":"API Key to access the Jsmon API. Example: \"X-JSMON-KEY: your_api_key_here\""}}},"paths":{"/api/v2/workspaces/{workspaceId}/pendingInvitations":{"post":{"summary":"List pending invitations for workspace","description":"Get a list of all pending invitations for a workspace. Workspace owners can see all invitations, other users can only see invitations they sent.","tags":["Workspace Sharing"],"parameters":[{"in":"path","name":"workspaceId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The workspace ID"}],"responses":{"200":{"description":"Successfully retrieved pending invitations","content":{"application/json":{"schema":{"type":"object","properties":{"workspaceId":{"type":"string","format":"uuid"},"pendingInvitations":{"type":"array","items":{"type":"object","properties":{"invitationId":{"type":"string","format":"uuid","description":"Invitation ID"},"inviterId":{"type":"string","description":"ID of user who sent the invitation"},"inviterName":{"type":"string","description":"Name of user who sent the invitation"},"invitedEmail":{"type":"string","format":"email","description":"Email address of invited user"},"status":{"type":"string","enum":["pending"],"description":"Invitation status"},"permissions":{"type":"string","enum":["read","write","admin"],"description":"Permission level for invited user"},"expiresAt":{"type":"string","format":"date-time","description":"Invitation expiration date"},"createdAt":{"type":"string","format":"date-time","description":"Invitation creation date"}}}}}}}}},"403":{"description":"Forbidden - No access to this workspace"},"404":{"description":"Workspace not found"},"500":{"description":"Internal server error"}}}}}}
```

## Resend workspace invitation

> Resend an invitation email for a pending workspace invitation. Only the original inviter or workspace owner can resend invitations.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"Bearer":[]},{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-JSMON-KEY","description":"API Key to access the Jsmon API. Example: \"X-JSMON-KEY: your_api_key_here\""}}},"paths":{"/api/v2/workspaceInvitations/{invitationId}/resend":{"post":{"summary":"Resend workspace invitation","description":"Resend an invitation email for a pending workspace invitation. Only the original inviter or workspace owner can resend invitations.","tags":["Workspace Sharing"],"parameters":[{"in":"path","name":"invitationId","required":true,"schema":{"type":"string","format":"uuid"},"description":"The invitation ID to resend"}],"responses":{"200":{"description":"Invitation resent successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"invitationId":{"type":"string","format":"uuid"},"invitedEmail":{"type":"string","format":"email"}}}}}},"400":{"description":"Bad Request - Invitation already processed"},"403":{"description":"Forbidden - Only inviter or workspace owner can resend"},"404":{"description":"Invitation not found"},"500":{"description":"Internal server error"}}}}}}
```
