# get_role_member_counts

Source: https://modulify.ai/docs/api/workspaces/get-role-member-counts

Counts how many people hold each role in a workspace.

- Title: Count the members on each role
- Scope: `workspaces:read`
- Access: Read only
- Endpoint: `POST /v1/get_role_member_counts`

Read it before `delete_workspace_role`, because deleting a role that people still hold moves them back to the stock Member role. Read it before changing a role's permissions with `update_workspace_role` too, so you know how many people the change reaches.

The answer maps each role to its count, keyed by `owner`, `member` or a custom role's id. Only people who have joined are counted, not pending invitations, and a role nobody holds is left out. See [Members and roles](https://modulify.ai/docs/reference/members-and-roles#delete-a-custom-role).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/get_role_member_counts`, sending the inputs below as a JSON object. The token needs the `workspaces:read` scope.

It only reads and changes nothing, so retrying it is safe.

```bash
curl -X POST https://api.modulify.ai/v1/get_role_member_counts \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"workspaceId":"WORKSPACE_ID"}'
```

Over MCP, the same method is the [get_role_member_counts tool](https://modulify.ai/docs/mcp/workspaces/get-role-member-counts).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `workspaceId` | string | Yes | The workspace id. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.