### Setup Key Response Example Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx An example of a successful response when creating a setup key, including its ID, name, expiration, and usage details. The 'key' field contains the actual setup key to be used for device onboarding. ```json { "id": 2531583362, "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", "type": "reusable", "valid": true, "revoked": false, "used_times": 2, "last_used": "2023-05-05T09:00:35.477782Z", "state": "valid", "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ], "updated_at": "2023-05-05T09:00:35.477782Z", "usage_limit": 0, "ephemeral": true, "allow_extra_dns_labels": true, "key": "A616097E-FCF0-48FA-9354-CA4A61142761" } ``` -------------------------------- ### Install and Start NetBird Service (Binary) Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/linux.mdx Install and start the NetBird client daemon service after manually installing the binary. ```bash sudo netbird service install sudo netbird service start ``` -------------------------------- ### Instance Setup Response Example Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/instance.mdx This is an example of a successful response from the /api/setup endpoint. It contains the user ID and the generated personal access token. ```json { "user_id": "abc123def456", "email": "admin@example.com", "personal_access_token": "nbp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } ``` -------------------------------- ### Download and Run NetBird Enterprise Getting Started Script Source: https://github.com/netbirdio/docs/blob/main/src/pages/selfhosted/enterprise/getting-started.mdx A script to download and execute the NetBird Enterprise setup process. This is used to reset the deployment and start the initial owner setup. ```bash curl -fsSL https://pkgs.netbird.io/getting-started-enterprise.sh | bash ``` -------------------------------- ### GET /api/instance Source: https://github.com/netbirdio/docs/blob/main/src/pages/selfhosted/identity-providers/local.mdx Checks if the instance requires initial setup. ```APIDOC ## GET /api/instance ### Description Checks the current setup status of the instance. Used to determine if the instance requires initial configuration. ### Method GET ### Endpoint /api/instance ### Response #### Success Response (200) - **setup_required** (boolean) - Indicates if setup is required #### Response Example { "setup_required": true } ``` -------------------------------- ### Install and Start NetBird Client Daemon (Homebrew) Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/linux.mdx Install and start the NetBird client daemon service using the Homebrew installation path. Adjust the command if your Homebrew prefix differs from the default. ```bash sudo /home/linuxbrew/.linuxbrew/bin/netbird service install sudo /home/linuxbrew/.linuxbrew/bin/netbird service start ``` -------------------------------- ### Create Postinstall Script for NetBird CLI Source: https://github.com/netbirdio/docs/blob/main/src/pages/manage/integrations/mdm-deployment/macos-cli-pkg-deployment.mdx This script installs and starts the NetBird daemon service. It also handles peer enrollment using a setup key on the first install, skipping enrollment on subsequent updates. ```bash #!/bin/sh LOG_FILE=/var/log/netbird/client_post_install.log AGENT=/usr/local/bin/netbird mkdir -p /var/log/netbird/ { echo "=== NetBird CLI postinstall: $(date) ===" # Install and start the daemon service $AGENT service install 2>/dev/null || true $AGENT service start || { echo "ERROR: Failed to start NetBird service" exit 1 } # Enroll the peer if not already configured. # The config file exists once the peer has been enrolled at least once. CONFIG_FILE="/var/lib/netbird/config.json" if [ ! -f "$CONFIG_FILE" ]; then echo "First install detected — enrolling with setup key" # Replace YOUR_SETUP_KEY with your actual reusable setup key. # For self-hosted deployments, add: --management-url https://your-management.example.com $AGENT up --setup-key YOUR_SETUP_KEY else echo "Existing configuration found — skipping enrollment" fi echo "Postinstall complete" exit 0 } >> "$LOG_FILE" 2>&1 ``` -------------------------------- ### Start NetBird with a Setup Key Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/linux.mdx Initiate NetBird using a setup key, typically for server peer activation or infrastructure-as-code deployments. ```bash netbird up --setup-key ``` -------------------------------- ### Create a setup key inside a tenant Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/guides/msp-api-access.mdx This example demonstrates how to create a setup key within a specific tenant using a POST request. The `account` parameter scopes the operation to the target tenant. ```bash curl -X POST https://api.netbird.io/api/setup-keys?account= \ -H "Authorization: Token {token}" \ -H "Content-Type: application/json" \ -d '{"name":"bootstrap","type":"reusable"}' ``` -------------------------------- ### Bash Command Example Source: https://github.com/netbirdio/docs/blob/main/README.md Example of a bash command for installation. This is a standard fenced code block. ```bash npm install npm run dev ``` -------------------------------- ### Start NetBird with Setup Key and Custom Management URL Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/linux.mdx Connect NetBird using a setup key and specify a custom URL for your Management Service, useful for self-hosted setups. ```bash netbird up --setup-key --management-url http://localhost:33073 ``` -------------------------------- ### List setup keys inside a tenant Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/guides/msp-api-access.mdx Append `?account=` to the endpoint to execute the request inside a specific tenant. This example shows how to list setup keys. ```bash curl https://api.netbird.io/api/setup-keys?account= \ -H "Authorization: Token {token}" ``` -------------------------------- ### Update Setup Key Response Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx Example of a successful response when updating a setup key. It shows the current state and properties of the key after the update. ```json { "state": "valid", "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ], "updated_at": "2023-05-05T09:00:35.477782Z", "usage_limit": 0, "ephemeral": true, "allow_extra_dns_labels": true, "key": "A6160****" } ``` -------------------------------- ### Setup Key Response Structure Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx This is an example of the JSON response structure when listing setup keys. It includes details like ID, name, expiration, type, and usage status. ```json [ { "id": 2531583362, "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", "type": "reusable", "valid": true, "revoked": false, "used_times": 2, "last_used": "2023-05-05T09:00:35.477782Z", "state": "valid", "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ], "updated_at": "2023-05-05T09:00:35.477782Z", "usage_limit": 0, "ephemeral": true, "allow_extra_dns_labels": true, "key": "A6160****" } ] ``` ```json [ { "id": "string", "name": "string", "expires": "string", "type": "string", "valid": "boolean", "revoked": "boolean", "used_times": "integer", "last_used": "string", "state": "string", "auto_groups": [ "string" ], "updated_at": "string", "usage_limit": "integer", "ephemeral": "boolean", "allow_extra_dns_labels": "boolean", "key": "string" } ] ``` -------------------------------- ### Retrieve Setup Key Information Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx Use this endpoint to get details about a specific setup key. Requires the key's unique identifier. The response includes key details such as its ID, name, expiration, type, and usage status. ```bash curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` ```javascript const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, url: '/api/setup-keys/{keyId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' } }; axios(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); }); ``` ```python import requests import json url = "https://api.netbird.io/api/setup-keys/{keyId}" headers = { 'Accept': 'application/json', 'Authorization': 'Token ' } response = requests.request("GET", url, headers=headers) print(response.text) ``` ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://api.netbird.io/api/setup-keys/{keyId}" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } req.Header.Add("Accept", "application/json") req.Header.Add("Authorization", "Token ") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` ```ruby require "uri" require "json" require "net/http" url = URI("https://api.netbird.io/api/setup-keys/{keyId}") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "Token " response = https.request(request) puts response.read_body ``` ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/setup-keys/{keyId}") .method("GET") .addHeader("Accept", "application/json") .addHeader("Authorization: Token ") .build(); Response response = client.newCall(request).execute(); ``` ```php 'https://api.netbird.io/api/setup-keys/{keyId}', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Accept: application/json', 'Authorization: Token ' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ?> ``` -------------------------------- ### POST /api/setup Source: https://github.com/netbirdio/docs/blob/main/src/pages/selfhosted/identity-providers/local.mdx Completes the initial instance setup by creating the owner account. ```APIDOC ## POST /api/setup ### Description Creates the initial owner account for the instance. This endpoint is only accessible when setup_required is true. ### Method POST ### Endpoint /api/setup ### Request Body - **email** (string) - Required - Admin email address - **password** (string) - Required - Admin password (min 8 chars) - **name** (string) - Optional - Admin name ### Request Example { "email": "admin@example.com", "password": "securepassword123", "name": "Admin User" } ### Response #### Success Response (200) - **user_id** (string) - Created user ID - **account_id** (string) - Created account ID #### Response Example { "user_id": "user-abc123", "account_id": "account-xyz789" } ``` -------------------------------- ### Create Setup Key Request (Java) Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx Demonstrates how to construct a POST request to create a new setup key using Java and OkHttp. Ensure you replace with your actual API token. ```java Request request = new Request.Builder() .url("https://api.netbird.io/api/setup-keys") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") .addHeader("Authorization: Token ") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Install and Start NetBird Daemon Service Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/macos.mdx Installs and starts the NetBird client daemon service after a CLI-only Homebrew installation. ```bash sudo netbird service install sudo netbird service start ``` -------------------------------- ### Start NetBird with Setup Key and Extra DNS Labels Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/cli.mdx When starting NetBird, you can provide a setup key and extra DNS labels. Ensure the setup key has the 'Allow Extra DNS Labels' option enabled. ```shell netbird up --setup-key AAAA-BBB-CCC-DDDDDD ``` ```shell netbird up --setup-key AAAA-BBB-CCC-DDDDDD --extra-dns-labels vpc1,mgmt1 ``` -------------------------------- ### Create Setup Key using Go Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx This Go program demonstrates creating a setup key via the Netbird API. It uses the standard `net/http` package to send a POST request with the appropriate headers and JSON payload. Remember to replace `` with your actual API token. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://api.netbird.io/api/setup-keys" method := "POST" payload := strings.NewReader(`{ "name": "Default key", "type": "reusable", "expires_in": 86400, "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ], "usage_limit": 0, "ephemeral": true, "allow_extra_dns_labels": true }`) client := &http.Client { } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) return } req.Header.Add("Content-Type", "application/json") req.Header.Add("Accept", "application/json") req.Header.Add("Authorization", "Token ") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Install and Start NetBird Service Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/macos.mdx Install and start the NetBird daemon service. This creates a launchd daemon that runs as root to manage the WireGuard interface. ```bash sudo netbird service install sudo netbird service start ``` -------------------------------- ### Start Development Server Source: https://github.com/netbirdio/docs/blob/main/README.md Starts the local development server for live previewing changes. ```bash $ npm run dev ``` -------------------------------- ### Retrieve a Setup Key Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx Get information about a specific setup key by its ID. ```APIDOC ## GET /api/setup-keys/{keyId} ### Description Get information about a setup key. ### Method GET ### Endpoint /api/setup-keys/{keyId} ### Parameters #### Path Parameters - **keyId** (string) - Required - The unique identifier of a setup key ### Request Example ```bash curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` ### Response #### Success Response (200) - **id** (string) - **name** (string) - **expires** (string) - **type** (string) - **valid** (boolean) - **revoked** (boolean) - **used_times** (integer) - **last_used** (string) - **state** (string) - **auto_groups** (array of strings) - **updated_at** (string) - **usage_limit** (integer) - **ephemeral** (boolean) - **allow_extra_dns_labels** (boolean) - **key** (string) #### Response Example ```json { "id": 2531583362, "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", "type": "reusable", "valid": true, "revoked": false, "used_times": 2, "last_used": "2023-05-05T09:00:35.477782Z", "state": "valid", "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ], "updated_at": "2023-05-05T09:00:35.477782Z", "usage_limit": 0, "ephemeral": true, "allow_extra_dns_labels": true, "key": "A6160****" } ``` ``` -------------------------------- ### Basic Setup Environment Variables Source: https://github.com/netbirdio/docs/blob/main/src/pages/selfhosted/environment-variables.mdx Sets the NetBird domain and Let's Encrypt email for initial setup. ```bash # setup.env NETBIRD_DOMAIN="netbird.example.com" NETBIRD_LETSENCRYPT_EMAIL="admin@example.com" ``` -------------------------------- ### Install and Run NetBird on VMs Source: https://github.com/netbirdio/docs/blob/main/src/pages/manage/networks/use-cases/cloud-to-on-premise.mdx Installs NetBird on a virtual machine and brings up the service using a provided setup key. Ensure you replace YOUR_CLOUD_SETUP_KEY with your actual setup key. ```bash curl -fsSL https://pkgs.netbird.io/install.sh | sh sudo netbird up --setup-key YOUR_CLOUD_SETUP_KEY ``` -------------------------------- ### Automated Deployment with Setup Key (MSI) Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/windows.mdx Combine silent MSI installation with the 'netbird up --setup-key' command for fully automated peer registration without user interaction. ```bash msiexec /i netbird_installer__windows_amd64.msi /quiet netbird up --setup-key ``` -------------------------------- ### Connect with Setup Key Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/macos.mdx Activate a server peer using a setup key. Replace with your actual setup key. This command can also include a custom management URL. ```bash netbird up --setup-key ``` ```bash netbird up --setup-key --management-url http://localhost:33073 ``` -------------------------------- ### Delete Setup Key using Python Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx This Python script utilizes the `requests` library to delete a setup key via the NetBird API. Make sure to install the library (`pip install requests`). ```python import requests import json url = "https://api.netbird.io/api/setup-keys/{keyId}" headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) print(response.text) ``` -------------------------------- ### List All Setup Keys Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx Use this endpoint to retrieve a list of all setup keys associated with your account. Ensure you include your API token in the Authorization header. ```bash curl -X GET https://api.netbird.io/api/setup-keys \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` ```javascript const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, url: '/api/setup-keys', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' } }; axios(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); }); ``` ```python import requests import json url = "https://api.netbird.io/api/setup-keys" headers = { 'Accept': 'application/json', 'Authorization': 'Token ' } response = requests.request("GET", url, headers=headers) print(response.text) ``` ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://api.netbird.io/api/setup-keys" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } req.Header.Add("Accept", "application/json") req.Header.Add("Authorization", "Token ") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` ```ruby require "uri" require "json" require "net/http" url = URI("https://api.netbird.io/api/setup-keys") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "Token " response = https.request(request) puts response.read_body ``` ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/setup-keys") .method("GET") .addHeader("Accept", "application/json") .addHeader("Authorization: Token ") .build(); Response response = client.newCall(request).execute(); ``` ```php 'https://api.netbird.io/api/setup-keys', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Accept: application/json', 'Authorization: Token ' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Delete Setup Key using JavaScript (Axios) Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx This JavaScript code snippet uses the Axios library to send a DELETE request to the NetBird API for deleting a setup key. Ensure you have Axios installed (`npm install axios`). ```javascript const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, url: '/api/setup-keys/{keyId}', headers: { 'Authorization': 'Token ' } }; axios(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); }); ``` -------------------------------- ### Connect NetBird Client Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/proxmox-ve.mdx Connect the installed NetBird client to your NetBird account using a generated setup key. Replace with your actual setup key. ```bash netbird up --setup-key ``` -------------------------------- ### Create first owner and PAT using setup API Source: https://github.com/netbirdio/docs/blob/main/src/pages/selfhosted/automated-setup.mdx Send a POST request to the /api/setup endpoint with create_pat set to true to create the initial owner user and generate a PAT. Optionally specify pat_expire_in for the token's lifetime in days. ```bash NETBIRD_URL="https://netbird.example.com" curl -fsS -X POST "${NETBIRD_URL}/api/setup" \ -H "Content-Type: application/json" \ -d '{ "email": "admin@example.com", "name": "Admin User", "password": "use-a-long-random-password", "create_pat": true, "pat_expire_in": 7 }' ``` -------------------------------- ### Java Instance Setup Request Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/instance.mdx Use this snippet to make a POST request to the /api/setup endpoint in Java. Ensure you have the OkHttp library included in your project. The request body includes user credentials and options for PAT creation. ```java MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, '{ "email": "admin@example.com", "password": "securepassword123", "name": "Admin User", "create_pat": true, "pat_expire_in": 30 }'); Request request = new Request.Builder() .url("https://api.netbird.io/api/setup") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") .addHeader("Authorization: Token ") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Create Setup Key using Ruby Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx This Ruby script illustrates how to create a setup key using Net::HTTP. It sends a POST request with the required JSON payload and headers. Ensure your API token is correctly set in the 'Authorization' header. ```ruby require "uri" require "json" require "net/http" url = URI("https://api.netbird.io/api/setup-keys") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = "application/json" request["Accept"] = "application/json" request["Authorization"] = "Token " request.body = JSON.dump({ "name": "Default key", "type": "reusable", "expires_in": 86400, "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ], "usage_limit": 0, "ephemeral": true, "allow_extra_dns_labels": true }) response = https.request(request) puts response.read_body ``` -------------------------------- ### Example Running Pod Status Source: https://github.com/netbirdio/docs/blob/main/src/pages/manage/integrations/kubernetes/index.mdx An example output showing the NetBird operator pod in a 'Running' state, indicating a successful installation. ```shell NAME READY STATUS RESTARTS AGE netbird-operator-b74984867-d68c8 1/1 Running 0 98s ``` -------------------------------- ### Automated Instance Setup via API Source: https://github.com/netbirdio/docs/blob/main/src/pages/selfhosted/identity-providers/local.mdx Checks if instance setup is required and completes the initialization process for automated deployments. ```bash # Check if setup is required curl "https://netbird.example.com/api/instance" # Response when setup is needed: { "setup_required": true } # Complete setup curl -X POST "https://netbird.example.com/api/setup" \ -H "Content-Type: application/json" \ -d '{ "email": "admin@example.com", "password": "securepassword123", "name": "Admin User" }' # Response: { "user_id": "user-abc123", "account_id": "account-xyz789" } ``` -------------------------------- ### Install NetBird and Enroll Routing Peer Source: https://github.com/netbirdio/docs/blob/main/src/pages/manage/networks/use-cases/site-to-vpn.mdx Installs NetBird on the routing peer and enrolls it into the NetBird network using a provided setup key. ```bash curl -fsSL https://pkgs.netbird.io/install.sh | sh sudo netbird up --setup-key YOUR_SITE_SETUP_KEY ``` -------------------------------- ### Automated Deployment with Setup Key (EXE) Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/windows.mdx Combine silent EXE installation with the 'netbird up --setup-key' command for fully automated peer registration without user interaction. ```bash netbird_installer__windows_amd64.exe /S netbird up --setup-key ``` -------------------------------- ### Create Setup Key Request (PHP) Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx Shows how to create a reusable setup key with specified parameters using PHP and cURL. The key can be configured with an expiration time, auto-assigned groups, and usage limits. ```php 'https://api.netbird.io/api/setup-keys', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => '{ "name": "Default key", "type": "reusable", "expires_in": 86400, "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ], "usage_limit": 0, "ephemeral": true, "allow_extra_dns_labels": true }', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'Accept: application/json', 'Authorization: Token ' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Cleanly Remove Existing NetBird Installation Source: https://github.com/netbirdio/docs/blob/main/src/pages/selfhosted/troubleshooting/installation.mdx Use this command to completely remove a previous NetBird installation, including all associated data and configuration files. This is necessary before re-running the installation script to start fresh. ```bash docker compose down --volumes rm -f docker-compose.yml dashboard.env config.yaml proxy.env \ traefik-dynamic.yaml nginx-netbird.conf caddyfile-netbird.txt \ npm-advanced-config.txt ``` -------------------------------- ### Install NetBird on Raspberry Pi Source: https://github.com/netbirdio/docs/blob/main/src/pages/get-started/install/raspberrypi.mdx Install NetBird using a one-line script that automatically detects the system architecture, adds the NetBird repository, installs the latest stable version, and configures the service to start on boot. ```bash curl -fsSL https://pkgs.netbird.io/install.sh | sh ``` -------------------------------- ### Setup Instance Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/instance.mdx Creates the initial admin user for the instance. This endpoint does not require authentication but only works when setup is required (no accounts exist and embedded IDP is enabled). If `create_pat` is true and the server has setup-time PAT issuance enabled, it also provisions a NetBird account and returns the plain text Personal Access Token. ```APIDOC ## POST /api/setup ### Description Creates the initial admin user for the instance. This endpoint does not require authentication but only works when setup is required (no accounts exist and embedded IDP is enabled). When the management server is started with `NB_SETUP_PAT_ENABLED=true` and the request includes `create_pat: true`, the endpoint also provisions the NetBird account for the new owner user and returns the plain text Personal Access Token in `personal_access_token`. The optional `pat_expire_in` value applies only when `create_pat` is true and defaults to 1 day when omitted. If a post-user step fails, setup-created resources are rolled back when safe; if account cleanup fails, the owner user is left in place to avoid leaving an account without its admin user. ### Method POST ### Endpoint /api/setup ### Parameters #### Request Body - **email** (string) - Required - Email address for the admin user - **password** (string) - Required - Password for the admin user (minimum 8 characters) - **name** (string) - Required - Display name for the admin user (defaults to email if not provided) - **create_pat** (boolean) - Optional - If true and the server has setup-time PAT issuance enabled (`NB_SETUP_PAT_ENABLED=true`), create a Personal Access Token for the new owner user and return it in the response. Ignored when the server feature is disabled. - **pat_expire_in** (integer) - Optional - Expiration of the Personal Access Token in days. Applies only when `create_pat` is true and the server feature is enabled. Defaults to 1 day when omitted. (min: 1, max: 365) ### Request Example ```json { "email": "admin@example.com", "password": "securepassword123", "name": "Admin User", "create_pat": true, "pat_expire_in": 30 } ``` ### Response #### Success Response (200) - **personal_access_token** (string) - The generated Personal Access Token (only present if `create_pat` was true and enabled). - **user_id** (string) - The ID of the created user. #### Response Example ```json { "personal_access_token": "", "user_id": "" } ``` ``` -------------------------------- ### Start Relay with Custom Metrics Port Source: https://github.com/netbirdio/docs/blob/main/src/pages/selfhosted/observability/relay.mdx Starts the NetBird Relay service and configures it to expose metrics on a specific port. This is useful for custom monitoring setups. ```bash netbird-relay --metrics-port 9090 ``` -------------------------------- ### Split-Horizon DNS Example Configuration Source: https://github.com/netbirdio/docs/blob/main/src/pages/manage/dns/internal-dns-servers.mdx Example setup for split-horizon DNS using two nameservers: one primary for internet and one match domain for internal resolution. ```text Primary (internet): Cloudflare (1.1.1.1, 1.0.0.1). Assign to "All Peers". Leave match domains empty. Match domain (internal): Custom DNS with internal DNS server IPs (e.g., 10.0.0.1, 10.0.0.2). Assign to "All Peers". Add match domain `company.internal`. Enable search domains. ``` -------------------------------- ### Create Setup Key using Java (OkHttpClient) Source: https://github.com/netbirdio/docs/blob/main/src/pages/ipa/resources/setup-keys.mdx This Java code snippet shows how to create a setup key using OkHttpClient. It defines the request body with the JSON payload and sets the necessary headers for the POST request to the Netbird API. ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, '{ "name": "Default key", "type": "reusable", "expires_in": 86400, "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ], "usage_limit": 0, "ephemeral": true, "allow_extra_dns_labels": true }'); ```