The Northflank API allows you to create and modify services and projects without using the user interface.
The API is available at https://api.northflank.com.
Requests and responses are both in JSON. Requests should include the header
Access to most endpoints is restricted and authenticated via a bearer token. Users can generate a personal API token in their account settings. Users can generate a team API token in that team's settings, provided an API token template has been created.
The API token must then be included in the Authorization header for the request:
Authorization: Bearer [YOUR AUTH TOKEN]
The Northflank CLI client allows you interact with Northflank via the command line. The CLI client can be installed via either NPM or yarn:
npm i -g @northflank/cli, or
yarn global add @northflank/cli
Once installed, authenticate yourself using the
northflank login command. You will need to create an API token at app.northflank.com.
The CLI client is fully interactive, meaning that it will ask for any parameters needed along the way. However, you always have the option to pass in any required parameters in your commands. For example, after entering the command
northflank get service details
you will be prompted to enter a project ID and a service ID. You can achieve the same result by using the command
northflank get service details --project <PROJECT_ID> --service <SERVICE_ID>
When creating resources on Northflank, you can do so interactively, or you can supply a resource definition. This can be done using the
-i option followed by a JSON/YAML string, or by using the
-f option followed by the path to a JSON/YAML file containing the definition.
The resource definitions are equivalent to the API request bodies you will find in this documentation.
Contexts allow you to separate different Northflank accounts and preferences when using the CLI client.
For example, you may have a context for your personal Northflank account, and a different context for a team account.
Contexts are created with the
northflank login command. You will be guided through the process of naming the context and supplying a token, or you can pass these values in as arguments. See
northflank login --help for the full list of options. Once logged in, the active context will be switched automatically.
Once created, contexts can be viewed with
northflank context list and switched to with
northflank context use <CONTEXT_NAME>.
To set a default project or service within a context, you can use the command
northflank context use project|service <PROJECT_ID|SERVICE_ID>
and you will no longer need to supply a project/service in your commands to use the defaults.
You can get help at any time by using the
--help flag. This includes getting help with specific commands, for example
northflank create project --help
will return helpful information about creating a project.
Extra CLI commands
There are a few CLI-specific commands that do not have an API equivalent, and therefore do not appear alongside API endpoints in this documentation.
These commands are:
- Port-forwarding for Northflank services and addons. For example
northflank forward serviceallows you to select a service and port forward it so it is available from your localhost.