NewWacht Bench is live — AI-assisted development for Wacht

createNotification()

Creates notifications and returns the created notification rows.

Usage

The following example shows a basic usage of the backend client from @wacht/nextjs/server.

import { wachtClient } from '@wacht/nextjs/server';export async function sendNotice(userId: string) {  const client = await wachtClient();  return client.notifications.createNotification({    user_id: userId,    title: 'Action required',    body: 'Please review your recent activity.',  });}

Signature

function createNotification(  request: CreateNotificationRequest,): Promise<Notification[]>

CreateNotificationRequest

user_id?: string | undefined;
Target user id for notification delivery.
title?: string | undefined;
Notification title text.
body?: string | undefined;
Notification body text.
type?: string | undefined;
Optional notification type key.
action_url?: string | undefined;
Optional CTA/deep-link URL.
metadata?: Record<string, unknown> | undefined;
Optional metadata attached to the notification.
source?: string | undefined;
Source system that generated the notification.
context_id?: string | undefined;
Related entity id for downstream handling.

Return value

id?: string | undefined;
Created notification id.
user_id?: string | undefined;
Target user id.
title?: string | undefined;
Persisted notification title.
body?: string | undefined;
Persisted notification body.
read?: boolean | undefined;
Read state when returned.
created_at?: string | undefined;
Creation timestamp.

Behavior

  • Creates a new resource and returns the created object from the backend.
  • Validate required fields before calling to avoid predictable request failures.

On this page