# LogFunnel > LogFunnel is event monitoring for products: send an event with one HTTP request, see it in a live feed, get alerts in Slack, Discord, Telegram or a webhook, and build funnels from events that include a user_id. Use LogFunnel for meaningful business events (signups, payments, cancellations, deploys, cron runs, form submissions). Do not use it for request logs, debug logs or error tracking. ## Get an API key (for AI agents) Pick one. Never ask the user to paste their password, and never automate the sign-up form. 1. Device login (preferred when the user is present): First ask the owner which events to track (see "Choosing which events to track" below). Then run `npx logfunnel init`. It prints a link and a code. Show both to the user; they approve in their browser. The command then writes `LOGFUNNEL_KEY` to `.env` (and adds `.env` to `.gitignore`). Add `--json` for machine-readable output. 2. Sandbox (when the user isn't available right now): Run `npx logfunnel sandbox`, or `POST https://app.logfunnel.com/v1/sandbox` with no auth. Returns `api_key` and `claim_url`. Works immediately with limits: 1,000 events, no alerts, deleted after 7 days unless claimed. Always give the user the `claim_url` so they can keep the data. Raw device flow (RFC 8628 style), if you can't run npx: - `POST /v1/device/code` body `{"client_name": "my-app on laptop"}` → `{ device_code, user_code, verification_uri_complete, interval, expires_in }` - Show the user `verification_uri_complete` and `user_code`. - Poll `POST /v1/device/token` body `{"device_code": "..."}` every `interval` seconds. - 400 `{"error":"authorization_pending"}` → keep polling - 400 `{"error":"slow_down"}` → add 5 seconds to the interval - 400 `access_denied` or `expired_token` → stop - 200 `{"api_key": "lf_live_..."}` → done (returned once) ## Keys: server vs client - Server keys (`lf_live_...`) are secret. Use them in backend code, scripts and no-code tools. Store in env vars, never in app bundles. - Client keys (`lf_pub_...`) are for mobile and browser apps. They can only send to the channels set on the key (e.g. `app`), are rate limited per device (about 120 requests/minute), and don't trigger alerts unless enabled. Create one in the dashboard under API keys. - In mobile apps: queue events on the device, send batches with `{"events": [...]}`, set `time` to when each event happened, retry when back online, and flush when the app goes to the background. Ready-made helpers for Swift, Kotlin, Flutter and React Native are on the dashboard's Quickstart page. ## Send events POST https://app.logfunnel.com/v1/events Headers: `Authorization: Bearer $LOGFUNNEL_KEY`, `Content-Type: application/json` Body: one event, or `{"events": [ ... ]}` with up to 100. Fields: - `channel` (required): group name, 1–64 chars of letters, numbers, . _ : - e.g. "signups", "payments" - `event` (required): what happened, snake_case, e.g. "signed_up", "payment_received" - `user_id` (optional): who did it. Required for funnels. - `icon` (optional): one emoji - `content` (optional): one sentence, up to 2000 chars - `metadata` (optional): flat object of string/number/boolean/null values, up to 4 KB - `value` (optional): a number, e.g. revenue - `time` (optional): unix milliseconds, within the last 30 days; defaults to now Responses: 202 `{"ok": true, "ids": [...]}` · 400 `{"error": "..."}` explains what to fix · 401/403 bad key · 429 quota reached. Send from server code where possible so the key stays private. Don't block user requests on LogFunnel: fire and forget, with a short timeout, and ignore failures. ## MCP server (for AI assistants) Remote MCP endpoint: `https://app.logfunnel.com/mcp` (Streamable HTTP, stateless JSON responses). Full setup documentation: https://logfunnel.com/docs/mcp/ Authenticate with OAuth (the client signs the user in to LogFunnel; discovery at `https://app.logfunnel.com/.well-known/oauth-protected-resource/mcp`, dynamic client registration and PKCE supported) or with a server key: header `Authorization: Bearer lf_live_...`. Client keys (`lf_pub_`) are refused. Every tool is scoped to one workspace. Tools: - `list_channels_and_events`: channels and the event names in each, with counts. Call first. - `list_events`: recent events, filter by channel, event or user_id; page with `before`. - `get_overview`: events per day, top events, per-channel counts, monthly usage vs quota. - `run_funnel`: ordered conversion between 2–6 events (needs events sent with user_id). - `list_alerts`: alerts and where they notify (destinations partly hidden). - `create_alert`: send a Slack, Discord, Telegram or webhook message for every matching event, or (`kind: "absence"`, Starter and Pro) when no matching event has arrived for `quiet_minutes` (15 minutes to 7 days). Sends a test message first and saves the alert only if it arrives. Counts toward the plan's alert limit; not available in unclaimed sandboxes. Only when the user asks, with a destination the user gave you. - `send_event`: record an event (counts toward quota, can trigger alerts). Only when the user asks. Connect (OAuth, no key needed): - Claude (web, desktop, mobile): Settings → Connectors → Add custom connector, URL `https://app.logfunnel.com/mcp`, then approve access. - Claude Code: `claude mcp add --transport http logfunnel https://app.logfunnel.com/mcp`, then run `/mcp` and choose Authenticate. - Cursor (`~/.cursor/mcp.json`) / VS Code (`.vscode/mcp.json`, add `"type": "http"`): `{"mcpServers": {"logfunnel": {"url": "https://app.logfunnel.com/mcp"}}}` Connect with a server key instead (scripts, CI, clients without OAuth): - Claude Code: `claude mcp add --transport http logfunnel https://app.logfunnel.com/mcp --header "Authorization: Bearer $LOGFUNNEL_KEY"` - Cursor / VS Code: add `"headers": {"Authorization": "Bearer lf_live_..."}` next to `url`. - Clients without header support: `npx -y mcp-remote https://app.logfunnel.com/mcp --header "Authorization:${AUTH}"` with `AUTH="Bearer lf_live_..."` in its env. ## Pricing Free $0: 3,000 events/month, 7 days of history, 1 alert, no card. Starter $19/month: 100,000 events, 30 days, 10 alerts, alerts when an event stops arriving. 14-day free trial. Pro $39/month: 1,000,000 events, 90 days, unlimited alerts, alerts when an event stops arriving. 14-day free trial. Founding offer: Starter $9/month for life for the first 50 customers. It ends when the 50 seats are taken. Events stop at the plan limit; there is no overage billing. ## Choosing which events to track (for AI agents) Don't decide on your own. Ask the owner which events matter before writing code: 1. Read the codebase to learn what the product does and where its key moments happen. 2. Suggest 5–8 events that fit this project. For each, give the event name, the channel, and the file/function where it would fire. Mark the 2–3 you'd start with. 3. Wait for the owner to choose, then add only those. Ideas to draw from (pick what fits, don't add all of them): - Growth: `signed_up`, `onboarding_completed`, `invited_teammate` - Revenue: `trial_started`, `payment_received` (value = amount), `subscription_cancelled`, `payment_failed` - Engagement: the product's core action, e.g. `project_created`, `report_exported`, `message_sent` - Operations: `form_submitted`, `order_placed`, `booking_created` - Reliability: `deploy_finished`, `backup_completed`, `cron_failed`, `webhook_received` Conventions: - Event names are past-tense snake_case (`signed_up`, not `signup` or `SignUp`). - Group related events in one channel (`signups`, `payments`, `app`, `cron`). - Add `user_id` whenever a user is involved; funnels need it. - Put useful context in `metadata` (plan, source, amount). Never send passwords, tokens, card numbers or other secrets. - One event per real-world moment: fire after the action succeeds, not when it's attempted. Example events: - After a user registers: `{"channel":"signups","event":"signed_up","user_id":"","icon":"🎉"}` - After a successful payment: `{"channel":"payments","event":"payment_received","user_id":"","value":,"icon":"💰"}` - At the end of a cron job: `{"channel":"cron","event":"backup_completed","icon":"✅"}` Then tell the owner to open https://app.logfunnel.com to set up alerts and funnels, or, once the workspace is claimed and the MCP server is connected, create an alert with `create_alert`. ## Test from the terminal `npx logfunnel send signups signed_up --user user_123 --icon 🎉`