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

# Bandwidth Management

> How bandwidth limits are tracked and enforced across OpenVPN and WireGuard.

## Overview

StartMyVPN tracks each user's data usage across all VPN servers and enforces monthly bandwidth limits set on their plan.

## How tracking works

**OpenVPN**: Every successful authentication creates a log entry. When the connection ends, the bytes transferred are recorded against the user's usage for the current billing period.

**WireGuard**: StartMyVPN periodically reads `rx_bytes` / `tx_bytes` counters from the WireGuard interface on each server and updates the `wireguard_configs` table.

Both sources are combined to calculate total usage.

## Billing period

Usage resets at the start of each billing period. The reset date is calculated from the service creation date — not the calendar month. For example, if a service started on the 15th, usage resets on the 15th of each month.

## Bandwidth limits

Plans can have a bandwidth limit set in GB. If set to `null`, bandwidth is unlimited.

When a user reaches their limit:

* **OpenVPN**: The next connection attempt is rejected during authentication
* **WireGuard**: The peer config is removed from all servers (user will be disconnected)

## API endpoints

Current usage for the authenticated user:

```http theme={null}
GET /v1/bandwidth/current
Authorization: Bearer {token}
```

Response:

```json theme={null}
{
  "success": true,
  "data": {
    "used_bytes": 5368709120,
    "limit_bytes": 10737418240,
    "used_formatted": "5.00 GB",
    "limit_formatted": "10.00 GB",
    "percentage": 50.0,
    "unlimited": false,
    "reset_date": "2026-04-15"
  }
}
```

Usage history:

```http theme={null}
GET /v1/bandwidth/history
```

Usage summary:

```http theme={null}
GET /v1/bandwidth/summary
```

## Admin view

Admins can see per-user bandwidth usage in **Admin → Users → \[User] → Bandwidth**.

## Unlimited plans

If a plan has no bandwidth limit (`null`), the API returns `"unlimited": true` and connections are never rejected for bandwidth reasons.
