Webhook Payload Reference
AI agents & LLMs: read this documentation as Markdown at nextblog.ai/docs/webhooks.md or browse the per-section Markdown index.
Webhooks allow you to receive real-time notifications when blog posts are approved or published. This enables you to integrate NextBlog with your custom applications and workflows.
Looking for detailed webhooks integration guide? See our Webhooks Integration page for step-by-step setup instructions, examples, and best practices.
Setting Up Webhooks
To configure webhooks for your project:
- Navigate to your project settings
- Scroll to the "Webhooks" section
- Enter your webhook URL (e.g., https://your-server.com/webhook)
- Save your changes
Webhook Events
Webhooks are triggered for the following events:
- approved: When a blog post is approved and published
Webhook Payload
When a webhook is triggered, a POST request is sent to your webhook URL with the following 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": "# How to Optimize Your Website\n\n...",
"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 for your webhook URLs
- Validate the webhook payload on your server
- Implement rate limiting on your webhook endpoint
- Verify the event type before processing
Example Webhook Handler
Here's an example webhook handler in Node.js:
// Express.js webhook handler
app.post('/webhook', express.json(), (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 });
});