Creating an API key
An API key lets your own scripts and tools read and change the data of one organization in Moleant Discover.
Before you start
You will need:
- A user that can sign in to Moleant Discover.
- Access to Settings for the organization the key should belong to.
Step 1 – Open API Keys
Sign in to Moleant Discover, open Settings and choose the API Keys tab. The tab lists the keys that already exist.
Step 2 – Add the key
- Select Add API Key.
- Choose the organization the key should give access to.
- Give the key a descriptive name, for example the tool or script that will use it.
- Save. The new key appears in the list.
A descriptive name makes it easy to see later which keys are still in use and which can be removed.
Keep your key secret. An API key gives access to its organization's data, including changing and deleting assets. Store it like a password, never put it in code that others can read, and remove keys you no longer use.
Step 3 – Use the key
Send the key in the X-Api-Key header on every request. For example:
curl -H "X-Api-Key: YOUR_API_KEY" \
"https://api.moleant.com/v2/organizations/YOUR_ORG_ID/systems"
Replace YOUR_API_KEY with your key and YOUR_ORG_ID with your Organisation ID, which
you can find in Settings, in the Permissions tab.
If the key is missing or wrong, the API answers with Key token invalid or empty.
See the API documentation for every endpoint and what it returns.
Removing a key
Open Settings and the API Keys tab again and remove the key from the list. Anything that still uses it stops working at once, so update your tools first if they are still in use.
