---
schema_version: "1"
id: 5fb091ee1d949d4dbbaa6899d24690b929b462c8a501b6eefb57688d7e5f87a1
title: validateApiRequest(insRequestValidationInputRepresentation)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/insurance_developer_guide/apex_ConnectAPI_InsuranceDesignAdvisorFamily_validateApiRequest_1.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_ConnectAPI_InsuranceDesignAdvisorFamily_validateApiRequest_1.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 6e39e4ab124b1af5faf539a93c193157cdef1ef8b03bd616c5d19804266b7bcf
description: Validate a JSON request body for the Insurance Quote or Insurance Product Rating API by checking product codes, attributes, instance keys, and required fields against the configured product model.
---
# validateApiRequest(insRequestValidationInputRepresentation)

Validate a JSON request body for the Insurance Quote or Insurance Product Rating API by checking product codes, attributes, instance keys, and required fields against the configured product model.

## API Version

68.0

## Requires Chatter

No

## Signature

public static ConnectApi.InsRequestValidationRepresentation validateApiRequest(ConnectApi.InsRequestValidationInputRepresentation insRequestValidationInputRepresentation)

## Parameters

insRequestValidationInputRepresentation

Type: [ConnectApi.InsRequest​Validation​InputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_connectapi_input_ins_request_validation.htm "Input representation that specifies the insurance Connect API path and serialized JSON request body to validate against the product model.")

Required. Input that specifies the insurance Connect API path and the serialized JSON request body to validate.

## Return Value

Type: [ConnectApi.InsRequest​Validation​Representation](https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_connectapi_output_ins_request_validation.htm "Output representation that contains the overall request validation result, individual findings, and any request-level errors that prevented validation.")

## Usage

Use this method at design time to pre-validate an Insurance Connect API request body before submission. Provide an API path such as insurance/quotes or insurance/product-rating, and a serialized JSON request body. The method verifies product references, hierarchy relationships, instance keys, attribute definitions, and JSON structure, and returns actionable findings for any detected issues.

Validation includes these checks:

- Product code existence and active status
- Parent-child hierarchy structure in quoteLineItems / salesTransactionItems and nested childProducts
- Non-empty instanceKey arrays in instanceKeys entries
- Attribute code existence and active status against registered AttributeDefinition records
- JSON parse validation for the request body string

For unsupported API paths, the method returns a valid result with an informational message rather than an error. Supported paths are insurance/quotes and insurance/product-rating.

When validation succeeds, isValid is true and results is empty or contains only informational findings. When validation finds issues, isValid is false and results lists the findings. When required input is missing, errors can include request-level failures such as:

- SF-INS-DSAV-00041 — the request payload is required. Provide a valid JSON payload and API path.

## Example

This sample validates an API request payload from Apex.

ConnectApi.InsRequestValidationInputRepresentation input =
    new ConnectApi.InsRequestValidationInputRepresentation();
input.apiPath     = 'insurance/product-rating';
input.requestBody = '{"ratingInputs":\[{"productCode":"autoSilver"}\]}';

ConnectApi.InsRequestValidationRepresentation result =
    ConnectApi.InsuranceDesignAdvisorFamily.validateApiRequest(input);

System.debug('isValid=' + result.isValid);
System.debug('results=' + result.results);
System.debug('errors=' + result.errors);