> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cassidyai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy via embed

> Embed your Agent on any website or app so external users can chat with it directly.

Embed your [Agent](/agents/overview) on any website so visitors or team members can chat with it without leaving the page. Choose between a static iframe that's always visible or a floating modal that opens on click.

<iframe className="aspect-video w-full rounded-xl" src="https://www.loom.com/embed/725cd4ec05f94026ad56bdb4b986b30c" title="Embed deployment demo showing how to add a Cassidy Agent chat widget to a website" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

## Set up the deployment

<Steps>
  <Step title="Navigate to your Agent">
    Go to **Agents** and select the Agent you want to embed. Click **Edit** to open the Agent settings.

    <Frame>
      <img src="https://mintcdn.com/cassidy/RZ75CscZWMGVg8C6/images/integrations/deploying-agents-via-embed-img-0.png?fit=max&auto=format&n=RZ75CscZWMGVg8C6&q=85&s=2719ba6058a85b451bd07a94a561e9ab" alt="Agents page showing the list of available Agents" width="2424" height="966" data-path="images/integrations/deploying-agents-via-embed-img-0.png" />
    </Frame>
  </Step>

  <Step title="Open the Deployments tab">
    Navigate to the **Deployments** tab in your Agent's settings.

    <Frame>
      <img src="https://mintcdn.com/cassidy/RZ75CscZWMGVg8C6/images/integrations/deploying-agents-via-embed-img-1.png?fit=max&auto=format&n=RZ75CscZWMGVg8C6&q=85&s=d9c35ee7ee398e8c74a37d340cba51be" alt="Agent settings with the Deployments tab selected" width="2490" height="1186" data-path="images/integrations/deploying-agents-via-embed-img-1.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cassidy/RZ75CscZWMGVg8C6/images/integrations/deploying-agents-via-embed-img-2.png?fit=max&auto=format&n=RZ75CscZWMGVg8C6&q=85&s=0ffc68695cdb0c3ad7b96902d4dd0121" alt="Deployments tab showing embed configuration options" width="1642" height="2078" data-path="images/integrations/deploying-agents-via-embed-img-2.png" />
    </Frame>
  </Step>

  <Step title="Enable embedded chat">
    Toggle on **Enable Embedded Chat Deployment**.

    <Frame>
      <img src="https://mintcdn.com/cassidy/opUjsHGkJXVqagIV/images/integrations/deploying-agents-via-embed-img-3.png?fit=max&auto=format&n=opUjsHGkJXVqagIV&q=85&s=1732f2fa7e3ba98b11c0328526eefebc" alt="Embedded Chat Deployment toggle switched on" width="1366" height="194" data-path="images/integrations/deploying-agents-via-embed-img-3.png" />
    </Frame>
  </Step>

  <Step title="Whitelist your domains">
    Click **Add Whitelisted Domain** to specify which website domains are allowed to embed the Agent. You can add multiple domains and remove them as needed.

    <Frame>
      <img src="https://mintcdn.com/cassidy/opUjsHGkJXVqagIV/images/integrations/deploying-agents-via-embed-img-4.png?fit=max&auto=format&n=opUjsHGkJXVqagIV&q=85&s=9bba2823aedddfca8ad5b385de411064" alt="Whitelisted domains section with the Add Whitelisted Domain button" width="1372" height="348" data-path="images/integrations/deploying-agents-via-embed-img-4.png" />
    </Frame>
  </Step>

  <Step title="Require a secure token (optional)">
    By default, anyone who has the embed URL can chat with your Agent. To restrict access to only your authenticated users, toggle on **Require Secure Token**.

    When enabled, the embed URL requires a short-lived authentication token to work. Create this token on your own backend with your Cassidy API key after you authenticate the user. See [Restrict access with secure tokens](#restrict-access-with-secure-tokens) below for setup instructions. If visitors see an **Unauthorized** error instead of the chat, see [Troubleshooting](#troubleshooting).

    <Frame>
      <img src="https://mintcdn.com/cassidy/8EtvEAQboOtR3Y_O/images/integrations/deploying-agents-via-embed-secure-deploy.png?fit=max&auto=format&n=8EtvEAQboOtR3Y_O&q=85&s=fe96668c3668ce4f7cbf5bc70f44dbb4" alt="Require Secure Token toggle in the embed Basic settings section" width="962" height="190" data-path="images/integrations/deploying-agents-via-embed-secure-deploy.png" />
    </Frame>
  </Step>

  <Step title="Set the display name">
    Enter the **Agent Display Name** that visitors will see in the embedded chat widget.

    <Frame>
      <img src="https://mintcdn.com/cassidy/opUjsHGkJXVqagIV/images/integrations/deploying-agents-via-embed-img-5.png?fit=max&auto=format&n=opUjsHGkJXVqagIV&q=85&s=527158f1a771eed68a4dd23bce113f0e" alt="Agent Display Name field in the embed configuration" width="1374" height="236" data-path="images/integrations/deploying-agents-via-embed-img-5.png" />
    </Frame>
  </Step>

  <Step title="Configure the first message">
    Enter the **First Message** that greets visitors when they open the chat. Use this to welcome users or prompt them to ask a question.

    <Frame>
      <img src="https://mintcdn.com/cassidy/opUjsHGkJXVqagIV/images/integrations/deploying-agents-via-embed-img-6.png?fit=max&auto=format&n=opUjsHGkJXVqagIV&q=85&s=3a356425c434857ffbfdf0dd642bcbab" alt="First Message field for setting the chat greeting" width="1368" height="292" data-path="images/integrations/deploying-agents-via-embed-img-6.png" />
    </Frame>
  </Step>

  <Step title="Choose the reference mode">
    Select the appropriate **Reference Mode** for your use case:

    * **Disable References** — no citations shown in responses
    * **Public Sources Only** — only links to publicly accessible sources
    * **Include All References** (default) — all citations shown, but users need permissions to view private documents
    * **Generate Public Links** — creates public URLs for cited documents

    <Frame>
      <img src="https://mintcdn.com/cassidy/opUjsHGkJXVqagIV/images/integrations/deploying-agents-via-embed-img-7.png?fit=max&auto=format&n=opUjsHGkJXVqagIV&q=85&s=33efa4097b347ccd0639541169ad692d" alt="Reference Mode dropdown showing the four available options" width="1380" height="908" data-path="images/integrations/deploying-agents-via-embed-img-7.png" />
    </Frame>

    <Warning>**Generate Public Links** can expose sensitive information. Only use this option if your Agent does not have access to private documents.</Warning>
  </Step>

  <Step title="Save your settings">
    Click **Save Settings** to apply your configuration.
  </Step>

  <Step title="Choose your embed format">
    In the **Embed Code** section, choose between two formats:

    * **Static IFrame** — the chat component is always visible on the page, ideal for support pages or help centers

    <Frame>
      <img src="https://mintcdn.com/cassidy/opUjsHGkJXVqagIV/images/integrations/deploying-agents-via-embed-img-8.png?fit=max&auto=format&n=opUjsHGkJXVqagIV&q=85&s=d8fa5478864c0ec486817f4152bfe82d" alt="Static IFrame embed code snippet" width="1376" height="530" data-path="images/integrations/deploying-agents-via-embed-img-8.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cassidy/opUjsHGkJXVqagIV/images/integrations/deploying-agents-via-embed-img-9.png?fit=max&auto=format&n=opUjsHGkJXVqagIV&q=85&s=b2482bf80b30be2d88dbe54183a9a083" alt="Preview of the static iframe embedded chat on a sample website" width="2224" height="1404" data-path="images/integrations/deploying-agents-via-embed-img-9.png" />
    </Frame>

    * **Modal** — a floating button that opens the chat as an overlay, best when you want to offer help without taking up permanent space

    <Frame>
      <img src="https://mintcdn.com/cassidy/RZ75CscZWMGVg8C6/images/integrations/deploying-agents-via-embed-img-10.png?fit=max&auto=format&n=RZ75CscZWMGVg8C6&q=85&s=2af83007a3ceacc51a2caf9b6181771b" alt="Modal embed code snippet" width="1376" height="1054" data-path="images/integrations/deploying-agents-via-embed-img-10.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cassidy/RZ75CscZWMGVg8C6/images/integrations/deploying-agents-via-embed-img-11.png?fit=max&auto=format&n=RZ75CscZWMGVg8C6&q=85&s=1550dc8f164aaa4ce60b0e3fad52c748" alt="Preview of the modal chat overlay on a sample website" width="2014" height="1528" data-path="images/integrations/deploying-agents-via-embed-img-11.png" />
    </Frame>
  </Step>

  <Step title="Add the code to your website">
    Copy the embed code and paste it into your website's HTML where you want the chat to appear. If you're using a website builder, add it to a custom HTML block.

    <Frame>
      <img src="https://mintcdn.com/cassidy/RZ75CscZWMGVg8C6/images/integrations/deploying-agents-via-embed-img-12.png?fit=max&auto=format&n=RZ75CscZWMGVg8C6&q=85&s=8014f91982ab61576804beef96b37d7b" alt="Embed code being added to a website's HTML" width="3020" height="1536" data-path="images/integrations/deploying-agents-via-embed-img-12.png" />
    </Frame>
  </Step>
</Steps>

<Tip>
  Test the embed on a staging environment before deploying to production. Click
  **Preview** in Cassidy to see what the embedded chat looks like before
  publishing.
</Tip>

## Regenerate your embed URL or modal

If you need to regenerate the current embed credentials (for example, when you suspect they may have been exposed), click the **Regenerate Embed Url/Key** button. This will create a new embed key or URL and immediately invalidate all existing chats using the old one.

<Frame>
  <img src="https://mintcdn.com/cassidy/PINd7ZuQEs0Ph_qK/images/integrations/deploying-agents-via-embed-img-13.png?fit=max&auto=format&n=PINd7ZuQEs0Ph_qK&q=85&s=53690f7b5949c64df8dbda99eabfd0de" alt="Preview of the modal chat overlay on a sample website" width="1792" height="1198" data-path="images/integrations/deploying-agents-via-embed-img-13.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/cassidy/aq-uOSOTtCZUO1Mf/images/integrations/deploying-agents-via-embed-img-14.png?fit=max&auto=format&n=aq-uOSOTtCZUO1Mf&q=85&s=41aed69231f80892e768ef9293d1c662" alt="Preview of the modal chat overlay on a sample website" width="1800" height="1170" data-path="images/integrations/deploying-agents-via-embed-img-14.png" />
</Frame>

## Restrict access with secure tokens

By default, an embedded Agent is public. Anyone with the embed URL can chat with it. Whitelisted domains only control which sites may visually embed the iframe in a browser; they do not stop someone who has the URL from opening it directly. To allow only your authenticated users to chat, enable **Require Secure Token**.

With secure tokens enabled, every embedded chat request must include a short-lived token. Your backend mints that token using your Cassidy API key.

<Warning>
  Never put your Cassidy API key in frontend code. Mint tokens only from your
  backend, then pass the resulting token to the frontend page.
</Warning>

<Steps>
  <Step title="Authenticate your user">
    Use your own login system to confirm the visitor is allowed to use the Agent.
  </Step>

  <Step title="Create a backend endpoint that mints tokens">
    From your backend, call the [embed token endpoint](https://app.cassidyai.com/api-docs) with your Cassidy API key. The token defaults to a 1-hour lifetime, with a 7-day maximum.

    ```js theme={null}
    const response = await fetch("https://app.cassidyai.com/api/assistants/embed/token/create", {
      method: "POST",
      headers: {
        "x-api-key": "{YOUR_API_KEY}",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        deployment_key: "YOUR_DEPLOYMENT_KEY",
        expires_in_seconds: 3600
      })
    })

    const { token, expires_at } = await response.json()
    ```

    Return the token to your frontend.
  </Step>

  <Step title="Pass the token to the embed">
    * **Static iframe** — append the token to the embed URL as a fragment (`#token=...`). The embed reads the token from the URL when it loads. Your app is responsible for refreshing tokens before they expire — mint a new token from your backend and update the iframe `src` with the new fragment.

    ```html theme={null}
    <iframe
      src="https://app.cassidyai.com/embed/chat/v2/YOUR_DEPLOYMENT_KEY#token=YOUR_GENERATED_TOKEN"
      style="border: none; height: 500px; width: 600px"
      allow="clipboard-read; clipboard-write"
    ></iframe>
    ```

    * **Modal** — fetch a token from your backend after authenticating the user, then pass it to `Cassidy.initialize` as `authToken`. Your app is responsible for refreshing tokens before they expire.

    ```html theme={null}
    <script src="https://unpkg.com/@cassidyai/chat-deployment@latest/dist"></script>
    <script>
      (async () => {
        const res = await fetch("/your-backend/cassidy-embed-token")
        const { token } = await res.json()

        Cassidy.initialize({
          key: "YOUR_DEPLOYMENT_KEY",
          baseUrl: "https://app.cassidyai.com",
          authToken: token,
        })
      })()
    </script>
    ```
  </Step>
</Steps>

### Troubleshooting

If **Require Secure Token** is enabled and the embed does not receive a valid token, visitors will see an **Unauthorized** screen instead of the chat. This means the embed is working, but the token was missing, expired, or not passed correctly.

<Frame>
  <img src="https://mintcdn.com/cassidy/8EtvEAQboOtR3Y_O/images/integrations/deploying-agents-via-embed-troubleshoot-unauthorized.jpeg?fit=max&auto=format&n=8EtvEAQboOtR3Y_O&q=85&s=c040e197a2d87a5bdb0c83d553dea25b" alt="Embedded chat Unauthorized error screen" width="1460" height="752" data-path="images/integrations/deploying-agents-via-embed-troubleshoot-unauthorized.jpeg" />
</Frame>

Common causes:

* The embed code on your website does not include a token (for example, the iframe URL is missing `#token=...`, or the modal was initialized without `authToken`).
* The token expired and your site has not refreshed it yet.
* Your backend is not minting tokens correctly, or the token was created for a different deployment key.

What to do:

* If you copied embed code from Cassidy before setting up secure tokens, update your website with the latest embed instructions above.
* Ask whoever manages your website to confirm tokens are being created on your backend and passed into the embed.
* Try reloading the page. If the error persists, contact your site administrator or Cassidy support.

## Next steps

<CardGroup cols={2}>
  <Card title="Agents overview" icon="robot" href="/agents/overview">
    Learn more about creating and configuring Agents.
  </Card>

  <Card title="Deploy via email" icon="envelope" href="/agents/deploy/email">
    Deploy your Agent to a dedicated email address.
  </Card>

  <Card title="Deploy via API" icon="terminal" href="/agents/deploy/api">
    Build a custom integration using the Cassidy API.
  </Card>
</CardGroup>
