> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mightynetworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Members

> Understanding Members in the Mighty Networks API

## What are Members?

**Members** are users who belong to your Network. The Members API allows you to list, search, view, and manage member data, profiles, permissions, and roles.

## Member Properties

Each member includes:

* **Member ID** - Unique identifier for the member
* **Email** - Member's email address
* **Name** - First and last name
* **Profile Data** - Avatar, location, timezone, bio
* **Role** - Admin, host, or member
* **Created At** - When they joined the Network
* **Activity** - Engagement metrics and participation
* **Profile Fields** - Additional profile information

## Listing Members

Get all members in your Network:

```bash cURL theme={null}
curl https://api.mn.co/admin/v1/networks/{network_id}/members \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

```javascript Node.js theme={null}
const response = await fetch(
  `https://api.mn.co/admin/v1/networks/${NETWORK_ID}/members`,
  {
    headers: {
      'Authorization': `Bearer ${API_TOKEN}`
    }
  }
);

const members = await response.json();
console.log(members.items);
```

```python Python theme={null}
response = requests.get(
    f"https://api.mn.co/admin/v1/networks/{NETWORK_ID}/members",
    headers={"Authorization": f"Bearer {API_TOKEN}"}
)

members = response.json()
print(members['items'])
```

### Pagination

Use pagination parameters to navigate through large member lists:

```bash theme={null}
curl "https://api.mn.co/admin/v1/networks/{network_id}/members?page=2&per_page=50" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

## Getting a Specific Member

Retrieve details about a single member by their ID:

```bash cURL theme={null}
curl https://api.mn.co/admin/v1/networks/{network_id}/members/{member_id}/ \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

```javascript Node.js theme={null}
const response = await fetch(
  `https://api.mn.co/admin/v1/networks/${NETWORK_ID}/members/${MEMBER_ID}/`,
  {
    headers: {
      'Authorization': `Bearer ${API_TOKEN}`
    }
  }
);

const member = await response.json();
```

```python Python theme={null}
response = requests.get(
    f"https://api.mn.co/admin/v1/networks/{NETWORK_ID}/members/{MEMBER_ID}/",
    headers={"Authorization": f"Bearer {API_TOKEN}"}
)

