# /api/webhooks/stripe (dashboard)

Source-derived dashboard endpoint contract, authentication, request validation, responses, and errors.

Source: https://docs.minds.sh/docs/api/platform/reference/dashboard--api-webhooks-stripe



This is the **dashboard** service route. Its origin and authentication are described in [Platform API overview](/docs/api/platform) and [Authentication](/docs/api/platform/authentication). A path shared by another service is a different endpoint.

| Property                       | Contract                                                                 |
| ------------------------------ | ------------------------------------------------------------------------ |
| Methods                        | POST, GET                                                                |
| Path                           | `/api/webhooks/stripe`                                                   |
| Path parameters                | None                                                                     |
| Query parameters read in route | None read directly; schema validation below may define additional fields |
| Headers read in route          | `x-cabbage-signature`, `x-webhook-signature`                             |

## Authentication and access [#authentication-and-access]

Webhook-specific signature or verification handler; not a customer bearer-token endpoint. See the handler and signing setup.

## Method behavior [#method-behavior]

The handler excerpt preserves field validation, response envelopes, cookie changes, and exception branches. Values returned by service helpers retain their named response type above; for passthrough routes, the upstream response is authoritative.

### POST [#post]

```typescript
export async function POST(request: NextRequest) {
  const webhookSecret = process.env.CABBAGE_WEBHOOK_SECRET

  // Verify webhook signature from Cabbage
  const signature = request.headers.get('x-cabbage-signature') || request.headers.get('x-webhook-signature')

  if (webhookSecret && !signature) {
    return NextResponse.json(
      { error: 'Missing webhook signature header' },
      { status: 400 }
    )
  }

  let event: { type: string; data: Record<string, unknown> }
  try {
    event = await request.json()
  } catch {
    return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 })
  }

  // TODO: Verify HMAC signature when CABBAGE_WEBHOOK_SECRET is set
  // For now, accept all events in development

  try {
    await billingEventService.handleCabbageWebhook(event)
    return NextResponse.json({ received: true }, { status: 200 })
  } catch (error) {
    console.error('Billing webhook processing failed:', error)
    return NextResponse.json(
      { error: 'Webhook processing failed' },
      { status: 500 }
    )
  }
}
```

Source: `minds-ui/apps/app/app/api/webhooks/stripe/route.ts:15`.

### GET [#get]

```typescript
export async function GET() {
  return NextResponse.json({
    status: 'active',
    webhook: 'cabbage-billing',
    stack: 'omerta → cabbage → chard',
    timestamp: new Date().toISOString()
  })
}
```

Source: `minds-ui/apps/app/app/api/webhooks/stripe/route.ts:54`.

## Response and error branches [#response-and-error-branches]

Literal HTTP statuses in the route: 200, 400, 500. Shared management error classes are defined in [Errors and responses](/docs/api/platform/errors).

```typescript
NextResponse.json(
      { error: 'Missing webhook signature header' },
      { status: 400 }
    )
```

Source: `minds-ui/apps/app/app/api/webhooks/stripe/route.ts:22`.

```typescript
request.json()
```

Source: `minds-ui/apps/app/app/api/webhooks/stripe/route.ts:30`.

```typescript
NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 })
```

Source: `minds-ui/apps/app/app/api/webhooks/stripe/route.ts:32`.

```typescript
NextResponse.json({ received: true }, { status: 200 })
```

Source: `minds-ui/apps/app/app/api/webhooks/stripe/route.ts:40`.

```typescript
NextResponse.json(
      { error: 'Webhook processing failed' },
      { status: 500 }
    )
```

Source: `minds-ui/apps/app/app/api/webhooks/stripe/route.ts:43`.

```typescript
NextResponse.json({
    status: 'active',
    webhook: 'cabbage-billing',
    stack: 'omerta → cabbage → chard',
    timestamp: new Date().toISOString()
  })
```

Source: `minds-ui/apps/app/app/api/webhooks/stripe/route.ts:55`.

## Evidence [#evidence]

Generated from the local source snapshot on 2026-09-12. This page documents implemented code and does not certify a deployed service, permissions configuration, or successful provider operation.

Source file: `minds-ui/apps/app/app/api/webhooks/stripe/route.ts`. SHA-256: `85472b6d4bb51be277c21dd5bd268a99ee6afcba7a516023f17c892bab1b19f6`.
