API Keys
Access your context files programmatically using our REST API. Build custom integrations, automate workflows, and connect ContextFile.ai to your tools.
Why Use the API?
The API allows you to interact with ContextFile.ai programmatically. This opens up possibilities like building custom AI integrations, automating context updates, or embedding context files in your own applications.
Creating API Keys
Step 1: Go to API Keys
Navigate to Settings → API Keys from the sidebar menu.
Step 2: Create New Key
Click "Create New Key" and give your key a descriptive name (e.g., "Production API Key" or "Development Key").
Step 3: Save Your Key
Important: Copy and save your API key immediately. For security, we only show the full key once. You won't be able to see it again.
API Endpoints
/v1/contextsList all your context files/v1/contexts/:idGet a specific context file/v1/contextsCreate a new context file/v1/contexts/:idUpdate a context file/v1/contexts/:idDelete a context fileExample Usage
Fetch your contexts using curl:
curl https://api.contextfile.ai/v1/contexts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"Using JavaScript/Node.js:
const response = await fetch(
'https://api.contextfile.ai/v1/contexts',
{
headers: {
'Authorization': `Bearer ${process.env.CONTEXTFILE_API_KEY}`,
'Content-Type': 'application/json'
}
}
);
const contexts = await response.json();Security Best Practices
Keep Keys Secret
Never expose API keys in client-side code, git repositories, or anywhere publicly accessible.
Use Environment Variables
Store API keys in environment variables, not in code. Use secrets managers for production deployments.
Rotate Keys Regularly
Periodically create new keys and revoke old ones to maintain security.
Monitor Usage
Review API key usage regularly to detect any unauthorized access or suspicious activity.
How AI Experts Use the API
- Never expose API keys in client-side code or public repositories
- Use environment variables to store API keys securely
- Create separate API keys for different applications
- Revoke unused keys to maintain security
- Use the API to build custom integrations with AI tools
- Monitor API usage to detect unauthorized access