Skip to main content

Overview

MySafeCache uses API key authentication to secure access to your cache. All API requests must include a valid API key in the Authorization header.

Getting Your API Key

1

Create Account

Sign up for a MySafeCache account at mysafecache.com
2

Access Dashboard

Log in and navigate to your dashboard
3

Generate API Key

Go to the “API Keys” tab and click “Generate New Key”
4

Save Securely

Copy your API key and store it securely (you won’t be able to see it again)

Authentication Format

Include your API key in the Authorization header of every request:
Authorization: Bearer YOUR_API_KEY_HERE

Examples

curl -X POST https://api.mysafecache.com/api/v1/check \
  -H "Authorization: Bearer sk-1234567890abcdef..." \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"Hello"}]}'

Environment Variables

Store your API key securely using environment variables:
MYSAFECACHE_API_KEY=sk-1234567890abcdef...

API Key Management

Multiple API Keys

You can generate multiple API keys for different environments or applications:
  • Development: For testing and development
  • Staging: For pre-production testing
  • Production: For live applications

Rotating API Keys

For security best practices:
  1. Generate a new API key
  2. Update your applications to use the new key
  3. Test that everything works
  4. Delete the old API key

API Key Permissions

Currently, all API keys have the same permissions:
  • Read and write access to your cache
  • Access to usage analytics
  • Ability to store and retrieve cached responses

Security Best Practices

Always use environment variables or secure credential management systems. Never commit API keys to version control.
Generate separate API keys for development, staging, and production to limit potential security exposure.
Periodically rotate your API keys as part of your security maintenance routine.
Regularly check your usage analytics to detect any unusual activity.
If possible, restrict API access to specific IP addresses or networks.

Error Responses

Invalid API Key

{
  "error": "Invalid API key",
  "message": "The provided API key is invalid or has been revoked",
  "status": 401
}

Missing API Key

{
  "error": "Missing API key",
  "message": "Authorization header is required",
  "status": 401
}

Malformed Authorization Header

{
  "error": "Invalid authorization format",
  "message": "Authorization header must be in format: Bearer YOUR_API_KEY",
  "status": 401
}

Testing Your Authentication

Use this simple test to verify your API key is working:
curl -X GET https://api.mysafecache.com/api/v1/usage \
  -H "Authorization: Bearer YOUR_API_KEY"

Rate Limits

API keys are subject to rate limits based on your plan:
PlanRequests per minuteBurst limit
Free60100
Pro6001000
Enterprise600010000
When you exceed rate limits, you’ll receive a 429 Too Many Requests response:
{
  "error": "Rate limit exceeded",
  "message": "You have exceeded your rate limit. Please try again later.",
  "retry_after": 60,
  "status": 429
}

Next Steps

Now that you understand authentication, you’re ready to: