# Members & Roles

Members are users who can access a tenant. Roles define their permissions. Send these requests to `https://api.laserdata.cloud`.

Listing members requires `member:read`. Invitations and removal require `member:manage`. Reading roles requires `role:read`, and creating or deleting them requires `role:manage`.

## Members

### List Members

`GET /tenants/{tenant_id}/members`

List all members of a tenant with their assigned roles.

```bash
curl "https://api.laserdata.cloud/tenants/{tenant_id}/members?page=1&results=10" \
-H "ld-api-key: YOUR_API_KEY"
```

```json
{
  "items": [
    {
      "id": 1,
      "email": "alice@example.com",
      "name": "Alice",
      "active": true,
      "roles": ["developer"],
      "created_at": "2025-01-15T10:00:00Z"
    }
  ],
  "page": 1,
  "total_results": 1,
  "total_pages": 1
}
```

### Update Member Role

`PUT /tenants/{tenant_id}/members/{member_id}`

Change the roles of a tenant member, or activate or deactivate the member. Requires member:manage.

```bash
curl -X PUT https://api.laserdata.cloud/tenants/{tenant_id}/members/{member_id} \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "active": true,
  "roles": [123, 456]
}'
```

`roles` replaces the member's roles. Each role the request adds must be one you hold yourself in the same scope: organization, workspace, or environment. Otherwise it answers `403` with `insufficient_permissions`. Roles the member already holds can stay in the list. Setting `active` to `false` suspends the [API keys](/security/api-keys) the member created in the organization until the member is active again.

### Remove Member

`DELETE /tenants/{tenant_id}/members/{member_id}`

Remove a member from the tenant. The API keys they created in the organization are deleted with them.

```bash
curl -X DELETE https://api.laserdata.cloud/tenants/{tenant_id}/members/{member_id} \
-H "ld-api-key: YOUR_API_KEY"
```

***

## Invitations

### Invite a Member

`POST /tenants/{tenant_id}/invitations`

Send an invitation email to a new member with a specified role.

```bash
curl -X POST https://api.laserdata.cloud/tenants/{tenant_id}/invitations \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "email": "bob@example.com",
  "roles": [100]
}'
```

Every role of the invitation must be one you hold yourself in the same scope. Otherwise it answers `403` with `insufficient_permissions` and no invitation is created.

