> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/discordplace/discord.place/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Bot Stats

> Update your bot's server count and command count on discord.place.

Keep your bot's listing accurate by periodically pushing your current server and command counts. At least one field must be provided per request.

## Endpoint

```
PATCH /bots/{id}/stats
```

**Authentication:** Required — pass your API key in the `Authorization` header.\
See [Authentication](/api-reference/authentication) for details.

## Path Parameters

<ParamField path="id" type="string" required>
  The Discord snowflake ID of your bot (a 17–20 digit numeric string).

  Example: `123456789012345678`
</ParamField>

## Request Body

At least one of the following fields must be present.

<ParamField body="server_count" type="integer">
  The number of servers your bot is currently in. Must be between `0` and `10,000,000`.

  The value you provide cannot differ from your bot's actual server count by more than the configured maximum difference (at minimum 50, or 10% of the actual count — whichever is larger). Exceeding this threshold returns a `400` error.

  Example: `1500`
</ParamField>

<ParamField body="command_count" type="integer">
  The number of slash/prefix commands your bot exposes. Must be between `0` and `1,000`.

  Example: `100`
</ParamField>

## Code Examples

<CodeGroup>
  ```bash curl theme={null}
  curl -X PATCH https://api.discord.place/bots/123456789012345678/stats \
    -H "Authorization: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"server_count": 1500, "command_count": 100}'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.discord.place/bots/123456789012345678/stats', {
    method: 'PATCH',
    headers: {
      'Authorization': process.env.DISCORD_PLACE_API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      server_count: client.guilds.cache.size,
      command_count: client.commands.size
    })
  });

  const data = await response.json();
  if (!data.success) {
    console.error(`Failed to update stats: ${data.error}`);
  }
  ```
</CodeGroup>

## Responses

### 200 — Success

<ResponseField name="success" type="boolean">
  Always `true` on a successful update.
</ResponseField>

```json theme={null}
{ "success": true }
```

### Error Responses

<Expandable title="400 Bad Request">
  Returned when the request body is invalid.

  <Tabs>
    <Tab title="Missing fields">
      ```json theme={null}
      {
        "success": false,
        "error": "One of the following fields is required: command_count, server_count.",
        "status": 400
      }
      ```
    </Tab>

    <Tab title="Invalid server count">
      ```json theme={null}
      {
        "success": false,
        "error": "Server count must be between 0 and 10 Million.",
        "status": 400
      }
      ```
    </Tab>

    <Tab title="Invalid command count">
      ```json theme={null}
      {
        "success": false,
        "error": "Commands count must be between 0 and 1,000.",
        "status": 400
      }
      ```
    </Tab>

    <Tab title="Server count too far off">
      ```json theme={null}
      {
        "success": false,
        "error": "The server count provided (99999) is too far off from the actual server count. It cannot differ by more than 50 from the actual server count, which is 1500.",
        "status": 400
      }
      ```
    </Tab>
  </Tabs>
</Expandable>

<Expandable title="401 Unauthorized">
  <Tabs>
    <Tab title="Missing key">
      ```json theme={null}
      {
        "success": false,
        "error": "Authorization header is required.",
        "status": 401
      }
      ```
    </Tab>

    <Tab title="Invalid key">
      ```json theme={null}
      {
        "success": false,
        "error": "Invalid API key.",
        "status": 401
      }
      ```
    </Tab>
  </Tabs>
</Expandable>

<Expandable title="404 Not Found">
  ```json theme={null}
  {
    "success": false,
    "error": "Bot not found.",
    "status": 404
  }
  ```
</Expandable>

<Expandable title="429 Too Many Requests">
  This endpoint allows **2 requests per 120 minutes**. See [Rate Limits](/api-reference/rate-limits).

  ```json theme={null}
  {
    "success": false,
    "error": "Too many requests, please try again later.",
    "status": 429
  }
  ```
</Expandable>

<Expandable title="500 Internal Server Error">
  Returned when the server cannot fetch your bot's actual guild count to validate `server_count`.

  ```json theme={null}
  {
    "success": false,
    "error": "Could not fetch server count.",
    "status": 500
  }
  ```
</Expandable>

## Tips

<Note>
  Call this endpoint on a scheduled interval (e.g., every hour) rather than reacting to every guild join/leave event. The rate limit is 2 requests per 120 minutes, so a once-per-hour schedule leaves headroom for retries.
</Note>
