API Dashboard

Manage your API keys, view usage, and configure your account.

Dashboard requires Supabase authentication. This page will be connected to the auth system in a future update. For now, you can manage API keys via the Supabase dashboard or the SQL examples below.

Create an API Key

Generate a new API key using the Supabase SQL editor or psql:

-- Generate a random API key
-- Store the key securely — it cannot be retrieved after creation

DO $$
DECLARE
  raw_key TEXT := 'gs_live_' || encode(gen_random_bytes(24), 'hex');
  hashed  TEXT := encode(digest(raw_key, 'sha256'), 'hex');
  prefix  TEXT := left(raw_key, 12);
BEGIN
  INSERT INTO api_keys (key_hash, key_prefix, name, tier, monthly_limit)
  VALUES (hashed, prefix, 'My First Key', 'free', 500);

  RAISE NOTICE 'Your API key (save it now!): %', raw_key;
  RAISE NOTICE 'Key prefix: %', prefix;
END $$;

Check Usage

Query your current usage via the API:

curl https://api.greenscore.dev/v1/usage \
  -H "Authorization: Bearer gs_live_YOUR_KEY"

# Response:
# {
#   "data": {
#     "current_period": "2026-03",
#     "calls_used": 42,
#     "calls_limit": 500,
#     "calls_remaining": 458,
#     "tier": "free",
#     "reset_date": "2026-04-01"
#   }
# }

Manage Keys

-- List your keys
SELECT key_prefix, name, tier, monthly_limit, is_active, created_at, last_used_at
FROM api_keys WHERE user_id = auth.uid();

-- Deactivate a key
UPDATE api_keys SET is_active = false WHERE key_prefix = 'gs_live_xxxx';

-- Delete a key (permanently)
DELETE FROM api_keys WHERE key_prefix = 'gs_live_xxxx';

Full dashboard with key management UI, usage charts, and Stripe billing coming soon.

Get started with the API →