API Authentication
Learn how to authenticate with the SocialRails Public API using API keys, including scopes and security best practices.
The SocialRails API uses API keys for authentication. Every request must include a valid API key in the Authorization header.
Creating an API Key
- Go to Dashboard > Settings > API
- Click Create Key
- Enter a descriptive name (e.g., "Zapier Integration", "Content Bot")
- Select the scopes your integration needs
- Click Create Key
- Copy your key immediately, it is only displayed once
Your key will look like: sr_live_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456789abc
Using Your API Key
Include the key in the Authorization header with the Bearer prefix:
Authorization: Bearer sr_live_your_key_hereExample with curl:
curl -X GET https://socialrails.com/api/v1/posts \
-H "Authorization: Bearer sr_live_your_key_here"Testing Your Key
After creating a key, verify it works by hitting the health endpoint (no auth needed) and then a protected endpoint:
# 1. Verify the API is reachable (no auth required)
curl https://socialrails.com/api/v1/health
# 2. Test your API key
curl https://socialrails.com/api/v1/workspace \
-H "Authorization: Bearer sr_live_your_key_here"If your key is valid, you'll see your workspace name and plan info. If not, you'll get a 401 UNAUTHORIZED error.
Scopes
Each API key has one or more scopes that control what it can access:
Select only the scopes your integration actually needs. A key with read scope cannot create posts. A key without ai scope cannot use the AI generation endpoint.
Security Best Practices
- Never expose your API key in client-side code, Only use API keys in server-side code or secure environments.
- Use separate keys for each integration, This limits the blast radius if a key is compromised.
- Rotate keys regularly, Revoke old keys and create new ones periodically.
- Use the minimum required scopes, Don't grant
writeoraiaccess if your integration only reads data. - Monitor usage, Check the API request logs in your dashboard to spot unusual activity.
Key Management
- View keys: Dashboard > Settings > API, shows all keys with their prefix and creation date
- Revoke a key: Click the trash icon next to any active key to immediately deactivate it
- Key limits: The number of active keys depends on your plan (2 for Creator, up to 10 for Agency)