---
schema_version: "1"
id: ca371ebdfbe282a1bd2b249eddff2961122fd8523ae886e5170d80d9e688b8ba
title: Add Eligible Insurance Clauses Action
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/insurance_developer_guide/actions_obj_add_eligible_insurance_clauses.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/actions_obj_add_eligible_insurance_clauses.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: e20efed63daaf708402afedbf3d998f84c974c6e0da2721917ecbfb4d84deedb
description: Add eligible insurance clauses to a quote or context. You must specify either a quote ID or a context ID, and either an instance key or a quote line item ID along with insurance product clause details.
---
# Add Eligible Insurance Clauses Action

Add eligible insurance clauses to a quote or context. You must specify either a quote ID or a context ID, and either an instance key or a quote line item ID along with insurance product clause details.

This action is available in API version 65.0 and later.

## Supported REST HTTP Methods

**URI**: /services/data/vXX.X/actions/standard/addEligibleInsuranceClauses

Where XX.X is the latest API version.

**Formats**: JSON, XML

**HTTP Methods**: POST

**Authentication**: Authorization: Bearer TOKEN

Where TOKEN is your OAuth access token.

## Inputs

| Input | Type | Description |
| --- | --- | --- |
| contextId | string | Required if quoteId isn't specified. Context ID of the insurance quote. |
| instanceKey | string | Required if quoteLineItemId isn't specified. Unique key that identifies the product to which a quote line item belongs. |
| insuranceProductClauses | string | Required. JSON object with the details of the insurance product clauses to add. |
| optionFlags | Apex-defined | An Apex [runtime\_industries\_insurance.AddEligibleInsuranceClausesOptions](https://developer.salesforce.com/docs/atlas.en-us.264.0.insurance_developer_guide.meta/insurance_developer_guide/apex_class_runtime_industries_insurance_AddEligibleInsuranceClausesOptions.htm "HTML (New Window)") record that contains the details to add eligible clauses to an insurance product. |
| quoteId | string | Required if contextId isn't specified. ID of the insurance quote to add eligible clauses. |
| quoteLineItemId | string | Required if instanceKey isn't specified. ID of the quote line items for adding eligible clauses. |

## Outputs

| Output | Type | Description |
| --- | --- | --- |
| errorsList | string | Errors that are encountered during the operation. |
| isSuccess | boolean | Indicates whether the operation is successful ( true ) or not ( false ). |
| quoteLineItemInsProductClauseIds | string | IDs of the quote line item insurance product clauses. |

## Example

Sample Request

{
  "inputs": \[
    {
      "quoteId": "0Q0xx0000000001AAA",
      "quoteLineItemId": "0QLxx0000000002BBB",
      "contextId": "0j5xx0000000003CCC",
      "instanceKey": \[
        "Auto",
        "Liability"
      \],
      "insuranceProductClauses": \[
        {
          "insuranceProductClauseId": "0j4xx0000000004DDD",
          "effectiveDate": "2025-01-01",
          "expirationDate": "2025-12-31"
        }
      \],
      "optionFlags": {
        "saveContext": true
      }
    }
  \]
}

This is a sample request to call this invocable action from Apex code.

public class AddEligibleInsuranceClausesInvoke {
    private static final String ACTION\_NAME = 'addEligibleInsuranceClauses';

    public static Boolean invokeMethod(Map<String, Object> inputs, Map<String, Object> output) {
        if (output == null) {
            output = new Map<String, Object>();
        }

        try {
            Invocable.Action action = Invocable.Action.createStandardAction(ACTION\_NAME);

            // Either quoteId or contextId is required
            setInvocationParameter(action, inputs, 'quoteId', false);
            setInvocationParameter(action, inputs, 'contextId', false);

            // Either quoteLineItemId or instanceKey is required
            setInvocationParameter(action, inputs, 'quoteLineItemId', false);
            setInvocationParameter(action, inputs, 'instanceKey', false);

            // insuranceProductClauses expects JSON
            setInvocationParameter(action, inputs, 'insuranceProductClauses', true);

            // Optional optionFlags map
            if (inputs != null && inputs.containsKey('optionFlags')) {
                Map<String, Object> addClauseOptions =
                    (Map<String, Object>) inputs.get('optionFlags');
                if (addClauseOptions != null) {
                    runtime\_industries\_insurance.AddEligibleInsuranceClausesOptions apexOptions =
                        new runtime\_industries\_insurance.AddEligibleInsuranceClausesOptions();
                    if (addClauseOptions.containsKey('saveContext')) {
                        apexOptions.SaveContext =
                            (Boolean) addClauseOptions.get('saveContext');
                    }
                    action.setInvocationParameter('addClauseOptions', apexOptions);
                }
            }

            List<Invocable.Action.Result> results = action.invoke();
            if (results != null && !results.isEmpty() && results\[0\].isSuccess()) {
                output.put('output', results\[0\].getOutputParameters());
                output.put('success', true);
                return true;
            }

            output.put('success', false);
            if (results != null && !results.isEmpty()) {
                output.put('errors', results\[0\].getErrors());
            }
            return false;
        } catch (Exception e) {
            output.put('success', false);
            output.put('errorMessage', e.getMessage());
            return false;
        }
    }

    private static void setInvocationParameter(
        Invocable.Action action,
        Map<String, Object> payload,
        String attribute,
        Boolean serializeJson
    ) {
        if (payload != null && payload.containsKey(attribute) && payload.get(attribute) != null) {
            if (serializeJson) {
                action.setInvocationParameter(attribute, JSON.serialize(payload.get(attribute)));
            } else {
                action.setInvocationParameter(attribute, payload.get(attribute));
            }
        }
    }
}

Sample Response

\[
  {
    "actionName": "addEligibleInsuranceClauses",
    "errors": null,
    "invocationId": null,
    "isSuccess": true,
    "outcome": null,
    "outputValues": {
      "isSuccess": true,
      "quoteLineItemInsProductClauseIds": \[
        "a1Cxx0000000001AAA"
      \],
      "errorsList": \[\]
    },
    "sortOrder": -1,
    "version": 1
  }
\]