Lemon Squeezy Webhook Arrives but No User Is Linked? A custom_data Checklist

A customer pays, Lemon Squeezy shows the order, and your database stays empty, or it has a subscription row that belongs to nobody. The signature check passes (if it doesn't, fix that first: Lemon Squeezy webhook "invalid signature" checklist). The problem is one step later: either the request never reaches your handler, or it arrives without anything that tells you which of your users bought. This checklist covers both, in the order that's quickest to rule out.

Quick reference

What you see Most likely cause Check
Webhook log shows 404 or 405 URL path doesn't match your route 2
Webhook log shows 419 (Laravel) CSRF protection on the webhook route 2
Your server logs a GET with an empty body A redirect in front of the route 2
Nothing in the log for that purchase Event not selected, or test/live mismatch 3
Payload has no meta.custom_data Checkout started from a link without custom data 4
custom_data is there but the lookup fails Wrong place or wrong type ("123" vs 123) 5
Renewal events can't find a user Invoice events carry a subscription id, not your user 5
Laravel: "Webhook skipped due to invalid custom data." Purchase didn't start from the package's checkout 8

☐ 1. Read the webhook log before changing code

Lemon Squeezy logs recent webhooks on the webhooks settings page. The docs say you can see "which events have been sent, the full payloads of each request and also resend webhooks". Open the delivery for the purchase you're debugging and note two things:

Lemon Squeezy needs a 200 back. Any other status is retried "up to three more times using an exponential backoff strategy (e.g. 5 secs, 25 secs, 125 secs)", and then the delivery counts as failed. Fix the cause, then resend from the log.

Sources: Webhooks, Webhook Requests.

☐ 2. Make sure the POST reaches your handler

404 or 405. The callback URL must match a route that accepts POST, character for character. With the Lemon Squeezy for Laravel package, the route ships with the package and its README says the path "is /lemon-squeezy/webhook by default". php artisan route:list shows whether it's registered in your app.

419 on Laravel. Laravel turns a CSRF token mismatch into an HTTP 419 response, and Lemon Squeezy can't send a CSRF token. Laravel's CSRF docs describe excluding webhook routes for exactly this reason. On Laravel 11 and later:

// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: [
        'lemon-squeezy/*', // or the path of your own webhook route
    ]);
})

On older versions, add the same path to $except in App\Http\Middleware\VerifyCsrfToken.

A GET with an empty body. This is a redirect. HTTP allows a client that follows a 301 or 302 to switch the request from POST to GET: RFC 9110 says "For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request." The body is lost on the way. Common sources:

Fix: enter the final URL in the webhook settings, with the exact scheme, host and trailing slash your route uses, so nothing has to redirect.

Note: Lemon Squeezy's docs don't say how its sender treats redirects. The fix above avoids the question.

Sources: Lemon Squeezy for Laravel README, Laravel CSRF Protection, Laravel exception handler (419 mapping), RFC 9110 §15.4, Django APPEND_SLASH.

☐ 3. Is the webhook subscribed to the right events and mode?

Sources: Event Types, Simulate Webhook Events.

☐ 4. Is meta.custom_data in the payload at all?

Lemon Squeezy doesn't know who your users are. It only sends back what you passed into the checkout. There are two ways to pass it, and both end up in meta.custom_data:

Checkout link with query parameters:

https://[STORE].lemonsqueezy.com/checkout/buy/[VARIANT_ID]?checkout[custom][user_id]=123

Checkout created through the API, with checkout_data.custom:

const res = await fetch("https://api.lemonsqueezy.com/v1/checkouts", {
  method: "POST",
  headers: {
    Accept: "application/vnd.api+json",
    "Content-Type": "application/vnd.api+json",
    Authorization: `Bearer ${process.env.LEMONSQUEEZY_API_KEY}`,
  },
  body: JSON.stringify({
    data: {
      type: "checkouts",
      attributes: {
        checkout_data: { email: user.email, custom: { user_id: String(user.id) } },
      },
      relationships: {
        store: { data: { type: "stores", id: STORE_ID } },
        variant: { data: { type: "variants", id: VARIANT_ID } },
      },
    },
  }),
});
const checkoutUrl = (await res.json()).data.attributes.url;

So when custom_data is missing, ask how that particular buyer reached the checkout:

Note: one comment in lmsqueezy/laravel#57 tentatively traces purchases without the expected custom data to Lemon Squeezy's recovered-cart emails, and suspects the default storefront as well. The docs don't confirm this either way. If you rely on custom data, check those payloads in the log.

Sources: Passing Custom Data, Taking Payments, Create a Checkout.

☐ 5. Read it from the right place, as the right type

