> For the complete documentation index, see [llms.txt](https://dadocs.rickyjs.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dadocs.rickyjs.xyz/endpoints/messages.md).

# /messages

{% hint style="info" %}
This endpoint supports the [Exclude](/exclude-header.md) header
{% endhint %}

### Endpoint Headers:

* bot-token - Token of the Bot <mark style="color:orange;">**\[String]**</mark> (<mark style="color:red;">**Required**</mark>)&#x20;
* chan-id - ID of the channel to be fetched <mark style="color:orange;">**\[Snowflake]**</mark> (<mark style="color:red;">**Required**</mark>)
* msg-id - ID of the message to be fetched <mark style="color:orange;">**\[Snowflake]**</mark> (<mark style="color:green;">**Optional**</mark>)&#x20;
* apikey - Your Api Auth Key <mark style="color:orange;">**\[String]**</mark> (<mark style="color:red;">**Required**</mark>)
* limit - Number of messages to fetch if no msg-id is provided <mark style="color:orange;">**\[Integer 1-100]**</mark> (<mark style="color:green;">**Optional**</mark>)

{% hint style="warning" %}
If no `msg-id` was specified, it will grab all data and retrieve an **Array**, otherwise it will grab the one specified and retrieve an **Object**.&#x20;

<mark style="color:red;background-color:yellow;">**This will affect how to grab your data!**</mark>
{% 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 `/messages` endpoint using BDFD

```bash
$httpAddHeader[apikey;<YOUR-API-KEY>]
$httpAddHeader[bot-token;<YOUR-BOT-TOKEN>]
$httpAddHeader[chan-id;433453456646243565]
$httpAddHeader[msg-id;1064098700307218463] $c[Optional header]
$httpGet[https://bdfddata.rickyjs.xyz/<version>/messages]


$httpResult OR $httpResult[details]
```

</details>

<details>

<summary>Discord.js</summary>

Example usage of `/messages` endpoint using Discord.js

```javascript
const axios = require('axios');
(async () => {
return await axios.get('https://bdfddata.rickyjs.xyz/<version>/messages', {
headers: {
"apikey": "<YOUR-API-KEY>",
"bot-token": "<YOUR-BOT-TOKEN>",
"chan-id": "9687459278405623556",
"msg-id": "64563453457782237788"  // Optional header
}
}).then(res=>res.data)
})()
```

</details>

### Possible Responses (Codes)

<details>

<summary>Code 200</summary>

API succeeded and details were fetched.

```javascript
{
 status: 200,
  details: {
    id: '1047848807775358976',
    type: 'Default',
    content: 'lol gn bro',
    channel_id: '1024040173345984562',
    ...
    ...
    ...
  >  'Read on `Message Objects` : https://discord.com/developers/docs/resources/channel#message-object'
}  
```

</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>
