Create a new organization
curl --request POST \
--url https://closedvpn.io/auth/create-org \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My New Org",
"vpnId": "60c72b2f5f1b2c001c8e4b2a",
"description": "Description of the organization"
}
'import requests
url = "https://closedvpn.io/auth/create-org"
payload = {
"name": "My New Org",
"vpnId": "60c72b2f5f1b2c001c8e4b2a",
"description": "Description of the organization"
}
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({
name: 'My New Org',
vpnId: '60c72b2f5f1b2c001c8e4b2a',
description: 'Description of the organization'
})
};
fetch('https://closedvpn.io/auth/create-org', 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://closedvpn.io/auth/create-org",
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([
'name' => 'My New Org',
'vpnId' => '60c72b2f5f1b2c001c8e4b2a',
'description' => 'Description of the organization'
]),
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://closedvpn.io/auth/create-org"
payload := strings.NewReader("{\n \"name\": \"My New Org\",\n \"vpnId\": \"60c72b2f5f1b2c001c8e4b2a\",\n \"description\": \"Description of the organization\"\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://closedvpn.io/auth/create-org")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My New Org\",\n \"vpnId\": \"60c72b2f5f1b2c001c8e4b2a\",\n \"description\": \"Description of the organization\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://closedvpn.io/auth/create-org")
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 \"name\": \"My New Org\",\n \"vpnId\": \"60c72b2f5f1b2c001c8e4b2a\",\n \"description\": \"Description of the organization\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Organization created successfully",
"org": {
"_id": "60c72b2f5f1b2c001c8e4b1a",
"name": "My Org",
"description": "Default organization",
"org_avatar": "data:image/svg+xml;base64,...",
"active": true,
"users": [
{
"user_id": "60c72b2f5f1b2c001c8e4b1b",
"email": "[email protected]",
"name": "John Doe",
"user_avatar": "JD",
"role": "owner",
"active": true,
"invitation": {
"status": "completed",
"createdAt": 1735689600000
},
"hasCertificate": true,
"membership_periods": [
{
"joinedAt": 1735689600000,
"leftAt": null
}
],
"createdAt": 1735689600000
}
],
"vpn_id": "60c72b2f5f1b2c001c8e4b2a",
"vpn_name": "Frankfurt Node",
"used_licenses": 3,
"total_licenses": 10,
"createdAt": 1735689600000
}
}{
"message": "Organization name is required"
}{
"message": "Unauthorized"
}{
"message": "User not found"
}{
"message": "Error creating organization"
}Organizations
Create Organization
Creates a new organization for the authenticated user, setting them as the owner and assigning the given VPN configuration to it.
POST
/
auth
/
create-org
Create a new organization
curl --request POST \
--url https://closedvpn.io/auth/create-org \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My New Org",
"vpnId": "60c72b2f5f1b2c001c8e4b2a",
"description": "Description of the organization"
}
'import requests
url = "https://closedvpn.io/auth/create-org"
payload = {
"name": "My New Org",
"vpnId": "60c72b2f5f1b2c001c8e4b2a",
"description": "Description of the organization"
}
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({
name: 'My New Org',
vpnId: '60c72b2f5f1b2c001c8e4b2a',
description: 'Description of the organization'
})
};
fetch('https://closedvpn.io/auth/create-org', 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://closedvpn.io/auth/create-org",
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([
'name' => 'My New Org',
'vpnId' => '60c72b2f5f1b2c001c8e4b2a',
'description' => 'Description of the organization'
]),
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://closedvpn.io/auth/create-org"
payload := strings.NewReader("{\n \"name\": \"My New Org\",\n \"vpnId\": \"60c72b2f5f1b2c001c8e4b2a\",\n \"description\": \"Description of the organization\"\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://closedvpn.io/auth/create-org")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My New Org\",\n \"vpnId\": \"60c72b2f5f1b2c001c8e4b2a\",\n \"description\": \"Description of the organization\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://closedvpn.io/auth/create-org")
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 \"name\": \"My New Org\",\n \"vpnId\": \"60c72b2f5f1b2c001c8e4b2a\",\n \"description\": \"Description of the organization\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Organization created successfully",
"org": {
"_id": "60c72b2f5f1b2c001c8e4b1a",
"name": "My Org",
"description": "Default organization",
"org_avatar": "data:image/svg+xml;base64,...",
"active": true,
"users": [
{
"user_id": "60c72b2f5f1b2c001c8e4b1b",
"email": "[email protected]",
"name": "John Doe",
"user_avatar": "JD",
"role": "owner",
"active": true,
"invitation": {
"status": "completed",
"createdAt": 1735689600000
},
"hasCertificate": true,
"membership_periods": [
{
"joinedAt": 1735689600000,
"leftAt": null
}
],
"createdAt": 1735689600000
}
],
"vpn_id": "60c72b2f5f1b2c001c8e4b2a",
"vpn_name": "Frankfurt Node",
"used_licenses": 3,
"total_licenses": 10,
"createdAt": 1735689600000
}
}{
"message": "Organization name is required"
}{
"message": "Unauthorized"
}{
"message": "User not found"
}{
"message": "Error creating organization"
}Authorizations
Personal Access Token (PAT) passed in the Authorization header (e.g., Bearer <pat>) for authenticated API requests. PATs are generated via /auth/generate-pat after authenticating through the magic link flow.
Body
application/json

