Skip to main content

Coupons API

Coupons, like products, are exposed as native WordPress custom-post-type REST. The storeengine_coupon post type is registered with show_in_rest => true, rest_base => storeengine_coupon, rest_namespace => storeengine/v1, and reuses core's WP_REST_Posts_Controller. StoreEngine's coupon.php only adds validation on top.

Authentication

Uses the coupon custom-post-type capability map:

ActionCapability
Read oneread_storeengine_coupon
Edit collectionedit_storeengine_coupons
Edit oneedit_storeengine_coupon
Publishpublish_storeengine_coupons
Delete onedelete_storeengine_coupon

See Authentication.

Routes

MethodPathPurpose
GET/storeengine_couponList coupons
POST/storeengine_couponCreate a coupon
GET/storeengine_coupon/<id>Get a coupon
PUT/PATCH/storeengine_coupon/<id>Update a coupon
DELETE/storeengine_coupon/<id>Delete a coupon

All paths are relative to /wp-json/storeengine/v1. Standard WordPress collection parameters apply (per_page, page, search, status, orderby, order, include, exclude, context).

Listing and reading

curl "https://your-store.example/wp-json/storeengine/v1/storeengine_coupon?per_page=20" \
-u "admin:APPLICATION_PASSWORD"

Discover the exact field schema with an OPTIONS request against the collection.

Creating and updating

Because this is a native CPT controller, coupon meta (discount type, amount, usage limits, allowed products/customers, expiry, etc.) is set through the post meta fields registered on the coupon type. Send them in the create/update body alongside the standard post fields (title, status).

curl -X POST https://your-store.example/wp-json/storeengine/v1/storeengine_coupon \
-u "admin:APPLICATION_PASSWORD" \
-H "Content-Type: application/json" \
-d '{ "title": "SUMMER25", "status": "publish" }'

Server-side validation

coupon.php hooks rest_pre_insert_storeengine_coupon to validate the payload before the coupon is saved — in particular that any referenced customer IDs, price IDs, and product IDs actually exist. An invalid reference is rejected with a WP_Error (4xx) rather than silently persisting a broken restriction. See Extending the API for how to add your own coupon validation or fields via the same filter.