All error codes

invalid_public_key

HTTP 422 Public key is not a valid WireGuard key

What happened

The public key is not a canonical WireGuard key: 32 bytes encoded as 44 characters of base64.

What to do

Send the public key exactly as `wg pubkey` prints it and repeat with a new idempotency key.

Retrying

Fix the request and send it again.

How it arrives

{
    "type": "https://docs.fiberax.com/errors/invalid_public_key",
    "title": "Public key is not a valid WireGuard key",
    "status": 422,
    "code": "invalid_public_key",
    "request_id": "a277dcd1ca652c65"
}

Branch your code on code, never on the wording of title.