Generate Config Files using API and NMCTL
Power users may wish to bulk-create and manage WireGuard config files for their network. For this, we recommend using the API or NMCTL.
Generating Clients via API
Static client configurations can be generated using the createExtClient endpoint of the netmaker API. Authorization to the API is required to access relevant endpoints.
Authenticate and get a JWT
Generate and grab a JWT token from the authenticate API endpoint using the following curl command (https://openapi.netmaker.io/#tag/authenticate/operation/authenticateUser):
curl -X POST --location 'https://api.netmaker.example.com/api/users/adm/authenticate' \
--header 'Content-Type: application/json' \
--data '{ "username":"<netmaker username>", "password":"<netmaker password>" }'Copy the JWT token printed to the terminal to use for subsequent API requests.
Identify the Remote Access Gateway (Host Network ID)
The createExtClient endpoint requires the netmaker network name and the Remote Access Gateway’s Host Network ID (also referred to as Device Network ID). To get the Host Network ID, navigate to the netmaker network and click the host name to reveal the id.
Create a static client via API
Use the extclients endpoint to generate a static client configuration. The endpoint documentation: https://openapi.netmaker.io/#tag/ext_client/operation/createExtClient
Replace , , and in the command below:
curl -X POST -L "https://api.netmaker.example.com/api/extclients/<network name>/<host network id>" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AuthToken>" \
--data '{"clientid":"SiteC"}'On successful execution, the POST request returns no body or error. To list all static client configurations for a network:
curl -X GET -L "https://api.netmaker.example.com/api/extclients/<network name>" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AuthToken>"To retrieve the WireGuard config for a specific static client:
curl -X GET -L "https://api.netmaker.example.com/api/extclients/<network name>/<static client id>/file" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AuthToken>"The extclients API endpoint can be used to generate, delete, and remotely manage static client configurations in bulk and can be integrated into automation systems.
Create Clients via NMCTL
NMCTL is a CLI utility for interacting with the netmaker server. It authenticates and makes API calls to the netmaker server via a CLI.
Setup NMCTL
Download the latest NMCTL tool from: https://github.com/gravitl/netmaker/releases/latest
Make sure to download the build that matches your CPU and OS architecture.
Ensure the nmctl binary is executable (set executable permissions) after downloading.
Authenticate and add the netmaker server to the CLI context.
Run the following to set a context (replace placeholders):
nmctl context set <context name> --endpoint=https://api.netmaker.example.com --username=<username> --password=<password>Then use the context:
nmctl context use <context name>The context name should be unique to identify and manage multiple netmaker servers via nmctl.
Create Client
Identify two pieces of information:
The netmaker network name where the gateway resides and where static clients will be created.
The Host Network ID of the Remote Access Gateway (Device Network ID). To obtain it, navigate to the netmaker network and click the host name to reveal the id.

Generate a static client configuration:
nmctl ext_client create <network name> <host network id> --id <static client id>The static client id must be unique to identify and manage different client configurations.
If the command responds with "Success", the static client was created successfully.
Get Client
Retrieve the static client configuration created above:
nmctl ext_client config <network name> <static client id>This will return the WireGuard configuration file for the static client, usable for setting up the WireGuard plugin on the device.
Other Options with NMCTL
NMCTL provides options to delete and update static clients. To view available ext_client commands:
Last updated
Was this helpful?