User Segmentation

Notification API with User Segmentation

Stop blasting every user with the same message. Target notifications by plan, role, company, or any custom attribute. Individual, segment, or broadcast. One REST API, real-time delivery via SSE.

Targeting

Three ways to reach your users

From a single user to your entire base. Send the right message to the right audience via the REST API.

Individual User

Target a single user by their ID. Perfect for transactional notifications like order confirmations, password resets, or personal alerts.

"userId": "user_123"

Segment

Target users matching attribute filters. Notify all Pro users, all admins, or all users from a specific company in one API call.

"segment": "plan:pro,role:admin"

Broadcast

Send to everyone. Ideal for system-wide announcements, maintenance notices, or major feature launches across your entire user base.

"broadcast": true

Custom Attributes

Define any attribute. Segment on anything.

Set custom key-value attributes on user profiles via the API. Then use those attributes to target notifications. No predefined schema. Use whatever makes sense for your product.

By Plan Tier

Notify only Enterprise users about SSO availability. plan:enterprise

By User Role

Send billing alerts to admins only, not every team member. role:admin

By Company

Target all members of a specific organization. company:acme-corp

By Region

Announce regional maintenance windows. region:eu-west

By Feature Flag

Notify beta testers about updates to their feature. beta:dashboard-v2

Set attributes via the API

create-user.sh
curl -X POST https://api.notilayer.com/v1/users \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user_123",
    "attributes": {
      "plan": "pro",
      "role": "admin",
      "company": "acme-corp",
      "region": "us-east"
    }
  }'

Then target a segment

send-batch.sh
curl -X POST https://api.notilayer.com/v1/notify/batch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "segment": "plan:pro,role:admin",
    "title": "New audit log available",
    "body": "View security events in Settings."
  }'

// Only Pro admins receive this notification
// Delivered in real time via SSE

Backend Integration

Send from your Node.js backend

The batch endpoint accepts a segment filter and delivers to all matching users. Combine multiple attributes with commas for AND logic. Notifications arrive in real time via SSE.

  • Combine attributes: plan:pro,role:admin
  • No segment limits on any plan
  • Delivered via SSE in under 1 second
  • Works with any language that can make HTTP requests

Node.js example

notify.js
const response = await fetch(
  'https://api.notilayer.com/v1/notify/batch',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      segment: 'plan:enterprise',
      title: 'SSO is now available',
      body: 'Enable SAML in your org settings.',
    }),
  }
);

Use Cases

Smarter notifications drive better engagement

When users only see notifications relevant to them, open rates go up and noise goes down. Read our segmentation guide for best practices.

Onboarding by Plan

Guide free users toward activation steps while sending Pro users tips about advanced features they are paying for.

plan:free plan:pro

Feature Rollouts

Announce a new feature only to users who have the corresponding feature flag enabled. No noise for everyone else.

beta:new-editor

Account-Level Alerts

Send billing alerts to admins only, not every team member. Reduce noise for individual contributors.

role:admin role:owner

Company-Specific Updates

Running a multi-tenant SaaS? Notify all members of a specific company about an outage or data migration affecting their account.

company:acme-corp

FAQ

Segmentation questions

How does user segmentation work in the Notilayer notification API?
Set custom key-value attributes on user profiles via the REST API, such as plan, role, or company. Then use the batch notification endpoint with a segment filter like plan:pro,role:admin to target only matching users. Segments are dynamic filters, not static lists.
What user attributes can I use for notification segmentation?
Any key-value pair you define. Common examples include plan tier (free, starter, pro, enterprise), user role (admin, member, viewer), company name, region, feature flags, and signup date. There is no predefined schema — use whatever attributes make sense for your product.
Can I send notifications to a specific user and a segment in the same request?
The single notification endpoint targets individual users by ID. The batch endpoint targets segments. For mixed targeting, make two API calls — one to the individual endpoint and one to the batch endpoint. Both are simple POST requests.
Is there a cost for using user segmentation in Notilayer?
Segmentation is included in all plans, including the free tier. There is no extra charge for creating or targeting segments. Pricing is based on monthly active users, not the number of segments or attributes you define.

Start Sending Targeted Notifications

Set user attributes, define segments, and reach the right audience. Free plan included.