---
schema_version: "1"
id: 89335cb29f31ad112cf0991ef4ccdf4c0272478a5fcb8dd07f73f383a970ace0
title: Context Eligibility API
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/comms-t-context-eligibility-api.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-context-eligibility-api.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b4c7e50d99896a3cc0206a9b0c423c5f1b6fccb2ada2a9cc7a986bf7772bb929
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Context Eligibility API

The Context Eligibility API identifies context combinations of products and promotions that are eligible for each of the combinations. The API accepts cacheKey as the request body parameter for Context Eligibility. Context Eligibility is an output parameter consisting of generated context combinations.

For each context combination in the output of the Context Combinations API, there is one context eligibility in the API response that contains qualifying products and promotions for that context combination.

You can obtain the cacheKey required in the request body of this API from the cacheKey node in the response body of the [Context Combinations API](https://developer.salesforce.com/docs/industries/cme/guide/comms-t-context-combinations-api.md).

## Precondition

You must first run the [Context Combinations API](https://developer.salesforce.com/docs/industries/cme/guide/comms-t-context-combinations-api.md) to obtain the cacheKey required in the request body of this API.

## URI

/services/apexrest/{namespace}/v3/admin/catalogs/{catalogCode}/contexteligibility

## 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/contexteligibility?effectiveStartTime=2021-07-04T12:08:56&expirationTime=2021-08-04T12:08:56
```

## Request Body Parameters

| Parameter | Data Type | Description                                                                                                                                                                                                                                                   | Default | Optional/Required |
| --------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ----------------- |
| cacheKey  | String    | Cache key pointing to the record containing combinations for the context eligibility that needs populating. You can obtain the cacheKey required in the request body of this API from the cacheKey node in the response body of the Context Combinations API. | N/A     | Required          |

## Sample Request Body

This is a sample request for a cacheKey.

```nolang
{
    "cacheKey": "1f1d5f350cb0efd232086e274ef00647"
}
```

## 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 = 'getEligibility';
requestBodyJSON = '{"cacheKey":"1f1d5f350cb0efd232086e274ef00647"}';
input.put('apiName','CMContextEligibility'); //required
input.put('catalogCode', 'TestCatalog');     //required
input.put('effectiveStartTime', null);       //optional
input.put('expirationTime', null);           //optional
input.put('requestBody', requestBodyJSON);   //required
input.put('methodName',methodName);          //required
input.put('requestURL', '/v3/admin/catalogs/TestCatalog/contexteligibility'); //required

//remote action invocation
vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
appHandler.invokeMethod(methodName, input, output, options);
```

## Parallel Invocation

You can process each contextCombinationResultItem in parallel. If there are 100 catalogs and each catalog links to 13 contextCombinationsResultItems, then all 1,300 contextCombinationResultItems can be run in parallel.

```nolang
THREAD1 -  POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/contexteligibility
THREAD2 -  POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/contexteligibility
...
THREAD13 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/contexteligibility
THREAD14 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog2/contexteligibility
......
THREAD1300 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog100/contexteligibility
```

## HTTP Headers

| Header       | Description      |
| ------------ | ---------------- |
| Content-Type | application/json |

## Response Body

This example shows the context combinations of products and promotions that are eligible for each of the combinations.

```
{
    "apiResponse": [
        {
            "eligibilityObjMap": {
                "Promotion": [],
                "Product": [
                    "01t5w00000FbI08AAF"
                ]
            },
            "contextValueKeySet": [
                "DIM_ORD_FUNCTION\"UPGRADE\"",
                "DIM_SALES_CHANNEL\"VHAOnlineStore\"",
                "DIM_ORD_TYPE_001\"Connect\"",
                "OriginatingChannel\"CallCenter\"",
                "AccountStatus\"Active\""
            ],
            "contextValueKeyCount": 5,
            "eligibilityContextString": "testcatalogCtxEligibilityResult0a49c26b44fcf8257224e7e077a5d97c",
            "eligibilityContextKey": "c161669788f961dba463ed0742f17622",
            "contextString": "{\"AccountStatus\":\"Active\",\"DIM_ORD_FUNCTION\":\"UPGRADE\",\"DIM_ORD_TYPE_001\":\"Connect\",\"DIM_SALES_CHANNEL\":\"VHAOnlineStore\",\"OriginatingChannel\":\"CallCenter\"}",
            "contextKey": "0a49c26b44fcf8257224e7e077a5d97c"
        }
    ],
    "catalogCode": "allDimensionProductsCatalog-",
    "errorCode": "INVOKE-200",
    "error": "OK"
}
```

## HTTP Response Codes

| Code | Description           |
| ---- | --------------------- |
| 200  | OK                    |
| 500  | Internal Server Error |
