Create a new co-term group

This endpoint lets you create a new co-term group by grouping subscriptions that share the same criteria.

The subscriptions you want to group together must share the same interval, currency, payment method, and account ID. If the subscriptions do not meet these criteria, FastSpring returns an error.

Co-Term Group Statuses

This table lists the four possible statuses for a cotermed group:

StatusDescription
CREATEDStatus for a newly created co-term group.
ESTIMATEDStatus after the POST /estimate method is called.
EXECUTEDStatus after the POST /execute method is called.
UNGROUPEDIndicates that the coterm group was deleted.

Working with displayName

When you create a co-term group, you can optionally provide a displayName in the request body for better identification. If you don't include displayName FastSpring will be generate one based on the grouping criteria .

Only one group with the same criteria combination is allowed. Attempting to create another group with the same criteria will result in a bad request.

Use Case: Create a Co-Term Group

This request creates a co-term group with a specified display name and a list of subscription IDs:

{
    "accountId": "V9dCaXJiQhmlQLKFe3sIYQ", // The unique identifier for the account.
    "coTermGroup": {
        "displayName": "some_display_name", // The optional display name for the co-term group.
        "subscriptions": [
            "0gK9THIwSmuK9Ij16UbhGw",
            "jOFqVINuSnaTRu3dpOih2Q",
            "jOFqVINuSnaTRu3dsadspOih2Q"
        ]
    }
}
{
    "action": "subscriptions.coterm.create",
    "accountId": "V9dCaXJiQhmlQLKFe3sIYQ",
    "result": "success",
    "coTermGroup": {
        "cotermGroupId": "3hMll2pFRDSpEDfEIauxRA", // The unique identifier of the co-term group.
        "displayName": "some_display_name", // The optional name of the co-term group.
        "groupingCriteria": [
            {
                "interval": [
                    {
                        "unit": "MONTH",
                        "unitCount": 1
                    }
                ],
                "currency": [
                    "EUR"
                ],
                "paymentMethod": [
                    {
                        "type": "card",
                        "ending": "*4242 (EUR)"
                    }
                ]
            }
        ],
        "subscriptions": [
            {
                "subscription": "0gK9THIwSmuK9Ij16UbhGw", // Subscription ID.
                "status": "CO_TERMED" // Status after the update.
            },
            {
                "subscription": "jOFqVINuSnaTRu3dpOih2Q",
                "status": "CO_TERMED"
            },
            {
                "subscription": "jOFqVINuSnaTRu3dsadspOih2Q",
                "status": "NOT_ELIGIBLE", // Indicates why the subscription isn't eligible for coterming.
                "error": {
                    "code": "subscription",
                    "message": "Subscription id: 'jOFqVINuSnaTRu3dsadspOih2Q' does not exist" // Error message.
                }
            }
        ]
    }
}

Partial Success Response

This response shows a partial success, where some subscriptions are eligible for co-terming while others aren't:

{
    "action": "subscriptions.coterm.create",
    "account": "V9dCaXJiQhmlQLKFe3sIYQ",
    "error": {
        "code": "subscription list validation",
        "message": "Minimum number eligible subscriptions should be at least 2" // Error indicating not enough eligible subscriptions.
    },
    "subscription": [
        {
            "subscription": "0gK9THIwSmuK9Ij16UbhGw",
            "status": "READY_FOR_CO_TERMING" // Status indicating the subscription is ready.
        },
        {
            "subscription": "jOFqVINuSnaTRu3dpOih2Q",
            "status": "NOT_ELIGIBLE",
            "error": {
                "code": "subscription",
                "message": "Subscription is part of an existing co-term group with id: 'R2nyrlQ4RYS71UfAq9lyUA'. Please remove the subscription from that group before adding to a new co-term group." // Error indicating subscription conflict
            }
        },
        {
            "subscription": "jOFqVINuSnaTRu3dsadspOih2Q",
            "status": "NOT_ELIGIBLE",
            "error": {
                "code": "subscription",
                "message": "Subscription id: 'jOFqVINuSnaTRu3dsadspOih2Q' does not exist" // Error indicating subscription not found.
            }
        }
    ]
}

Error handling

This table lists errors you may run into when working with this endpoint, as well as solutions to help you troubleshoot.

Status CodeError MessageSolution
400AccountId is not present in the requestEnsure the accountId is included in your request payload.
400Account not found with id: [account_id]Verify the accountId is correct.
400Number of subscriptions cannot exceed the maximum of [max_allowed] allowedReduce the number of subscriptions in the request to be within the allowed limit.
400Minimum number eligible subscriptions should be at least 2Ensure that at least two eligible subscriptions are included in the request.
422Subscription ID [subscription_id] is not valid to co-termVerify the subscription ID is correct and eligible for co-terming.
422Subscription is part of an existing co-term group with id: [coterm_group_id]Remove the subscription from the existing co-term group before adding it to a new one.
422Subscription Id: [subscription_id] does not have same Account with id: [account_id]Ensure all subscriptions in the request belong to the same account.
422All subscriptions must have same grouping criteria (interval, currency, and payment method type)Verify that all subscriptions have matching grouping criteria, including interval, currency, and payment method type.
500Error retrieving subscription co-term informationRetry the request or contact FastSpring support if the issue persists.
500Error handling co-term requestRetry the request or contact FastSpring support if the issue persists.
Language
Credentials
Basic
base64
:
Click Try It! to start a request and see the response here!