> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhook Integration

> Forward app notification events to your backend for push delivery

App Notifications in Sublay are in-app records — they appear in a notification feed inside your app. To deliver push notifications (iOS APNs, Android FCM) when users are not actively using the app, you can configure a webhook that fires whenever a notification is created.

## How It Works

**1. Configure a webhook URL in the dashboard**

In your Sublay project dashboard, go to **Settings → Webhooks** and add a webhook URL pointing to your backend endpoint. Select the **App Notification Created** event.

**2. Receive the event on your backend**

When Sublay creates an app notification, it sends an HTTP POST to your webhook URL with a JSON payload describing the notification:

```json theme={null}
{
  "type": "app-notification.created",
  "projectId": "your-project-id",
  "data": {
    "projectId": "your-project-id",
    "userId": "recipient-user-id",
    "type": "entity-comment",
    "action": "open-comment",
    "metadata": {
      "entityId": "...",
      "commentId": "...",
      "initiatorId": "...",
      "initiatorName": "Alice"
    }
  }
}
```

**3. Look up the recipient's push token**

Use `data.userId` to look up the FCM or APNs token stored in your own database for that user.

**4. Send the push notification**

Use your push provider (Firebase Admin SDK, APNs, Expo Push, etc.) to send a push notification to the device. Build the message text using `data.type` and `data.metadata` from the webhook payload.

## Payload Fields

| Field | Type | Description |
| - | - | - |
| `type` | `string` | Always `"app-notification.created"` |
| `projectId` | `string` | The Sublay project ID |
| `data.projectId` | `string` | The Sublay project ID (repeated inside data) |
| `data.userId` | `string` | The recipient's user ID |
| `data.type` | `string` | The notification type (e.g., `"entity-comment"`) |
| `data.action` | `string` | Navigation hint for the push tap action |
| `data.metadata` | `object` | Type-specific data — see [Notification Templates](https://docs.sublay.io/v7/sdk/app-notifications/notification-templates.md) for fields per type |

> [!NOTE]
>
> This page describes the **bring-your-own-provider** bridge: you store the push
> tokens in your own backend and dispatch through your own provider. Sublay can
> also do this for you — the [`push` bundle](https://docs.sublay.io/v7/push-notifications) stores each
> user's registered devices per account and dispatches to APNs, FCM and Web Push
> itself, in which case no webhook bridge is needed.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.