Skip to main content

What are Spaces?

Spaces are organizational units within a network where content and members are organized. Think of them as communities, groups, or channels within your larger network. Spaces help you:
  • Organize content by topic or purpose
  • Control access and permissions
  • Create focused communities within your network
  • Manage members at a granular level

Space Properties

Each space includes:
  • Space ID - Unique identifier for the space
  • Name - Display name of the space
  • Visibility - Public, private, or secret
  • Members - Users who have access to this space
  • Posts - Content created within the space
  • Settings - Configuration for moderation, features, etc.

Listing Spaces

Get all spaces in your network:
curl https://api.mn.co/admin/v1/networks/{network_id}/spaces \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Example Response

{
  "items": [
    {
      "id": 12345,
      "name": "General Discussion",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-03-20T14:22:00Z"
    },
    {
      "id": 12346,
      "name": "Announcements",
      "created_at": "2024-01-15T10:35:00Z",
      "updated_at": "2024-03-19T09:15:00Z"
    }
  ],
  "links": {
    "self": "https://api.mn.co/admin/v1/networks/123/spaces?page=1",
    "next": "https://api.mn.co/admin/v1/networks/123/spaces?page=2"
  }
}

Getting a Specific Space

Retrieve details about a single space:
curl https://api.mn.co/admin/v1/networks/{network_id}/spaces/{space_id} \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Space Membership

Listing Members in a Space

Get all members who have access to a specific space:
curl https://api.mn.co/admin/v1/networks/{network_id}/spaces/{space_id}/members \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Adding Members to a Space

Add a user to a space:
curl -X POST https://api.mn.co/admin/v1/networks/{network_id}/spaces/{space_id}/members?user_id={user_id} \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Removing Members from a Space

Remove a user from a space:
curl -X DELETE https://api.mn.co/admin/v1/networks/{network_id}/spaces/{space_id}/members/{user_id}/ \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Space Roles

Members can have different roles within a space:
  • Host - Can manage space settings, content, and members
  • Member - Standard access to view and create content
  • Moderator - Can moderate content but not change settings

Updating Member Roles

Change a member’s role in a space:
curl -X PATCH https://api.mn.co/admin/v1/networks/{network_id}/spaces/{space_id}/members/{user_id}/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"role": "host"}'

Common Use Cases

Bulk Member Assignment

Add multiple users to a space:
async function addMembersToSpace(networkId, spaceId, userIds, apiToken) {
  const results = [];

  for (const userId of userIds) {
    try {
      const response = await fetch(
        `https://api.mn.co/admin/v1/networks/${networkId}/spaces/${spaceId}/members?user_id=${userId}`,
        {
          method: 'POST',
          headers: { 'Authorization': `Bearer ${apiToken}` }
        }
      );

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

  return results;
}

Space Analytics

Get member count for each space:
async function getSpaceAnalytics(networkId, apiToken) {
  const spacesResponse = await fetch(
    `https://api.mn.co/admin/v1/networks/${networkId}/spaces`,
    { headers: { 'Authorization': `Bearer ${apiToken}` } }
  );

  const spaces = await spacesResponse.json();

  const analytics = [];
  for (const space of spaces.items) {
    const membersResponse = await fetch(
      `https://api.mn.co/admin/v1/networks/${networkId}/spaces/${space.id}/members`,
      { headers: { 'Authorization': `Bearer ${apiToken}` } }
    );

    const members = await membersResponse.json();
    analytics.push({
      spaceName: space.name,
      memberCount: members.items?.length || 0
    });
  }

  return analytics;
}

Automated Space Assignment

Automatically assign new members to a default space:
async function assignToDefaultSpace(networkId, spaceId, newMemberId, apiToken) {
  const response = await fetch(
    `https://api.mn.co/admin/v1/networks/${networkId}/spaces/${spaceId}/members?user_id=${newMemberId}`,
    {
      method: 'POST',
      headers: { 'Authorization': `Bearer ${apiToken}` }
    }
  );

  if (!response.ok) {
    throw new Error(`Failed to add member to space: ${response.statusText}`);
  }

  return await response.json();
}

Best Practices

  1. Organize Content Logically - Use spaces to group related content and discussions
  2. Manage Permissions Carefully - Consider who should have access to each space
  3. Use Pagination - Always paginate when listing space members
  4. Handle Errors - Check for 404 errors if a space doesn’t exist
  5. Respect Rate Limits - Be mindful when performing bulk operations across spaces

Next Steps