notifly's plugin system lets you register any HTTP endpoint as a notification service. Once
registered, your service works exactly like a built-in service — pass its URL to notify() and it dispatches alongside the others.
ServiceDefinition interface
typescript
interface ServiceDefinition { // The URL scheme(s) this service handles, e.g. ['myapp'] schemas: string[]; // Parse a URL object into a config object for send() parseUrl(url: URL): ServiceConfig; // Send the notification using the parsed config send(config: ServiceConfig, message: NotiflyMessage): Promise<NotiflyResult>;}
Step-by-step example
Let's build a custom service for a fictional API at https://api.myapp.com/notify.
1. Define the URL scheme
Choose a URL scheme that doesn't conflict with built-ins. Your notification URLs will look like
myapp://TOKEN/CHANNEL.
2. Implement parseUrl()
Extract credentials from the URL. The url argument is a standard URL object.
typescript
function parseUrl(url: URL) { // For myapp://TOKEN/CHANNEL // url.hostname → TOKEN // url.pathname → '/CHANNEL' return { service: 'myapp', token: url.hostname, channel: url.pathname.slice(1), // strip leading / };}
import type { ServiceDefinition, ServiceConfig, NotiflyMessage, NotiflyResult,} from '@ambersecurityinc/notifly';
Sharing custom services
Package your service definition as a standalone npm module and document its URL scheme format.
Users install your package and call registerService() at startup.