API Usage Guide
This guide explains how to configure and use third-party APIs and integrations in Multi-Domain AutoBlogger. All API keys are configured through environment variables or the admin panel.
Required API Keys
1. Anthropic Claude API (Required)
Purpose: AI-powered content generation (blog posts, FAQs, CTAs)
Getting Your API Key
- Visit console.anthropic.com
- Sign up or log in to your account
- Navigate to API Keys section
- Click "Create Key"
- Copy the API key (starts with
sk-ant-api03-)
Configuring the API Key
- Open your
.env.localfile - Add or update:
ANTHROPIC_API_KEY=sk-ant-api03-your-key-here - Save the file
- Restart your development server
Usage & Costs
- Uses Claude Haiku model (fast and cost-effective)
- Token usage is tracked per generation
- Costs vary based on content length
- Check your Anthropic dashboard for usage and billing
Note: The API key is required for AI content generation. Without it, you can still create posts manually, but AI generation features will not work.
Optional API Integrations
2. GoHighLevel API (Optional)
Purpose: Email capture and CRM integration
Getting Your Credentials
- Log in to your GoHighLevel account
- Go to Settings > Private Integrations
- Click "New Private Integration"
- Give the integration a name
- Select the following scopes:
- View Contacts
- Edit Contacts
- View Locations
- Click "Create"
- Copy the API Key
- Note your Location ID (found in Location settings)
Configuring in Admin Panel
- Go to Admin > Plugins
- Find "GoHighLevel Marketing Provider"
- Click "Configure"
- Select a domain or configure default settings
- Enter:
- Location ID - Your GoHighLevel location ID
- API Key - Your private integration API key
- Click "Save Configuration"
Alternative: Domain-Level Configuration
- Go to Admin > Domains
- Click on a domain
- Go to the Marketing tab (if plugin is enabled)
- Enter Location ID and API Key
- Save the domain
Note: GoHighLevel integration enables email capture forms on blog posts. Contacts are automatically added to your GoHighLevel CRM when users submit the form.
3. Google Analytics 4 (Optional)
Purpose: Website analytics and tracking
Getting Your Measurement ID
- Visit analytics.google.com
- Sign in with your Google account
- Create a new GA4 property or select an existing one
- Go to Admin > Data Streams
- Click on your web stream
- Copy the Measurement ID (format:
G-XXXXXXXXXX)
Configuring in Admin Panel
- Go to Admin > Domains
- Click on a domain
- Go to the Analytics tab (if GA4 plugin is enabled)
- Enter your GA4 Property ID (Measurement ID)
- Save the domain
Alternative: Domain Settings
You can also configure GA4 directly in domain settings:
- Edit a domain (Admin > Domains > Click domain)
- In the Basic Settings tab, find GA4 Property ID
- Enter your Measurement ID
- Save the domain
Note: GA4 tracking code is automatically injected into all pages for the configured domain. Each domain can have its own GA4 property ID.
Environment Variables for APIs
Some API configurations are stored in environment variables. Here's a complete reference:
| Variable | Required | Purpose | Where to Get It |
|---|---|---|---|
ANTHROPIC_API_KEY |
Yes | Claude AI for content generation | console.anthropic.com |
DATABASE_URL |
Yes | PostgreSQL database connection | Your database provider (Neon, Vercel, etc.) |
NEXTAUTH_SECRET |
Yes | Session encryption | Generate with: openssl rand -base64 32 |
CRON_SECRET |
Yes | Cron job authentication | Generate with: openssl rand -base64 16 |
ADMIN_PASSWORD |
No | Default admin password | Your choice (defaults to "admin123") |
PLUGINS_JSON_URL |
No | Third-party plugins feed | URL to your plugins JSON feed |
Configuring API Keys in Production
Vercel Deployment
When deploying to Vercel:
- Go to your Vercel project dashboard
- Navigate to Settings > Environment Variables
- Add each environment variable:
- Variable name (e.g.,
ANTHROPIC_API_KEY) - Variable value (your actual key)
- Environment (Production, Preview, Development)
- Variable name (e.g.,
- Click "Save"
- Redeploy your application for changes to take effect
Other Hosting Providers
For other hosting providers:
- Check your provider's documentation for environment variable configuration
- Most providers have a settings/configuration section
- Ensure variables are set for the correct environment (production/staging)
- Restart your application after adding variables
API Usage Best Practices
Security
- Never commit API keys to Git - Always use
.env.local(which should be in.gitignore) - Use different keys for development and production - This prevents accidental usage in wrong environments
- Rotate keys regularly - Especially if you suspect a key has been compromised
- Use environment-specific configuration - Don't use production keys in development
Cost Management
- Monitor API usage - Check your Anthropic dashboard regularly
- Set usage limits - Configure spending limits in your API provider dashboard
- Review token usage - Token usage is tracked per post in the admin panel
- Optimize prompts - Shorter, more focused prompts use fewer tokens
Error Handling
- Check API status - If generation fails, check if the API is experiencing issues
- Verify key validity - Ensure your API key hasn't expired or been revoked
- Check quotas - Some APIs have rate limits or usage quotas
- Review error messages - Error messages in the admin panel provide details about failures
Troubleshooting API Issues
Anthropic API Issues
Problem: AI generation fails with authentication error
Solution:
Solution:
- Verify
ANTHROPIC_API_KEYis correct in.env.local - Ensure the key starts with
sk-ant-api03- - Check your Anthropic account has sufficient credits
- Verify the key hasn't been revoked
Problem: Generation works but is slow
Solution:
Solution:
- This is normal - AI generation takes 30-60 seconds
- Check job status in the admin panel
- Longer posts take more time to generate
GoHighLevel API Issues
Problem: Email capture forms don't submit contacts
Solution:
Solution:
- Verify Location ID and API Key are correct
- Check the integration has required scopes
- Ensure the integration is active in GoHighLevel
- Check browser console for error messages
Google Analytics Issues
Problem: GA4 tracking not working
Solution:
Solution:
- Verify Measurement ID format is correct (
G-XXXXXXXXXX) - Check the GA4 plugin is enabled
- Verify the property ID is configured for the domain
- Use browser dev tools to check if the GA4 script is loaded
Testing API Integrations
Testing Anthropic API
- Go to Admin > Posts
- Click "New Post"
- Fill in generation parameters
- Click "Generate with AI"
- Check the job status - it should show "processing" then "completed"
- If it fails, check the error message
Testing GoHighLevel Integration
- Ensure domain has Location ID and API Key configured
- Visit a blog post on that domain
- Wait 3 seconds for email capture form to appear
- Submit the form with test data
- Check your GoHighLevel contacts to verify the contact was created
Testing Google Analytics
- Configure GA4 Property ID for a domain
- Visit the domain in a browser
- Open browser dev tools (F12)
- Go to Network tab and filter for "gtag" or "analytics"
- You should see requests to Google Analytics
- Check GA4 Real-Time reports to see your visit
Next Steps
Now that you've configured your APIs: