API Endpoints & Cron Jobs

This document provides a reference for the custom API endpoints and scheduled tasks (cron jobs) registered by the EDGE Store plugin.

API Endpoints

The plugin registers several custom routes to handle administrative actions and integrations. The main route files are located in the /routes/ directory.

Admin Routes (routes/admin-routes.php)

These routes are typically called via AJAX from the “EDGE Sync Dashboard” admin page.

  • POST /wp-json/edge/v1/sync/{action}:

    • Description: Triggers a manual synchronization process.
    • {action} Parameter: Can be products, customers, prices, visibility, etc.
    • Authentication: Requires administrator privileges.
  • GET /wp-admin/edge/crm/sync:

    • Description: The primary endpoint for initiating the full Zoho product sync. This is often called in a chain, redirecting to itself to process products in batches and avoid timeouts.
    • Authentication: Requires administrator privileges.

Cron Routes (routes/cron-routes.php)

These routes are designed to be called by a server-side cron job to trigger scheduled tasks.

  • GET /edge-cron/{action}:
    • Description: Executes a specific scheduled task.
    • {action} Parameter:
      • sync-products: Runs the Zoho product sync.
      • sync-prices: Runs the Zoho price sync.
      • sync-visibility: Runs the Zoho visibility sync.
      • clean-queue: Cleans up old tasks from the sync queue.
    • Security: These endpoints should be protected from public access at the server level (e.g., by allowing requests only from localhost or a specific IP).

Scheduled Tasks (Cron Jobs)

While the plugin defines the endpoints for cron jobs, the scheduling itself is typically managed at the server level (e.g., using a Linux crontab) rather than using the WordPress internal cron system.

A typical server-side cron setup might look like this:

# Run the Zoho product sync every night at 1 AM
0 1 * * * wget -q -O - https://yourstore.com/edge-cron/sync-products >/dev/null 2>&1
 
# Run the price sync every hour
0 * * * * wget -q -O - https://yourstore.com/edge-cron/sync-prices >/dev/null 2>&1

This approach is generally more reliable than relying on WP-Cron, which only triggers on site visits.


Next: 05 - Authentication & Tokens