# GitLab merge request notifications on your phone > Get a push notification when a GitLab merge request is opened, marked ready, gets a review request, is approved, or is merged. - Company: GitLab (https://www.justpush.io/recipes/gitlab) - Event: `Merge Request Hook` (Merge request events) - Tags: Code hosting, Pull requests - Install: https://studio.justpush.io/recipes/gitlab/merge-request - Web page: https://www.justpush.io/recipes/gitlab/merge-request ## 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 your GitLab project (or group), go to Settings > Webhooks and click Add new webhook. 3. Paste your webhook URL (shown in Studio after install) as the URL. 4. Under Trigger, tick Merge request events and click Add webhook. Use the Test dropdown to send a sample event. 5. Tick **Merge request events** under **Trigger**. Pushes go out when a merge request is opened (not as a draft), marked ready, gets a new reviewer, is fully approved, or is merged. Edits, new commits, closes and single approvals are ignored. 6. A group webhook covers every project in the group. Links in the push come from the payload, so self-managed GitLab instances work too. 7. GitLab can sign deliveries with a **Signing token** (`webhook-signature`, HMAC-SHA256) or send a plain **Secret token** (`X-Gitlab-Token`), but JustPush doesn't check either yet, 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 // GitLab โ†’ Merge Request Hook (merge request) // Fires when a merge request is opened, marked ready, gets a review request, is approved, or is merged. // Docs: https://docs.gitlab.com/user/project/integrations/webhook_events/#merge-request-events // The merge request moments worth a push. const ACTIONS = { open: { emoji: "๐Ÿ”€", verb: "opened", priority: 0 }, ready: { emoji: "๐Ÿ”€", verb: "ready for review", priority: 0 }, review: { emoji: "๐Ÿ‘€", verb: "review requested", priority: 0 }, approved: { emoji: "๐Ÿ‘", verb: "approved", priority: 0 }, merge: { emoji: "๐ŸŸฃ", verb: "merged", priority: -1 }, } // Header names can arrive in any case. function header(request, name) { const headers = request.headers || {} const key = Object.keys(headers).find((k) => k.toLowerCase() === name) const value = key ? headers[key] : null return Array.isArray(value) ? value[0] : value } // Only link to real http(s) URLs. function link(url, cta) { return typeof url === "string" && /^https?:\/\//.test(url) ? [{ cta, url }] : [] } // Usernames from a list of GitLab users. function usernames(list) { return Array.isArray(list) ? list.map((user) => user?.username).filter((name) => typeof name === "string") : [] } function handleRequest(request) { const body = request.body && typeof request.body === "object" ? request.body : {} const event = header(request, "x-gitlab-event") // Guard: only merge request events. The header decides when it's there; the payload's // shape is the fallback (for example in Studio's Test runner). if (event ? event !== "Merge Request Hook" : body.object_kind !== "merge_request") { console.log(`Ignoring GitLab "${event ?? body.object_kind ?? "unknown"}" event`) return null } const mr = body.object_attributes ?? {} const changes = body.changes && typeof body.changes === "object" ? body.changes : {} let action = mr.action let reviewers = [] // "update" covers many things; only two of them are worth a push. if (action === "update") { const before = usernames(changes.reviewers?.previous) reviewers = usernames(changes.reviewers?.current).filter((name) => !before.includes(name)) if (changes.draft?.previous === true && changes.draft?.current === false) action = "ready" else if (reviewers.length) action = "review" } // Drafts aren't ready for eyes yet; closes, reopens and single approvals are skipped too. if (!Object.prototype.hasOwnProperty.call(ACTIONS, action) || (action === "open" && mr.draft)) { console.log(`Skipping merge request action "${mr.action ?? "unknown"}"`) return null } const what = ACTIONS[action] const repo = body.project?.path_with_namespace ?? mr.target?.path_with_namespace ?? "a project" const branches = mr.source_branch && mr.target_branch ? `${mr.source_branch} โ†’ ${mr.target_branch}` : null const who = body.user?.username const detail = action === "review" ? `for ${reviewers.map((name) => `@${name}`).join(", ")}` : who ? `by @${who}` : null return { title: `${what.emoji} MR ${mr.iid ? `!${mr.iid} ` : ""}${what.verb}: ${mr.title ?? "Untitled merge request"}`, message: [repo, branches, detail].filter(Boolean).join(" ยท "), topic: "GitLab", priority: what.priority, // Normal while it needs eyes, Low once merged buttons: link(mr.url, "View merge request"), } } ``` ## GitLab Merge Request Hook webhook payload (sample) ```json { "user": { "id": 51, "name": "Sam Lee", "email": "[REDACTED]", "username": "sam-lee" }, "labels": [], "changes": { "merge_status": { "current": "checking", "previous": "preparing" } }, "project": { "id": 7, "name": "web", "web_url": "https://gitlab.example.com/acme/web", "namespace": "Acme", "default_branch": "main", "path_with_namespace": "acme/web" }, "assignees": [ { "id": 51, "name": "Sam Lee", "username": "sam-lee" } ], "reviewers": [ { "id": 42, "name": "Jane Doe", "state": "unreviewed", "username": "janedoe", "re_requested": false } ], "event_type": "merge_request", "object_kind": "merge_request", "object_attributes": { "id": 930, "iid": 42, "url": "https://gitlab.example.com/acme/web/-/merge_requests/42", "draft": false, "state": "opened", "title": "Add Apple Pay to checkout", "action": "open", "author_id": 51, "created_at": "2026-09-28T09:20:11.000Z", "updated_at": "2026-09-28T09:20:14.000Z", "description": "Adds Apple Pay as a payment method.", "source_branch": "feature/apple-pay", "target_branch": "main", "detailed_merge_status": "checking" } } ``` ## 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 GitLab 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.