Authentication
The Spyglasses API uses API key authentication. Both kinds of key travel in the same x-api-key header, so you only ever learn one header — but they are not interchangeable, and using the wrong one returns 401.
Which Key Do I Need?
| Property API key | Organization API key | |
|---|---|---|
| Scope | One property | Every property in the organization |
| Where to find it | Property → Settings → API Key | Organization Settings → API Key |
| Who can generate it | Any member with access to the property | Admins and owners |
| Use it for | Traffic analytics, AI visibility rankings, historical metrics, /api/me | AIVPS publisher scoring, PQS placement scoring, coverage group ingestion |
| Endpoints | /api/analytics/*, /api/properties/:id/*, /api/me | /api/v1/* |
The rule of thumb: reading one property's analytics uses the property key; anything under /api/v1/ uses the organization key.
The organization key is the right choice for automation platforms and agency workflows. It works across every client property in the organization, so one Zapier or n8n connection can serve your whole book of business rather than one credential per client. Endpoints that take a propertyId verify that the property belongs to the authenticated organization, so the key can never reach another customer's data.
The organization key is the more powerful of the two. Treat it like a production credential: store it in your automation platform's secret store, never in a shared spreadsheet or a browser extension.
API Key Format
Spyglasses API keys follow this format:
The sg_ prefix identifies it as a Spyglasses API key.
Finding Your Property API Key
- Log in to your Spyglasses dashboard
- Select your property from the sidebar
- Navigate to Settings
- Locate the API Key section
- Click the copy button to copy your key
Finding Your Organization API Key
- Log in to your Spyglasses dashboard
- Open Organization Settings
- Locate the API Key section
- Click Generate API Key if you don't have one yet, then copy it
Generating a new organization key immediately invalidates the previous one. Update every integration that uses it in the same sitting.
Using Your API Key
Include your API key in the x-api-key header of every request:
Example with POST Request
For POST requests, also include the Content-Type header:
Property ID vs API Key
Some endpoints require a propertyId parameter. This is different from your API key:
- API Key (
sg_XXX...) - Used for authentication in thex-api-keyheader - Property ID (
cm9XXX...) - Used to identify which property's data you want to access
To get your property ID, call the /api/me endpoint:
The response includes your propertyId:
Security Best Practices
Your API key grants full access to your property's analytics data. Keep it secure!
Do
- Store API keys in environment variables
- Use server-side code to make API requests
- Rotate keys if you suspect they've been compromised
Don't
- Commit API keys to version control
- Expose API keys in client-side JavaScript
- Share API keys in public forums or documentation
Regenerating Your API Key
If your API key is compromised, you can regenerate it:
- Go to your property Settings
- Find the API Key section
- Click Regenerate API Key
- Update your integrations with the new key
Regenerating your API key immediately invalidates the old key. Make sure to update all your integrations.