Webhooks Integration
AI agents & LLMs: read this documentation as Markdown at nextblog.ai/docs/integration-webhooks.md or browse the per-section Markdown index.
Webhooks Integration
Receive real-time notifications when blog posts are approved or published. Use webhooks to integrate NextBlog with any custom CMS or application.
Looking for the exact payload fields, headers and retry behaviour? See the Webhook Payload Reference.
Overview
Webhooks allow you to:
- Receive real-time notifications when posts are approved
- Sync content to custom CMS systems
- Trigger notifications in Slack, Discord, or other services
- Update external databases or systems
- Build custom publishing workflows
Step 1: Set Up Your Webhook Endpoint
1.1 Create Webhook Endpoint
Create an HTTP endpoint (URL) that can receive POST requests. This endpoint should:
- Be publicly accessible (use HTTPS)
- Accept POST requests
- Return a 200 status code on success
- Handle JSON payloads
1.2 Example Webhook Handler (Node.js/Express)
// Express.js webhook handler
const express = require('express');
const app = express();
app.use(express.json());
app.post('/webhook', (req, res) => {
const { event, blog } = req.body;
if (event === 'approved') {
console.log('Blog post approved:', blog.title);
// Process the approved blog post
// e.g., sync to another CMS, send notifications, etc.
}
res.status(200).json({ received: true });
});
app.listen(3000, () => {
console.log('Webhook server running on port 3000');
});Step 2: Configure Webhook in NextBlog
2.1 Navigate to Project Settings
- Log into your NextBlog dashboard
- Click on your project to open it
- Click on "Settings"
2.2 Enter Webhook URL
- Scroll down to the "Webhooks" section
- Enter your webhook URL (must be HTTPS, e.g.,
https://your-server.com/webhook) - Leave empty to disable webhooks
2.3 Save Changes
Click the "Save Changes" button to save your webhook settings.
Webhook Events
Approved Event
Webhooks are triggered when a blog post is approved and published. The event type is
"approved".Webhook Payload
When a webhook is triggered, a POST request is sent to your webhook URL with the following JSON payload:
{
"event": "approved",
"timestamp": "2024-01-01T12:00:00Z",
"blog": {
"id": "blog_123",
"title": "How to Optimize Your Website",
"slug": "how-to-optimize-website",
"description": "Learn the best practices...",
"markdown": "# Full markdown content...",
"cover_image_url": "https://example.com/image.jpg",
"cover_image_alt": "Website optimization",
"published": true,
"status": "approved",
"created_at": "2024-01-01T10:00:00Z",
"updated_at": "2024-01-01T12:00:00Z",
"project_id": "project_456"
}
}Webhook Headers
Each webhook request includes the following headers:
Content-Type: application/json
User-Agent: NextBlog-Webhook/1.0Error Handling
If your webhook endpoint returns an error or is unreachable, NextBlog will automatically retry once. Failed webhooks are logged but do not prevent the blog post from being published.
Security Best Practices
- Use HTTPS: Always use HTTPS for your webhook URLs to encrypt data in transit
- Validate Payload: Validate the webhook payload on your server to ensure it's from NextBlog
- Rate Limiting: Implement rate limiting on your webhook endpoint to prevent abuse
- Verify Event Type: Check the event type before processing to handle different events appropriately
- Idempotency: Make your webhook handler idempotent to handle duplicate deliveries
Testing Your Webhook
To test your webhook:
- Set up your webhook endpoint
- Configure the webhook URL in NextBlog
- Approve a test blog post
- Check your webhook endpoint logs to verify the request was received
Use Cases
- Sync content to custom CMS systems
- Send notifications to Slack, Discord, or email
- Update external databases or search indices
- Trigger automated workflows in other services
- Build custom analytics and tracking