DEV Community

Alex Spinov
Alex Spinov

Posted on

Knock Has a Free API That Powers In-App Notifications Like Slack

Knock is the notification infrastructure platform that gives you a Slack-like notification feed, cross-channel delivery, and preference management — all via API.

What Is Knock?

Knock handles the entire notification stack: in-app feeds, email digests, push notifications, Slack messages, and SMS. One API call triggers the right notification on the right channel.

Quick Start

npm install @knocklabs/node
Enter fullscreen mode Exit fullscreen mode
import { Knock } from '@knocklabs/node'

const knock = new Knock(process.env.KNOCK_API_KEY!)

// Trigger notification
await knock.notify('new-comment', {
  recipients: ['user-123'],
  data: {
    commenter: 'Alice',
    commentText: 'Great article!',
    postTitle: 'Getting Started with Knock',
    postUrl: 'https://app.example.com/posts/456',
  },
})
Enter fullscreen mode Exit fullscreen mode

REST API

export KNOCK_KEY="your-api-key"

# Trigger workflow
curl -s -X POST 'https://api.knock.app/v1/workflows/new-comment/trigger' \
  -H "Authorization: Bearer $KNOCK_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "recipients": ["user-123"],
    "data": {"commenter": "Alice", "commentText": "Great work!", "postUrl": "/posts/456"}
  }'

# Get user feed
curl -s 'https://api.knock.app/v1/users/user-123/feeds/in-app-feed' \
  -H "Authorization: Bearer $KNOCK_KEY" | jq '.entries | length'

# Set user preferences
curl -s -X PUT 'https://api.knock.app/v1/users/user-123/preferences' \
  -H "Authorization: Bearer $KNOCK_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"channel_types": {"email": true, "sms": false, "push": true}}'
Enter fullscreen mode Exit fullscreen mode

In-App Feed (React)

import { KnockProvider, KnockFeedProvider, NotificationIconButton, NotificationFeedPopover } from '@knocklabs/react'
import '@knocklabs/react/dist/index.css'

function App() {
  const [isVisible, setIsVisible] = useState(false)
  const buttonRef = useRef(null)

  return (
    <KnockProvider apiKey={KNOCK_PUBLIC_KEY} userId={currentUser.id}>
      <KnockFeedProvider feedId="in-app-feed">
        <NotificationIconButton ref={buttonRef} onClick={() => setIsVisible(!isVisible)} />
        <NotificationFeedPopover buttonRef={buttonRef} isVisible={isVisible} onClose={() => setIsVisible(false)} />
      </KnockFeedProvider>
    </KnockProvider>
  )
}
Enter fullscreen mode Exit fullscreen mode

Workflow Features

  • Batching: Group 50 comments into 1 email digest
  • Throttling: Max 1 notification per hour per user
  • Delays: Wait 5 minutes before sending (in case user sees it in-app)
  • Conditions: Only email if user has not read in-app notification
  • Preferences: Users control their own channel preferences

Supported Channels

Channel Providers
In-app feed Knock (built-in)
Email SendGrid, Postmark, Mailgun, SES
Push FCM, APNs, Expo
Chat Slack, Discord, MS Teams
SMS Twilio, Vonage, Telnyx

Free Tier

Feature Free Growth
Notifications 10K/mo 100K/mo
In-app feed Yes Yes
Channels All All
Preferences Yes Yes

Need real-time alerts for scraped data? Scrapfly + Knock = instant notifications on web changes. Email spinov001@gmail.com for custom monitoring.

Top comments (0)