## POST /api/v2/routed-ipv6

**Allocate a routed IPv6 pool or route a subnet**

Use `action: "allocate_pool"` to add the account-level /48 when the account has none yet. Use `action: "create_route"` with `poolId`, `vpsId`, and `prefixLength` to route a /48, /56, or /64 to a VPS. `prefix` is optional; when omitted, the server chooses the first available child prefix in the selected /48.

### Related Endpoints

- `GET /api/v2/routed-ipv6`: List account routed IPv6
- `DELETE /api/v2/routed-ipv6/{id}`: Release an empty routed IPv6 pool
- `DELETE /api/v2/routed-ipv6/routes/{id}`: Delete a routed IPv6 route

### Headers

- `Accept`: application/json
- `Authorization`: Bearer YOUR_API_KEY
- Required API scope: `write:network`
- `Content-Type`: application/json

### Request Body

- `action` (string, optional) Example: `create_route`
  Allowed values: allocate_pool, create_route
- `poolId` (string, optional): Required for `create_route`. Use `pools[].id` from `GET /api/v2/routed-ipv6`. Example: `ripv6_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `vpsId` (string, optional): Required for `create_route`. Use an eligible `destinations[].vpsId` value. Example: `vps_01hxa3b4c5d6e7f8g9h0j1k2m5`
- `prefixLength` (integer, optional): Required for `create_route`; allowed child prefix length. Example: `64`
  Allowed values: 48, 56, 64
- `prefix` (string, optional): Optional explicit child prefix. Omit it to let the server choose the first available prefix. Example: `2001:db8:1000:100::/56`
- `label` (string, optional): Optional customer label for the route. Example: `web subnet`

### Request Examples

#### Allocate an account /48

```bash
curl -X POST "https://cloud.hostup.se/api/v2/routed-ipv6" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "allocate_pool"
  }'
```

```json
{
  "action": "allocate_pool"
}
```

#### Route one /64 to a VPS

```bash
curl -X POST "https://cloud.hostup.se/api/v2/routed-ipv6" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "create_route",
    "poolId": "ripv6_01hxa3b4c5d6e7f8g9h0j1k2m3",
    "vpsId": "vps_01hxa3b4c5d6e7f8g9h0j1k2m5",
    "prefixLength": 64,
    "label": "web subnet"
  }'
```

```json
{
  "action": "create_route",
  "poolId": "ripv6_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "vpsId": "vps_01hxa3b4c5d6e7f8g9h0j1k2m5",
  "prefixLength": 64,
  "label": "web subnet"
}
```

#### Route a specific child prefix

```bash
curl -X POST "https://cloud.hostup.se/api/v2/routed-ipv6" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "create_route",
    "poolId": "ripv6_01hxa3b4c5d6e7f8g9h0j1k2m3",
    "vpsId": "vps_01hxa3b4c5d6e7f8g9h0j1k2m5",
    "prefixLength": 56,
    "prefix": "2001:db8:1000:100::/56"
  }'
```

```json
{
  "action": "create_route",
  "poolId": "ripv6_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "vpsId": "vps_01hxa3b4c5d6e7f8g9h0j1k2m5",
  "prefixLength": 56,
  "prefix": "2001:db8:1000:100::/56"
}
```

### Response Schema

- `available` (boolean, optional) Example: `true`
- `reason` (string,null, optional) Example: `null`
- `allowedPrefixLengths` (array<integer>, optional) Example: `[48,56,64]`
- `pools` (array<object>, optional)
- `pools[].id` (string, required) Example: `ripv6_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `pools[].parentCidr` (string, required) Example: `2001:db8:1000::/48`
- `pools[].prefixLength` (integer, required) Example: `48`
  Allowed values: 48
- `pools[].status` (string, required) Example: `active`
  Allowed values: active
- `pools[].allocatedAt` (string,null, required) Example: `2026-06-15T12:00:00.000Z`
- `pools[].updatedAt` (string,null, required) Example: `2026-06-15T12:00:00.000Z`
- `pools[].routes` (array<object>, required)
- `pools[].routes[].id` (string, required) Example: `ripv6rt_01hxa3b4c5d6e7f8g9h0j1k2m4`
- `pools[].routes[].prefix` (string, required) Example: `2001:db8:1000:10::/64`
- `pools[].routes[].prefixLength` (integer, required) Example: `64`
  Allowed values: 48, 56, 64
