Skip to main content

Automating Host Creation with the API

Creating new hosts on the Defined Networking admin panel is quick and easy, but if you are regularly creating ephemeral hosts that live for a short time before being torn down, you might want to consider using the Managed Nebula API to automate the process of creating and enrolling the hosts into your Managed Nebula network. This guide will explain how to generate and use a Defined Networking Managed Nebula API key.

Creating an API key

To create a new key, visit the API Keys page of the admin panel. Click the button to add a new key. Choose a descriptive name for the key which will help you remember the reason it was created, and select any necessary permission scopes the key will need. You will need to select at least hosts:create and hosts:enroll to be able to set up new hosts. After pressing the “Save” button, you will be shown the new token in a green banner. Be sure to store this key somewhere safe, because it will only be shown once.

The admin panel opened to the API Keys page with a new API key shown

Using the Defined Networking API

Reference the API documentation for properties you can set on the host, along with an example curl command. You will need a few pieces of information to create a new host:

  1. Your networkID can be found in the top left of the admin panel by hovering the network CIDR, which you can click on to copy the network ID.
Copy the network ID from the top left of the admin panelCopy the network ID from the top left of the admin panel
  1. To assign a role to the host you're creating, find the roleID in the roles list.

  2. The bearer token you will use in the Authorization header is the API key token you generated earlier.

Installing dnclient and using the enroll code

Reference the dnclient installation and enrollment guide shown when enrolling a host in the admin panel.