Skip to main content
POST
/
vpn
/
instances
/
{instanceId}
/
peers
Create a peer
curl --request POST \
  --url https://v1.api.altostrat.io/vpn/instances/{instanceId}/peers \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "type": "client",
  "protocol": "wireguard",
  "site_id": "c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e",
  "user_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
  "subnets": [
    "192.168.100.0/24"
  ],
  "route_all": false
}
'
import requests

url = "https://v1.api.altostrat.io/vpn/instances/{instanceId}/peers"

payload = {
    "type": "client",
    "protocol": "wireguard",
    "site_id": "c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e",
    "user_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
    "subnets": ["192.168.100.0/24"],
    "route_all": False
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    type: 'client',
    protocol: 'wireguard',
    site_id: 'c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e',
    user_id: 'a1b2c3d4-e5f6-7890-1234-567890abcdef',
    subnets: ['192.168.100.0/24'],
    route_all: false
  })
};

fetch('https://v1.api.altostrat.io/vpn/instances/{instanceId}/peers', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://v1.api.altostrat.io/vpn/instances/{instanceId}/peers",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'type' => 'client',
    'protocol' => 'wireguard',
    'site_id' => 'c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e',
    'user_id' => 'a1b2c3d4-e5f6-7890-1234-567890abcdef',
    'subnets' => [
        '192.168.100.0/24'
    ],
    'route_all' => false
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://v1.api.altostrat.io/vpn/instances/{instanceId}/peers"

	payload := strings.NewReader("{\n  \"type\": \"client\",\n  \"protocol\": \"wireguard\",\n  \"site_id\": \"c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e\",\n  \"user_id\": \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n  \"subnets\": [\n    \"192.168.100.0/24\"\n  ],\n  \"route_all\": false\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://v1.api.altostrat.io/vpn/instances/{instanceId}/peers")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"type\": \"client\",\n  \"protocol\": \"wireguard\",\n  \"site_id\": \"c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e\",\n  \"user_id\": \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n  \"subnets\": [\n    \"192.168.100.0/24\"\n  ],\n  \"route_all\": false\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://v1.api.altostrat.io/vpn/instances/{instanceId}/peers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"type\": \"client\",\n  \"protocol\": \"wireguard\",\n  \"site_id\": \"c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e\",\n  \"user_id\": \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n  \"subnets\": [\n    \"192.168.100.0/24\"\n  ],\n  \"route_all\": false\n}"

response = http.request(request)
puts response.read_body
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "type": "client",
  "user_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
  "site_id": "c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e",
  "subnets": [
    "192.168.100.0/24"
  ],
  "route_all": false,
  "protocol": "wireguard",
  "connected": false,
  "connected_from": null,
  "token": "eyJpdiI6...",
  "token_ttl": 3600,
  "created_at": "2025-10-29T12:45:00Z"
}
{
  "type": "invalid_request_error",
  "code": "parameter_missing",
  "message": "The 'name' parameter is required for this request.",
  "doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}
{
  "type": "invalid_request_error",
  "code": "parameter_missing",
  "message": "The 'name' parameter is required for this request.",
  "doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}
{
  "type": "invalid_request_error",
  "code": "parameter_missing",
  "message": "The 'name' parameter is required for this request.",
  "doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}
{
  "type": "invalid_request_error",
  "code": "parameter_missing",
  "message": "The 'name' parameter is required for this request.",
  "doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}
{
  "type": "invalid_request_error",
  "code": "parameter_missing",
  "message": "The 'name' parameter is required for this request.",
  "doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}

Authorizations

Authorization
string
header
required

Enter your bearer token in the format: Bearer {token}

Path Parameters

instanceId
string<uuid>
required

The unique identifier (UUID) for the VPN instance.

Example:

"d290f1ee-6c54-4b01-90e6-d701748f0851"

Body

application/json
type
enum<string>
required

The type of peer to create.

Available options:
client,
site
Example:

"client"

protocol
enum<string>
required

The protocol for the peer. client peers must use wireguard.

Available options:
wireguard,
openvpn
Example:

"wireguard"

site_id
string<uuid>

The unique identifier for the site. Required if type is site.

Example:

"c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e"

user_id
string<uuid>

The unique identifier for the user. Required if type is client.

Example:

"a1b2c3d4-e5f6-7890-1234-567890abcdef"

subnets
string[]

A list of subnets (in CIDR notation) for the site. Required if type is site.

route_all
boolean

If true, route all traffic for the client through the VPN. Required if type is client.

Example:

false

Response

The peer was created successfully.

id
string<uuid>

The unique identifier for the peer.

Example:

"550e8400-e29b-41d4-a716-446655440000"

type
enum<string>

The type of peer. client represents an individual user, while site represents a site-to-site connection.

Available options:
client,
site
Example:

"client"

user_id
string<uuid> | null

The unique identifier for the user, if the peer is of type client.

Example:

"a1b2c3d4-e5f6-7890-1234-567890abcdef"

site_id
string<uuid> | null

The unique identifier for the site, if the peer is of type site.

Example:

"c3d5e2a0-88c9-4f7f-9f7b-6a1e2b4c5d6e"

subnets
string[]

A list of subnets (in CIDR notation) that this peer routes. Only applicable for site peers.

route_all
boolean

If true, all of the client's traffic will be routed through the VPN. Only applicable for client peers.

Example:

false

protocol
enum<string>

The VPN protocol used by this peer.

Available options:
wireguard,
openvpn
Example:

"wireguard"

connected
boolean

Indicates if the peer is currently connected.

Example:

false

connected_from
string<ipv4> | null

The public IP address of the connected peer.

Example:

null

token
string | null

A short-lived token for client peers to retrieve their configuration files. Not for direct API use.

Example:

"eyJpdiI6..."

token_ttl
integer

The time-to-live for the token in seconds.

Example:

3600

created_at
string<date-time>

The timestamp when the peer was created.

Example:

"2025-10-29T12:45:00Z"