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

**Get VPS bandwidth period usage**

Return the current bandwidth-allowance period of one VPS: when it started and resets, the allowance counter, and when the traffic actually happened. Get `{id}` from `GET /api/v2/vps` `data[].id`. `allowance` carries the same fields as `bandwidth` on `GET /api/v2/vps/{id}` — the running total for this period. `breakdown.days` splits that traffic into Europe/Stockholm calendar days from the period start through today (every day is listed; a day with no traffic is a real zero), and `breakdown.peakHour` is the busiest 60-minute window. Values are measured on the VPS's own network interface, so a single large transfer shows up as one spiked day/hour rather than being spread out. `breakdown.source` says whether that came from exact counters or was estimated from sampled rates. When `breakdown.available` is false, show `reason`; `days` is then empty and `peakHour` null, which means the breakdown was not measured — never that no traffic occurred. `period` is null only when the service has no billing anchor at all. This endpoint works for suspended and over-allowance services too.

### Related Endpoints

- `GET /api/v2/vps/{id}`: Get VPS details
- `GET /api/v2/vps/{id}/iso`: List VPS ISO media
- `GET /api/v2/vps/{id}/disks`: List VPS disks

### Headers

- `Accept`: application/json
- `Authorization`: Bearer YOUR_API_KEY
- Required API scope: `read:vm`

### Parameters

- `id` (path, string, required): Public VPS ID. Get it from `GET /api/v2/vps` `data[].id`. Do not invent this value; use the exact ID returned by the referenced API response. Example: `vps_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Example

```bash
curl -X GET "https://cloud.hostup.se/api/v2/vps/vps_01hxa3b4c5d6e7f8g9h0j1k2m3/bandwidth" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json"
```

### Response Schema

- `id` (string, required): Public VPS ID. Example: `vps_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `period` (object, required, nullable): The running allowance period. Null when the service has no billing anchor.
- `allowance` (object, required): Running usage for this period; identical to `bandwidth` on `GET /api/v2/vps/{id}`.
- `allowance.usedGb` (number, required) Example: `123.25`
- `allowance.limitGb` (number, required) Example: `2048`
- `allowance.inboundGb` (number, required) Example: `65.13`
- `allowance.outboundGb` (number, required) Example: `58.12`
- `allowance.usagePercent` (number, required) Example: `6.02`
- `allowance.hasOverage` (boolean, required) Example: `false`
- `breakdown` (object, required)
- `breakdown.available` (boolean, required): False when the per-day breakdown could not be measured; `days` is then empty and `peakHour` null. Example: `true`
- `breakdown.reason` (string, required, nullable): Plain-English explanation when `available` is false; null otherwise. Example: `null`
- `breakdown.source` (string, required, nullable): `counters` = exact cumulative interface counters. `estimated` = integrated from sampled traffic rates; treat amounts as approximate. Null when unavailable. Same vocabulary as `totals.source` on `GET /api/v2/vps/{id}/metrics`. Example: `counters`
  Allowed values: counters, estimated
- `breakdown.window` (object, required): Actual measurement coverage inside the period (first and last instant traffic telemetry exists for). Both null when unavailable.
- `breakdown.window.startAt` (string, required, nullable): Nullable (may be null when not applicable). Example: `2026-08-27T15:00:00.000Z`
- `breakdown.window.endAt` (string, required, nullable): Nullable (may be null when not applicable). Example: `2026-08-31T12:00:00.000Z`
- `breakdown.days` (array<object>, required): One entry per Europe/Stockholm calendar day from the period start through today, oldest first.
- `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 attributed to individual hours. False for an `estimated` breakdown whose samples are coarser than an hour; `hours` is then empty and `peakHour` null. Example: `true`
- `breakdown.hours` (array<object>, required): Every 60-minute window in the period with measured traffic, oldest first. Windows 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 60-minute window with the most traffic in this period. Null when no traffic was measured, or when an `estimated` breakdown's samples are coarser than an hour (no single hour can be named honestly).

### Responses

#### 200 - Bandwidth period usage.
```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 body failed validation.",
  "code": "invalid_request",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z",
  "errors": [
    {
      "pointer": "/items/0/domainName",
      "detail": "`domainName` is required.",
      "code": "invalid_request"
    }
  ]
}
```

#### 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.
```json
{
  "type": "https://developer.hostup.se/errors/not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "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": "Too many requests. Retry after the limit resets.",
  "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"
}
```
