Mamba REST API Reference

Mamba provides a REST API for managing cache purges, warmups, statistics, and CDN integrations. This enables automation and external systems to integrate with Mamba’s caching workflows.

  • Namespace: mamba-wc/v1
  • Base: /wp-json/mamba-wc/v1

Authentication and Permissions

All endpoints require a user with either the manage_options or manage_woocommerce capability.

Supported authentication methods:

  • Application Passwords (recommended for server-to-server communication)
  • Basic Auth over HTTPS
  • Logged-in Cookie + X-WP-Nonce (for admin context)

Purge Endpoints

POST /purge
Clears cache entries based on the provided scope.

Request Body (JSON):

  • scope (string, required): one of all, store-api, url, urls, tags, product, category, shop, home
  • value(varies by scope):
    • url: string
    • urls: array of strings
    • tags: string (comma-separated) or array of strings
    • product: integer (product ID)
    • category: integer (term ID)
    • all, shop, home, store-api: omit
  • and_warm (boolean, optional): warm the URL(s) after purge (default: false, only relevant for page URLs)

Response:

  • 200 on success
  • 207 for partial errors
{ 
  "success": true, 
  "actions": [], 
  "warmed": [], 
  "errors": [] 
}

Example: Purge a URL and warm it

curl -X POST https://yoursite.com/wp-json/mamba-wc/v1/purge \
  -u 'USER:APP_PASSWORD' \
  -H 'Content-Type: application/json' \
  -d '{"scope":"url","value":"https://yoursite.com/sample-page/","and_warm":true}'

GET /purge-stats
Returns cache statistics (hits, misses, size, last cleared).

curl https://yoursite.com/wp-json/mamba-wc/v1/purge-stats -u 'USER:APP_PASSWORD'

Warmup Endpoints

POST /warmup
Starts a warmup job.

GET /warmup-status
Returns current or last warmup job status.

POST /warmup-cancel
Cancels the most recent warmup job.

POST /warmup-resume
Resumes a paused warmup job.

GET /warmup-errors
Returns recent warmup errors (up to 100).

Examples:

# Start warmup
curl -X POST https://yoursite.com/wp-json/mamba-wc/v1/warmup -u 'USER:APP_PASSWORD'

# Check warmup status
curl https://yoursite.com/wp-json/mamba-wc/v1/warmup-status -u 'USER:APP_PASSWORD'

Cache and Statistics

GET /cache-status
Returns cache enablement summary and warmup statistics.

GET /stats
Returns hit/miss rates, per-type stats, and average generation time.


Background Warmup (Advanced)

POST /background-warmup
Schedules a background warmup job (if supported by the environment).

GET /background-jobs
Lists recent background warmup jobs.

GET /test-background
Diagnostics endpoint to verify warmup internals are accessible.


CDN Integration

POST /cdn/test-connection
Tests connectivity to the configured CDN provider.

POST /cdn/test-purge (with optional type parameter: url or tag)
Executes a test purge against the CDN.

POST /cdn/apply-recommended-settings
Applies Mamba’s recommended CDN configuration.

GET /cdn/actions
Returns recent CDN action logs (mirrors, invalidations, etc.).

Examples:

# Test CDN connection
curl -X POST https://yoursite.com/wp-json/mamba-wc/v1/cdn/test-connection -u 'USER:APP_PASSWORD'

# Test CDN tag purge
curl -X POST "https://yoursite.com/wp-json/mamba-wc/v1/cdn/test-purge?type=tag" -u 'USER:APP_PASSWORD'

Notes and Best Practices

  • Same-origin requirement: purge url only works with same-origin URLs; external domains are rejected.
  • and_warm default: Disabled by default for safety. Enable per-call when desired.
  • CLI vs. REST differences: On shared hosting, WP-CLI may require a specific PHP binary (e.g., /usr/bin/php ~/bin/wp ...).
  • Discoverability:
    • CLI help: wp help mamba, wp help mamba purge, wp help mamba warmup

Copyright 2025 - Mamba


Mamba mascot