## TL;DR

`` // routes/api.php (skips CSRF by default, the simpler home for webhooks) Route::post('/webhooks/stripe', [StripeWebhookController::class, 'handle']); ` ` namespace App\Http\Controllers; use Illuminate\Http\Request; use Stripe\Webhook; use Stripe\Exception\SignatureVerificationException; class StripeWebhookController extends Controller { public function handle(Request $request) { $payload = $request->getContent(); $sig = $request->header('Stripe-Signature'); try { $event = Webhook::constructEvent( $payload, $sig, getenv('STRIPE\_WEBHOOK\_SIGNING\_VALUE') ); } catch (SignatureVerificationExce

```text
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Stripe\Webhook;
use Stripe\Exception\SignatureVerificationException;

class StripeWebhookController extends Controller
{
    public function handle(Request $request)
    {
        $payload = $request->getContent();
        $sig = $request->header('Stripe-Signature');
        try {
            $event = Webhook::constructEvent(
                $payload, $sig, getenv('STRIPE_WEBHOOK_SIGNING_VALUE')
            );
        } catch (SignatureVerificationException $e) {
            return response('bad signature', 400);
        }
        // switch ($event->type) ...
        return response()->json(['received' => true]);
    }
}
```

## Steps

1. ```
// routes/api.php (skips CSRF by default, the simpler home for webhooks)
Route::post('/webhooks/stripe', [StripeWebhookController::class, 'handle']);
```

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Stripe\Webhook;
use Stripe\Exception\SignatureVerificationException;

class StripeWebhookController extends Controller
{
 public function handle(Request $request)
 {
 $payload = $request->getContent();
 $sig = $request->header('Stripe-Signature');
 try {
 $event = Webhook::constructEvent(
 $payload, $sig, getenv('STRIPE_WEBHOOK_SIGNING_VALUE')
 );
 } catch (SignatureVerificationException $e) {
 return response('bad signature', 400);
 }
 // switch ($event->type) ...
 return response()->json(['received' => true]);
 }
}
```

2. If the route must live in `web.php`, add its URI to the `$except` array in the `VerifyCsrfToken` middleware.

## When to use

You are seeing this: Laravel's CSRF middleware returns 419 for Stripe's POSTs, and reaching for $request->json() or $request->all() gives parsed data. Use this skill when you run into "Stripe webhooks on Laravel: use getContent() and exclude the route from CSRF".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
