The WebberZone Knowledge Base plugin exposes selected functionality via the WordPress REST API.

All endpoints live under the namespace wzkb/v1 and therefore share the base path:

https://example.com/wp-json/wzkb/v1/

Replace https://example.com with your site’s domain.

Authentication & Permissions

  • The API piggybacks on WordPress capabilities. Standard WordPress authentication mechanisms (cookies for logged-in sessions, app passwords, basic auth plugins, etc.) all work.
  • All REST responses follow standard WordPress structures with code, message, and data.
  • Cache lifetime is 300 seconds. Cache busts automatically on KB content or taxonomy changes, and when the cache is cleared from Knowledge Base → Tools or the settings page.
  • When used in a headless context, ensure Gutenberg meta _wzkb_product_ids and _wzkb_section_ids are synced.
  • Permissions can be customized per route via the wzkb_rest_route_permissionOpens in a new window filter.
  • By default, all read-only routes are public. Use the permission filter below to restrict access.

Permission overrides

Developers can override route-level visibility without replacing the controller. The filter receives the route slug and the default public flag (true for read endpoints).

add_filter(
    'wzkb_rest_route_permission',
    static function ( $permission, $route_slug, $is_public ) {
        if ( 'search' === $route_slug ) {
            // Require logged-in users with the custom capability.
            return 'read_private_kb';
        }

        // Fall back to default behavior.
        return $permission;
    },
    10,
    3
);

Return values:

  1. bool – grant/deny outright.
  2. string – capability checked via current_user_can().
  3. callable – custom logic returning boolean.

Multi-product prerequisite

The Sections endpoint requires multi-product mode in Knowledge Base. Enable Knowledge Base → Settings → General → Enable Multi-Product Mode. If disabled, the Sections endpoint returns a wzkb_rest_sections_disabled error.

TranslatePress translation

Since Knowledge Base 3.1.5, REST responses under wzkb/v1 are translated when TranslatePress is active. TranslatePress never runs its page output buffer for REST requests, so the plugin translates each response directly before it is sent.

Request a language with the lang parameter. It accepts a TranslatePress locale (for example fr_FR) or its URL slug (for example fr):

GET https://example.com/wp-json/wzkb/v1/knowledgebase?lang=fr

When lang is omitted, the plugin checks the current request URL and then a referring URL on the same host. Public requests can use published languages. Users with the TranslatePress translating capability can also request configured unpublished languages. An invalid language or the default language leaves the response untranslated.

The optional lang argument is available on all six endpoints below. It must be a string no longer than 20 characters. This response-translation parameter is specific to TranslatePress; WPML and Polylang use their own WordPress translation integrations.

Override the resolved language with the wzkb_trp_rest_language filter:

add_filter(
    'wzkb_trp_rest_language',
    static function ( string $language, $request ): string {
        // Force all Knowledge Base REST responses to render in Spanish.
        return 'es_ES';
    },
    10,
    2
);
ParameterTypeDescription
$languagestringLanguage code resolved from the request.
$requestWP_REST_Request|nullREST request that produced the response.

Return the target language code, or an empty string to keep the default language. Content fields such as title, excerpt, content, name, and description are translated, and link and permalink URLs are rewritten to the target language.

Use wzkb_trp_rest_translatable_keys to change which response fields are translated. The filter receives an array with content and url lists. The defaults are html, title, excerpt, content, name, and description for content, and link and permalink for URLs. The plugin leaves guid unchanged because it is an identifier.

Endpoints

GET /wzkb/v1/sections

Fetches Knowledge Base sections (wzkb_category terms) filtered by one or more product IDs, preserving parent/child relationships for hierarchical rendering.

ParameterTypeRequiredDescription
productsstringyesComma-separated list of wzkb_product term IDs. Example: 173,178

Request example

GET https://example.com/wp-json/wzkb/v1/sections?products=173,178

Successful response

[
  {
    "id": 201,
    "name": "Advanced",
    "parent": 0,
    "product": 173
  },
  {
    "id": 202,
    "name": "More advanced",
    "parent": 201,
    "product": 173
  },
  {
    "id": 310,
    "name": "Getting Started",
    "parent": 0,
    "product": 178
  }
]
  • id: Section term ID.
  • name: Section name.
  • parent: Parent term ID (0 when top-level).
  • product: Associated product ID pulled from product_id term meta (0 when unassigned).

Error responses

HTTP CodeError codeReason
400wzkb_rest_sections_disabledMulti-product mode is disabled.
401 / 403rest_forbiddenUser lacks the capability granted via the wzkb_rest_route_permission filter.

GET /wzkb/v1/knowledgebase

List published Knowledge Base posts with optional filtering.

ParameterTypeRequiredDescription
per_pageintnoResults per page (1–50). Default: 10.
pageintnoPage number. Default: 1.
searchstringnoFree-text search term.
productintnoFilter by wzkb_product term ID.
sectionintnoFilter by wzkb_category term ID.

Response

[
  {
    "id": 123,
    "title": "How to configure caching",
    "slug": "configure-caching",
    "excerpt": "Configure caching in three easy steps…",
    "permalink": "https://example.com/kb/configure-caching/",
    "products": [{ "id": 5, "name": "Pro", "slug": "pro" }],
    "sections": [{ "id": 18, "name": "Setup", "slug": "setup" }],
    "date": "2025-10-21T09:30:00",
    "modified": "2025-10-23T14:05:00"
  }
]

Headers: X-WP-Total (total posts) and X-WP-TotalPages.

GET /wzkb/v1/knowledgebase/{id}

Return a single Knowledge Base post including full content when published.

GET /wzkb/v1/products

List all Knowledge Base products.

[
  {
    "id": 5,
    "name": "Contextual Related Posts",
    "slug": "contextual-related-posts",
    "description": "CRP-specific documentation.",
    "count": 34
  }
]

Lightweight search endpoint wrapping Knowledge Base queries.

ParameterTypeRequiredDescription
querystringyesSearch keywords (min 2 characters).
productintnoFilter by product term ID.
sectionintnoFilter by section term ID.
limitintnoResults to return (1–50). Default: 10.

limit applies only to this endpoint. The number of results on the knowledge base search results page is set separately with the wzkb_search_posts_per_page filter (default 12), which does not override limit:

add_filter( 'wzkb_search_posts_per_page', fn() => 20 );

Fetch related articles for a given Knowledge Base post.

ParameterTypeRequiredDescription
post_idintyesBase Knowledge Base post ID.
limitintnoNumber of related items (1–20).

POST /wzkb/v1/ask

Knowledge Base Pro 3.2.0 or later, on WordPress 7.0 or later, with Ask the Docs enabled. Answer a visitor’s question from the knowledge base using the connected AI provider.

ParameterTypeRequiredDescription
questionstringyesThe question (3–300 characters).

This route is meant for your site’s own pages. It refuses requests from other origins and from bots. See the Ask the Docs developer reference for the response fields, errors and filters.

Using the API in Gutenberg

The custom Gutenberg panel (includes/admin/js/editor-sections-panel.js) consumes /sections to show product-aware section lists. Other clients (mobile apps, headless front ends, internal tools) can consume the same endpoint, provided they authenticate and the site is running in multi-product mode.

Support

The above REST API is a preliminary implementation. If you notice any issue, have any usage questions or to suggest additional endpoints, please open a ticket.

See also

Was this article helpful?