Skip to main content

Authentication

The Alentis API uses API key authentication for secure access to your organisation's data.

Generating an API Key

To generate an API key, you need to be logged into the Alentis platform:

  1. Navigate to Company Profile

    • Log in to your Alentis account
    • Go to the Company Profile section
  2. Access API Keys

    • In the Company Profile, find the "API Keys" section
    • Click on "Manage API Keys" or navigate to the API Keys page
  3. Create a New API Key

    • Click the "Create API Key" button
    • Provide a descriptive name for your API key (e.g., "Production API", "Development Key")
    • Click "Create"
  4. Save Your API Key

    • ⚠️ Important: The API key will be displayed only once
    • Copy and store it securely immediately
    • You won't be able to view the full key again after closing the dialog

Using Your API Key

Once you have your API key, include it in all API requests using the x-api-key header:

curl -H "x-api-key: your-api-key-here" \
https://app.alentisenergy.com/api/sites

Example with cURL

# Get all sites
curl -H "x-api-key: sk_live_your_key_here" \
https://app.alentisenergy.com/api/sites

# Get a specific site
curl -H "x-api-key: sk_live_your_key_here" \
https://app.alentisenergy.com/api/sites?siteId=123e4567-e89b-12d3-a456-426614174000

# Create a new site
curl -X POST \
-H "x-api-key: sk_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{"siteName": "Solar Farm Alpha", "capacity": 1000, "unit": "kW"}' \
https://app.alentisenergy.com/api/sites

Example with JavaScript (fetch)

const apiKey = "sk_live_your_key_here";
const response = await fetch("https://app.alentisenergy.com/api/sites", {
headers: {
"x-api-key": apiKey,
"Content-Type": "application/json",
},
});

const sites = await response.json();

Example with Python (requests)

import requests

api_key = 'sk_live_your_key_here'
headers = {
'x-api-key': apiKey,
'Content-Type': 'application/json'
}

response = requests.get(
'https://app.alentisenergy.com/api/sites',
headers=headers
)

sites = response.json()

API Key Format

API keys follow this format:

sk_live_<base64-encoded-key>

Example: sk_live_AbCdEf123456...

Security Best Practices

  1. Keep your API keys secret - Never commit API keys to version control
  2. Use environment variables - Store API keys in environment variables, not in code
  3. Rotate keys regularly - Delete old keys and create new ones periodically
  4. Use descriptive names - Name your keys based on their purpose (e.g., "Production", "Development", "CI/CD")
  5. Monitor key usage - Regularly review which keys are active and delete unused ones

Managing API Keys

  • View all keys: See a list of all your API keys with their prefixes, creation dates, and last used timestamps
  • Delete keys: Remove API keys that are no longer needed
  • Note: You cannot view the full key value after creation - only the prefix is shown

Troubleshooting

Invalid API Key Error

If you receive a 401 Unauthorized error:

  • Verify the API key is correct (check for typos)
  • Ensure you're using the x-api-key header (not Authorization)
  • Check if the API key has expired
  • Verify the API key is active (not deleted)

Missing Organisation ID Error

If you receive an error about missing organisation ID:

  • Ensure your API key is associated with an active organisation
  • Contact support if the issue persists