- `pools[].routes[].nextHop` (string, required) Example: `2001:db8::10`
- `pools[].routes[].label` (string,null, required) Example: `web subnet`
- `pools[].routes[].vpsId` (string, required) Example: `vps_01hxa3b4c5d6e7f8g9h0j1k2m5`
- `pools[].routes[].vpsName` (string, required) Example: `web-01`
- `pools[].routes[].status` (string, required) Example: `active`
  Allowed values: active
- `pools[].routes[].allocatedAt` (string,null, required) Example: `2026-06-15T12:01:00.000Z`
- `pools[].routes[].updatedAt` (string,null, required) Example: `2026-06-15T12:01:00.000Z`
- `pools[].routes[].actions` (object, required)
- `pools[].routes[].actions.canDelete` (object, required): Whether one routed IPv6 action is currently available.
- `pools[].routes[].actions.canDelete.allowed` (boolean, required) Example: `true`
- `pools[].routes[].actions.canDelete.reason` (string,null, required) Example: `null`
- `pools[].actions` (object, required)
- `pools[].actions.canCreateRoute` (object, required): Whether one routed IPv6 action is currently available.
- `pools[].actions.canCreateRoute.allowed` (boolean, required) Example: `true`
- `pools[].actions.canCreateRoute.reason` (string,null, required) Example: `null`
- `pools[].actions.canRelease` (object, required): Whether one routed IPv6 action is currently available.
- `pools[].actions.canRelease.allowed` (boolean, required) Example: `true`
- `pools[].actions.canRelease.reason` (string,null, required) Example: `null`
- `destinations` (array<object>, optional)
- `destinations[].vpsId` (string, required) Example: `vps_01hxa3b4c5d6e7f8g9h0j1k2m5`
- `destinations[].name` (string, required) Example: `web-01`
- `destinations[].primaryIp` (string,null, required) Example: `192.0.2.10`
- `destinations[].nextHop` (string,null, required) Example: `2001:db8::10`
- `destinations[].serviceStatus` (string, required) Example: `active`
- `destinations[].actions` (object, required)
- `destinations[].actions.canReceiveRoute` (object, required): Whether one routed IPv6 action is currently available.
- `destinations[].actions.canReceiveRoute.allowed` (boolean, required) Example: `true`
- `destinations[].actions.canReceiveRoute.reason` (string,null, required) Example: `null`
- `actions` (object, optional)
- `actions.canAllocatePool` (object, required): Whether one routed IPv6 action is currently available.
- `actions.canAllocatePool.allowed` (boolean, required) Example: `true`
- `actions.canAllocatePool.reason` (string,null, required) Example: `null`
- `actions.canCreateRoute` (object, required): Whether one routed IPv6 action is currently available.
- `actions.canCreateRoute.allowed` (boolean, required) Example: `true`
- `actions.canCreateRoute.reason` (string,null, required) Example: `null`

### Responses

#### 201 - Updated routed IPv6 state.
```json
{
  "available": true,
  "reason": null,
  "allowedPrefixLengths": [
    48,
    56,
    64
  ],
  "pools": [],
  "destinations": [],
  "actions": {
    "canAllocatePool": {
      "allowed": true,
      "reason": null
    },
    "canCreateRoute": {
      "allowed": false,
      "reason": "Add a routed /48 before creating routes."
    }
  }
}
```

#### 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"
}
```

#### 409 - The account already has a routed /48, the requested prefix overlaps an existing route, or no capacity remains.
```json
{
  "type": "https://developer.hostup.se/errors/routed_ipv6_pool_exists",
  "title": "Routed IPv6 conflict",
  "status": 409,
  "detail": "This account already has a routed /48.",
  "code": "routed_ipv6_pool_exists",
  "instance": "/api/v2/routed-ipv6",
  "requestId": "550e8400-e29b-41d4-a716-446655440000",
  "timestamp": "2026-06-15T12:00:00.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"
}
```
