> For the complete documentation index, see [llms.txt](https://partner-docs.covergenius.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://partner-docs.covergenius.com/elements/integration.md).

# Integration

See the full flow of a CG Elements integration, from offer to booking.

Read this page before you write code.

### Flow

```mermaid
%%{init: {'theme': 'base', 'themeVariables': {
  'actorBkg': '#FFE600',
  'actorBorder': '#FFE600',
  'actorTextColor': '#001833',
  'actorLineColor': '#C8C8C8',
  'signalColor': '#001833',
  'signalTextColor': '#001833',
  'lineColor': '#001833',
  'noteBkgColor': '#F7F7F7',
  'noteBorderColor': '#C8C8C8',
  'noteTextColor': '#001833'
}, 'themeCSS': '.actor { rx: 12px; ry: 12px; }'}}%%
sequenceDiagram
    participant P as Customer page
    participant B as Your backend
    participant O as Offers API
    P->>B: Open checkout
    B->>O: Create Offer
    O-->>B: Offer response
    B-->>P: Offer response
    P->>P: render(response)
    P->>B: change event (selected quote IDs)
    B->>O: Confirm Offer
```

### Steps

{% stepper %}
{% step %}
**Create the offer**

Your backend calls Create Offer. The response includes `products`, `content`, and `presentation`.
{% endstep %}

{% step %}
**Send the response to the browser**

Your backend sends the response to the browser.
{% endstep %}

{% step %}
**Register the SDK**

Your page registers the SDK once with `registerElements()`.
{% endstep %}

{% step %}
**Render the offer**

Your page calls `render(response)` on the instance that `getElement()` returns.
{% endstep %}

{% step %}
**The panel shows**

The SDK shows the panel. The `ready` event fires.
{% endstep %}

{% step %}
**The customer chooses**

The customer chooses an option. The `change` event fires with the selection.
{% endstep %}

{% step %}
**Confirm the offer**

Your backend calls Confirm Offer with the selected quote IDs.
{% endstep %}
{% endstepper %}

### Concepts

| Term           | Meaning                                                                                                                                                 |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Offer response | The Create Offer response. It holds the quotes (`products`), the copy (`content`), the selection rules (`product_rules`), and the `presentation` field. |
| Presentation   | The `presentation` field of the offer response. It names the `layout` and the `theme`. Cover Genius sets it for your offer. You do not edit it.         |
| Placement      | One `<cg-elements>` element on your page. Most pages have one placement. A page can have more than one. See Multiple Placements.                        |
| Selection      | The option that the customer chooses. An option is an opt-in choice or the decline choice. The SDK reports the selection as option IDs and quote IDs.   |
| Quote ID       | The `id` of an entry in `products[]`. The `change` event returns quote IDs in `selectedProductIDs`. Use these IDs to confirm the offer.                 |

### What the SDK does not do

{% hint style="info" %}
The SDK does not do these things. Your backend and your checkout do them.

* It does not create, confirm, modify, or cancel offers.
* It does not take payment.
* It does not render on the server.
* It does not store customer data.
* It does not make network calls for offer data, and it holds no credentials.
  {% endhint %}

### Environments

Set the `environment` option in `registerElements()` to `production`, `uat`, or `develop`. Use the value that matches the Offers API environment that your backend calls.

### Requirements

* A browser with custom elements and `<script type="module">` support. Mobile WebViews and installed PWAs also work.
* An Offers API integration on your backend.
* A presentation configured for your offer. Visit Your Program in our Partner Portal and request a change for your Offer Presentation.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://partner-docs.covergenius.com/elements/integration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
