> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://allianz.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://allianz.ferndocs.com/_mcp/server.

# SmartCircuit events

SmartCircuit talks to the Partner Web Application (PWA) through DOM custom events. **Listening** events come from SmartCircuit; **sending** events go from the PWA to SmartCircuit with the quote, purchase or note decline data.

| Event                         | Name                                           | Type      |
| ----------------------------- | ---------------------------------------------- | --------- |
| Component ready               | `azpComponentReady`                            | Listening |
| Quote request                 | `azpQuoteRequest`                              | Sending   |
| Insurance selected / declined | `azpInsuranceSelected`, `azpInsuranceDeclined` | Listening |
| Default offer                 | `azpLoadingDefaultOffer`                       | Listening |
| Purchase request              | `azpPurchaseRequest`                           | Sending   |
| Purchase response             | `azpPurchaseResponse`                          | Listening |
| Note decline request          | `azpNoteDeclineRequest`                        | Sending   |
| Note decline response         | `azpNoteDeclineResponse`                       | Listening |
| Error                         | `azpFatalError`                                | Listening |

## Listening events

### azpComponentReady

The PWA must wait for this event before interacting with SmartCircuit.

### azpInsuranceSelected and azpInsuranceDeclined

The PWA needs the customer's choice to show the insurance price in the booking total and to decide whether to send a purchase request or a note decline request.

```javascript
var insuranceSelected = false;
var insurancePrice = 0;

function insuranceSelectedFunc(event) {
  insuranceSelected = true;
  insurancePrice = event.detail.insurancePrice;
}

// Fires when the customer selects "Yes" in the offer.
window.document.addEventListener("azpInsuranceSelected", insuranceSelectedFunc);
```

### azpLoadingDefaultOffer

If no optimized offer arrives in time after a quote request, SmartCircuit displays a single default offer. This is rare, and it keeps the offer on the page.

### azpPurchaseResponse

Handling this event is optional but recommended to confirm the purchase succeeded. A failure message includes a unique partner booking ID that can be used to reprocess payment later.

### azpNoteDeclineResponse

AzP responds with `SUCCESS` when it receives the note decline.

### azpFatalError

Something went wrong, usually with the quote service, and no quote can be displayed. Hide any insurance-related elements when this event arrives.

## Sending events

### azpQuoteRequest

Send this once `azpComponentReady` has fired and the PWA has enough information to quote. The event detail is a quote request object.

```javascript
var jsonQuoteRequest = { /* quote request */ };
var quoteRequest = new CustomEvent("azpQuoteRequest", { detail: jsonQuoteRequest });
document.dispatchEvent(quoteRequest);
```

### azpPurchaseRequest

Send this when the customer completes the core booking with insurance selected. The event detail is a purchase request object.

```javascript
var jsonPurchaseRequest = { /* purchase request */ };
var purchaseRequest = new CustomEvent("azpPurchaseRequest", { detail: jsonPurchaseRequest });
document.dispatchEvent(purchaseRequest);
```

### azpNoteDeclineRequest

Send this each time a booking completes with insurance declined. AzP matches it to the original quote request to measure performance and drive optimization. It needs no data.

```javascript
var noteDeclineEvent = new CustomEvent("azpNoteDeclineRequest");
document.dispatchEvent(noteDeclineEvent);
```

## Code examples

#### [SmartCircuit code examples](/in-path-offers/client-side/code-examples)

A full event example from the sandbox, plus the hosted SmartCircuit demo.