---
title: "Give a peer a new key. The old key stops working within seconds."
method: POST
path: "/v1/networks/wireguard/peers/{id}:rotate"
tags: ["networks"]
---

# Give a peer a new key. The old key stops working within seconds.

`POST /v1/networks/wireguard/peers/{id}:rotate`

## Request

- Base URL: `https://api.withruntime.com`
- URL: `https://api.withruntime.com/v1/networks/wireguard/peers/{id}:rotate`
- Auth: HTTP bearer

## Path parameters

- `id` string, required: Resource identifier (UUID).

## Headers

- `Idempotency-Key` string

## Request body

- object
  - `publicKey` string: The peer's WireGuard public key. Leave it out and Runtime generates the pair.

## Response `200`

Success

- object
  - `tunnel` object
    - `funded` boolean: Funding permits traffic. False disables traffic while retaining the reservation; check balance, spending limits and account permissions.
    - `fundedUntil` string, date-time, nullable: Last funded-through timestamp, possibly in the past. Null means no meter exists. Free IPv6 also receives renewable deadlines.
    - `rateMicros` integer: Immutable quoted monthly price in millionths of a US dollar.
    - `rateUnit` 'unit_month'
    - `id` string
    - `subnet` string
    - `gatewayAddress` string
    - `endpoint` string: Where peers send WireGuard: address:udpPort.
    - `gatewayPublicKey` string, nullable: Null until a funded gateway is ready.
    - `disabled` boolean
    - `peers` object[]
      - `id` string
      - `name` string
      - `publicKey` string
      - `address` string: The peer's address inside the private network.
      - `routes` string[]: Your own ranges behind this peer, which sandboxes may reach through it.
      - `createdAt` string, date-time
      - `rotatedAt` string, date-time, nullable
    - `sandboxes` object[]
      - `sandboxId` string
      - `name` string, nullable
      - `address` string: Reach this sandbox's ports at this address.
      - `state` string
    - `createdAt` string, date-time
  - `peer` object
    - `id` string
    - `name` string
    - `publicKey` string
    - `address` string: The peer's address inside the private network.
    - `routes` string[]: Your own ranges behind this peer, which sandboxes may reach through it.
    - `createdAt` string, date-time
    - `rotatedAt` string, date-time, nullable
  - `config` string, nullable: A wg-quick file or a draft when configReady is false. Keep it: a Runtime-generated private key is delivered here once. Complete the gateway PublicKey before using a draft.
  - `configReady` boolean: Whether config includes the gateway public key. Funding and access are reported separately on tunnel.
  - `hint` string

## Other responses

- `default`: Error

---

[API](https://skmtc.dev/withruntime/apis/runtime-cloud-api.md) · [All operations](https://skmtc.dev/withruntime/apis/runtime-cloud-api/llms.txt) · [OpenAPI document](https://skmtc.dev/withruntime/apis/runtime-cloud-api/revisions/6f4012286988?raw)
