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

# Iframe API

Exchange local data and commands with an embedded Sonoran CAD frontend.

The iframe API uses the browser [`window.postMessage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) interface to exchange messages between Sonoran CAD and the page embedding it. These messages stay on the local client; they are not HTTP API requests and do not require a community API key.

The following iframe integrations are available:

* [Notepad Sync](/cad/api-integration/api-endpoints-v2/iframe-endpoints/notepad-sync.md) provides bidirectional synchronization of the user's locally stored CAD notes and runs name or plate searches from external text selections.
* [Screenshot Capture](/cad/api-integration/api-endpoints-v2/iframe-endpoints/screenshot-capture.md) requests a PNG capture of the current CAD viewport.
* [Set Community Link](/cad/api-integration/api-endpoints-v2/general/accounts/set-community-link.md#cad-frontend-iframe-event) documents the account-link event emitted after a successful CAD login.

## Message Security

Sonoran CAD only accepts iframe API requests from its direct parent window. The parent must also validate messages received from CAD:

```javascript
const cadFrame = document.getElementById('cadFrame');
const cadOrigin = new URL(cadFrame.src).origin;

window.addEventListener('message', (event) => {
  if (event.source !== cadFrame.contentWindow || event.origin !== cadOrigin) return;

  // Handle supported event.data.type values here.
});
```

Send requests to the exact CAD origin whenever the iframe has a standard HTTP or HTTPS URL:

```javascript
cadFrame.contentWindow.postMessage(message, cadOrigin);
```

FiveM NUI pages can have an opaque origin. Sonoran CAD accepts messages from its direct parent in that environment and replies directly to the verified sender. Keep the iframe and its parent under trusted control.

## Common Fields

Iframe API messages are plain objects with a namespaced `type`. A request may include an opaque string or number in `requestId`; the corresponding response echoes it so callers can match concurrent operations.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sonoransoftware.com/cad/api-integration/api-endpoints-v2/iframe-endpoints.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
