MATIH Platform is in active MVP development. Documentation reflects current implementation status.
8. Platform Services
Subscriptions

Subscriptions

The SubscriptionManagementService manages the complete subscription lifecycle for tenants. Subscriptions link tenants to pricing plans and control their access to platform features and resources. The service supports plan changes, pausing, resuming, cancellation, discounts, and credit management.


Subscription Endpoints

Get Active Subscription

Endpoint: GET /api/v1/billing/tenants/:tenantId/subscription

List All Subscriptions

Endpoint: GET /api/v1/billing/tenants/:tenantId/subscriptions

Create Subscription

Endpoint: POST /api/v1/billing/tenants/:tenantId/subscriptions

ParameterTypeDescription
planIdUUIDPlan to subscribe to
stripeCustomerIdStringOptional Stripe customer ID
curl -X POST "http://localhost:8087/api/v1/billing/tenants/550e8400/subscriptions?planId=plan-pro" \
  -H "Authorization: Bearer ${TOKEN}"

Plan Management

Change Plan

Endpoint: POST /api/v1/billing/subscriptions/:subscriptionId/change-plan

ParameterTypeDescription
newPlanIdUUIDTarget plan ID

Handles prorated billing for mid-cycle plan changes. Syncs with Stripe if a Stripe subscription exists.

List Available Plans

Endpoint: GET /api/v1/billing/plans

Get Plan Details

Endpoint: GET /api/v1/billing/plans/:planId


Subscription Lifecycle

Cancel

Endpoint: POST /api/v1/billing/subscriptions/:subscriptionId/cancel

ParameterTypeDefaultDescription
immediatelybooleanfalseCancel immediately or at period end
reasonStringnullCancellation reason

Reactivate

Endpoint: POST /api/v1/billing/subscriptions/:subscriptionId/reactivate

Reactivates a cancelled subscription before its end date.

Pause

Endpoint: POST /api/v1/billing/subscriptions/:subscriptionId/pause

Temporarily suspends billing and access without cancelling.

Resume

Endpoint: POST /api/v1/billing/subscriptions/:subscriptionId/resume

Resumes a paused subscription.


Discounts and Credits

Apply Discount

Endpoint: POST /api/v1/billing/subscriptions/:subscriptionId/discount

ParameterTypeDescription
discountPercentBigDecimalDiscount percentage (0-100)
endDateLocalDateDiscount expiration date

Add Credits

Endpoint: POST /api/v1/billing/subscriptions/:subscriptionId/credits

ParameterTypeDescription
amountBigDecimalCredit amount in base currency
reasonStringReason for credit (optional)

Billing Preview

Preview Current Period

Endpoint: GET /api/v1/billing/tenants/:tenantId/billing/preview

Shows what the current billing period invoice would look like based on usage so far.

Monthly Estimate

Endpoint: GET /api/v1/billing/tenants/:tenantId/billing/estimate

Projects the estimated monthly total based on current usage trends.

{
  "estimatedMonthlyTotal": 2450.00
}