Add a user to an organization
curl --request POST \
--url https://closedvpn.io/auth/add-user \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"org_id": "60c72b2f5f1b2c001c8e4b1a",
"email": "[email protected]",
"role": "member"
}
'import requests
url = "https://closedvpn.io/auth/add-user"
payload = {
"org_id": "60c72b2f5f1b2c001c8e4b1a",
"email": "[email protected]",
"role": "member"
}
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', email: '[email protected]', role: 'member'})
};
fetch('https://closedvpn.io/auth/add-user', 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/add-user",
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',
'email' => '[email protected]',
'role' => 'member'
]),
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/add-user"
payload := strings.NewReader("{\n \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\",\n \"email\": \"[email protected]\",\n \"role\": \"member\"\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/add-user")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\",\n \"email\": \"[email protected]\",\n \"role\": \"member\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://closedvpn.io/auth/add-user")
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 \"email\": \"[email protected]\",\n \"role\": \"member\"\n}"
response = http.request(request)
puts response.read_body{
"message": "User added 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 ID, email, and role are required"
}{
"message": "Unauthorized"
}{
"message": "Only owners can invite users"
}{
"message": "Organization not found"
}{
"message": "Failed to add the user to the organization in the database. Please try again later."
}Members
Add Member
Adds a user to an organization with a specified role and activates membership immediately. Only owners can add users.
POST
/
auth
/
add-user
Add a user to an organization
curl --request POST \
--url https://closedvpn.io/auth/add-user \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"org_id": "60c72b2f5f1b2c001c8e4b1a",
"email": "[email protected]",
"role": "member"
}
'import requests
url = "https://closedvpn.io/auth/add-user"
payload = {
"org_id": "60c72b2f5f1b2c001c8e4b1a",
"email": "[email protected]",
"role": "member"
}
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', email: '[email protected]', role: 'member'})
};
fetch('https://closedvpn.io/auth/add-user', 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/add-user",
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',
'email' => '[email protected]',
'role' => 'member'
]),
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/add-user"
payload := strings.NewReader("{\n \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\",\n \"email\": \"[email protected]\",\n \"role\": \"member\"\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/add-user")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"org_id\": \"60c72b2f5f1b2c001c8e4b1a\",\n \"email\": \"[email protected]\",\n \"role\": \"member\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://closedvpn.io/auth/add-user")
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 \"email\": \"[email protected]\",\n \"role\": \"member\"\n}"
response = http.request(request)
puts response.read_body{
"message": "User added 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 ID, email, and role are required"
}{
"message": "Unauthorized"
}{
"message": "Only owners can invite users"
}{
"message": "Organization not found"
}{
"message": "Failed to add the user to the organization in the database. Please try again later."
}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"
Example:
Available options:
owner, member Example:
"member"

