---
schema_version: "1"
id: fc304b0a9b157814bc9e3dccd9785eac34cc3b4047ee1ec6dd246b138693a1ec
title: Promotion Wrapper API
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/comms-t-promotion-wrapper-api.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-promotion-wrapper-api.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: abafeb34a2377b2dfff098a00c2159f3d52bf85775ac683173ac6c827a11b913
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Promotion Wrapper API

The Promotion Wrapper API takes the promotion Id (offerId) as input in the URI and populates the promotion wrapper in the cache. You must execute this API for each Promotion offerId that you received in the response of the Catalog Profile API. The promotion Wrapper API is required if you have promotions.

If you are not using any promotions in your catalog, you do not need to perform this API call.

You can obtain the offerId required in the URI of this API from the apiResponse.data.catalogProductRelationDetails.Promotion node in the response body of the [Catalog Profile API](https://developer.salesforce.com/docs/industries/cme/guide/comms-t-catalog-profile-api.md).

## Precondition

You must first run the the [Catalog Profile API](https://developer.salesforce.com/docs/industries/cme/guide/comms-t-catalog-profile-api.md) to obtain the offerId required in the request body of this API.

## URI

/services/apexrest/{namespace}/v3/admin/offers/{offerId}/promotionWrapper

## HTTP Method

GET

## URI Parameters

If you specify just one of these two parameters, it follows the behavior described in the table below and accepts your defined time for the parameter you specified. If you are using one or both parameters, you must specify them with the same values for all of the Populate Cache APIs in this sequence.

| Parameter          | Example             | Default                         | Optional/Required | Notes                                                                                                                                                                                                                                                                                                                              |
| ------------------ | ------------------- | ------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| effectiveStartTime | 2001-07-04T12:08:56 | Current date and time           | Optional          | effectiveStartTime is the time that you want your cached catalog entries to be effective. It should be in the UTC date-time format. Your effectiveStartTime must occur after the current time for which you are executing the Populate Cache APIs or you will receive an error message.                                            |
| expirationTime     | 2001-07-04T12:08:56 | effectiveStartTime + TimeToLive | Optional          | expirationTime is the time that you want your cached catalog entries to expire. It should also be in the UTC date-time format. Your expirationTime must occur after your effectiveStartTime or you receive an error message. TimeToLive is a custom setting created in CPQ Configuration Setup. It has a default value of 30 days. |

Here is an example of how to pass the URI parameters:

```nolang
GET /services/apexrest/vlocity_cmt/v3/admin/catalogs/AS-Test-Catalog/promotionWrapper?effectiveStartTime=2021-07-04T12:08:56&expirationTime=2021-08-04T12:08:56
```

## Remote API

This is an example of how you invoke the API using Apex:

```nolang
String methodName;

Map<String, Object> input = new Map<String, Object>();
Map<String, Object> output = new Map<String, Object>();
Map<String, Object> options = new Map<String, Object>();

// Setting remote parameters
methodName = 'getPromotionWrapper';
input.put('methodName', methodName);        // required
input.put('apiName', 'CMPromotionWrapper'); // required
input.put('offers', 'a3S4W000002aAUhUAM');  // required
input.put('effectiveStartTime', null);      // optional
input.put('expirationTime', null);          // optional
input.put('requestURL', '/v3/admin/offers/01t4W00000BgaKvQAJ/promotionWrapper'); // required

//remote action invocation
vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
appHandler.invokeMethod(methodName, input, output, options);
```

## Parallel Invocation

You can run this API in parallel for multiple offers. For example, if there are 10 catalogs (Catalog1, Catalog2..Catalog 10) and each catalog has 100 offers, you can run this API for all 1,000 offers in parallel threads.

```nolang
THREAD1 -  GET /services/apexrest/{namespace}/v3/admin/offers/offer1/promotionwrapper
THREAD2 -  GET /services/apexrest/{namespace}/v3/admin/offers/offer2/promotionwrapper
......
THREAD10 -  GET /services/apexrest/{namespace}/v3/admin/offers/offer10/promotionwrapper
THREAD11 -  GET /services/apexrest/{namespace}/v3/admin/offers/offer11/promotionwrapper
......
THREAD100 -  GET /services/apexrest/{namespace}/v3/admin/offers/offer/promotionwrapper
```

## HTTP Headers

| Header       | Description      |
| ------------ | ---------------- |
| Content-Type | application/json |

## Response Body

This example contains promotion offer IDs.

```
{
  "cacheKey": "demopromo",
  "apiResponse": {
    "promotion": {
      "attributes": {
        "type": "vlocity_cmt__Promotion__c",
        "url": "/services/data/v52.0/sobjects/vlocity_cmt__Promotion__c/a3S4W000002aAUhUAM"
      },
      "Id": "a3S4W000002aAUhUAM",
      "Name": "demopromo",
      "vlocity_cmt__Code__c": "demopromo",
      "vlocity_cmt__IsActive__c": true,
      "vlocity_cmt__IsOrderable__c": true,
      "vlocity_cmt__PriceListId__c": "a3C4W00000P3RfDUAV"
    },
    "promoItemWrappers": [
      {
        "promoItem": {
          "attributes": {
            "type": "vlocity_cmt__PromotionItem__c",
            "url": "/services/data/v52.0/sobjects/vlocity_cmt__PromotionItem__c/a3R4W000005M6E1UAK"
          },
          "Id": "a3R4W000005M6E1UAK",
          "Name": "PromotionItem__ca3F6g0000001ugP",
          "vlocity_cmt__ActionType__c": "Add/Update",
          "vlocity_cmt__IsActive__c": true,
          "vlocity_cmt__IsUndoable__c": false,
          "vlocity_cmt__MaxQuantity__c": 4,
          "vlocity_cmt__MinQuantity__c": 1,
          "vlocity_cmt__ProductHierarchyPath__c": "01t4W00000BgKvFQAV",
          "vlocity_cmt__ProductId__c": "01t4W00000BgKvFQAV",
          "vlocity_cmt__PromotionId__c": "a3S4W000002aAUhUAM",
          "vlocity_cmt__Quantity__c": 1,
          "vlocity_cmt__UpdateScope__c": "Update Item Only"
        },
        "lastRealParentHierarchyPath": null,
        "appliedPromoItemWrappers": [
          {
            "productHierarchyPath": "01t4W00000BgKvFQAV",
            "lineItem": {
              "attributes": {
                "type": "OrderItem"
              },
              "vlocity_cmt__Product2Id__c": "01t4W00000BgKvFQAV",
              "PricebookEntryId": "01u4W000009zh0VQAQ",
              "vlocity_cmt__ProvisioningStatus__c": "New",
              "vlocity_cmt__Action__c": "Add",
              "vlocity_cmt__LineNumber__c": "0001",
              "vlocity_cmt__CurrencyPaymentMode__c": "Currency",
              "vlocity_cmt__InCartQuantityMap__c": null,
              "vlocity_cmt__SequenceNumber__c": 1,
              "UnitPrice": 0,
              "Quantity": 1,
              "vlocity_cmt__ProductHierarchyPath__c": "01t4W00000BgKvFQAV",
              "vlocity_cmt__JSONAttribute__c": null
            },
            "compiledAttributeOverride": null,
            "appliedPromoItem": {
              "attributes": {
                "type": "vlocity_cmt__OrderAppliedPromotionItem__c"
              },
              "vlocity_cmt__AppliedAction__c": "Add",
              "vlocity_cmt__MaxQuantity__c": 4,
              "vlocity_cmt__MinQuantity__c": 1
            },
            "adjustments": [
              {
                "attributes": {
                  "type": "vlocity_cmt__OrderPriceAdjustment__c"
                },
                "vlocity_cmt__PromotionId__c": "a3S4W000002aAUhUAM",
                "vlocity_cmt__Action__c": "Add",
                "vlocity_cmt__PriceListEntryId__c": "a3B4W00000MsXI7UAN",
                "vlocity_cmt__AdjustmentValue__c": -11,
                "vlocity_cmt__Amount__c": null,
                "vlocity_cmt__AddedByUserId__c": "0054W00000BUE7wQAH",
                "vlocity_cmt__PricingElementGlobalKey__c": "40ebefe6-d244-15fa-9f3a-0a0f10a42aec",
                "vlocity_cmt__PricingElementVersionId__c": "a3E4W00000KmbYxUAJ",
                "vlocity_cmt__PricingVariableId__c": "a3I4W000003Bj1OUAS",
                "vlocity_cmt__Source__c": "Promotion",
                "vlocity_cmt__TimePlanId__c": null,
                "vlocity_cmt__TimePolicyId__c": null
              }
            ]
          }
        ]
      }
    ],
    "id": "a3S4W000002aAUhUAM",
    "code": "demopromo",
    "appliedPromo": {
      "attributes": {
        "type": "vlocity_cmt__OrderAppliedPromotion__c"
      },
      "vlocity_cmt__Action__c": "Add",
      "vlocity_cmt__PromotionId__c": "a3S4W000002aAUhUAM",
      "vlocity_cmt__PromotionId__r": {
        "attributes": {
          "type": "vlocity_cmt__Promotion__c",
          "url": "/services/data/v52.0/sobjects/vlocity_cmt__Promotion__c/a3S4W000002aAUhUAM"
        },
        "Id": "a3S4W000002aAUhUAM",
        "Name": "demopromo",
        "vlocity_cmt__Code__c": "demopromo",
        "vlocity_cmt__IsActive__c": true,
        "vlocity_cmt__IsOrderable__c": true,
        "vlocity_cmt__PriceListId__c": "a3C4W00000P3RfDUAV"
      }
    }
  },
  "errorCode": "INVOKE-200",
  "error": "OK"
}
```

## HTTP Response Codes

| Code | Description           |
| ---- | --------------------- |
| 200  | OK                    |
| 500  | Internal Server Error |
