Skip to content

REST API

The documents attached to products are readable over the REST API, so a mobile app, a headless front end, a migration script, or an audit can reach the data without opening the database.

Namespace: wcdp/v1. Both routes are read only.

A caller must be able to edit products or edit posts (edit_products or edit_posts). Otherwise the route returns a 401 or 403. The routes never bypass WordPress permissions.

GET /wp-json/wcdp/v1/documents

Query parameters:

  • page (integer, default 1)
  • per_page (integer, default 20, maximum 100)
  • problems (boolean, default false) returns only products that have a link which cannot preview

The response is an array of products. Pagination is returned in the X-WP-Total and X-WP-TotalPages response headers.

GET /wp-json/wcdp/v1/documents/<product_id>

Returns a 404 if the ID is not a product.

Each product includes its product_id, name, edit_link, a documents array, and a problems array of URLs that will not preview. Each document reports its name, url, detected service (or null), the chosen renderer (pdfjs or google), and a previewable boolean.