Skip to main content

Authentication

Brewry uses API keys to authenticate requests. Each API request must include a valid API key in the header.

API Keys

Getting an API Key

  1. Log in to your Brewry dashboard
  2. Create a new Cellar or navigate to an existing cellar.
  3. Navigate to "API Keys" in the top menu
  4. Click "Create New Key"
  5. Copy and securely store your API key

Using API Keys

Include your API key in the X-API-Key header with every request:

curl -X POST https://tap.brewry.xyz/api/v1/ingest \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"cellar": "example",
"rack": "device-name",
"keg": "sensor-name",
"value": 42,
"timestamp": "2024-03-20T10:30:00Z"
}'

Security Best Practices

  1. Never share your API key

    • Keep it secure and private
    • Don't commit it to version control
    • Don't include it in client-side code
  2. Rotate API keys regularly

    • Generate new keys periodically
    • Revoke old keys when no longer needed
    • Use different keys for different applications
  3. Use environment variables

    export BREWRY_API_KEY="your-api-key"
  4. Implement proper error handling

    • Check for 401 Unauthorized responses
    • Handle API key expiration
    • Monitor for suspicious activity

API Key Management

Viewing Active Keys

  • List all active API keys in your dashboard
  • See creation date and last used date
  • Monitor usage patterns

Revoking Keys

  • Immediately revoke compromised keys
  • Set expiration dates for temporary keys
  • Maintain an audit trail of key usage

Error Responses

Invalid API Key

{
"error": "Invalid API key",
"status": 401
}

Expired API Key

{
"error": "API key has expired",
"status": 401
}

Missing API Key

{
"error": "API key is required",
"status": 401
}

Rate Limiting

API keys are subject to rate limiting. See the Rate Limiting section for details.

Support

If you need help with authentication: