Skip to main content

Subscription API

There are three endpoints available for managing subscriptions from the client application: subscribing, canceling a subscription, and retrieving the list of active subscriptions for the current user.

All endpoints are executed on behalf of an authorized user — the subscription is always tied to the token used for the request.

Subscribing​

Creates a new subscription for the current user for the specified token.

The behavior depends on the type of payment account linked to the subscription in the module settings:

  • stripe, midtrans — a subscription record is created, and a payment link is returned. The subscription becomes active after a successful charge from the provider.
  • custom — the subscription is created and is immediately considered active. A payment link is not returned; payment is recorded manually by the administrator through the user card.

Canceling a Subscription​

Immediately cancels the user's active subscription.

The behavior depends on the type of payment account:

  • stripe, midtrans — the subscription is canceled through the provider's API: automatic charges are stopped, and the subscription status changes to canceled.
  • custom — cancellation through the API is not available. Such subscriptions can only be canceled by an administrator through the user card.
info

Attempting to cancel a custom subscription through the API will return an error. This is intentional: manual subscriptions are managed by the administrator, as payments for them occur outside the system.

Retrieving Active Subscriptions​

Returns an array of tokens for the active subscriptions of the current user.

A subscription is considered active if:

  • It has been successfully subscribed.
  • Its current period has not yet expired.
  • It has not been canceled (canceled).

If a subscription has expired or been canceled, its token automatically disappears from the list. This endpoint is conveniently used on the client side to check access to content: if the required subscription token is present in the array, access is granted.