The [tenant configuration](/api/organization#get-tenant-config) determines these domain-restriction errors:

| Status / Code | Cause |
| --- | --- |
| `400 invitee_domain_locked` | The invitee's email domain belongs to another tenant that has set `block_external_invitations: true`. |
| `400 invitee_domain_not_allowed` | This tenant has `enforce_domain_only_invitations: true` and the invitee's email domain is outside the tenant's claimed `email_domain` (and any workspace subdomains). |

### List Invitations

`GET /tenants/{tenant_id}/invitations`

List all pending invitations.

```bash
curl "https://api.laserdata.cloud/tenants/{tenant_id}/invitations?page=1&results=10" \
-H "ld-api-key: YOUR_API_KEY"
```

### Cancel Invitation

`DELETE /tenants/{tenant_id}/invitations/{invitation_id}`

Cancel a pending invitation before it is accepted.

```bash
curl -X DELETE https://api.laserdata.cloud/tenants/{tenant_id}/invitations/{invitation_id} \
-H "ld-api-key: YOUR_API_KEY"
```

***

## Roles

### List Roles

`GET /tenants/{tenant_id}/roles`

List all roles defined in the tenant, including built-in and custom roles.

```bash
curl "https://api.laserdata.cloud/tenants/{tenant_id}/roles?page=1&results=10" \
-H "ld-api-key: YOUR_API_KEY"
```

```json
{
  "items": [
    {
      "id": 1,
      "name": "admin",
      "kind": "system"
    },
    {
      "id": 2,
      "name": "developer",
      "kind": "custom"
    }
  ],
  "page": 1,
  "total_results": 2,
  "total_pages": 1
}
```

Role `kind` identifies how the role was created:

* `system` identifies `admin`, `developer`, `viewer`, or `billing`. These four built-in roles cannot be deleted. Tenant ownership is stored separately.
* `custom` identifies a role created through the API or Console.
* `api_key` identifies a dedicated role created from inline key permissions instead of an existing `role_id`.

### Get Role

`GET /tenants/{tenant_id}/roles/{role_id}`

Get a role by ID.

```bash
curl https://api.laserdata.cloud/tenants/{tenant_id}/roles/{role_id} \
-H "ld-api-key: YOUR_API_KEY"
```

### List Role Members

`GET /tenants/{tenant_id}/roles/{role_id}/members`

List all members assigned to a role.

```bash
curl "https://api.laserdata.cloud/tenants/{tenant_id}/roles/{role_id}/members?page=1&results=10" \
-H "ld-api-key: YOUR_API_KEY"
```

### Create Role

`POST /tenants/{tenant_id}/roles`

Create a custom role with tenant, workspace, and environment permission scopes.

```bash
curl -X POST https://api.laserdata.cloud/tenants/{tenant_id}/roles \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "name": "developer",
  "permissions": {
    "tenant": ["info:read", "member:read", "workspace:read"],
    "workspace": ["environment:read", "environment:manage"],
    "environment": ["deployment:read"],
    "workspaces": {
      "1": {
        "permissions": ["environment:read"],
        "environment": ["deployment:read", "deployment:manage"],
        "environments": {
          "2": ["deployment:read", "deployment:manage", "deployment:telemetry:read"]
        }
      }
    }
  }
}'
```

| Field | Required | Description |
| --- | --- | --- |
| `name` | Yes | Unique role name within the tenant |
| `permissions.tenant` | No | Tenant-level permission strings (e.g. `info:read`, `member:manage`) |
| `permissions.workspace` | No | Default workspace permissions applied to all workspaces |
| `permissions.environment` | No | Default environment permissions applied to every environment in every workspace. The blanket "all environments" knob: spares you per-workspace overrides for read-only or developer-style roles |
| `permissions.workspaces` | No | Per-workspace overrides keyed by workspace ID. Each entry takes its own `permissions`, `environment` (default for that workspace's environments), and `environments` map (per-environment overrides) |

Environment permissions use the most specific grant: the environment override, workspace `environment` default, then global `permissions.environment`. Without a matching grant, access is denied. Workspace permissions use per-workspace `permissions`, then global `permissions.workspace`, then none.

A new role can hold only permissions you hold yourself in the same scope: organization, workspace, or environment. Otherwise it answers `403` with `insufficient_permissions` and no role is created.

### Assign Role to Members

`PUT /tenants/{tenant_id}/roles/{role_id}/members/assign`

Assign one or more members to a role.

```bash
curl -X PUT https://api.laserdata.cloud/tenants/{tenant_id}/roles/{role_id}/members/assign \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "members": [1, 2, 3]
}'
```

You can assign only a role you hold yourself in the same scope. Otherwise it answers `403` with `insufficient_permissions` and nobody is assigned.

### Revoke Role from Members

`PUT /tenants/{tenant_id}/roles/{role_id}/members/revoke`

Remove one or more members from a role.

```bash
curl -X PUT https://api.laserdata.cloud/tenants/{tenant_id}/roles/{role_id}/members/revoke \
-H "ld-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "members": [2]
}'
```

### Delete Role

`DELETE /tenants/{tenant_id}/roles/{role_id}`

Delete a custom role. Built-in roles cannot be deleted. Members assigned to this role will need a new role assigned.

```bash
curl -X DELETE https://api.laserdata.cloud/tenants/{tenant_id}/roles/{role_id} \
-H "ld-api-key: YOUR_API_KEY"
```

- [Roles & Permissions Guide](/organization/roles-permissions): Full permission list and built-in role templates
- [API Keys](/api/api-keys): Programmatic access keys tied to roles

Source: https://docs.laserdata.com/api/members
