All subscription endpoints require manage_options capability (WordPress administrator).
GET /subscriptions
List all subscriptions with pagination.
Authentication: manage_options
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
page | int | No | Page number (default: 1) |
per_page | int | No | Items per page (default: 20) |
status | string | No | Filter by status (active, suspended, cancelled, expired, pending) |
search | string | No | Search term |
Example Request:
curl https://your-site.com/wp-json/slswc/v1/subscriptions \
-H "X-WP-Nonce: YOUR_NONCE" \
--cookie "wordpress_logged_in_xxx=..."
Success Response (200):
{
"total": 45,
"total_pages": 3,
"page": 1,
"per_page": 20,
"items": [
{
"id": 1,
"order_id": 100,
"product_id": 123,
"customer_id": 5,
"license_id": 42,
"status": "active",
"gateway": "slswc_stripe_gateway",
"gateway_subscription_id": "sub_abc123",
"renewal_fee": "49.0000",
"subscription_period": "month",
"subscription_interval": 1,
"start_date": "2025-01-01 00:00:00",
"next_payment_date": "2025-02-01 00:00:00",
"auto_renew": 1,
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-15 10:30:00"
}
]
}
PUT /subscriptions
Bulk update subscription statuses.
Authentication: manage_options
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
ids | array | Yes | Array of subscription IDs to update |
status | string | Yes | New status: active, on-hold, cancelled, expired, or pending |
Example Request:
curl -X PUT https://your-site.com/wp-json/slswc/v1/subscriptions \
-H "X-WP-Nonce: YOUR_NONCE" \
-H "Content-Type: application/json" \
--cookie "wordpress_logged_in_xxx=..." \
-d '{"ids": [1, 2, 3], "status": "cancelled"}'
Success Response (200):
{
"success": [1, 2, 3],
"failed": []
}
Partial Failure Response (200):
{
"success": [1, 3],
"failed": [2]
}
Tip: Bulk status changes also update the linked license for each subscription. For example, cancelling a subscription sets its associated license to
cancelledas well.
Error Response (400):
{
"code": "invalid_data",
"message": "Valid IDs and status required.",
"data": []
}
DELETE /subscriptions
Bulk delete subscriptions.
Authentication: manage_options
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
ids | array | Yes | Array of subscription IDs to delete |
Example Request:
curl -X DELETE https://your-site.com/wp-json/slswc/v1/subscriptions \
-H "X-WP-Nonce: YOUR_NONCE" \
-H "Content-Type: application/json" \
--cookie "wordpress_logged_in_xxx=..." \
-d '{"ids": [4, 5]}'
Success Response (200):
{
"success": [4, 5],
"failed": []
}
Warning: Deleting a subscription also unlinks its associated license. The license itself is not deleted, but it will no longer be tied to any subscription for renewal purposes.
Error Response (400):
{
"code": "invalid_ids",
"message": "Valid subscription IDs required.",
"data": []
}
GET /subscriptions/counts
Get subscription counts grouped by status.
Authentication: manage_options
Example Request:
curl https://your-site.com/wp-json/slswc/v1/subscriptions/counts \
-H "X-WP-Nonce: YOUR_NONCE" \
--cookie "wordpress_logged_in_xxx=..."
Success Response (200):
{
"active": 30,
"suspended": 5,
"cancelled": 8,
"expired": 2,
"pending": 0,
"total": 45
}
GET /subscription/{id}
Get a single subscription by ID.
Authentication: manage_options
Example Request:
curl https://your-site.com/wp-json/slswc/v1/subscription/1 \
-H "X-WP-Nonce: YOUR_NONCE" \
--cookie "wordpress_logged_in_xxx=..."
Success Response (200):
{
"id": 1,
"order_id": 100,
"product_id": 123,
"customer_id": 5,
"license_id": 42,
"status": "active",
"gateway": "slswc_stripe_gateway",
"gateway_subscription_id": "sub_abc123",
"signup_fee": "0.0000",
"renewal_fee": "49.0000",
"subscription_period": "month",
"subscription_interval": 1,
"trial_period": null,
"trial_length": 0,
"start_date": "2025-01-01 00:00:00",
"next_payment_date": "2025-02-01 00:00:00",
"end_date": null,
"trial_end_date": null,
"last_payment_date": "2025-01-01 00:00:00",
"auto_renew": 1,
"grace_period_end": null,
"suspension_count": 0,
"retry_count": 0,
"cancelled_at": null,
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-15 10:30:00"
}
PUT /subscription/{id}
Update a single subscription.
Authentication: manage_options
DELETE /subscription/{id}
Delete a single subscription.
Authentication: manage_options