> 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.

# Integrate SmartCircuit

A SmartCircuit integration has three parts: a reference to the hosted SmartCircuit JavaScript bundle, an HTML element where the offer is displayed, and partner scripting that [exchanges events](/in-path-offers/client-side/documentation/events) with the component.

#### Reference the SmartCircuit bundle

AzP hosts the bundle on the AWS CDN. A static inclusion is usually enough because the bundle is small; use a dynamic inclusion to load it only when the page flow needs it.

#### Static inclusion

Reference the bundle in the `head` of each page where a quote or purchase happens.

**`index.html`**

```html title="index.html"
<html>
  <head>
    <script src="https://sc-uat.allianzpartnergateway.com/wci/bundles/default/allianzinsurance-uat-default.js"></script>
  </head>
  <body>
    <allianz-insurance accam="code" allow-price-validation="false" access-token="accessToken" type="TRAVEL" log-level="debug"></allianz-insurance>
  </body>
</html>
```

#### Dynamic inclusion

Inject the bundle into the page header when it's needed.

**`index.js`**

```javascript title="index.js"
var node = document.createElement("script");
node.src = "https://sc-uat.allianzpartnergateway.com/wci/bundles/default/allianzinsurance-uat-default.js";
node.async = true;
document.getElementsByTagName("head")[0].appendChild(node);
```

On a single-page application, moving between pages that each initialize SmartCircuit leaves two listeners for the same event, and the customer can receive a different quote for their search criteria.

#### Get an access token

Your server calls the SmartCircuit authorize endpoint. The access token is valid for 1 hour, and the refresh token renews it for 24 hours. Once the access token expires, call the authorize endpoint again with the refresh token.

**`Token request`**

```json title="Token request"
{
  "username": "YOUR_USERNAME",
  "password": "YOUR_PASSWORD"
}
```

**`Token response`**

```json title="Token response"
{
  "accessToken": "access token",
  "refreshToken": "refresh token",
  "expiresInSec": "3600",
  "TokenType": "Bearer"
}
```

**`Refresh request`**

```json title="Refresh request"
{
  "username": "YOUR_USERNAME",
  "refreshToken": "refresh token"
}
```

**`Refresh response`**

```json title="Refresh response"
{
  "accessToken": "access token",
  "expiresInSec": "3600",
  "TokenType": "Bearer"
}
```

#### Example: get a token in PHP

```php
// Required variables to get the token
$scAuthEndpoint = "https://pg-uat-api-partnermgmt.allianzpartnergateway.com/authorize";
$scUsername = "PartnerUsername";
$scPassword = "PartnerPassword";
$scAccam = "F000000";

// Get an authorization token using scGetToken below.
$scToken = scGetToken($scUsername, $scPassword, $scAuthEndpoint);

// Create the allianz-insurance element with the token.
$html = '<allianz-insurance id="trip-protection" allow-price-validation="false" log-level="1" access-token="' . $scToken . '" type="TRAVEL" accam="' . $scAccam . '"></allianz-insurance>';

function scGetToken($scUsername, $scPassword, $authEndpoint) {
    $data = array(
        'username' => $scUsername,
        'password' => $scPassword
    );
    $options = array(
        'http' => array(
            'method'  => 'POST',
            'content' => json_encode($data),
            'header'  => "Content-Type: application/json\r\n" .
                         "Accept: application/json\r\n"
        )
    );
    $context  = stream_context_create($options);
    $result = file_get_contents($authEndpoint, false, $context);
    $response = json_decode($result);
    return $response->accessToken;
}
```

#### Place the allianz-insurance element

Put the element where the offer should appear. SmartCircuit injects the offer into it.

```html
<allianz-insurance id="trip-protection" accam="F000000" allow-price-validation="false" access-token="eyJraWQiOiJGcFh2TFU4cXhr...VLvWaZ0kgNlTEWPidiAxKQAlRTkNc5Fg" type="TRAVEL" log-level="warn"></allianz-insurance>
```

**`access-token`** `string` — required

Access token from the server-side authentication call. SmartCircuit uses it to authenticate the page.

---

**`accam`** `string` — required

Which of the partner's ACCAMs to use when the partner has more than one.

---

**`type`** `"TRAVEL" | "EVENT"` — required

Whether the quote is for travel or an event.

---

**`allow-price-validation`** `boolean` — default: false

Verify the quoted price before a purchase. On a mismatch, SmartCircuit returns `Price in Purchase Request does not match price was returned in quote request. TotalPrice should be XXX passed as YYY`.

---

**`log-level`** `"debug" | "info" | "warn" | "error"`

How much SmartCircuit logs to the console, from `debug` (most) to `error` (errors only). Use `debug` during development and `warn` or `error` in production.

---

#### Listen for and send events

Wire your checkout to the [SmartCircuit events](/in-path-offers/client-side/documentation/events): wait for `azpComponentReady`, send `azpQuoteRequest`, track the customer's choice, then send a purchase or note decline.

## Residency of the insured

US travel insurance is regulated by each state, so benefits, limits and pricing depend on the insured's state of residence. Every quote request must include:

| Attribute      | Object            | Type   | Notes                                      | Example |
| -------------- | ----------------- | ------ | ------------------------------------------ | ------- |
| `region`       | `customerAddress` | String | 2-letter billing state code of the insured | `VA`    |
| `postalCode`   | `customerAddress` | String | Billing ZIP code of the insured            | `23111` |
| `businessUnit` | `requestDetail`   | String | 2-letter country code                      | `US`    |