---
schema_version: "1"
id: 1ed6cd43918aaa96d295e528d28e02b4f0c481a362f7318483263b739a604c84
title: Contains Offer API
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/comms-t-contains-offer-api.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-contains-offer-api.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 77598233a4b977c4297426bb44ba05c5c760e5ad71e0cdabc1c671dc6d9c04c4
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Contains Offer API

Running the Contains Offer API is optional.

The Contains Offer API finds all the products and promotions that contain a given offer in their hierarchy and also qualifies under the given context combination. This API also paginates and sorts the list of products and promotions and caches the result. This API adds the required action nodes to the responses if there are remaining pages after the current page.

You can obtain the ctxEligibilityCacheKey required in the request body of this API from the apiResponse.eligibilityContextKey node in the response body of the [Context Eligibility API](https://developer.salesforce.com/docs/industries/cme/guide/comms-t-context-eligibility-api.md).

You can obtain the offerId required in the URI of this API from the apiResponse.data.catalogProductRelationDetails.Product node in the response body of the [Catalog Profile API](/docs/commerce/commerce/guide/comms-t-catalog-profile-api.html).


## Preconditions

You must first run the [Context Eligibility API](https://developer.salesforce.com/docs/industries/cme/guide/comms-t-context-eligibility-api.md) to obtain the offerId required in the request body of this API.

## URI

/services/apexrest/{namespace}/v3/admin/catalogs/{catalogCode}/offers/{offerId}/containsoffer

## HTTP Method

POST

## 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/containsoffer?effectiveStartTime=2021-07-04T12:08:56&expirationTime=2021-08-04T12:08:56

```

## Request Body Parameters

| Parameter              | Data type | Description                                                                                                                               | Default                                                             | Optional/Required |
| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ----------------- |
| ctxEligibilityCacheKey | String    | Cache key pointing to the context eligibility record whose context combination calculates the eligibility of offers returned by this API. | Null, which produces a response for the default context combination | Optional          |

## Sample Request Body

This is a sample request for the ctxEligibilityCacheKey.

```
{
    "ctxEligibilityCacheKey": "200b3622d38bb67369192ced32fbda5c"
}
```

## Remote API

This is an example of how you invoke the API using Apex:

```nolang
String methodName;
String requestBodyJSON;
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 = 'getContainingOffers';
requestBodyJSON = '{"ctxEligibilityCacheKey":"02ab891802e4df7a0f68a0f998a55879"}';
input.put('apiName', 'CMContainsOffer');    // required
input.put('methodName', methodName);        // required
input.put('catalogCode', 'TestCatalog');    // required
input.put('offerId', '01t4x000000x269AAA'); // required
input.put('requestBody', requestBodyJSON);  // required
input.put('effectiveStartTime', null);      // optional
input.put('expirationTime', null);          // optional

//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 catalogs, offers, and context combinations. For example, there may be 100 products (Product1, Product2 ... Product100) and 100 context combinations (Combo1, Combo2 ... Combo100) that you can run in parallel.

```nolang
THREAD1 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product1/containsoffer
THREAD2 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product1/containsoffer
......
THREAD100 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product1/containsoffer
THREAD101 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product2/containsoffer
......
THREAD10000 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product100/containsoffer
```

## HTTP Headers

| Header       | Description      |
| ------------ | ---------------- |
| Content-Type | application/json |

## Response Body

This example shows products and promotions that contain a given offer in their hierarchy and also qualifies under the given context combination.

```
[
  {
    "contextKey": "d187cb8118349e3e32460393c62e44e1",
    "result": {
      "Promotion": [
        "a3T4x000000l39BEAQ"
      ],
      "Product": [
        "01t4x000000wx2vAAA",
        "01t4x000000wx2wAAA"
      ]
    }
  }
]
```

## HTTP Response Codes

| Code | Description           |
| ---- | --------------------- |
| 200  | OK                    |
| 500  | Internal Server Error |
