Want to automate the management of your Infomaniak services? Create accounts programmatically, manage your domains, or interact with kDrive from your applications? The Infomaniak APIs make it possible. This technical guide shows you how to get started.
Overview of Infomaniak APIs
Infomaniak exposes several APIs to interact with its services:
- Manager API – Product, user, and billing management
- kDrive API – File management, sharing, metadata
- Mail API – Mailbox, alias, and filter management
- DNS API – DNS record management
The APIs follow REST standards and return JSON.
Authentication
Obtaining an API Token
- Log in to Infomaniak Manager
- Go to your profile → "API" or "Tokens"
- Create a new token
- Define the required permissions (scopes)
- Copy the generated token (it will not be displayed again)
Using the Token
Include the token in your request headers:
``` Authorization: Bearer YOUR_TOKEN_HERE ```Token Security
- Never commit a token to a Git repository
- Use environment variables
- Create tokens with the minimum required permissions
- Revoke unused tokens
Usage Examples
List Your Products (Manager API)
```bash curl -X GET "https://api.infomaniak.com/1/products" \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" ```Response:
```json { "result": "success", "data": [ { "id": 12345, "name": "Mail Hosting", "status": "active" }, { "id": 12346, "name": "kSuite", "status": "active" } ] } ```Upload a File to kDrive (kDrive API)
```bash curl -X POST "https://api.infomaniak.com/2/drive/{drive_id}/files/upload" \ -H "Authorization: Bearer YOUR_TOKEN" \ -F "file=@/path/to/file.pdf" \ -F "directory_id=1" ```Add a DNS Record
```bash curl -X POST "https://api.infomaniak.com/1/domain/{domain_id}/dns/record" \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "type": "A", "source": "www", "target": "123.45.67.89", "ttl": 3600 }' ```SDKs and Libraries
You can call the API directly with any language capable of making HTTP requests. Here are some examples:
Python
```python import requests API_TOKEN = "your_token" BASE_URL = "https://api.infomaniak.com" headers = { "Authorization": f"Bearer {API_TOKEN}", "Content-Type": "application/json" } # List products response = requests.get(f"{BASE_URL}/1/products", headers=headers) products = response.json() for product in products["data"]: print(f"{product['name']}: {product['status']}") ```JavaScript (Node.js)
```javascript const axios = require('axios'); const API_TOKEN = process.env.INFOMANIAK_TOKEN; const BASE_URL = 'https://api.infomaniak.com'; const client = axios.create({ baseURL: BASE_URL, headers: { 'Authorization': `Bearer ${API_TOKEN}`, 'Content-Type': 'application/json' } }); // List products async function listProducts() { const response = await client.get('/1/products'); return response.data.data; } listProducts().then(products => { products.forEach(p => console.log(`${p.name}: ${p.status}`)); }); ```PHP
```php Automation Use CasesUser Provisioning
Automate account creation when new team members join:
- HR registers the new hire in the HRIS
- A script detects the new entry
- Via the API, it creates the email account and kDrive access
- A welcome email is sent automatically
Automated Backup
Regularly download your kDrive data to another location:
- Scheduled script (cron) every night
- Lists recently modified files via the API
- Downloads the relevant files
- Stores them on a local NAS or Swiss Backup
Dynamic DNS Management
Update your DNS records automatically:
- Your public IP changes (connection without a static IP)
- A script detects the change
- Via the DNS API, it updates the A record
- Your domain always points to the correct IP
Reporting
Generate automatic reports on service usage:
- Weekly script
- Collects statistics via the various APIs
- Generates a report (PDF, email)
- Sends it to managers
Limits and Best Practices
Rate Limiting
APIs have request limits to prevent abuse:
- Respect the documented limits
- Implement delays between requests if necessary
- Handle 429 (Too Many Requests) errors
Error Handling
APIs return explicit error codes:
200– Success400– Malformed request401– Invalid or expired token403– Insufficient permissions404– Resource not found429– Too many requests500– Server error
Handle these errors in your code for robust automations.
Idempotency
Design your scripts to be idempotent: running the same script twice should not create duplicates or errors.
Documentation
The official Infomaniak API documentation is available on the Infomaniak developer site. You will find:
- Complete list of endpoints
- Accepted parameters
- Request and response examples
- Version changelog
Need Help?
For complex integrations or custom development, InfoSwitch can assist you. We know the Infomaniak APIs well and can develop the automations you need.
Conclusion
Infomaniak APIs open up many automation possibilities. Whether for user provisioning, file management, or DNS administration, you can integrate Infomaniak into your automated workflows.
Start with simple scripts, test thoroughly, and expand gradually. The development investment is quickly recouped through daily time savings.
Ready to migrate to Infomaniak?
Contact us for a free 15-minute audit. We will analyze your situation and provide you with a personalized quote.
Request a free audit