> ## Documentation Index
> Fetch the complete documentation index at: https://moonshadow-ep3.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Permissions and Roles in Moonshadow Workspaces

> Moonshadow uses role-based access control with Owner, Admin, Member, and Viewer roles. Learn what each role can do and how to manage members.

Moonshadow uses role-based access control (RBAC) to manage what each person can do inside a workspace. Every member is assigned one of four roles: Owner, Admin, Member, or Viewer. Roles determine who can manage billing, create integrations, build automations, or simply view dashboards.

## Role Permissions

The following table shows what each role can do inside a workspace:

| Permission                  | Owner | Admin | Member | Viewer |
| --------------------------- | :---: | :---: | :----: | :----: |
| Manage billing and plans    |  Yes  |   No  |   No   |   No   |
| Delete workspace            |  Yes  |   No  |   No   |   No   |
| Manage integrations         |  Yes  |  Yes  |   No   |   No   |
| Invite and remove members   |  Yes  |  Yes  |   No   |   No   |
| Manage API keys             |  Yes  |  Yes  |   No   |   No   |
| Create and edit automations |  Yes  |  Yes  |   Yes  |   No   |
| View events and dashboards  |  Yes  |  Yes  |   Yes  |   Yes  |
| Receive notifications       |  Yes  |  Yes  |   Yes  |   Yes  |

Owners have full control over the workspace, including destructive actions like deletion and billing changes. Admins can manage day-to-day operations such as integrations and members but cannot alter billing or delete the workspace. Members can build automations and view data but cannot change workspace settings. Viewers have read-only access and cannot modify anything.

## Changing a Member's Role

Only Owners and Admins can change roles. To update a role from the dashboard:

1. Go to **Settings > Members** inside the workspace.
2. Find the member whose role you want to change.
3. Select the new role from the dropdown.
4. Confirm the change.

The member's permissions update immediately without requiring them to log out.

## Adding and Removing Members via API

You can invite a new member or remove an existing one programmatically.

### Invite a Member

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.moonshadow.dev/v1/workspaces/{workspace_id}/members \
    -H "Authorization: Bearer <API_KEY>" \
    -H "Content-Type: application/json" \
    -d '{
      "email": "alex@example.com",
      "role": "member"
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.moonshadow.dev/v1/workspaces/{workspace_id}/members",
      headers={
          "Authorization": "Bearer <API_KEY>",
          "Content-Type": "application/json"
      },
      json={
          "email": "alex@example.com",
          "role": "member"
      }
  )
  print(response.json())
  ```
</CodeGroup>

Example response:

```json theme={null}
{
  "id": "usr_3a9b8c7d6e5f4a2b",
  "email": "alex@example.com",
  "role": "member",
  "status": "pending",
  "invited_at": "2024-06-12T15:45:00Z"
}
```

### Remove a Member

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE https://api.moonshadow.dev/v1/workspaces/{workspace_id}/members/usr_3a9b8c7d6e5f4a2b \
    -H "Authorization: Bearer <API_KEY>"
  ```

  ```python Python theme={null}
  import requests

  response = requests.delete(
      "https://api.moonshadow.dev/v1/workspaces/{workspace_id}/members/usr_3a9b8c7d6e5f4a2b",
      headers={"Authorization": "Bearer <API_KEY>"}
  )
  print(response.status_code)
  ```
</CodeGroup>

A successful removal returns HTTP `204 No Content`.

## Workspace Ownership Transfer

You can transfer ownership of a workspace to another Admin if you are the current Owner. From the dashboard:

1. Go to **Settings > Members**.
2. Click the actions menu on the Admin you want to promote.
3. Select **Transfer Ownership**.
4. Confirm the transfer.

You will be downgraded to Admin, and the new Owner will assume full control.

<Warning>
  Transferring ownership is immediate and cannot be reverted by the previous Owner. Make sure you trust the recipient before confirming.
</Warning>
