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

# Push notifications

> Send push notifications to engage your users

Send push notifications to users in your app. Notifications appear in the Whop mobile app and web interface.

There are two ways to send notifications:

* **Experience notifications** - Send to users who have access to an experience (your app customers)
* **Company notifications** - Send to team members of a company (dashboard app users)

<Info>
  To send experience notifications, the experience must belong to your app. To
  send company notifications, the company must have your app installed. No
  additional permissions are required.
</Info>

# Sending to everyone in an experience

Send notifications to all users with access to an experience:

<CodeGroup>
  ```typescript Typescript theme={null}
  const result = await client.notifications.create({
    experience_id: 'exp_xxxxxxxxxxxxxx',
    title: 'New Feature Available',
    subtitle: 'Check it out now',
    content: 'We just released a new feature that helps you track your progress better.',
  });

  console.log(result.success); // true

  ```

  ```python Python theme={null}
  result = client.notifications.create(
      experience_id="exp_xxxxxxxxxxxxxx",
      title="New Feature Available",
      subtitle="Check it out now",
      content="We just released a new feature that helps you track your progress better.",
  )

  print(result.success)  # True
  ```

  ```ruby Ruby theme={null}
  result = client.notifications.create(
    experience_id: "exp_xxxxxxxxxxxxxx",
    title: "New Feature Available",
    subtitle: "Check it out now",
    content: "We just released a new feature that helps you track your progress better."
  )

  puts result.success  # true
  ```
</CodeGroup>

<Note>
  **Example use case:** If you're building a fitness tracking app, you could
  send a notification to everyone when a new workout program is released, or
  send targeted notifications to users who completed a 7-day streak to celebrate
  their achievement.
</Note>

## Sending to specific users

Use the `user_ids` parameter to send notifications only to specific users. These users must also have access to the experience.

<CodeGroup>
  ```typescript Typescript theme={null}
  const result = await client.notifications.create({
    experience_id: 'exp_xxxxxxxxxxxxxx',
    title: 'Complete your daily workout',
    content: 'You\'re 50% of the way to your goal. Finish strong!',
    user_ids: ['user_abc123', 'user_def456'],
  });
  ```

  ```python Python theme={null}
  result = client.notifications.create(
      experience_id="exp_xxxxxxxxxxxxxx",
      title="Complete your daily workout",
      content="You're 50% of the way to your goal. Finish strong!",
      user_ids=["user_abc123", "user_def456"],
  )
  ```

  ```ruby Ruby theme={null}
  result = client.notifications.create(
    experience_id: "exp_xxxxxxxxxxxxxx",
    title: "Complete your daily workout",
    content: "You're 50% of the way to your goal. Finish strong!",
    user_ids: ["user_abc123", "user_def456"]
  )
  ```
</CodeGroup>

# Sending to company team members

Send notifications to all team members of a company (dashboard app users):

<CodeGroup>
  ```typescript Typescript theme={null}
  const result = await client.notifications.create({
    company_id: 'biz_xxxxxxxxxxxxxx',
    title: 'Monthly Report Ready',
    subtitle: 'October 2024',
    content: 'Your monthly analytics report has been generated and is ready to view.',
  });
  ```

  ```python Python theme={null}
  result = client.notifications.create(
      company_id="biz_xxxxxxxxxxxxxx",
      title="Monthly Report Ready",
      subtitle="October 2024",
      content="Your monthly analytics report has been generated and is ready to view.",
  )
  ```

  ```ruby Ruby theme={null}
  result = client.notifications.create(
    company_id: "biz_xxxxxxxxxxxxxx",
    title: "Monthly Report Ready",
    subtitle: "October 2024",
    content: "Your monthly analytics report has been generated and is ready to view."
  )
  ```
</CodeGroup>

<Note>
  **Example use case:** If you're building a tax filing dashboard, you could
  send notifications to all team members when a filing deadline is approaching,
  or send targeted reminders to specific users who still need to complete steps
  in the filing process.
</Note>

## Sending to specific team members

Use the `user_ids` parameter to send notifications only to specific team members. These users must also be team members of the company.

<CodeGroup>
  ```typescript Typescript theme={null}
  const result = await client.notifications.create({
    company_id: 'biz_xxxxxxxxxxxxxx',
    title: 'Action Required',
    content: 'Please review and approve the pending invoices.',
    user_ids: ['user_manager1', 'user_manager2'],
  });
  ```

  ```python Python theme={null}
  result = client.notifications.create(
      company_id="biz_xxxxxxxxxxxxxx",
      title="Action Required",
      content="Please review and approve the pending invoices.",
      user_ids=["user_manager1", "user_manager2"],
  )
  ```

  ```ruby Ruby theme={null}
  result = client.notifications.create(
    company_id: "biz_xxxxxxxxxxxxxx",
    title: "Action Required",
    content: "Please review and approve the pending invoices.",
    user_ids: ["user_manager1", "user_manager2"]
  )
  ```