member = response.json()
```

### Example Response

```json theme={null}
{
  "id": 12345,
  "email": "john.doe@example.com",
  "first_name": "John",
  "last_name": "Doe",
  "avatar": "https://cdn.mn.co/avatars/12345.jpg",
  "location": "San Francisco, CA",
  "time_zone": "America/Los_Angeles",
  "permalink": "https://yournetwork.mn.co/members/12345",
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-03-20T14:22:00Z"
}
```

## Member Roles

Members can have different roles within your Network:

### Role Types

* **Admin** - Full Network management access, can manage all settings and content
* **Host** - Can manage specific spaces and moderate content
* **Member** - Standard Network access with basic permissions
* **Guest** - Limited access to specific content (if enabled)

### Updating Member Roles

Change a member's role in the Network:

```bash cURL theme={null}
curl -X PATCH https://api.mn.co/admin/v1/networks/{network_id}/members/{member_id}/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"role": "host"}'
```

```javascript Node.js theme={null}
const response = await fetch(
  `https://api.mn.co/admin/v1/networks/${NETWORK_ID}/members/${MEMBER_ID}/`,
  {
    method: 'PATCH',
    headers: {
      'Authorization': `Bearer ${API_TOKEN}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ role: 'host' })
  }
);

const updatedMember = await response.json();
```

```python Python theme={null}
response = requests.patch(
    f"https://api.mn.co/admin/v1/networks/{NETWORK_ID}/members/{MEMBER_ID}/",
    headers={
        "Authorization": f"Bearer {API_TOKEN}",
        "Content-Type": "application/json"
    },
    json={"role": "host"}
)

updated_member = response.json()
```

## Space Membership

Members can belong to specific spaces within your Network.

### Listing Members in a Space

Get members of a specific space:

```bash theme={null}
curl https://api.mn.co/admin/v1/networks/{network_id}/spaces/{space_id}/members \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

### Getting Space Member Details

Get a specific member's details within a space:

```bash theme={null}
curl https://api.mn.co/admin/v1/networks/{network_id}/spaces/{space_id}/members/{user_id}/ \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

## Banning Members

Ban a user from the Network:

```bash cURL theme={null}
curl -X POST https://api.mn.co/admin/v1/networks/{network_id}/spaces/{space_id}/members/{user_id}/ban \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ban_reason": "Spam"}'
```

```javascript Node.js theme={null}
const response = await fetch(
  `https://api.mn.co/admin/v1/networks/${NETWORK_ID}/spaces/${SPACE_ID}/members/${USER_ID}/ban`,
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_TOKEN}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ ban_reason: 'Spam' })
  }
);
```

> [!WARNING]
>
> Banning a member removes them from the Network and prevents them from rejoining.

## Common Use Cases

### Member Search

Search for members by email or name:

```javascript theme={null}
async function findMemberByEmail(networkId, email, apiToken) {
  const response = await fetch(
    `https://api.mn.co/admin/v1/networks/${networkId}/members`,
    { headers: { 'Authorization': `Bearer ${apiToken}` } }
  );

  const members = await response.json();

  return members.items.find(m =>
    m.email.toLowerCase() === email.toLowerCase()
  );
}
```

### Member Activity Report

Generate a report of member activity:

```javascript theme={null}
async function generateMemberReport(networkId, apiToken) {
  let allMembers = [];
  let page = 1;
  let hasMore = true;

  while (hasMore) {
    const response = await fetch(
      `https://api.mn.co/admin/v1/networks/${networkId}/members?page=${page}&per_page=100`,
      { headers: { 'Authorization': `Bearer ${apiToken}` } }
    );

    const data = await response.json();
    allMembers = allMembers.concat(data.items);

    hasMore = data.links?.next != null;
    page++;
  }

  return {
    totalMembers: allMembers.length,
    recentJoins: allMembers.filter(m => {
      const joinDate = new Date(m.created_at);
      const daysAgo = (Date.now() - joinDate) / (1000 * 60 * 60 * 24);
      return daysAgo <= 30;
    }).length
  };
}
```

### Bulk Role Updates

Update roles for multiple members:

```javascript theme={null}
async function promoteToHosts(networkId, memberIds, apiToken) {
  const results = [];

  for (const memberId of memberIds) {
    try {
      const response = await fetch(
        `https://api.mn.co/admin/v1/networks/${networkId}/members/${memberId}/`,
        {
          method: 'PATCH',
          headers: {
            'Authorization': `Bearer ${apiToken}`,
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({ role: 'host' })
        }
      );

      if (response.ok) {
        results.push({ memberId, success: true });
      }
    } catch (error) {
      results.push({ memberId, success: false, error: error.message });
    }

    // Rate limiting: wait between requests
    await new Promise(resolve => setTimeout(resolve, 100));
  }

  return results;
}
```

### CRM Integration

Sync member data with external CRM:

```javascript theme={null}
async function syncToCRM(networkId, apiToken, crmEndpoint) {
  const response = await fetch(
    `https://api.mn.co/admin/v1/networks/${networkId}/members`,
    { headers: { 'Authorization': `Bearer ${apiToken}` } }
  );

  const members = await response.json();

  for (const member of members.items) {
    await fetch(crmEndpoint, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        email: member.email,
        firstName: member.first_name,
        lastName: member.last_name,
        source: 'Mighty Networks',
        customFields: {
          mightyNetworksId: member.id,
          joinDate: member.created_at
        }
      })
    });
  }
}
```

## Best Practices

1. **Use Pagination** - Always paginate through member lists to avoid timeouts
2. **Respect Rate Limits** - Add delays when performing bulk operations
3. **Cache Member Data** - Store frequently accessed member data locally
4. **Validate Permissions** - Ensure your API token has the necessary member scopes
5. **Handle Errors Gracefully** - Check for 404 errors when accessing specific members
6. **Protect Privacy** - Never expose sensitive member data publicly

## Next Steps

> [card] [Spaces](https://docs.mightynetworks.com/spaces.md)
>
> Learn about organizing members in spaces.

> [card] [Profile Fields](https://docs.mightynetworks.com/admin-api.md)
>
> Work with member profile fields.

> [card] [Authentication](https://docs.mightynetworks.com/authentication.md)
>
> Manage API token permissions for member access.

> [card] [Pagination](https://docs.mightynetworks.com/api-pagination.md#overview)
>
> Learn pagination best practices.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.