Authentication
FFmpeg API uses Basic Authentication for secure API access. Every request requires an Authorization
header with your unique API key. This guide shows you how to get your key, use it properly, and avoid common pitfalls.
Get Your API Key
Your header value is a pre-formatted string that looks like this:
Basic dGVzdF91c2VyX2tleV9hYmNkZWZnaGlqa2xtbm9w
Ready to copy? Your dashboard displays the complete Authorization
header value. Just copy and paste it into your code.
How to Use Your API Key
const headers = {
'Authorization': 'Basic YOUR_API_KEY_HERE',
'Content-Type': 'application/json'
}
const response = await fetch('https://api.ffmpeg-api.com/file', {
method: 'POST',
headers,
body: JSON.stringify({ file_name: 'video.mp4' })
})
Security Best Practices
â Donât Do This
- ⢠Expose API keys in client-side JavaScript
- ⢠Commit API keys to version control
- ⢠Share API keys in public forums or docs
- ⢠Use API keys in URLs or GET parameters
- ⢠Store keys in plain text files
â Best Practices
- ⢠Use environment variables
- ⢠Make API calls from your backend/server
- ⢠Regularly rotate your API keys
- ⢠Monitor usage in your dashboard
- ⢠Use HTTPS for all API requests
Critical: Your API key grants full access to your account. Treat it like a password and never expose it in client-side code.
Environment Variables
Store your API key securely using environment variables:
.env file:
FFMPEG_API_KEY=Basic dGVzdF91c2VyX2tleV9hYmNkZWZnaGlqa2xtbm9w
In your code:
const API_KEY = process.env.FFMPEG_API_KEY
Troubleshooting Authentication
â Error 401: âInvalid API keyâ
This means your API key is incorrect or malformed. Check:
- Format: Must start with âBasic â (note the space)
- Copying: Copy the entire string from your dashboard
- Whitespace: No extra spaces or line breaks
- Header name: Use âAuthorizationâ, not âAuthâ or âBearerâ
â Error 403: âQuota exceededâ
Youâve hit your usage limits. Solutions:
- Check your current usage in the Dashboard
- Wait for your quota to reset (monthly cycle)
- Upgrade your plan for higher limits
- Optimize your usage patterns
â Error 400: âMissing Authorization headerâ
Your request is missing the auth header entirely. Ensure:
- Header is named exactly âAuthorizationâ
- Header is included in your request headers object
- Not accidentally putting it in the request body
- Using the correct HTTP client method for headers
đ âMy API key stopped workingâ
If a previously working key stops working:
- Check if you regenerated your key in the dashboard
- Verify your account status hasnât changed
- Look for any recent billing issues
- Contact support if the issue persists
Testing Your Authentication
Hereâs a quick test to verify your API key works:
const response = await fetch('https://api.ffmpeg-api.com/directory', {
method: 'GET',
headers: {
'Authorization': 'Basic YOUR_API_KEY_HERE'
}
})
const data = await response.json()
console.log(data)
Success response:
{
"ok": true,
"directories": []
}
Failed auth response:
{
"ok": false,
"error": "Invalid API key"
}
Ready to make your first request? Head to the Quick Start guide to see authentication in action, or jump into Examples for language-specific implementations.