Customization and Reference
Component <m8ty-chat>
Section titled “Component <m8ty-chat>”| Kind | Name | Description |
|---|---|---|
| Attribute | share |
Share ID (required) |
| Attribute | locale |
de or en; default: page language |
| Attribute | theme |
light, dark or auto (default) |
| Attribute | api-base |
Override of the Ragty chat API URL; only needed for special proxy setups |
| Property | getTicket |
Delegated shares: (nonce: string) => Promise<{ ticket: string }> |
| Property | version |
Component version (read-only) |
| Method | reset() |
Starts a new, empty conversation |
| Event | m8ty-ready |
Session established; detail.version |
| Event | m8ty-error |
detail.code: unavailable, rate_limited or failed |
| Event | m8ty-session-expired |
The session could not be renewed (e.g. getTicket failed) |
Events bubble and cross the shadow boundary. They never contain tokens, chat content or user identifiers.
Type declarations: https://rag.example.com/embed-assets/v1/m8ty-chat.d.ts.
Theming
Section titled “Theming”Without any styling the component uses the Ragty look (Meridian palette:
answer cards, amber accents, rounded input) in light or dark mode, chosen by
the theme attribute (light, dark, or auto to follow the visitor’s
system setting).
Override colors, font and corner radius with CSS custom properties on the element. Each property you set replaces the built-in value in both modes:
m8ty-chat { --m8ty-color-primary: #0b5fff; /* avatar, send button, links */ --m8ty-color-on-primary: #ffffff; /* icon/text on primary */ --m8ty-color-background: #ffffff; /* chat background */ --m8ty-color-surface: #ffffff; /* answer cards */ --m8ty-color-header: #ffffff; --m8ty-color-text: #1b1f24; --m8ty-color-muted: #5f6b7a; /* secondary text, source details */ --m8ty-color-border: #d9dee5; --m8ty-color-input: #ffffff; --m8ty-color-code: rgba(0, 0, 0, .06); --m8ty-color-user: #e8f0ff; /* user message background */ --m8ty-color-user-border: #bcd0ff; --m8ty-color-accent-soft: #e8f0ff; /* icon tiles, selected history entry */ --m8ty-font-family: "Inter", sans-serif; --m8ty-font-size: 15px; --m8ty-radius: 16px;}To use different colors per mode, scope the properties to the theme:
m8ty-chat[theme="dark"] { --m8ty-color-user: #1d2b4a; --m8ty-color-user-border: #2f4a80;}@media (prefers-color-scheme: dark) { m8ty-chat[theme="auto"] { --m8ty-color-user: #1d2b4a; }}Style individual parts with ::part():
m8ty-chat::part(header) { display: none; }m8ty-chat::part(message-user) { border-radius: 4px; }m8ty-chat::part(avatar) { display: none; }Parts: container, header, history, messages, message,
message-user, message-assistant, avatar, avatar-user,
avatar-assistant, sources, preview, preview-snippet, input-row,
input, send.
Behavior
Section titled “Behavior”- Answers stream in; numbered markers
[1]refer to the cited sources listed below the answer, one entry per document (name, pages, number of passages, link for web sources). - Clicking a marker, in the answer or in the source list, opens a source preview over the chat: document name, page and the cited passage, plus a link for web sources. The passage comes with the answer; the embedded chat never loads the document itself. Escape or the close button returns to the chat.
- The history button lists the user’s previous chats; they can be reopened and deleted by the user.
- Maximum question length and daily quota are configured on the share; the component shows a localized message when they are reached.
iframe
Section titled “iframe”https://rag.example.com/embed/{shareId}?locale=de&theme=auto| Kind | Name | Description |
|---|---|---|
| Query parameter | locale |
de or en; default: browser language |
| Query parameter | theme |
light, dark or auto (default) |
| Attribute | referrerpolicy="strict-origin" |
Required: lets the iframe determine your page origin |
| Attribute | allow="clipboard-write" |
Optional: allows the chat to write to the clipboard |
| Function | connectIframe(iframe, { getTicket }) |
Delegated shares: answers the iframe’s ticket requests; returns a function that disconnects it. Exported by m8ty-chat.js and available as window.M8tyEmbed.connectIframe |
The iframe requests a ticket on start and whenever the session must be
renewed. It repeats the request with backoff until your page acknowledges it
and gives up after 15 seconds; connectIframe calls getTicket only once per
request, even if it was repeated. See iframe. Theming via CSS is not
possible inside the iframe; use theme or the web component.
HTTP endpoints you call
Section titled “HTTP endpoints you call”Only one endpoint is called by your code, and only for delegated shares.
POST /api/v1/embed/tickets (server to server)
Section titled “POST /api/v1/embed/tickets (server to server)”| Caller | Your backend only |
| Headers | Authorization: Bearer <gateway key>, X-End-User-Assertion: <JWT>, Content-Type: application/json |
| Body | {"share_id": "shr_…", "origin": "https://…", "nonce": "…"} |
| Success | 200 {"ticket": "…", "expires_in": 60} — single use, bound to share, origin, nonce and user |
| Status | detail |
Meaning | What to do |
|---|---|---|---|
401 |
unauthorized |
Missing headers, unknown/revoked/expired gateway key, or invalid assertion (iss, aud, exp, signature, kid) |
Check key and assertion format (How the User Is Passed) |
403 |
forbidden |
Origin not allowed for the share, assertion issuer differs from the share’s issuer, or user erased/blocked | Use an allowed origin; check issuer; contact the administrator |
404 |
unavailable / not_found |
Share unknown, disabled, expired, not delegated, not bound to this gateway key, or delegation disabled on the platform | Check the share with the administrator |
422 |
invalid_origin / validation |
Malformed origin, share ID or nonce | Fix the request |
429 |
rate_limited |
Too many tickets for this gateway key | Retry later; do not request tickets in a loop |
503 |
temporarily_unavailable |
Ragty state backend unavailable | Retry with backoff |
HTTP endpoints called by the component
Section titled “HTTP endpoints called by the component”For reference and for firewall/proxy rules — you do not call them yourself.
| Method | Path | Purpose |
|---|---|---|
GET |
/embed/v1/shares/{id}/config |
Name, greeting and limits of the share |
POST |
/embed/v1/shares/{id}/visitor |
Public: resume or create the anonymous visitor |
POST |
/embed/v1/shares/{id}/session |
Delegated: redeem the ticket |
GET, POST |
/embed/v1/shares/{id}/conversations |
List / create own chats |
GET, DELETE |
/embed/v1/shares/{id}/conversations/{cid} |
Read / delete own chat |
POST |
/embed/v1/shares/{id}/conversations/{cid}/messages |
Ask a question (Server-Sent Events) |
GET |
/embed-assets/v1/m8ty-chat.js |
Component script |
GET |
/embed/{shareId} |
iframe page |
All chat requests carry X-M8TY-Embed: 1, an Authorization: M8TY-PoP <token>
header and an M8TY-PoP proof signed by the browser’s non-exportable device
key. Responses: 401 unauthorized, 404 unavailable, 429 rate_limited
(with Retry-After), 503 temporarily_unavailable.
If you run a reverse proxy or WAF in front of your own site, nothing has to be configured for these calls — they go directly from the browser to the Ragty URL. Make sure response buffering is disabled for Server-Sent Events if you proxy the Ragty URL itself.
Related topics
Section titled “Related topics”© m8ty GmbH 2023 · m8ty.eu
