Skip to main content

Products API

Products are exposed two ways. The main CRUD is native WordPress custom-post-type REST, and a handful of auxiliary stock/inventory routes live in product.php. Both sit under the storeengine/v1 namespace.

Native CPT CRUD

The storeengine_product post type is registered with show_in_rest => true, rest_base => storeengine_product, rest_namespace => storeengine/v1, and reuses WordPress core's WP_REST_Posts_Controller. That means you get the full standard REST surface — collection parameters, OPTIONS schema discovery, and _links — for free.

StoreEngine only extends it: it filters the response (rest_prepare_storeengine_product) to add commerce fields (prices, stock, inventory visibility) and persists custom fields on insert (rest_insert_storeengine_product).

Authentication

Uses the custom-post-type capability map (not manage_options):

ActionCapability
Read oneread_storeengine_product
Edit collectionedit_storeengine_products
Edit oneedit_storeengine_product
Publishpublish_storeengine_products
Delete onedelete_storeengine_product

Routes

MethodPathPurpose
GET/storeengine_productList products
POST/storeengine_productCreate a product
GET/storeengine_product/<id>Get a product
PUT/PATCH/storeengine_product/<id>Update a product
DELETE/storeengine_product/<id>Delete a product
GET/POST/storeengine_product_categoryProduct categories (terms)
GET/POST/storeengine_product_tagProduct tags (terms)

All paths are relative to /wp-json/storeengine/v1. Because these are core controllers, they accept the standard collection parameters: per_page, page, search, slug, status, orderby, order, include, exclude, context, and taxonomy filters.

# List published products
curl "https://your-store.example/wp-json/storeengine/v1/storeengine_product?per_page=20&status=publish" \
-u "admin:APPLICATION_PASSWORD"

# Discover the exact create/update schema
curl -X OPTIONS https://your-store.example/wp-json/storeengine/v1/storeengine_product \
-u "admin:APPLICATION_PASSWORD"

Categories (storeengine_product_category) and tags (storeengine_product_tag) are registered with WP_REST_Terms_Controller under the same namespace, so they support the standard term CRUD and query parameters.

Extending the response

  • rest_prepare_storeengine_product — filter each product response object.
  • rest_insert_storeengine_product — act after a product is created/updated (StoreEngine uses this to save its custom fields).

See Extending the API.

Stock and inventory

product.php registers auxiliary routes for inventory management. These are not under storeengine_product — they live at /products/* and /inventory/* and gate on the broad edit_storeengine_products capability.

MethodPathPurpose
POST/products/<id>/stock-adjustAdjust stock (add/remove/set)
GET/products/<id>/stock-movementsStock movement history
POST/inventory/generate-codeGenerate a SKU or barcode
POST/inventory/resolve-codesResolve pasted codes to products

POST /products/<id>/stock-adjust

POST /wp-json/storeengine/v1/products/<id>/stock-adjust

ParamTypeRequiredNotes
actionstringyesOne of add, remove, set.
quantityintegeryesMinimum 0.
variation_idintegernoDefault 0; target a variation.
reasonstringnoDefault manual.
notestringnoFree-text note for the movement log.
curl -X POST https://your-store.example/wp-json/storeengine/v1/products/42/stock-adjust \
-u "admin:APPLICATION_PASSWORD" \
-H "Content-Type: application/json" \
-d '{ "action": "add", "quantity": 25, "reason": "restock", "note": "PO #883" }'

GET /products/<id>/stock-movements

GET /wp-json/storeengine/v1/products/<id>/stock-movements

Paginated stock-movement history.

ParamTypeDefaultNotes
variation_idinteger0Filter to a variation.
per_pageinteger251–100.
pageinteger1

POST /inventory/generate-code

POST /wp-json/storeengine/v1/inventory/generate-code

Generates a SKU or barcode on demand (the "Generate" buttons in the product editor).

ParamTypeRequiredNotes
typestringyessku or barcode.
namestringnoProduct name, used by the SKU pattern.
category_idintegernoCategory context for the pattern.

Returns { value: "…" }.

POST /inventory/resolve-codes

POST /wp-json/storeengine/v1/inventory/resolve-codes

Batch-resolves pasted SKUs/barcodes to product name + price (used by the Barcode Labels screen, since the product collection search only matches title/content).

ParamTypeRequiredNotes
codesstring[]yesArray of raw SKUs/barcodes.