API Overview

Each Pro community has access to the Unit Commander API, and all of the associated functionality. Like with the user permissions, API permisison handling is configured via the Roles & Abilities functionality already provided.

The exact API specification can be found by selecting the navigation option at the top of this page.

Creating your first token

Start by opening your Pro Panel, and navigating to the API Configuration page. This will be the primary page where you control access to your community's data.

Unit Commander provides access to the API through what we call Bot Tokens, and we'll circle back to why this is relevant shortly. Click the Create Bot button.

You should now have a form, with a field for naming the token, and another for assigning a role. We recommend giving the bot a unique name, so it's distinguishable from other bot's. In terms of adding a role, we recommend creating a dedicated role with fine tuned permissions, as once you have created a bot token, you cannot change it.

Fill out the form, then click the Create Token button to save. Do not close the panel, as your token will be displayed there. Make sure to note it down, as we will not show the token again via the UI.

Using your token

In order to progress, it is assumed you have a working knowledge of HTTP requests and basic HTTP Headers.

All requests to the Unit Commander API must use the following Base URL format: https://api.unitcommander.co.uk/community/{{Community ID}}. You can find your Community's ID by finding it on the main Unit Commander website and copying the ID from the URL.

In order to authenticate, you must provide your newly created token as an authentication header, which is done in the following format: Authorization: Bot {{TOKEN HERE, OMIT CURLY BRACES}}. Below is an example of an API request to fetch ranks (using cURL):

curl --location --request GET 'https://api.unitcommander.co.uk/community/{{Community ID}}/ranks' \
--header 'Authorization: Bot {{Token}}' \
--header 'Content-Type: application/json'

Was this page helpful?