Skip to content

REST API

All endpoints are registered under the WordPress REST API namespace defined in RestController. Authentication uses the standard WP REST nonce (wp_rest), passed from PHP to the Vue components via the nonce attribute.

Capability required for all endpoints: edit_shop_order.


Cancellation reasons (global list)

GET /cancellation-reasons

Returns all cancellation_reason posts available for selection.


Subscription cancellation reasons

GET /subscription/{subscription_id}/cancellation-reasons

Returns all cancellation reason entries recorded for a subscription.

Response (array):

[
  {
    "id": 12,
    "subscription_id": 456,
    "date": "2024-04-22 10:00:00",
    "reason_id": 99,
    "title": "Too expensive",
    "slug": "too-expensive"
  }
]

POST /subscription/{subscription_id}/cancellation-reasons

Records one or more cancellation reasons for a subscription.

Body:

{ "reason_post_ids": [99, 101] }

Response: array of inserted reason objects (same shape as GET).


Subscription item reason

GET /subscription/{subscription_id}/cancellation-reasons/{id}

Returns a single cancellation reason entry by its row ID.


Pause

POST /subscription/{subscription_id}/pause

Puts the subscription on hold until a given date (auto_reactivation). Sets the auto_reactivation date and aligns the next payment to the day after the pause ends.


Force-activate

POST /subscription/{subscription_id}/force-activate

Force-activates a subscription that is on hold.