# /massrole

{% hint style="info" %}
This endpoint will require a POST request.&#x20;
{% endhint %}

{% hint style="warning" %}
Guilds with high member counts are subject to rate limits, response will be delayed based off member count.
{% endhint %}

### Endpoint Headers:

* bot-token - Token of the Bot <mark style="color:orange;">**\[String]**</mark> (<mark style="color:red;">**Required**</mark>)&#x20;
* apikey - Your Api Auth Key <mark style="color:orange;">**\[String]**</mark> (<mark style="color:red;">**Required**</mark>)
* guild-id - ID of the guild to be fetched <mark style="color:orange;">**\[Snowflake]**</mark> (<mark style="color:red;">**Required**</mark>)&#x20;
* channel-id - ID of the channel to send the final response in <mark style="color:orange;">**\[Snowflake]**</mark> (<mark style="color:green;">**Optional**</mark>) (*See*[ *Status 200*](#code-200) *for example!*)

### Endpoint Body Parameters

* add - Role(s) to add to members <mark style="color:orange;">**\[Array of Snowflakes]**</mark> (<mark style="color:green;">**Optional\***</mark>)
* remove - Role(s) to remove from members <mark style="color:orange;">**\[Array of Snowflakes]**</mark> (<mark style="color:green;">**Optional\***</mark>)

{% hint style="danger" %}
At least one role is required in either `add` or `remove.`&#x20;

It is **Not Required** to have both supplied simultaneously.&#x20;
{% endhint %}

### Examples:

{% hint style="info" %}
Data API version required. Must replace `<version>` with either **release** or **beta**.
{% endhint %}

<details>

<summary>Bot Designer for Discord</summary>

Example usage of `/guild/massroll` endpoint using BDFD

```bash
$httpAddHeader[apikey;<YOUR-API-KEY>]
$httpAddHeader[bot-token;<YOUR-BOT-TOKEN>]
$httpAddHeader[guild-id;1064098700307218463] 
$httpAddHeader[channel-id;1064098702001721486] $c[Optional header]
$httpPost[https://bdfddata.rickyjs.xyz/<version>/guild/massrole;{
"add": ["1064410587293028413"],
"remove": ["1065288607352488017"]
}]


$httpResult OR $httpResult[details]
```

</details>

<details>

<summary>Discord.js</summary>

Example usage of `/guild/massrole` endpoint using Discord.js

```javascript
const axios = require('axios');
(async () => {
return await axios.post('https://bdfddata.rickyjs.xyz/<version>/guild/massrole', {
"add": ["1064410587293028413"],
"remove": ["1065288607352488017"]
}, {
headers: {
'apikey': <YOUR-API-KEY>,
'bot-token': <YOUR-BOT-TOKEN>,
'guild-id': '1064098700307218463',
'channel-id': '1064098702001721486' // Optional header
}
}).then(res=>res.data)
})()
```

</details>

### Possible Responses (Codes)

<details>

<summary>Code 200</summary>

API succeeded and details were fetched.\
\
\
If a `channel-id` was provided, a follow-up response will be sent to that channel when the action has completed. \
The message will consist of completion data results like\
\&#xNAN;**-** Successful role toggles\
\&#xNAN;**-** Failed role toggles (*Could have failed for a number of reasons, usually going to be a permissions or role hierarchy error*)\
\&#xNAN;**-** Amount of time it took to fully complete the request\
\
As stated before, the time the request takes will fluctuate based of the member count and how many rate limits it may hit.

<figure><img src="/files/pXIIqpIg0Fwnmk1kfDsC" alt=""><figcaption></figcaption></figure>

{% code fullWidth="false" %}

```javascript
{
  status: 200,
    details: "Operation has started, this could take a while"
}
```

{% endcode %}

</details>

<details>

<summary>Code 400</summary>

An error occurred that stopped execution.

```javascript
{
    status: 400
    error: 'Cannot read ...  (This can vary)'
}
```

</details>

<details>

<summary>Code 401</summary>

Invalid bot token was provided.

```javascript
{
  status: 401,
  details: { message: '401: Unauthorized', code: 0 }
}
```

</details>

<details>

<summary>Code 404</summary>

Guild was not found via DAPI

```javascript
{
  status: 404,
  details: { message: 'Unknown Guild', code: 10004 } (this can vary)
}
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dadocs.rickyjs.xyz/endpoints/guild/massrole.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
