Users - API Key Management

Users can now generate an API key that can be used instead of a username + password combination.

You can either create a new API key, delete an existing API key, retrieve details like last_auth time, key_id of a single API key or list all API keys

Create a new API Token

POST /1/users/{user_id}/apiKeys
Host: https://api.cogniac.io

Example to create a new API token

curl -X POST https://api.cogniac.io/1/users/di71rG94/apiKeys \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json" \
-d '{
  "description":"New Token for Image downloads",
}'
{
  "user_id": "ufL2GnI3VDgV",
  "description": "New API token for image downloads",
  "created_at": 1550011606, 
  "key_id":"LZIDR",
  "api_key":"LZIDR:H00FQKIJZHEIAB5TJGJXL94UIDW4",
  "email": "[email protected]"
}

πŸ“˜

Note: API token

API tokens can only be accessed once, at the time of creation. Please save the API token at the time of creation. You cannot retrieve the token later using the GET call

Delete API token

DELETE /1/users/{user_id}/apiKeys/{api_key_id}
Host: https://api.cogniac.io

Example to delete an API token

curl -X DELETE https://api.cogniac.io/1/users/di71rG94/apiKeys/g56gdercb \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz"
HTTP 204 Code (with no body)

Retrieve individual API token

GET /1/users/{user_id}/apiKeys/{api_key_id}
Host: https://api.cogniac.io
curl -X GET https://api.cogniac.io/1/users/di71rG94/apiKeys/g56gdercb \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz"
{
  "user_id": "ufL2GnI3VDgV",
  "description": "New API token for image downloads",
  "created_at": 1550011606, 
  "key_id":"LZIDR",
  "api_key":None,
  "last_auth" : None,
  "email": "[email protected]"
}

List all API tokens

GET /1/users/{user_id}/apiKeys
Host: https://api.cogniac.io
curl -X GET https://api.cogniac.io/1/users/di71rG94/apiKeys \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz"
{
    "data": [
      {
  "user_id": "ufL2GnI3VDgV",
  "description": "New API token for image downloads",
  "created_at": 1550011606, 
  "key_id":"LZIDR",
  "api_key":None,
  "last_auth" : None,
  "email": "[email protected]"
      }]
}