# BugSnag rate limit notifications on your phone > Get a push notification when a BugSnag project nears its event rate limit, or starts dropping events because it hit it. - Company: BugSnag (https://www.justpush.io/recipes/bugsnag) - Event: `projectSamplingStarted` (Rate limit) - Tags: Developer tools, Monitoring - Install: https://studio.justpush.io/recipes/bugsnag/rate-limit - Web page: https://www.justpush.io/recipes/bugsnag/rate-limit ## Setup 1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL. 2. In BugSnag, open your project's Settings > Integrations and data forwarding and choose Webhook. 3. Paste your webhook URL (shown in Studio after install) as the webhook URL. 4. Under notifications, pick the Rate limit triggers you want and save. Use Test to send a sample. 5. On the webhook integration, turn on the **approaching rate limit** and **rate limited** notifications (`projectApproachingRateLimit` and `projectSamplingStarted`). Every other trigger is ignored by this recipe. 6. BugSnag doesn't sign webhook requests, so keep your endpoint URL private. ## Code Studio calls `handleRequest(request)` with the incoming webhook (`{ method, headers, body, query, raw }`) and sends the message object it returns. Returning `null` sends nothing. ```js // BugSnag → rate limiting // Fires when a BugSnag project is close to its event rate limit, or has started // sampling (dropping) events because it hit it. // Docs: https://docs.bugsnag.com/product/integrations/data-forwarding/webhook/ const TRIGGERS = { projectApproachingRateLimit: { title: "⚠️ Approaching BugSnag rate limit", text: "is close to its event rate limit", priority: 0, }, projectSamplingStarted: { title: "🚫 BugSnag is sampling events", text: "hit its rate limit, so BugSnag is now dropping some events", priority: 1, }, } // Only link to real http(s) URLs. function link(url, cta) { return typeof url === "string" && /^https?:\/\//.test(url) ? [{ cta, url }] : [] } function handleRequest(request) { const body = request.body || {} const type = body.trigger?.type // Guard: only rate-limit triggers, so error notifications on this integration stay quiet. if (!Object.prototype.hasOwnProperty.call(TRIGGERS, type)) { console.log(`Ignoring BugSnag trigger "${type ?? "unknown"}"`) return null } const trigger = TRIGGERS[type] return { title: trigger.title, message: `${body.project?.name ?? "Your project"} ${trigger.text}`, topic: "BugSnag", priority: trigger.priority, // High once you're actually losing error reports buttons: link(body.project?.url, "View project"), } } ``` ## BugSnag projectSamplingStarted webhook payload (sample) ```json { "account": { "id": "56b9ca7f17025f8756f69054", "url": "https://app.bugsnag.com/accounts/acme", "name": "Acme" }, "project": { "id": "56b9ca7f17025f8756f69055", "url": "https://app.bugsnag.com/acme/web-app", "name": "Web App" }, "trigger": { "type": "projectSamplingStarted", "message": "Project is being rate limited" } } ``` ## FAQ ### Does this work on iPhone and Android? Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification. ### Do I need to write code? No. Install the recipe in Studio, paste your webhook URL into BugSnag and you are done. The code is there if you want to change the text, the sound or the buttons. ### Can I change what the notification says? Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save. ### What does it cost? JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.