n8n Integration Endpoints
Available Webhook Endpoints
These REST API endpoints are configured for n8n integration. Use these URLs in your n8n webhooks.
Task Completed:
POST /wp-json/custom/v1/webhook/task-completed
Journal Entry Saved:
POST /wp-json/custom/v1/webhook/journal-saved
Calendar Event Saved:
POST /wp-json/custom/v1/webhook/event-saved
Diary Entry Saved:
POST /wp-json/custom/v1/webhook/diary-saved
User Registration:
POST /wp-json/custom/v1/webhook/user-registered
⚠️ Required: Add to functions.php
Copy and paste the following code into your theme’s functions.php file to enable these endpoints:
// Register Custom REST API Endpoints for n8n Integration add_action('rest_api_init', function() { // Task Completed Endpoint register_rest_route('custom/v1', '/webhook/task-completed', array( 'methods' => 'POST', 'callback' => 'handle_task_completed_webhook', 'permission_callback' => '__return_true' )); // Journal Saved Endpoint register_rest_route('custom/v1', '/webhook/journal-saved', array( 'methods' => 'POST', 'callback' => 'handle_journal_saved_webhook', 'permission_callback' => '__return_true' )); // Event Saved Endpoint register_rest_route('custom/v1', '/webhook/event-saved', array( 'methods' => 'POST', 'callback' => 'handle_event_saved_webhook', 'permission_callback' => '__return_true' )); // Diary Saved Endpoint register_rest_route('custom/v1', '/webhook/diary-saved', array( 'methods' => 'POST', 'callback' => 'handle_diary_saved_webhook', 'permission_callback' => '__return_true' )); // User Registered Endpoint register_rest_route('custom/v1', '/webhook/user-registered', array( 'methods' => 'POST', 'callback' => 'handle_user_registered_webhook', 'permission_callback' => '__return_true' )); }); // Webhook Handler Functions function handle_task_completed_webhook($request) { $data = $request->get_json_params(); // Forward to n8n or process data $n8n_url = get_option('n8n_task_completed_url', ''); if (!empty($n8n_url)) { wp_remote_post($n8n_url, array( 'body' => json_encode($data), 'headers' => array('Content-Type' => 'application/json') )); } return new WP_REST_Response(array('success' => true), 200); } function handle_journal_saved_webhook($request) { $data = $request->get_json_params(); $n8n_url = get_option('n8n_journal_saved_url', ''); if (!empty($n8n_url)) { wp_remote_post($n8n_url, array( 'body' => json_encode($data), 'headers' => array('Content-Type' => 'application/json') )); } return new WP_REST_Response(array('success' => true), 200); } function handle_event_saved_webhook($request) { $data = $request->get_json_params(); $n8n_url = get_option('n8n_event_saved_url', ''); if (!empty($n8n_url)) { wp_remote_post($n8n_url, array( 'body' => json_encode($data), 'headers' => array('Content-Type' => 'application/json') )); } return new WP_REST_Response(array('success' => true), 200); } function handle_diary_saved_webhook($request) { $data = $request->get_json_params(); $n8n_url = get_option('n8n_diary_saved_url', ''); if (!empty($n8n_url)) { wp_remote_post($n8n_url, array( 'body' => json_encode($data), 'headers' => array('Content-Type' => 'application/json') )); } return new WP_REST_Response(array('success' => true), 200); } function handle_user_registered_webhook($request) { $data = $request->get_json_params(); $n8n_url = get_option('n8n_user_registered_url', ''); if (!empty($n8n_url)) { wp_remote_post($n8n_url, array( 'body' => json_encode($data), 'headers' => array('Content-Type' => 'application/json') )); } return new WP_REST_Response(array('success' => true), 200); }
💡 Configuration Instructions
- Copy the PHP code above and add it to your theme’s functions.php file
- In n8n, create webhook nodes and point them to the endpoints listed above
- Optionally, configure n8n webhook URLs in WordPress options to enable two-way communication
- Test each endpoint using the notification system on your site