Klarity

Manage API Keys

API Keys list

  1. In the top-left corner, select your main menu.
  2. Select Users and Permissions. Users and permissions
  3. Select tab Global API keys.

Accessing API

To make use of API for Klarity’s App, you require authentication in the form of your Secret Key. To create an API Secret Key please follow the below instruction.

Create API Key

Prerequisite:

  • You need to be a Klarity user with Full access permissions, to be able to create an API Secret Key both from the API Key list or programmatically.

On the API Keys list view:

  1. Select + Add New Api Key.
  2. Enter required Description and optional Expiration Date.
  3. Select required Role.
  4. Select + Add New Api Key to confirm creating a new key.

Save the API Secret Key, somewhere safe. After you leave the page, you no longer have access to the key.

Edit API Key

On the API Keys list view:

  1. Select an icon with three dots on the row with the API key you wish to edit.
  2. Select Edit API Key
  3. Change selected field: Description, Expiration Date or Role.
  4. Select + Edit API Keyto saved the changes.

Recreate API Key

On the API Keys list view:

  1. Select an icon with three dots on the row with the API key you wish to recreate.
  2. Select Recreate API Secret Key
  3. Confirm the recreation by selecting Recreate API Secret Key.

Save the API Secret Key, somewhere safe. After you leave the page, you no longer have access to the key.

Delete API Key

On the API Keys list view:

  1. Select an icon with three dots on the row with the API key you wish to delete.
  2. Select Delete API Key
  3. Confirm the recreation by selecting Delete API Key.

title: API requests from external source

Calling API from external source

To call the API from your local machine or any other external source you need two pieces of information. Endpoint and the API key.

API Endpoint:

https://api.cnop-int.nordcloudapp.com/graphql

API key is generating two values. ID and secret. Both values have to be combined with / sign in the middle to succesfully authenticate to the API.

API_KEY_ID/API_KEY_SECRET

Examples

Bash

curl -X POST https://api.cnop-int.nordcloudapp.com/graphql \
-H 'x-api-key: API_KEY_ID/API_KEY_SECRET' \
-H 'content-type: application/json' \
-d '{"query": "query exampleQuery {accountsV2(limit: 100, page: 0) {accounts {name}}}"}'

Python

import json
from http.client import HTTPException
import requests
KLARITY_URL = 'https://api.cnop-int.nordcloudapp.com/graphql'
KLARITY_KEY = 'API_KEY_ID/API_KEY_SECRET'
def graphql_query(query: str, variables: dict | None) -> dict:
"""
Send a GraphQL query to the given URL.
"""
response = requests.post(KLARITY_URL, json={
'query': query,
'variables': variables
}, headers={
'x-api-key': KLARITY_KEY
})
if response.status_code != 200:
raise HTTPException(response.text)
else:
return json.loads(response.text)
if __name__ == '__main__':
query = '''
query exampleQuery {
accountsV2(limit: 100, page: 0) {
accounts {
name
}
}
}
'''
graphql_query(query)
Edit this page on GitHub