# Previews



Socotra enables users to preview the outcome of certain key operations without committing to the changes.

Overview [#overview]

As detailed in the feature guides for [Quotes](/features/policy-quotation/quotes) and [Policy Transactions](/features/policy-management/policy-transactions), the results of data validation, pricing, and underwriting are persisted once the entity is successfully transitioned to that step of the lifecycle.
For many entities in the system, once they have transitioned to or beyond the `validated` state, their extension data becomes immutable, which may prove too rigid for certain quoting experiences.

To provide implementers with flexibility in developing tailored experiences for selling and servicing policies, Socotra enables **previews** of the results of certain key **Quote** and **Policy Transaction** operational functions, including:

* Validation
* Pricing
* Underwriting
* Invoicing

In most cases, this preview can be executed in both a `stateful` or `stateless` fashion.

Stateful Preview [#stateful-preview]

In this context, "stateful preview" refers to a request that the system produce what the result of some state transition **will be**, for **an entity (quote or transaction) that has already been created and stored in the system**. This is achieved by setting the `stateless` boolean query parameter to `true`.

**Example**

Request a preview of the validation result for an existing quote that is in a draft state, without advancing to the validated state:

```
PATCH /policy/{tenantLocator/quotes/{quoteLocator}/validate?stateless=true
```

<span id="StatelessPreview" />

Stateless Preview [#stateless-preview]

"Stateless preview" refers to a request that the system produce what the result of some key function **would be**, for **an entity (quote or transaction) that has not yet been created in the system**.

For example, before asking the system to persist a draft quote via a <ApiLink name="createQuote">Create Quote</ApiLink> request, a user can use the same <ApiLink name="QuoteCreateRequest">request payload</ApiLink> to have the system show what the price for the hypothetical quote would be, without having to create and store the entity or the price.

In order for the system to produce a preview of a hypothetical policy transaction, the underlying base policy must exist, and be specified in the stateless preview request.

**Example**

Request a price preview for a hypothetical quote that has not yet been created in the system:

```
POST /policy/{tenantLocator}/quotes/pricePreview
```

Request a preview of the underwriting result for a hypothetical transaction that has not yet been created in the system:

```
POST /policy/{tenantLocator}/policies/{policyLocator}/{transactionType}/underwritePreview
```

<Callout>
  In order for the system to produce either a `stateful` or `stateless` preview result for pricing or underwriting, it is necessary that the request entity would pass validation.
</Callout>

<span id="billing-previews" />

Billing Previews [#billing-previews]

Often insureds will want to know the specific details of payments they will be required to make, given a prospective quote or policy transaction. Socotra enables this by extending the preview capability to the billing service in both a `stateful` and `stateless` manner.

A `stateful` preview of prospective invoices may be generated for a prospective quote or policy transaction, given that the quote or policy transaction has been created and is in a `priced` state. See the <ApiLink name="previewInvoicesForQuote" /> and <ApiLink name="previewInvoicesForTransaction" /> endpoints in the [Invoices API](/api/billing/invoices) for details.

A `stateless` preview of prospective installments or invoices may be generated for a hypothetical quote by providing the results of its stateless pricing preview in the request. See the <ApiLink name="previewInstallmentsForStatelessQuote" /> endpoint in the [Installments API](/api/billing/installments) and the <ApiLink name="previewInvoicesForStatelessQuote" /> endpoint in the [Invoices API](/api/billing/invoices) for details.
