Leave an organization
curl --request POST \
--url https://closedvpn.io/auth/leave-org \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"org_id": "60c72b2f5f1b2c001c8e4b1a"
}
'import requests
url = "https://closedvpn.io/auth/leave-org"
payload = { "org_id": "60c72b2f5f1b2c001c8e4b1a" }
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({org_id: '60c72b2f5f1b2c001c8e4b1a'})
};
fetch('https://closedvpn.io/auth/leave-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/leave-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([
'org_id' => '60c72b2f5f1b2c001c8e4b1a'
]),
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/leave-org"
payload := strings.NewReader("{\n \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\"\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/leave-org")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://closedvpn.io/auth/leave-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 \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\"\n}"
response = http.request(request)
puts response.read_body{
"message": "You have successfully left the organization",
"orgs": [
{
"_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 ID is required"
}{
"message": "Unauthorized"
}{
"message": "Cannot leave as the last owner. Add another owner or delete the organization."
}{
"message": "Organization not found"
}{
"message": "Error leaving organization"
}Members
Leave Organization
Allows a user to leave an organization. Cannot leave if the user is the last owner.
POST
/
auth
/
leave-org
Leave an organization
curl --request POST \
--url https://closedvpn.io/auth/leave-org \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"org_id": "60c72b2f5f1b2c001c8e4b1a"
}
'import requests
url = "https://closedvpn.io/auth/leave-org"
payload = { "org_id": "60c72b2f5f1b2c001c8e4b1a" }
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({org_id: '60c72b2f5f1b2c001c8e4b1a'})
};
fetch('https://closedvpn.io/auth/leave-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/leave-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([
'org_id' => '60c72b2f5f1b2c001c8e4b1a'
]),
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/leave-org"
payload := strings.NewReader("{\n \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\"\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/leave-org")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://closedvpn.io/auth/leave-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 \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\"\n}"
response = http.request(request)
puts response.read_body{
"message": "You have successfully left the organization",
"orgs": [
{
"_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 ID is required"
}{
"message": "Unauthorized"
}{
"message": "Cannot leave as the last owner. Add another owner or delete the organization."
}{
"message": "Organization not found"
}{
"message": "Error leaving 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
Example:
"60c72b2f5f1b2c001c8e4b1a"

