> ## Documentation Index
> Fetch the complete documentation index at: https://docs.axle.insure/llms.txt
> Use this file to discover all available pages before exploring further.

# Policy Validation with Templates

> Templates let you evaluate a set of Rules against a policy by storing rules and inputs, and pulling dynamic values from custom metadata.

## Overview

As an extension of [Policy Validation](/guides/validate/policy-validation), you can also use Templates to simplify Rule configuration in your application. Instead of manually storing the list of rules, you can define them once and let Axle handle rule maintenance and policy validation.

### Dynamic Inputs via `source` and `default`

Rules that can have inputs (e.g. `collision-coverage-meets-requirements` which can have a `deductible` input) are configured in a template using a `source` key instead of a hardcoded value. At evaluation time, Axle looks up the rule input value dynamically using the following priority order:

1. **Request body metadata** — the flat `metadata` object passed in the [Validate Policy with Template](/api-reference/validation/validate-policy-template) request body, keyed by `source`.
2. **Ignition session metadata** — the `metadata` object via [Start Ignition](/api-reference/ignition/start-ignition), keyed by `source`.
3. **Template default** — the `default` value defined on the rule input in the template (if set).

This means you can store rule configuration once in a template and provide the actual input values at runtime — either when launching an Ignition session or when calling the validate endpoint.

<Info>
  **Metadata rules** are defined in [Start Ignition](/api-reference/ignition/start-ignition) (`metadata` on the session) and [Validate Policy with Template](/api-reference/validation/validate-policy-template) (request body).
</Info>

### Example Template

```json theme={null}
{
  "id": "tem_jsK9vrCIfABlCW7PqIknc",
  "rules": [
    {
      "rule": "collision-coverage-meets-requirements",
      "input": {
        "deductible": {
          "source": "maxDeductible",
          "default": 500
        }
      }
    }
  ],
  "createdAt": "2025-06-10T13:57:22.300Z",
  "modifiedAt": "2025-06-10T13:57:22.300Z"
}
```

In this example, `source: "maxDeductible"` tells Axle to look for a key named `maxDeductible` in the request body metadata or Ignition session metadata. If neither provides that key, the `default` value of `500` is used.

### Usage

<Steps>
  <Step title="Create or modify Validation Template">
    Start by identifying the [rules](/guides/validate/policy-validation#supported-rules) you want to use. Then, either [create](/api-reference/validation/templates/create-template) a new template or [modify](/api-reference/validation/templates/update-template) an existing one.

    If your application is a [platform](/guides/platform-integration), you can [create](/api-reference/platform/create-templates) shareable template across all of your destination clients. If you are existing Axle for Platforms customer, please reach out to Axle team for more information.
  </Step>

  <Step title="Provide dynamic inputs to Ignition metadata (optional)">
    Include `metadata` in [Start Ignition](/api-reference/ignition/start-ignition) to serve as dynamic Rule inputs. The keys in this object must match the `source` values defined in your Template's rule inputs, and the values must conform to the associated Rule input type.

    For example, if a template rule input has `"source": "maxDeductible"`, include `"maxDeductible": 500` in the `metadata` object when starting Ignition.
  </Step>

  <Step title="Retrieve Validation Templates">
    After creating a template, you can store its Template identifier in your application. Using this identifier, you can [retrieve](/api-reference/validation/templates/get-template) specific template and all of its details or [get all the available](/api-reference/validation/templates/get-templates) Templates for your Axle client or destination client.
  </Step>

  <Step title="Request Policy Validation with Template">
    Use the Template identifier to make a request to [Validate Policy with Template](/api-reference/validation/validate-policy-template). The request body accepts a flat `metadata` object whose keys correspond to the `source` values in your Template's rule inputs — these values override any matching keys from the Ignition session metadata.

    {" "}

    <Warning>
      Request body metadata keys take priority over Ignition session metadata keys
      when resolving rule inputs. See [Dynamic Inputs via `source` and
      `default`](#dynamic-inputs-via-source-and-default) for the full resolution
      order.
    </Warning>
  </Step>
</Steps>
