Skip to main content

REST API Authentication

All Meter API requests require authentication using an API key in the Authorization header.

Authentication header

Include your API key using the Bearer authentication scheme:
Authorization: Bearer sk_live_your_key_here

Example requests

Using curl

curl https://api.meter.sh/v1/strategies \
  -H "Authorization: Bearer sk_live_your_key_here" \
  -H "Content-Type: application/json"

Using JavaScript (fetch)

const response = await fetch('https://api.meter.sh/v1/strategies', {
  headers: {
    'Authorization': `Bearer ${process.env.METER_API_KEY}`,
    'Content-Type': 'application/json'
  }
});

const data = await response.json();

Using Python (requests)

import requests
import os

headers = {
    'Authorization': f'Bearer {os.getenv("METER_API_KEY")}',
    'Content-Type': 'application/json'
}

response = requests.get('https://api.meter.sh/v1/strategies', headers=headers)
data = response.json()

Getting an API key

See the main Authentication guide for instructions on obtaining and managing API keys.

Error responses

401 Unauthorized

Missing or invalid API key:
{
  "detail": "Invalid or missing API key"
}
Solutions:
  • Verify your API key is correct
  • Ensure the Authorization header is included
  • Check the key hasn’t been deleted

403 Forbidden

Valid key but insufficient permissions:
{
  "detail": "You do not have permission to access this resource"
}
Solutions:
  • Verify you’re accessing your own resources
  • Check the resource exists

Best practices

Use Environment Variables

Never hardcode API keys in source code

Secure Transmission

Always use HTTPS, never HTTP

Rotate Keys

Generate new keys periodically

Monitor Usage

Track API calls in your dashboard

Next steps

Need help?

Email me at [email protected]