## GET /api/v2/vps/{id}/bandwidth

**Get VPS bandwidth usage for this period**

Shows how much bandwidth a VPS has used in the current allowance period and when the traffic happened. `allowance` holds the same numbers as `bandwidth` on `GET /api/v2/vps/{id}`. `breakdown.days` splits the traffic by calendar day in Europe/Stockholm time. `breakdown.peakHour` is the busiest hour. Traffic is measured on the VPS's network interface. A single large transfer shows up as one busy day or hour. When `breakdown.available` is false, the traffic could not be measured. It does not mean there was no traffic. This also works for a suspended VPS and for a VPS over its allowance.

### Related Endpoints

- `GET /api/v2/vps/{id}`: Get a VPS
- `GET /api/v2/vps/{id}/iso`: List ISO images and CD/DVD drives
- `GET /api/v2/vps/{id}/disks`: List VPS disks

### Headers

- `Authorization`: Bearer $HOSTUP_API_KEY
- Scope: `read:vm`

### Parameters

- `id` (path, string, required): The VPS ID (`vps_…`). Example: `vps_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Example

```bash
curl "https://cloud.hostup.se/api/v2/vps/vps_01hxa3b4c5d6e7f8g9h0j1k2m3/bandwidth" \
  -H "Authorization: Bearer $HOSTUP_API_KEY"
```

### Response Schema

- `id` (string, required): The VPS ID. Example: `vps_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `period` (object, required, nullable): The current allowance period. Null when the VPS has no billing date to count from.
- `allowance` (object, required): Use in this period. The same numbers as `bandwidth` on `GET /api/v2/vps/{id}`.
- `allowance.usedGb` (number, required): Traffic counted against the allowance, in GB. Example: `123.25`
- `allowance.limitGb` (number, required): The allowance for the period, in GB. Example: `2048`
- `allowance.inboundGb` (number, required): Incoming traffic, in GB. Example: `65.13`
- `allowance.outboundGb` (number, required): Outgoing traffic, in GB. Example: `58.12`
- `allowance.usagePercent` (number, required): Share of the allowance used, in percent. Example: `6.02`
- `allowance.hasOverage` (boolean, required): True when the VPS has used more than its allowance. Example: `false`
- `breakdown` (object, required)
- `breakdown.available` (boolean, required): False when the traffic could not be measured. `days` is then empty and `peakHour` null. Example: `true`
- `breakdown.reason` (string, required, nullable): Why the breakdown is missing when `available` is false. Null otherwise. Example: `null`
- `breakdown.source` (string, required, nullable): `counters` for exact interface counters. `estimated` for amounts worked out from sampled traffic rates. Null when unavailable. The same values as `totals.source` on `GET /api/v2/vps/{id}/metrics`. Example: `counters`
  Allowed values: counters, estimated
- `breakdown.window` (object, required): The first and last moment in the period with traffic data. Both null when unavailable.
- `breakdown.window.startAt` (string, required, nullable) Example: `2026-08-27T15:00:00.000Z`
- `breakdown.window.endAt` (string, required, nullable) Example: `2026-08-31T12:00:00.000Z`
- `breakdown.days` (array<object>, required): One entry per Europe/Stockholm calendar day from the start of the period through today, oldest first. A day with no traffic is a real zero.
- `breakdown.days[].date` (string, required) Example: `2026-08-27`
- `breakdown.days[].inboundGb` (number, required) Example: `65.05`
- `breakdown.days[].outboundGb` (number, required) Example: `57.61`
- `breakdown.hasHourlyResolution` (boolean, required): Whether traffic can be placed in single hours. False for an `estimated` breakdown with samples further apart than an hour. `hours` is then empty and `peakHour` null. Example: `true`
- `breakdown.hours` (array<object>, required): Every hour in the period with measured traffic, oldest first. Hours not listed had none. Empty when `hasHourlyResolution` is false.
- `breakdown.hours[].startAt` (string, required): Start of the 60-minute window (a whole hour). Example: `2026-08-27T16:00:00.000Z`
- `breakdown.hours[].inboundGb` (number, required) Example: `65`
- `breakdown.hours[].outboundGb` (number, required) Example: `57.6`
- `breakdown.peakHour` (object, required, nullable): The hour with the most traffic in this period. Null when no traffic was measured or when `hasHourlyResolution` is false.

### Responses

#### 200 - Bandwidth use in the current period.
```json
{
  "id": "vps_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "period": {
    "startAt": "2026-08-25T22:00:00.000Z",
    "endAt": "2026-09-25T22:00:00.000Z",
    "timezone": "Europe/Stockholm"
  },
  "allowance": {
    "usedGb": 123.25,
    "limitGb": 2048,
    "inboundGb": 65.13,
    "outboundGb": 58.12,
    "usagePercent": 6.02,
    "hasOverage": false
  },
  "breakdown": {
    "available": true,
    "reason": null,
    "source": "counters",
    "window": {
      "startAt": "2026-08-27T15:00:00.000Z",
      "endAt": "2026-08-31T12:00:00.000Z"
    },
    "days": [
      {
        "date": "2026-08-26",
        "inboundGb": 0,
        "outboundGb": 0
      },
      {
        "date": "2026-08-27",
        "inboundGb": 65.05,
        "outboundGb": 57.61
      },
      {
        "date": "2026-08-28",
        "inboundGb": 0.2,
        "outboundGb": 0.1
      },
      {
        "date": "2026-08-29",
        "inboundGb": 0.1,
        "outboundGb": 0.05
      },
      {
        "date": "2026-08-30",
        "inboundGb": 0,
        "outboundGb": 0
      },
      {
        "date": "2026-08-31",
        "inboundGb": 0.02,
        "outboundGb": 0.01
      }
    ],
    "hasHourlyResolution": true,
    "hours": [
      {
        "startAt": "2026-08-27T15:00:00.000Z",
        "inboundGb": 0.05,
        "outboundGb": 0.01
      },
      {
        "startAt": "2026-08-27T16:00:00.000Z",
        "inboundGb": 65,
        "outboundGb": 57.6
      },
      {
        "startAt": "2026-08-27T23:00:00.000Z",
        "inboundGb": 0.2,
        "outboundGb": 0.1
      },
      {
        "startAt": "2026-08-29T10:00:00.000Z",
        "inboundGb": 0.1,
        "outboundGb": 0.05
      },
      {
        "startAt": "2026-08-31T09:00:00.000Z",
        "inboundGb": 0.02,
        "outboundGb": 0.01
      }
    ],
    "peakHour": {
      "startAt": "2026-08-27T16:00:00.000Z",
      "inboundGb": 65,
      "outboundGb": 57.6
    }
  }
}
```

#### 400 - Invalid request. The response body is an RFC 7807 Problem Details document.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "The request is invalid.",
  "code": "invalid_request",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 401 - Unauthorized. Authentication is required.
```json
{
  "type": "https://developer.hostup.se/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication is required.",
  "code": "unauthorized",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 403 - Forbidden. The caller lacks a required scope or does not own the resource.
```json
{
  "type": "https://developer.hostup.se/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "The caller lacks a required scope or does not own the resource.",
  "code": "forbidden",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 404 - Not found. The resource does not exist or is not owned by the caller; `code` is `vps_not_found`.
```json
{
  "type": "https://developer.hostup.se/errors/vps_not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "vps_not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Rate limit exceeded. Please try again later.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```
