Authentication
Secure your API requests with authentication. All mnml API endpoints require authentication using an API key.
Security First
API keys provide secure access to mnml API services. Each key is unique and should be kept confidential.
Getting Your API Key
To start using the mnml API, you'll need to create an API key from your dashboard:
- 1
Sign in to your account
Go to mnmlai.dev/login and sign in with your credentials
- 2
Navigate to API Keys
Click on API Keys in your dashboard
- 3
Create a new API key
Click "Create New API Key" and give it a descriptive name (e.g., "Production App" or "Development")
- 4
Copy and secure your key
Copy the generated API key immediately. You won't be able to see it again!
Important: Store your API key securely. If compromised, revoke it immediately and create a new one.
Using Your API Key
Include your API key in all requests to the mnml API using the Authorization header:
Authentication Methods
HTTP Header (Recommended)
The preferred method is to include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
cURL Example
curl -X POST https://api.mnmlai.dev/v1/exterior \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F "image=@/path/to/building.jpg" \
-F "prompt=Modern exterior design with glass facade"
JavaScript/Node.js Example
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('image', fs.createReadStream('/path/to/building.jpg'));
form.append('prompt', 'Modern exterior design with glass facade');
const response = await fetch('https://api.mnmlai.dev/v1/exterior', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY',
...form.getHeaders()
},
body: form
});
const data = await response.json();
Python Example
import requests
files = {
'image': open('/path/to/building.jpg', 'rb')
}
data = {
'prompt': 'Modern exterior design with glass facade'
}
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
}
response = requests.post(
'https://api.mnmlai.dev/v1/exterior',
headers=headers,
files=files,
data=data
)
Security Best Practices
Use Environment Variables
Never hardcode API keys in your source code. Use environment variables instead:
.env file:
MNML_API_KEY=your_api_key_here
Usage in Node.js:
const apiKey = process.env.MNML_API_KEY;
Regular Key Rotation
Rotate your API keys periodically to maintain security:
- Rotate keys every 90 days for production environments
- Use different keys for development, staging, and production
- Revoke old keys after successful rotation
Additional Security Measures
- Never expose API keys in client-side code
- Add API keys to .gitignore to prevent accidental commits
- Use server-side proxy for client applications
- Monitor API key usage in your dashboard
Troubleshooting
401 Unauthorized Error
This error indicates an authentication problem. Check that:
- • Your API key is correct and hasn't been revoked
- • The Authorization header is properly formatted
- • You're using "Bearer" before your API key
- • There are no extra spaces or characters in your key
403 Forbidden Error
This error means your API key doesn't have permission for the requested resource. Ensure:
- • Your account has the necessary permissions
- • You're using the correct API endpoint
- • Your subscription plan includes access to the requested feature