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

# Check that a widget embed is installed on a page

> Have MITHUNAI read one page of your website and report whether the embed's line is on it and whether that website is allowed to show the widget.

MITHUNAI fetches the page once, without credentials, and looks for two things in its HTML: a reference to the widget script and this deployment's widget key. Nothing from the page is returned or stored.

The check has limits you should know before relying on it:

* **It reads the HTML the server sends.** A line added by a tag manager or by JavaScript after the page loads is not in that HTML, so the result is `not_found` even though the widget works. Open the page and look for the button.
* **It does not follow redirects.** A page that redirects, for example to a `www` address or to one ending in a slash, reports `unreachable`. Send the final address.
* **It only reads websites the embed allows.** If the page's origin is not in the deployment's `allowed_origins`, nothing is fetched and the result is `origin_not_allowed`.
* **The page must be public.** A page behind a sign-in, on a private network or on an unusual port reports `unreachable`.

A deployment that does not exist, a deployment in another organization and a malformed ID all return the same `404`. At most a few checks run at the same time; a `429` means try again in a moment.

You need the `assistant.publish` permission, which the owner, admin and editor roles hold. Authenticate with an `arukz_sk_` API key or a signed-in console session.

<ParamField path="deployment_id" type="string" required>
  The deployment's ID (UUID), as returned in `id`.
</ParamField>

<ParamField body="url" type="string" required>
  The page to read: an `http` or `https` address of at most 2,048 characters, with no credentials in
  it. A `#fragment` is ignored.
</ParamField>

## Response

<ResponseField name="url" type="string" required>
  The address that was checked, trimmed and without any fragment.
</ResponseField>

<ResponseField name="origin" type="string" required>
  The address's origin: scheme, host and any port.
</ResponseField>

<ResponseField name="origin_allowed" type="boolean" required>
  Whether that origin is in the deployment's `allowed_origins`.
</ResponseField>

<ResponseField name="fetched" type="boolean" required>
  Whether the page was read. `true` only when it answered with a `2xx` status.
</ResponseField>

<ResponseField name="http_status" type="integer | null" required>
  The status the page answered with, or `null` when it was not fetched or did not answer.
</ResponseField>

<ResponseField name="snippet_found" type="boolean" required>
  Whether the HTML references the widget script.
</ResponseField>

<ResponseField name="key_found" type="boolean" required>
  Whether the HTML contains this deployment's widget key.
</ResponseField>

<ResponseField name="result" type="string" required>
  One of `installed` (script and key found, origin allowed), `key_missing` (script found with a
  different key), `not_found` (no script reference in the HTML), `origin_not_allowed` or
  `unreachable`.
</ResponseField>

<RequestExample>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl --request POST "$MITHUNAI_URL/mithunai/api/v1/widget-deployments/8d0f5a2e-3c41-4b7a-9e6d-1f2a3b4c5d6e/installation-check" \
    --header "Authorization: Bearer $MITHUNAI_API_KEY" \
    --header "Content-Type: application/json" \
    --data '{"url": "https://www.example.com/docs/"}'
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os, requests

  deployment_id = "8d0f5a2e-3c41-4b7a-9e6d-1f2a3b4c5d6e"
  response = requests.post(
      f"{os.environ['MITHUNAI_URL']}/mithunai/api/v1/widget-deployments/{deployment_id}/installation-check",
      headers={"Authorization": f"Bearer {os.environ['MITHUNAI_API_KEY']}"},
      json={"url": "https://www.example.com/docs/"},
      timeout=60,
  )
  response.raise_for_status()
  print(response.json()["result"])
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const deploymentId = '8d0f5a2e-3c41-4b7a-9e6d-1f2a3b4c5d6e'
  const response = await fetch(
    `${process.env.MITHUNAI_URL}/mithunai/api/v1/widget-deployments/${deploymentId}/installation-check`,
    {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.MITHUNAI_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ url: 'https://www.example.com/docs/' }),
    },
  )
  console.log((await response.json()).result)
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "url": "https://www.example.com/docs/",
    "origin": "https://www.example.com",
    "origin_allowed": true,
    "fetched": true,
    "http_status": 200,
    "snippet_found": true,
    "key_found": true,
    "result": "installed"
  }
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.