# Add moderators to a community

Give accounts the moderator role in a community, or add them as moderators, from your own systems.

Moderators are the community's admins: they approve join requests, review posts, manage groups, and add other moderators. This endpoint does what **Manage** > **Users** > **Make admin** does in Brand Control Center. The account behind your access token has to be the community's leader or a moderator already; your brand's owner account is a moderator of every community created under the brand. See [Generate an access token](https://begenuin.com/developers/developer-resources/api/generate-access-token-using-authentication-api) for the token.

## Endpoint

`POST /api/thirdparty/community/add_moderators`

| Environment | Base URL |
| --- | --- |
| Production | https://api.begenuin.com |
| QA | https://api.qa.begenuin.com |

Send the token as a bearer token in the `Authorization` header, and the fields as a JSON body with the `Content-Type: application/json` header.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| community_id | string | Required | UUID of the community. |
| users | array | Required | Who to make moderators, each {"user_id": "<uuid>"} or {"phone_number": "<digits>"}. At least one entry has to be valid; invalid entries are ignored. |

`user_id` is the UUID of an existing account; accounts that are active or pending qualify. `phone_number` is digits only with the country code first, such as `14155552671`; a number without an account gets a pending account that the person takes over when they sign up.

## Returns

Returns `200 OK` with the member objects that were made moderators. A listed account that was already a member is promoted; one that wasn't a member is added with the moderator role. The leader and existing moderators are left as they are. Pending accounts are added with an inactive status and become active on signup.

## Request

```bash title="cURL"
curl -X POST https://api.begenuin.com/api/thirdparty/community/add_moderators \
  -H "Authorization: Bearer {{GN_ACCESS_TOKEN}}" \
  -H "Content-Type: application/json" \
  -d '{
    "community_id": "{{COMMUNITY_ID}}",
    "users": [{ "user_id": "{{USER_ID}}" }]
  }'
```

## Response

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

`role` is `3`, the moderator role; `1` is the leader and `2` a member. `moderators_added` lists only the accounts whose role changed in this call.

## Errors

Every error response carries an HTTP status, a string `code`, a `message`, and a `data` object. Match on `code`.

| HTTP status | code | Cause | Fix |
| --- | --- | --- | --- |
| 412 Precondition Failed | 5166 | community_id isn't a UUID, users is empty or has no valid entry, or the token's account isn't the leader or a moderator of the community. Message: XXXX-[Invalid Use of API]. | Check the ids, and call from an account with the moderator role. |
| 404 Not Found | 5218 | The community doesn't exist or is deleted. Message: The community you are looking for is no longer available. | Check the UUID. |
| 400 Bad Request | 1099 | The server couldn't process the request. | Retry once. If it persists, contact the Genuin team with the request timestamp. |

## Limitations

- **One community per call**: Loop over communities to add the same moderator to several.
- **No demotion**: There's no third-party endpoint to remove the moderator role. Change roles in Brand Control Center under **Manage** > **Users**.
- **Rate limit**: There's no rate limit on this endpoint.

## See also

- [Add members to a community](https://begenuin.com/developers/developer-resources/api/add-members-to-a-community-programmatically-api)
- [Create a community](https://begenuin.com/developers/developer-resources/api/create-a-community-programmatically-using-community-api)
- [Set moderation, roles, and brand safety](https://begenuin.com/developers/get-started/any-business/how-are-moderation-and-brand-safety-applied-for-destination-brands-publishers-and-the-genuin-ecosystem)
- [Generate an access token](https://begenuin.com/developers/developer-resources/api/generate-access-token-using-authentication-api)
- [Handle API errors](https://begenuin.com/developers/developer-resources/api/handle-api-errors)