</CodeGroup>

# Deep linking with rest\_path

Direct users to specific pages in your app when they tap a notification using the `rest_path` parameter.

## Setting up your app path

First, configure your app path in the dashboard to handle the dynamic route parameter:

1. Go to your app settings in the [developer dashboard](https://whop.com/dashboard/developer)
2. In the hosting section, update your "App path" to include `[restPath]`

**For experience apps:**

```
/experiences/[experienceId]/[restPath]
```

**For dashboard apps:**

```
/companies/[companyId]/[restPath]
```

## Sending notifications with deep links

Add the `rest_path` parameter to your notification. This will be appended to your app's base URL.

<CodeGroup>
  ```typescript Typescript theme={null}
  // Experience app: Direct to a specific workout
  await client.notifications.create({
    experience_id: 'exp_xxxxxxxxxxxxxx',
    title: 'Today\'s Recommended Workout',
    content: 'Based on your progress, we recommend this HIIT session.',
    rest_path: '/workouts/hiit-advanced-1',
  });

  // Dashboard app: Direct to a specific report
  await client.notifications.create({
  company_id: 'biz_xxxxxxxxxxxxxx',
  title: 'Unusual Activity Detected',
  content: 'Review the flagged transactions in your dashboard.',
  rest_path: '/reports/flagged-transactions',
  });

  ```

  ```python Python theme={null}
  # Experience app: Direct to a specific workout
  client.notifications.create(
      experience_id="exp_xxxxxxxxxxxxxx",
      title="Today's Recommended Workout",
      content="Based on your progress, we recommend this HIIT session.",
      rest_path="/workouts/hiit-advanced-1",
  )

  # Dashboard app: Direct to a specific report
  client.notifications.create(
      company_id="biz_xxxxxxxxxxxxxx",
      title="Unusual Activity Detected",
      content="Review the flagged transactions in your dashboard.",
      rest_path="/reports/flagged-transactions",
  )
  ```

  ```ruby Ruby theme={null}
  # Experience app: Direct to a specific workout
  client.notifications.create(
    experience_id: "exp_xxxxxxxxxxxxxx",
    title: "Today's Recommended Workout",
    content: "Based on your progress, we recommend this HIIT session.",
    rest_path: "/workouts/hiit-advanced-1"
  )

  # Dashboard app: Direct to a specific report
  client.notifications.create(
    company_id: "biz_xxxxxxxxxxxxxx",
    title: "Unusual Activity Detected",
    content: "Review the flagged transactions in your dashboard.",
    rest_path: "/reports/flagged-transactions"
  )
  ```
</CodeGroup>

## Handling the route in your app

When a user taps the notification, they'll be directed to the full URL constructed from your app path and the `rest_path`.

**Example for experience app:**

If your app is hosted at `https://your-app.com` and you send:

```typescript theme={null}
rest_path: "/posts/post_123";
```

The user will open:

```
https://your-app.com/experiences/exp_xxxxxxxxxxxxxx/posts/post_123
```

**In Next.js**, create a file at:

```
app/experiences/[experienceId]/posts/[postId]/page.tsx
```

**In Express**, handle the route:

```typescript theme={null}
app.get("/experiences/:experienceId/posts/:postId", (req, res) => {
	// Handle the notification deep link
});
```

You can also use query parameters:

```typescript theme={null}
rest_path: "?action=review&id=123";
```

# Custom notification icons

By default, notifications display your experience or company avatar. Customize the icon by providing a Whop user ID whose profile picture will be used.

<CodeGroup>
  ```typescript Typescript theme={null}
  await client.notifications.create({
    experience_id: 'exp_xxxxxxxxxxxxxx',
    title: 'New Comment',
    content: 'Sarah replied to your post: "Great progress!"',
    icon_user_id: 'user_sarah123',
    rest_path: '/posts/my-post-123',
  });
  ```

  ```python Python theme={null}
  client.notifications.create(
      experience_id="exp_xxxxxxxxxxxxxx",
      title="New Comment",
      content='Sarah replied to your post: "Great progress!"',
      icon_user_id="user_sarah123",
      rest_path="/posts/my-post-123",
  )
  ```

  ```ruby Ruby theme={null}
  client.notifications.create(
    experience_id: "exp_xxxxxxxxxxxxxx",
    title: "New Comment",
    content: 'Sarah replied to your post: "Great progress!"',
    icon_user_id: "user_sarah123",
    rest_path: "/posts/my-post-123"
  )
  ```
</CodeGroup>

This is useful for social features where you want to show who performed an action (commented, liked, followed, etc).
