Last updated
Last updated
It's time to start providing subscription features in one of your Commerce Layer markets. You want to define the available subscription frequencies for the market in question and set the subscription strategy based on which the necessary order subscriptions will be automatically generated.
You need to create and configure a subscription model and associate it with your market. To do that:
Send a POST
request to the /api/subscription_models
endpoint, setting the frequencies
and strategy
attributes.
Send a PATCH
request to the /api/markets/:id
endpoint, setting the subscription_model
relationship.
The following request creates a new subscription model that allows five subscription frequencies:
The following request associates the subscription model identified by the "AavWRUbbMQ" ID with the market identified by the "bgOEQhznoZ" ID:
The following request updates the subscription model identified by the ID "AavWRUbbMQ", adding an additional allowed frequency and changing both the default subscription strategy and auto-activate / auto-cancel behavior:
To create a new subscription model you need an token of type admin (or a custom role with the necessary permissions).
To update a market you need an token of type admin (or a custom role with the necessary permissions).
You may want to add some new frequencies to an existing subscription model or remove some of the allowed ones, change the subscription strategy or the default behavior in terms of , and more. To do that, you just need to send a PATCH
request to the /api/subscription_models/:id
endpoint, properly setting the related attributes.
Please note that any changes to an existing subscription model don't affect already generated subscriptions. The changes will apply starting from the next only. If you try to some of the already generated subscriptions in a way that's not consistent with the new changes to the subscription model you will receive a validation error.
To update a subscription model you need an token of type admin (or a custom role with the necessary permissions).
See our API reference if you need more information on how to and , or .
How to create a subscription model to set the available subscription frequencies and the subscription strategy for a market