WPSubscription Pro includes REST API support for performing subscription actions programmatically. This feature allows developers and automation tools to manage subscriptions remotely using secure API requests.


API Settings

To enable and access REST API functionality:

  1. Go to WPSubscription > Settings > API Settings

  2. Check Enable REST API endpoints for subscription actions

  3. Copy the REST API Endpoint URL provided

  4. Use or regenerate the API Key for authentication

Keep your API key secure. It must be included in every API request.
Screenshot from 2025-06-02 16-13-57.png

Available Subscription Actions

Each API request must be made as a POST request to:

/wp-json/wpsubscription/v1/action

Every request must include:

  • action: Type of operation to perform (e.g. cancel_subscription)

  • subscription_id: ID of the subscription to target

  • api_key: Your plugin-generated API key

  • data: Optional additional info (e.g. reason for cancellation)

Supported Actions

Action

Description

Example Use Case

cancel_subscription

Cancels an active subscription

Trigger from CRM when customer churns

pause_subscription

Puts a subscription on hold (pending)

Vacation pause or payment issue

resume_subscription

Reactivates a paused subscription

Resume billing after pause

change_status

Change status to: active, pending, cancelled, expired

Sync with external system or admin rule

reactivate_subscription

Reactivate a cancelled subscription

Manual override from support or CRM

expire_subscription

Mark subscription as expired manually

Time-limited plans or force expiry

trial_end

Trigger custom logic at end of free trial

Convert free to paid in other systems

payment_failed

Log or react to failed renewal attempts

Dunning workflows, CRM alert

verify_api

Verify API key validity

Test connection from external tool


Sample JSON Request

Screenshot from 2025-06-02 16-14-17.png

Here’s how to resume a subscription via Postman or external system:

POST /wp-json/wpsubscription/v1/action
{
"action": "resume_subscription",
"subscription_id": 168,
"api_key": "your-api-key",
"data": {
"reason": "Customer request"
}
}

Sample JSON Success Response

{
"status": "success",
"message": "Subscription action \"resume_subscription\" processed successfully",
"subscription_id": 168
}

Logs & Debugging

All REST API activity is logged inside WooCommerce > Status > Logs under the log file named subscription-pro-api-YYYY-MM-DD.

Screenshot from 2025-06-02 16-13-36.png

Each log includes:

  • Timestamp

  • Action type

  • Subscription ID

  • Status (processed or error)

  • Payload data (if any)


Authentication & Security

  • All API calls require the API key for access.

  • API keys can be regenerated anytime from the API settings.

  • Keys should be securely stored and not exposed in public requests.


Error Handling

REST responses will return appropriate error codes for invalid input or failure states.

Error Code

Meaning

rest_forbidden

Invalid or missing API key

not_found

Subscription ID not found

invalid_status

Provided status value is invalid

action_failed

General action failure

Always verify that your request body includes:

  • Valid API key

  • Correct action name

  • Valid subscription ID