Follow and complete a Learn MOAR Summer ’22 trailmix for admins or developers by July 31, 2022, 11:59 pm PT to earn a special community badge and enter for a chance to win one of five $200 USD Salesforce Certification vouchers. Restrictions apply. Learn how to participate and review the Official Rules by visiting the Trailhead Quests page.

Introducing Subscription Management

With Subscription Management available Summer ‘22, Salesforce empowers businesses to manage and monetize their business subscriptions across any self-service channel. This new feature enables you to automate the process of billing, invoicing, and collecting payments for subscription products and one-time sales. It also leverages Einstein AI capabilities to evaluate the risk of late payments and maximize revenue.

Subscription Management is powered by some new standard objects on Salesforce core and headless API-first design. The logic for the various processes involved in the subscription is in the APIs. This decouples it from the application layer and allows flexibility for developers to use these APIs with the front-end of their choice, including websites, Slack, and mobile apps.

The API supports common use cases for managing recurring subscription sales, including:

  • Calculating prices and price adjustments
  • Implementing a “buy now” experience (checkout) across all self-service channels
  • Canceling and renewing a subscription
  • Handling billing and payments

Get started with the Subscription Management API

To get started, you will need a Salesforce org configured with the following:

  • Product data
  • Pricing and invoicing information
  • A payment gateway
  • A tax provider
  • Optionally, a connected app for OAuth 2.0 implementation. You’ll need this only if you are using Subscription Management REST API’s to integrate with systems outside of Salesforce core.

You can find more information about the data model for Subscription Management, and how to configure the org to enable this functionality, in Salesforce documentation (available soon).

How to work with the Subscription Management API

The Subscription Management API is a collection of synchronous and asynchronous APIs. These APIs can be accessed securely using tokens obtained via OAuth 2.0 authorization flow using connected apps.

You can chain one or more of these APIs easily to accomplish end-to-end functionality, such as creating a buy now solution (checkout experience) that lets customers select and purchase products using a preconfigured payment method.

The diagram below shows an example of how to chain the REST endpoints of Subscription Management APIs to create a “buy now” solution. See the reference guide to learn more about each of the steps involved.


For Asynchronous APIs, a platform event is published whenever the process is completed. A subscriber can then subscribe to it and listen in one of several ways (see docs).

Invoking the Subscription Management API

You can invoke Subscription Management APIs using one or a combination of tools.

Salesforce Flows

There are different flow invocable actions provided to invoke various Subscription Management APIs. See the docs for an example flow template for a “buy now” solution.

The diagram below shows how to use the Flow pause element to wait for the completion events of asynchronous actions (platform events). In this example, when invoice creation is complete, then an invoice processed event is published.

Apex and LWC

You can call invocable actions via Apex and subscribe to the completion events (platform events) of asynchronous actions via triggers.

You can also build your own LWC components as a front-end to work with the Subscription Management APIs.

ProTip: Leverage the Lightning EMP API base component to subscribe to the completion events (platform events) of an asynchronous action.

REST API

When integrating to systems outside of Salesforce core, you can simply invoke REST APIs of Subscription Management using the tools and language of your choice. Easily subscribe to the completion events of asynchronous APIs via the cometD client available in various popular open source languages.

The example below shows an HTTP request body that creates an order for an evergreen subscription.

We have a couple of assumptions: 1) the subscription costs $10/month and starts January 1, 2021, with an estimated sales tax of 7.25%, and 2) the following information is configured for the records that are referenced in the request.

  • The account has a billing address and shipping address
  • The price book entry is configured for an evergreen product
  • The default billing treatment and tax treatment is configured for the product
  • The default payment term is configured
POST /services/data/v55.0/composite
{
    "allOrNone": true,
    "compositeRequest": [
        {
            "method": "POST",
            "url": "/services/data/vXX.0/sobjects/Order",
            "referenceId": "refOrder",
            "body": {
                "AccountId": "001RM00000XXXXX",
                "EffectiveDate": "2022-01-01",
                "Pricebook2Id": "01sRM00000XXXXX",
                "BillToContactId": "003xx00000XXXXX",
                "Status": "Draft"
            }
        },
        {
            "method": "POST",
            "url": "/services/data/vXX.0/sobjects/AppUsageAssignment",
            "referenceId": "refAppTag",
            "body": {
                "AppUsageType": "SubscriptionManagement",
                "RecordId": "@{refOrder.id}"
            }
        },
        {
            "method": "POST",
            "url": "/services/data/vXX.0/sobjects/OrderAction",
            "referenceId": "refOrderAction",
            "body": {
                "OrderId": "@{refOrder.id}",
                "Type": "New Sale"
            }
        },
        {
            "method": "POST",
            "url": "/services/data/vXX.0/sobjects/OrderItem",
            "referenceId": "refOrderItem",
            "body": {
                "OrderId": "@{refOrder.id}",
                "OrderActionId": "@{refOrderAction.id}",
                "PricebookEntryId": "01uRM00000XXXXX",
                "ServiceDate": "2022-01-01",
                "Quantity": 1.0,
                "UnitPrice": 10.0,
                "NetUnitPrice": 10.0,
                "TotalLineAmount": 10.0,
                "PeriodBoundary": "Anniversary",
                "BillingFrequency2": "Monthly"
            }
        },
        {
            "method": "POST",
            "url": "/services/data/vXX.0/sobjects/OrderItemTaxLineItem",
            "referenceId": "refTaxLineItem",
            "body": {
                "OrderItemId": "@{refOrderItem.id}",
                "Name": "Sales Tax",
                "Amount": 0.73,
                "Type": "Estimated",
                "TaxEffectiveDate": "2022-01-01"
            }
        }
    ]

You can learn more about the various Subscription Management APIs via the documentation. Note that the docs provide sample code in various languages, including Java, Javascript, and Python, that show you how to invoke the APIs.

Helpful references

Learn MOAR this week

Product Managers and the Developer Relations team are back to share the latest features and functionality in Summer ‘22. To help you develop faster, new content from Developer Relations will cover their favorite new features. Also, be sure to check out Release Readiness Live on Friday, May 20, 2022 at 9:00 a.m. PST. Lastly, keep an eye on the Salesforce Developers blog every day this week for more posts on Summer ’22!

To learn even more, check out the Summer ’22 trailmix.

About the author

Mohith Shrivastava works as a Lead Developer Advocate at Salesforce. He is currently focusing on APIs & Integrations and Developer Tooling. You can follow him via Twitter @msrivastav13.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS