---
url: >-
  https://docs.ridgedata.ai/reference/embed-api/Function.isEmbedProtocolMessage.md
---
# Function: isEmbedProtocolMessage()

```ts
function isEmbedProtocolMessage(value: unknown): value is EmbedProtocolMessage;
```

Check that a value has a recognized iframe message name and a structurally valid payload.
This checks the message format. Component-specific state values are validated when applied.

Use this to distinguish Ridge messages from other window messages. Check the event's
origin and source separately before accepting a message.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `value` | `unknown` | The incoming message payload, usually `event.data`. |

## Returns

`value is EmbedProtocolMessage`

`true` when the payload matches a supported Ridge message format.

## Example

```ts
window.addEventListener("message", (event) => {
  if (event.origin !== ridgeOrigin || event.source !== frame.contentWindow) return;
  if (!isEmbedProtocolMessage(event.data)) return;
  if (event.data.type === "ridge:stateChange") {
    console.log(event.data.state);
  }
});
```
