API Documentation

Developer Reference

OpenAPI Document

Fetching the spec

GET /wp-json/wcusage/v2/openapi

Returns an OpenAPI 3.1 document generated live from the registered routes — every path, parameter, enum, default and required flag, plus both security schemes (bearer API key and Basic application password). Because it is generated from the actual route definitions, it never drifts from the implementation, and it automatically reflects which endpoints you have switched off and which add-ons are active.

The document is public by default, since the WordPress REST index already enumerates routes. Restrict it to admins with:

add_filter( 'wcusage_api_openapi_public', '__return_false' );

Amend the generated spec — to add descriptions, tags or examples — with the wcusage_api_openapi_spec filter.

What it contains

{
  "openapi": "3.1.0",
  "info": {
    "title": "Coupon Affiliates REST API",
    "description": "Affiliate data for WooCommerce: affiliates, coupons, referred orders, commission, payouts, registrations, clicks, events and reports.",
    "version": "8.2.0"
  },
  "servers": [ { "url": "https://example.com/wp-json/wcusage/v2" } ],
  "paths": {
    "/coupons/{id}/stats": {
      "get": {
        "operationId": "get_coupons_id_stats",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } },
          { "name": "from", "in": "query", "required": false, "schema": { "type": "string" } },
          { "name": "refresh", "in": "query", "required": false, "schema": { "type": "boolean", "default": false } }
        ],
        "security": [ { "bearerApiKey": [] }, { "basicAppPassword": [] } ],
        "responses": { "200": { "description": "Success." }, "401": { "description": "Authentication required or invalid." }, "403": { "description": "Insufficient permissions or scope." } }
      }
    }
  },
  "components": { "securitySchemes": { "bearerApiKey": { "type": "http", "scheme": "bearer" }, "basicAppPassword": { "type": "http", "scheme": "basic" } } }
}

Path parameters, query parameters and JSON request bodies are all derived from the routes' own argument definitions, including types, enums, defaults and required flags. Because the document is built per request, it reflects exactly what cette install exposes: endpoints switched off in the settings are absent, and so are routes belonging to add-ons that are not active.

Using it is covered under AI Agents & Assistants et No-Code Platforms — most tools that accept an OpenAPI URL will generate a working client from it directly.