How do you assign moderators to a community using the Add Moderators API?

Who is this for and why it matters

Use this API when you want to programmatically assign moderators (admins) to a community within your Community Media Network.

This matters because:

  • Moderators help maintain content quality and community guidelines
  • It enables distributed community management at scale
  • It allows you to automate role-based access control

If you're managing large or active communities, assigning moderators via API is critical for governance and efficiency.

What does the Add Moderators API do?

This API allows you to:

  • Assign users as moderators (admins) within a community
  • Enable them to manage content, users, and moderation workflows

It acts as a role assignment layer for community governance.

API Details

  • URL: /api/thirdparty/community/add_moderators
  • Method: POST
  • Authentication Required: Yes (Bearer Token)

Before you begin

1. Authenticate your request

Generate a gn-access-token using the Authentication API.

Pass it in the header: Authorization - Bearer <gn-access-token>

2. Ensure community and users exist

You must have:

  • A valid community_id
  • Valid users to assign as moderators

Request Structure

Request Body
{
  "community_id": "any",
  "users": "any"
}

Field-level understanding

  • community_id - The community where moderators will be assigned
  • users - List or identifier(s) of users to be assigned as moderators

What happens on success?

Success Condition

If the request is valid:

  • Users are successfully assigned as moderators
  • Their roles are updated within the community

Response Code 200 OK

Response Body
{
    "code": 200,
    "message": "XXXX-[Members Added]",
    "data": {
        "moderators_added": [
            {
                "name": null,
                "bio": null,
                "nickname": null,
                "is_brand_system_user": false,
                "is_avatar": true,
                "profile_image": "dog_face",
                "profile_image_s": "",
                "profile_image_m": "",
                "profile_image_l": "",
                "member_id": "8bf08f1f-9fb6-445b-85b4-156f19f6ae8b",
                "role": 3
            }
        ]
    }
}

Important

  • Each object in moderators_added includes a member_id, which uniquely identifies the assigned moderator
  • role: 3 indicates moderator-level access within the community

Error Handling

1. Bad Request

Condition: Invalid or malformed request data

Response Code: 400 Bad Request

Response Body:
{
  "code": "1099",
  "message": "An unexpected error occurred processing the request",
  "data": {}
}

2. Not Found

Condition: Community or user does not exist

Response Code: 404 Not Found

Response Body:
{
  "code": "5218",
  "message": "The community you are looking for is no longer available.",
  "data": {}
}

3. Precondition Failed

Condition: Invalid API usage or unmet conditions

Response Code: 412 Precondition Failed

Response Body:
{
  "code": "5166",
  "message": "XXXX-[Invalid Use of API]",
  "data": {}
}

Best Practices

  • Assign moderators only to trusted users
  • Validate community_id and user data before making the request
  • Avoid duplicate role assignments
  • Combine with member management APIs for complete control
  • Ensure proper role-based governance workflows

What to do next

After assigning moderators:

  • Enable them to manage content and users
  • Set up content moderation workflows
  • Scale your community operations efficiently
Genuin Footer