Note: the docs don't say explicitly whether invoice events include custom_data. Linking through subscription_id works either way.

Sources: Webhook Requests, Event Types, The Subscription Invoice Object.

☐ 6. Have a fallback when there's no user id

Some purchases will arrive without your id (check 4). Don't drop them, and don't return an error that makes Lemon Squeezy retry a payload that will never change. Save the record unlinked and match it later.

Order and subscription objects both include user_email and customer_id. Lemon Squeezy's guide recommends storing the subscription id, order_id, customer_id, product_id and variant_id.

type LsEvent = {
  meta: { event_name: string; custom_data?: Record<string, unknown> };
  data: { type: string; id: string; attributes: Record<string, any> };
};

// Returns the local user for an order or subscription event, or null.
async function resolveUser(evt: LsEvent, db: Db) {
  const raw = evt.meta.custom_data?.user_id;
  if (raw !== undefined && raw !== null && raw !== "") {
    const user = await db.findUserById(String(raw));
    if (user) return user;
  }
  const email = String(evt.data.attributes.user_email ?? "").trim().toLowerCase();
  if (!email) return null;
  const user = await db.findUserByEmail(email);
  // Only trust an email match if your app has verified that this user owns the address.
  return user?.emailVerified ? user : null;
}

// In the handler, after the signature check:
const user = await resolveUser(evt, db);
await db.upsertSubscription({
  lsId: evt.data.id,
  userId: user?.id ?? null,               // null = unlinked; keep it
  customerEmail: evt.data.attributes.user_email,
  customerId: String(evt.data.attributes.customer_id),
  status: evt.data.attributes.status,
});
return new Response("OK", { status: 200 });

// Later, after sign-in (not at sign-up), once the email is verified:
async function attachUnlinked(user: { id: string; email: string; emailVerified: boolean }, db: Db) {
  if (!user.emailVerified) return 0;
  return db.linkSubscriptionsByEmail(user.email.trim().toLowerCase(), user.id); // only rows with userId = null
}

Then, when someone signs in with that email and your app has verified they own it, attach any unlinked subscriptions to them.

☐ 7. Don't treat a user id from a public link as proof

The signature proves the request came from Lemon Squeezy. It doesn't prove who the buyer is in your app. Whoever opens a checkout link can edit its query string first, checkout[custom][user_id] included.

☐ 8. Laravel package: "Webhook skipped due to invalid custom data."

The official Lemon Squeezy for Laravel package links purchases through two custom-data keys it sets itself, billable_id and billable_type.

Sources: Lemon Squeezy for Laravel README, WebhookController.php, issue #57, issue #83, issue #86.

☐ 9. Don't rely only on the browser success event

With the checkout overlay, Lemon.js fires Checkout.Success and passes it an Order object. That's useful for showing a thank-you state straight away. But the event runs in the buyer's browser, so if the tab closes, your code never sees it. Lemon Squeezy's guide suggests storing subscription data from the subscription_created and subscription_updated webhooks. Use the browser event for the UI, and the webhook as the record.

Sources: Handling Events with Lemon.js, Taking Payments.

Symptom table

Symptom Likely cause Check
Order visible in Lemon Squeezy, database empty Handler not reached (404/419/redirect) 1, 2
Some purchases linked, others not Those buyers came through a link without custom data 4, 6
Every purchase unlinked after moving to a new checkout button New button is a plain share link 4
Lookup fails though user_id is in the log Read from data.attributes, or number/string mismatch 5
Renewals fail to update Invoice events handled like subscription events 5
Laravel returns 400 to every share-link purchase Package needs billable_id/billable_type 8
Paid users see "no subscription" after closing the tab Relying on Checkout.Success only 9

If you're starting a Lemon Squeezy subscription app

Rindstack is a Next.js 15 starter for selling licensed software through Lemon Squeezy, with this linking already wired up. Its product page lists:

In its source, a webhook links to a user only when the user_id from custom data belongs to an existing user. The dashboard also shows subscriptions whose customer email matches the signed-in user's email, so a purchase made without the id can still appear for the same email.

Note: Since v1.0.2, Rindstack's dashboard matches a subscription by email only when the GitHub or Google sign-in reports that address as verified (for GitHub, only the verified primary email). Emails are compared case-insensitively, only subscriptions not yet linked to a user are matched, and the first match links the subscription to that user permanently. The email-only demo login never matches by email; it runs only when AUTH_DEV_LOGIN is true, and never when NODE_ENV is production. If you add other sign-in methods, check email verification before matching subscriptions by email.

It costs $99 one-time (Personal) or $199 (Team).

Its listed limits:

Sources

Note: code samples follow the current docs listed above. Framework defaults change between versions, so check the docs for the version you use.