diff --git a/docs.json b/docs.json index 84acce61f..f9cc6b0c8 100644 --- a/docs.json +++ b/docs.json @@ -1321,7 +1321,14 @@ "xchat/cryptography-primer", "xchat/getting-started", "xchat/xchat-xdk", - "xchat/migrate-from-legacy-dms" + { + "group": "Migrate from Legacy DMs", + "root": "xchat/migrate-from-legacy-dms", + "expanded": true, + "pages": [ + "xchat/migrate-from-legacy-dms/faq" + ] + } ] }, { diff --git a/snippets/faq-search.mdx b/snippets/faq-search.mdx new file mode 100644 index 000000000..97f1dc69e --- /dev/null +++ b/snippets/faq-search.mdx @@ -0,0 +1,303 @@ +{/* Live search + topic filter chips for FAQ pages (XDS filled input, + pill chips). Questions stay in the server-rendered page: on mount + this reads every .x-faq-topic section (data-topic, data-label) and + its .x-faq-item entries, then only toggles their [hidden] state and + paints match highlights, so answers remain indexable, linkable, and + readable without JavaScript. Matching folds typographic quotes 1:1 + so highlight offsets still line up with the original text nodes. + On mount each .x-faq-q becomes a toggle and its answer collapses; + searching opens the matching rows, clearing the search closes them + again, and hash links open their row. Keep JS comments out + of the component body: Mintlify's snippet parser rejects them. */} +export const FaqSearch = () => { + const [query, setQuery] = useState(""); + const [topic, setTopic] = useState(""); + const [topics, setTopics] = useState([]); + const [counts, setCounts] = useState({ shown: 0, total: 0, byTopic: {} }); + const [fade, setFade] = useState(undefined); + const inputRef = useRef(null); + const chipsRef = useRef(null); + const pendingTarget = useRef(null); + const wasSearching = useRef(false); + + const normalize = (value) => + value.toLowerCase().replace(/[\u2018\u2019]/g, "'").replace(/[\u201C\u201D]/g, '"'); + + const isWordChar = (ch) => /[a-z0-9]/.test(ch); + + const findAll = (text, term) => { + const hits = []; + let index = text.indexOf(term); + while (index !== -1) { + if (index === 0 || !isWordChar(term[0]) || !isWordChar(text[index - 1])) hits.push(index); + index = text.indexOf(term, index + 1); + } + return hits; + }; + + const decode = (value) => { + try { + return decodeURIComponent(value); + } catch (error) { + return value; + } + }; + + const findTarget = (hash) => { + const raw = (hash || "").replace(/^#/, ""); + if (!raw) return null; + return document.getElementById(raw) || document.getElementById(decode(raw)); + }; + + const setOpen = (item, open) => { + item.dataset.state = open ? "open" : "closed"; + const question = item.querySelector(".x-faq-q"); + if (question) question.setAttribute("aria-expanded", open ? "true" : "false"); + }; + + const openItem = (target) => { + const item = target.closest(".x-faq-item"); + if (item) setOpen(item, true); + }; + + const toggle = (question) => { + const item = question.closest(".x-faq-item"); + if (item) setOpen(item, item.dataset.state !== "open"); + }; + + const collectRanges = (root, terms, ranges) => { + const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT); + let node = walker.nextNode(); + while (node) { + const text = normalize(node.data); + terms.forEach((term) => { + findAll(text, term).forEach((index) => { + const range = document.createRange(); + range.setStart(node, index); + range.setEnd(node, index + term.length); + ranges.push(range); + }); + }); + node = walker.nextNode(); + } + }; + + useEffect(() => { + const sections = Array.from(document.querySelectorAll(".x-faq-topic")); + setTopics(sections.map((section) => ({ id: section.dataset.topic, label: section.dataset.label }))); + + const items = Array.from(document.querySelectorAll(".x-faq-item")); + items.forEach((item) => { + const question = item.querySelector(".x-faq-q"); + if (!question) return; + question.setAttribute("role", "button"); + question.tabIndex = 0; + setOpen(item, false); + }); + + const onKeyDown = (event) => { + const question = event.target.closest && event.target.closest(".x-faq-q"); + if (question && (event.key === "Enter" || event.key === " ")) { + event.preventDefault(); + toggle(question); + return; + } + if (event.key !== "/" || event.metaKey || event.ctrlKey || event.altKey) return; + const active = document.activeElement; + if (active && (active.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(active.tagName))) return; + event.preventDefault(); + if (inputRef.current) inputRef.current.focus(); + }; + const reveal = (hash, scroll) => { + const target = findTarget(hash); + if (!target) return; + openItem(target); + if (target.closest(".x-faq-topic[hidden], .x-faq-item[hidden]")) { + pendingTarget.current = target; + setQuery(""); + setTopic(""); + } else if (scroll) { + target.scrollIntoView(); + } + }; + const onHashChange = () => reveal(window.location.hash); + const onClick = (event) => { + const question = event.target.closest && event.target.closest(".x-faq-q"); + if (question && !event.target.closest("a")) toggle(question); + const link = event.target.closest && event.target.closest("a[href*='#']"); + if (link && link.pathname === window.location.pathname) reveal(link.hash); + }; + + document.addEventListener("keydown", onKeyDown); + document.addEventListener("click", onClick); + window.addEventListener("hashchange", onHashChange); + const frame = window.requestAnimationFrame(() => reveal(window.location.hash, true)); + return () => { + window.cancelAnimationFrame(frame); + document.removeEventListener("keydown", onKeyDown); + document.removeEventListener("click", onClick); + window.removeEventListener("hashchange", onHashChange); + document.querySelectorAll(".x-faq-topic, .x-faq-item").forEach((el) => { + el.hidden = false; + }); + items.forEach((item) => { + delete item.dataset.state; + const question = item.querySelector(".x-faq-q"); + if (!question) return; + question.removeAttribute("role"); + question.removeAttribute("tabindex"); + question.removeAttribute("aria-expanded"); + }); + if (typeof CSS !== "undefined" && CSS.highlights) CSS.highlights.delete("x-faq-match"); + }; + }, []); + + useEffect(() => { + const terms = normalize(query).split(/\s+/).filter(Boolean); + const byTopic = {}; + const ranges = []; + let shown = 0; + let total = 0; + + document.querySelectorAll(".x-faq-topic").forEach((section) => { + const id = section.dataset.topic; + const inTopic = topic === "" || topic === id; + let matches = 0; + let visible = 0; + section.querySelectorAll(".x-faq-item").forEach((item) => { + const text = normalize(item.textContent); + const match = terms.every((term) => findAll(text, term).length > 0); + const show = match && inTopic; + item.hidden = !show; + if (terms.length > 0) setOpen(item, show); + else if (wasSearching.current) setOpen(item, false); + total += 1; + if (match) matches += 1; + if (show) { + visible += 1; + if (terms.length > 0) collectRanges(item, terms, ranges); + } + }); + byTopic[id] = matches; + section.hidden = visible === 0; + shown += visible; + }); + + wasSearching.current = terms.length > 0; + setCounts({ shown, total, byTopic }); + if (typeof CSS !== "undefined" && CSS.highlights && typeof Highlight === "function") { + CSS.highlights.set("x-faq-match", new Highlight(...ranges)); + } + if (pendingTarget.current) { + openItem(pendingTarget.current); + pendingTarget.current.scrollIntoView(); + pendingTarget.current = null; + } + }, [query, topic, topics]); + + useEffect(() => { + const row = chipsRef.current; + if (!row) return undefined; + const update = () => { + const start = row.scrollLeft > 1; + const end = row.scrollLeft < row.scrollWidth - row.clientWidth - 1; + setFade(start && end ? "both" : start ? "start" : end ? "end" : undefined); + }; + update(); + row.addEventListener("scroll", update, { passive: true }); + const observer = typeof ResizeObserver === "function" ? new ResizeObserver(update) : null; + if (observer) observer.observe(row); + return () => { + row.removeEventListener("scroll", update); + if (observer) observer.disconnect(); + }; + }, [topics, counts]); + + const filtered = query.trim() !== "" || topic !== ""; + const noun = (n) => (n === 1 ? "question" : "questions"); + const placeholder = counts.total > 0 ? `Search ${counts.total} questions` : "Search questions"; + const clearAll = () => { + setQuery(""); + setTopic(""); + if (inputRef.current) inputRef.current.focus(); + }; + + return ( +
+
+ + setQuery(event.target.value)} + onKeyDown={(event) => { + if (event.key === "Escape") setQuery(""); + }} + /> + {query ? ( + + ) : ( + + )} +
+ +
+ + {topics.map((item) => ( + + ))} +
+ +

+ {filtered && counts.shown > 0 ? `Showing ${counts.shown} of ${counts.total} ${noun(counts.total)}` : ""} + {filtered && counts.shown > 0 ? ( + + ) : null} +

+ + {filtered && counts.shown === 0 && counts.total > 0 ? ( +
+
No matching questions
+

+ Try fewer or different words, or pick another topic. +

+ +
+ ) : null} +
+ ); +}; diff --git a/snippets/legacy-dm-faq-redirect.mdx b/snippets/legacy-dm-faq-redirect.mdx new file mode 100644 index 000000000..5c0cce05f --- /dev/null +++ b/snippets/legacy-dm-faq-redirect.mdx @@ -0,0 +1,53 @@ +{/* The Partner FAQ used to sit on xchat/migrate-from-legacy-dms as + accordions. Deep links to those questions are forwarded to the + standalone FAQ page, where each question keeps its old slug as id. The + list is frozen: questions added after the move never had anchors on + the guide, and unknown hashes must stay put (some guide links use + stale section anchors). */} +export const LegacyDmFaqRedirect = () => { + useEffect(() => { + const slugs = [ + "what-is-changing", + "when-does-this-happen", + "what-stops-working-after-december-9-2026", + "do-we-need-to-move-or-archive-our-existing-dm-history", + "will-my-customers-notice", + "where-is-the-up-to-date-documentation", + "do-i-have-to-switch-to-oauth-2-0-to-use-x-chat", + "what-app-permission-or-scopes-do-i-need", + "if-i-change-my-apps-permission-do-my-customers-have-to-reconnect", + "chat-xdk-examples-use-oauth-2-0-with-pkce-does-chat-xdk-require-that", + "does-sign-in-with-x-change", + "what-are-keys-and-what-is-the-pin", + "my-customers-staff-use-our-web-app-but-only-an-admin-knows-the-pin-does-that-work", + "what-if-the-account-has-never-set-a-pin-or-the-admin-doesnt-know-it", + "how-do-i-check-whether-an-account-already-has-keys-or-can-receive-encrypted-chats", + "is-there-a-limit-on-wrong-pin-guesses", + "do-i-need-xs-approval-to-store-keys-on-my-servers", + "if-a-customer-revokes-my-apps-access-are-the-keys-revoked-too", + "if-we-pause-our-dm-integration-for-a-while-can-we-read-those-messages-later", + "can-we-export-keys-in-the-browser-can-the-pin-stay-off-our-servers", + "can-we-capture-messages-now-and-decrypt-them-after-the-customer-gives-us-keys", + "which-events-replace-the-old-dm-events", + "can-i-create-webhook-subscriptions-with-oauth-1-0a", + "the-chat-events-dont-include-the-senders-name-or-profile-how-do-i-get-them", + "our-bot-only-replies-to-messages-do-we-need-to-do-anything-to-start-conversations", + "is-there-a-full-map-from-the-old-dm-endpoints-to-the-new-ones", + "is-there-a-replacement-for-custom-profiles-listing-all-dm-events-at-once-or-looking-up-one-event-by-id", + "what-about-attachments-welcome-messages-and-surveys", + "what-are-the-x-chat-rate-limits", + "which-languages-does-chat-xdk-support", + "can-i-send-plain-text-through-the-x-chat-api", + "what-do-xchat-setup-required-and-recipient-xchat-setup-required-mean", + "why-does-key-setup-post-2-chat-conversations-id-keys-return-403", + "what-do-message-request-not-supported-and-recipient-not-messageable-mean", + "we-have-several-services-sending-from-the-same-brand-account-can-we-move-them-one-at-a-time", + "some-dms-no-longer-show-up-in-the-legacy-endpoints-why", + "what-other-errors-might-i-see", + ]; + const hash = window.location.hash.slice(1); + if (slugs.includes(hash)) window.location.replace("/xchat/migrate-from-legacy-dms/faq#" + hash); + }, []); + + return null; +}; diff --git a/style.css b/style.css index 8b85ba2f6..018a136dd 100644 --- a/style.css +++ b/style.css @@ -2152,6 +2152,330 @@ td[data-label="Free Limit"] strong { cursor: pointer; } +/* FAQ pages (xchat/migrate-from-legacy-dms/faq) — every answer is + server-rendered markdown inside .x-faq-topic sections and + .x-faq-item rows; FaqSearch (snippets/faq-search.mdx) only toggles + [hidden]/[data-state] and paints ::highlight ranges over them, so + without JavaScript every answer stays visible. */ +.x-faq-glance { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 12px; + margin: 4px 0 28px; +} +.x-faq-glance-tile { + background: var(--x-tile-bg); + border-radius: var(--x-radius-md); + padding: 16px; +} +.x-faq-glance-label { + font-size: var(--x-text-subtext2); + line-height: var(--x-leading-subtext2); + font-weight: 700; + color: var(--x-fg-secondary); +} +.x-faq-glance-value { + margin-top: 6px; + font-size: var(--x-text-headline1); + line-height: var(--x-leading-headline1); + font-weight: 800; + letter-spacing: -0.01em; + color: var(--x-fg-primary); +} +.x-faq-glance-caption { + margin-top: 6px; + font-size: var(--x-text-subtext1); + line-height: 20px; + color: var(--x-fg-secondary); + text-wrap: pretty; +} +@media (max-width: 639px) { + .x-faq-glance { + grid-template-columns: 1fr; + } +} + +/* Reserves the client-rendered toolbar's height (search + chip row) + so the questions below don't shift when it mounts. */ +.x-faq-toolbar { + min-height: 90px; +} +.x-faq-search-field { + position: relative; +} +.x-faq-search-icon { + position: absolute; + left: 16px; + top: 50%; + width: 18px; + height: 18px; + transform: translateY(-50%); + color: var(--x-fg-secondary); + pointer-events: none; +} +.x-faq-search-field input { + width: 100%; + height: 44px; + padding: 0 48px 0 44px; + background: var(--x-bg-inputs); + border: 1px solid transparent; + border-radius: var(--x-radius-full); + color: var(--x-fg-primary); + font-size: var(--x-text-body); + -webkit-appearance: none; + appearance: none; + transition: border-color 120ms ease; +} +.x-faq-search-field input::placeholder { + color: var(--x-fg-secondary); +} +.x-faq-search-field input:focus { + outline: none; + border-color: var(--x-border-active); + box-shadow: none; +} +.x-faq-search-field input::-webkit-search-cancel-button { + display: none; + -webkit-appearance: none; +} +.x-faq-search-kbd { + position: absolute; + right: 16px; + top: 50%; + transform: translateY(-50%); + min-width: 20px; + text-align: center; + font-family: var(--x-font-sans); + font-size: var(--x-text-subtext2) !important; + line-height: 18px; + color: var(--x-fg-secondary); +} +.x-faq-search-clear { + position: absolute; + right: 8px; + top: 50%; + transform: translateY(-50%); + display: grid; + place-items: center; + width: 28px; + height: 28px; + border-radius: var(--x-radius-full); + color: var(--x-fg-secondary); + background: transparent; + cursor: pointer; + transition: background 120ms ease, color 120ms ease; +} +.x-faq-search-clear:hover { + background: var(--x-hover-subtle); + color: var(--x-fg-primary); +} +.x-faq-search-clear svg { + width: 18px; + height: 18px; +} +.x-faq-chips { + display: flex; + gap: 6px; + margin-top: 12px; + overflow-x: auto; + scrollbar-width: none; +} +.x-faq-chips::-webkit-scrollbar { + display: none; +} +.x-faq-chips[data-fade="end"] { + -webkit-mask-image: linear-gradient(to right, black calc(100% - 32px), transparent); + mask-image: linear-gradient(to right, black calc(100% - 32px), transparent); +} +.x-faq-chips[data-fade="start"] { + -webkit-mask-image: linear-gradient(to left, black calc(100% - 32px), transparent); + mask-image: linear-gradient(to left, black calc(100% - 32px), transparent); +} +.x-faq-chips[data-fade="both"] { + -webkit-mask-image: linear-gradient(to right, transparent, black 32px, black calc(100% - 32px), transparent); + mask-image: linear-gradient(to right, transparent, black 32px, black calc(100% - 32px), transparent); +} +.x-faq-chip { + flex: none; + display: inline-flex; + align-items: center; + gap: 5px; + height: 32px; + padding: 0 12px; + border: 1px solid var(--x-border-normal); + border-radius: var(--x-radius-full); + background: transparent; + color: var(--x-fg-primary); + font-size: var(--x-text-subtext2); + font-weight: 700; + white-space: nowrap; + cursor: pointer; + transition: background 120ms ease, border-color 120ms ease, color 120ms ease; +} +.x-faq-chip:hover { + background: var(--x-hover-subtle); + border-color: var(--x-border-hover); +} +.x-faq-chip:active { + transform: scale(0.97); + transition: transform 100ms ease; +} +.x-faq-chip[aria-pressed="true"] { + background: var(--x-fg-primary); + border-color: var(--x-fg-primary); + color: var(--x-bg-primary); +} +.x-faq-chip-count { + font-weight: 500; + color: var(--x-fg-secondary); + font-variant-numeric: tabular-nums; +} +.x-faq-chip[aria-pressed="true"] .x-faq-chip-count { + color: inherit; + opacity: 0.65; +} +.x-faq-chip[data-empty]:not([aria-pressed="true"]) { + color: var(--x-fg-tertiary); +} +.x-faq-status { + margin: 12px 0 0; + font-size: var(--x-text-subtext1); + line-height: 20px; + color: var(--x-fg-secondary); +} +.x-faq-status:empty { + margin: 0; +} +.x-faq-status button { + margin-left: 8px; + padding: 0; + background: none; + font-weight: 700; + color: var(--x-fg-primary); + text-decoration: underline; + text-decoration-color: var(--x-border-active); + text-underline-offset: 3px; + cursor: pointer; +} +.x-faq-status button:hover { + text-decoration-color: var(--x-fg-primary); +} +.x-faq-empty { + margin-top: 24px; + padding: 32px 24px; + border-radius: var(--x-radius-md); + background: var(--x-tile-bg); +} + +.x-faq-topic { + margin-top: 40px; +} +.x-faq-topic[hidden], +.x-faq-item[hidden] { + display: none !important; +} +#content-area .prose .x-faq-topic > h2, +mdx-content .x-faq-topic > h2 { + margin-top: 0 !important; + margin-bottom: 4px !important; +} +#content-area .prose .x-faq-topic-desc, +mdx-content .x-faq-topic-desc { + display: block; + margin: 0 0 16px; + color: var(--x-fg-secondary); +} +.x-faq-item { + border-top: 1px solid var(--x-border-normal); + scroll-margin-top: 96px; +} +.x-faq-item:last-of-type { + border-bottom: 1px solid var(--x-border-normal); +} +.x-faq-item > .x-faq-q { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16px; + margin: 0 -12px; + padding: 16px 12px; + border-radius: var(--x-radius-sm); + font-size: var(--x-text-headline2); + line-height: 24px; + font-weight: 600; + color: var(--x-fg-primary); + -webkit-tap-highlight-color: transparent; +} +.x-faq-item[data-state] > .x-faq-q { + cursor: pointer; + user-select: none; +} +.x-faq-item[data-state="closed"] > :not(.x-faq-q) { + display: none !important; +} +.x-faq-item[data-state] > .x-faq-q::after { + content: ""; + flex: none; + width: 20px; + height: 20px; + background-color: var(--x-fg-secondary); + -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 15.5 5.5 9l1.4-1.4 5.1 5.1 5.1-5.1L18.5 9z'/%3E%3C/svg%3E") center / 20px no-repeat; + mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 15.5 5.5 9l1.4-1.4 5.1 5.1 5.1-5.1L18.5 9z'/%3E%3C/svg%3E") center / 20px no-repeat; + transition: transform 0.2s ease; +} +.x-faq-item[data-state="open"] > .x-faq-q::after { + transform: rotate(180deg); +} +.x-faq-item[data-state] > .x-faq-q:hover { + background: var(--x-hover-subtle); +} +.x-faq-item > .x-faq-q:focus-visible { + outline: 2px solid var(--x-border-active); + outline-offset: -2px; +} +.x-faq-item[data-state="open"] > :last-child { + margin-bottom: 20px !important; +} +/* Mintlify emits paragraphs inside HTML wrappers as + and only blocks them as direct .prose + children, so items restate the paragraph rhythm. */ +.x-faq-item > span[data-as="p"], +.x-faq-item > p, +.x-faq-item > ul { + display: block; + margin-top: 0 !important; + margin-bottom: 16px !important; +} +::highlight(x-faq-match) { + background-color: color-mix(in srgb, var(--x-fg-primary) 22%, transparent); + color: var(--x-fg-primary); +} + +.x-faq-help { + margin-top: 48px; + padding: 24px; + border-radius: var(--x-radius-md); + background: var(--x-tile-bg); +} +.x-faq-help-title { + font-size: var(--x-text-headline1); + line-height: var(--x-leading-headline1); + font-weight: 800; + color: var(--x-fg-primary); +} +.x-faq-help-text { + margin-top: 6px; + font-size: var(--x-text-body); + line-height: 22px; + color: var(--x-fg-secondary); +} +.x-faq-help-actions { + display: flex; + flex-wrap: wrap; + gap: 8px; + margin-top: 16px; +} + /* Grok assistant — rebrand Mintlify's assistant entry points */ #assistant-entry span { font-size: 0 !important; diff --git a/xchat/migrate-from-legacy-dms.mdx b/xchat/migrate-from-legacy-dms.mdx index 08f074e26..73487dd7c 100644 --- a/xchat/migrate-from-legacy-dms.mdx +++ b/xchat/migrate-from-legacy-dms.mdx @@ -2,9 +2,11 @@ title: "Migrate from Legacy Direct Messages to the X Chat API" sidebarTitle: Migrate from Legacy DMs description: "Complete guide to moving from v1.1 and v2 Direct Messages to the end-to-end encrypted X Chat API: timeline, auth scopes, endpoint mapping, key custody, real-time events, cutover checklist, troubleshooting, and FAQ." -keywords: ["X Chat migration", "legacy DM migration", "Direct Messages to X Chat", "dm_events", "dm_conversations", "direct_messages", "E2EE migration", "X Chat troubleshooting", "X Chat FAQ"] +keywords: ["X Chat migration", "legacy DM migration", "Direct Messages to X Chat", "dm_events", "dm_conversations", "direct_messages", "E2EE migration", "X Chat troubleshooting"] --- +import { LegacyDmFaqRedirect } from '/snippets/legacy-dm-faq-redirect.mdx'; + Moving from Legacy Direct Messages (`v1.1 direct_messages/*`, `v2 /2/dm_events`, `/2/dm_conversations`, and Account Activity DM webhooks) to the **X Chat API** (`/2/chat/*`) is an architectural change, not a URL swap. X routes only ciphertext; encryption, decryption, and signing run in your client using the **[Chat XDK](/xchat/xchat-xdk)**. @@ -456,210 +458,8 @@ For SDK-specific cryptography, backup recovery, and decryption issues, see [Fix ### Partner FAQ - - - - - X is replacing legacy Direct Messages with X Chat. Legacy DMs were unencrypted; X Chat messages are end-to-end encrypted so that only participants in the conversation can read them. Apps using legacy DM endpoints need to move to the X Chat API (`/2/chat/*`). - - - - **December 9, 2026** is the last day to move. After that, the X Chat API is the only API for Direct Messages. X will confirm the exact switch-over time ahead of the date. - - - - After December 9, X stops accepting new unencrypted DMs — every new DM must be sent encrypted through X Chat. Legacy webhooks also stop sending unencrypted DM events, and new messages arrive as encrypted X Chat events instead. - - Retired surfaces: v1.1 `direct_messages/*` and `custom_profiles/*`, v2 `/2/dm_events` and `/2/dm_conversations/*` (including DM media), `media_category=dm_*` uploads, Account Activity DM events (`direct_message_events`, typing, read), and X Activity `dm.*` events. The replacements are `/2/chat/*` and X Activity `chat.received`, `chat.sent`, and `chat.conversation.join`. Your message history is not lost. - - - - No. Existing conversations are upgraded on X's side, so there is nothing for you to move or archive. Older unencrypted messages stay in their conversations and remain readable through the X Chat API alongside new encrypted messages. `chat-xdk` handles both kinds, and older unencrypted messages do not require keys. - - There is no time limit on how far back you can read — page with `pagination_token` until `has_more` is `false`. A few legacy details do not carry over: edits and deletions of older messages, attachments after the first on an older message, and disappearing messages that already expired. Because `chat-xdk` rejects older unencrypted (unverified) messages by default, opt in with `set_reject_unverified(false)` and label them as unverified in your product. - - - - For most customers this is a small change. At most, a customer may need to enter their X Chat PIN once. Accounts that have never set up X Chat do not need an existing PIN, because you can create encryption keys for them through the API (only do this for accounts with no X Chat keys; storing customer keys on your servers requires X's approval). - - - - Use the X Chat docs starting at [docs.x.com/xchat/introduction](/xchat/introduction). They are kept current — do not rely on older PDF guides. - - - - - - - - No. OAuth 1.0a user tokens work with the X Chat endpoints, including welcome messages, surveys, and the endpoints that look up and register a user's public keys. Your app needs the **"Read, Write and Direct Messages"** permission. App-Only Bearer tokens do not work on X Chat endpoints, so use user-context tokens. - - OAuth 1.0a itself retires on **January 31, 2027**, so plan your move to OAuth 2.0 before then. The [OAuth 1.0a to OAuth 2.0 token exchange](/fundamentals/authentication/oauth-2-0/oauth-1-0a-token-exchange) moves existing users with DM permission over without asking them to reconnect. - - - - - **OAuth 1.0a:** Your app needs **"Read, Write and Direct Messages"** (the legacy DM endpoints already required it). - - **OAuth 2.0:** The token needs `dm.read` and `dm.write`, plus `tweet.read` and `users.read`. Add `media.write` to download or upload chat media, and `offline.access` for refresh tokens. There are no separate X Chat scopes. If you only read and archive messages, `dm.write` is not needed. - - - - Yes. A token keeps the permission it was created with. If you change the app's permission, customers must authorize your app again to get new tokens. If your app already has **"Read, Write and Direct Messages"**, nothing needs to change and existing tokens keep working. - - The same applies when exchanging OAuth 1.0a tokens for OAuth 2.0: scopes come from the original token permission. **"Read, Write and Direct Messages"** exchanges to `dm.read`, `dm.write`, and `media.write` (plus `offline.access`) with no consent screen. **"Read and Write"** gets `media.write` only, and **"Read"** gets neither, so those users must re-authorize for X Chat. - - - - No. `chat-xdk` encrypts, decrypts, and signs messages locally and never calls the X API with your token. Your own code makes the HTTP calls, so you can sign them with OAuth 1.0a or OAuth 2.0. - - - - No. The move to X Chat only affects DM access. To read or send X Chat for a user, the token needs DM access; if sign-in tokens already have it, nothing changes — otherwise users go through consent once. X Chat also needs the account's encryption keys, which are separate from sign-in. - - - - - - - - Each X Chat account has a set of private encryption keys that unlock and sign the account's messages. Anyone who holds them can read that account's messages and send as that account, so treat them like a master password. The PIN is a short code the account owner sets in the X app to recover those keys from X's secure key backup. - - - - Yes, with approved server-side key storage. Your backend can hold the account's encryption keys, decrypt messages as they come in, and display them to the customer's staff in your web app — staff never need the PIN. - - The PIN is used only once, when the admin connects the company's X account. Unlock and export the keys once, save them securely in your KMS/secret manager, and never save the PIN. If the admin later changes their PIN in the X app, the saved keys keep working. They stop working only if the account owner runs **Reset Chat** or resets a forgotten PIN — watch for a change in `public_key_version`, and if it changes, stop sending from that account and ask the admin to reconnect. Key export works in the server and native editions of `chat-xdk`, not in the browser edition. - - - - - **Never set up X Chat (`GET /2/users/{id}/public_keys` returns no keys):** You can create a new keypair for the account through the API and save it. Have the admin choose the account's PIN in your connect flow rather than picking one for them, so the business can still use X Chat in the X app later. - - **Already uses X Chat, but the admin doesn't know the PIN:** Do **not** create new keys — a new keypair replaces the account's identity and breaks X Chat in the X app. The admin must find the PIN or reset it in the X app (resetting makes messages encrypted under the old keys unreadable). - - Older unencrypted DMs do not need keys at all. - - - - Call `GET /2/users/{id}/public_keys` (or batch `GET /2/users/public_keys?ids=...`). If key backup details are returned, the account already uses X Chat — recover the existing keys with the PIN instead of creating new ones. - - To check whether you can start an encrypted chat with someone, request `GET /2/users/{id}?user.fields=receives_your_chat` with the sending account's token: `encrypted` means you can, `unencrypted` means the pair cannot be encrypted yet, and `none` means you cannot message them. - - - - Yes. Secure key backup allows only a small number of wrong guesses, and that budget cannot be reset. If it runs out, the backup is deleted and older encrypted messages become unreadable. Ask the account owner to confirm their PIN in the X app first, and stop after one wrong attempt. - - Unlock once per account and reuse the result — do not unlock per message or per request. Unlocks have a separate rate limit (about 30 per minute per IP address), independent of X API rate limits. - - - - Yes. Storing customers' keys on your servers requires approval from X. All of the following must be true: - - Your customers are businesses or organizations, not individual consumers. - - You run a business messaging or automation tool on their behalf. - - Your customers knowingly give you their key material. - - Each customer's keys are used only for that customer's own X Chat account. - - You tell customers, in your product or contract, that keys are separate from sign-in access and that revoking your app's access does not revoke keys they already shared. - - Your contract with each customer covers how you store and protect keys, who can access them, breach notice, and deleting or returning keys when the relationship ends. + - To start the review, send your X account representative a Yes or No for each point above along with a short description of how your product uses X DMs. - - - - No. Revoking access only stops your app's API tokens; keys a customer already shared keep working. When a customer leaves, delete every copy and backup of their keys and instruct them to revoke your app's access and run **Reset Chat** in the X app. Reset Chat is the only way to invalidate previously shared keys — there is no app-level key revocation today. - - - - Yes, as long as you still have the keys needed to decrypt them and the account has not run Reset Chat or reset a forgotten PIN in the meantime. You can fetch history later while the account is still in the conversation. If you cannot stay subscribed, store the encrypted events (including the conversation key-change events on each page) and decrypt them later. - - - - The browser edition of `chat-xdk` cannot export keys. Export works in the server and native editions: Node (`@xdevplatform/chat-xdk-server`), Python, Go, .NET, JVM, and Rust. If the PIN must not touch your servers, the business can run a small local tool that unlocks and exports the keys on its own machine and uploads only the exported keys. Without approved key storage, decryption works only in the account owner's own session, so background or scheduled processing is not possible. There is no way to export keys without the PIN. - - - - Yes, as long as the account keeps the same X Chat keys. Store the encrypted events now, including the conversation key-change events on each page, and decrypt them once the customer provides key access. If the owner runs Reset Chat or resets a forgotten PIN before then, messages encrypted under the old keys cannot be decrypted. Capturing alone does not let you reply; replies must be sent encrypted. - - - - - - - - Subscribe to `chat.received` for inbound messages, `chat.sent` for outbound messages, and `chat.conversation.join` for when an account joins a conversation (plus group membership/admin/settings events as needed). Message text arrives encrypted and is decrypted with `chat-xdk`. - - Existing DM subscriptions and Account Activity webhooks do not carry chat events, so create new subscriptions via `POST /2/activity/subscriptions` for each account (you can point them at your existing `webhook_id`). While unencrypted conversations still exist, their messages arrive as `dm.received`, so subscribe to both during cutover and deduplicate. - - - - Yes. `POST /2/activity/subscriptions` accepts OAuth 1.0a user tokens for chat events if the app has the **"Read, Write and Direct Messages"** permission (without it, `chat.*` and `dm.*` subscriptions return `403 oauth1-permissions`). With OAuth 2.0, the token needs the `dm.read` scope. - - - - Chat events currently include user IDs only, not names or profiles — each event has the sender's user ID and the conversation ID. Look up profile details with `GET /2/users?ids=...`, or use `GET /2/chat/conversations` / `GET /2/chat/conversations/{id}` with `expansions=participant_ids` and `user.fields`, and cache profiles by user ID. Profile details for the sender and subscribed user are being added to chat events in an `includes.users` block, matching other X Activity API events. - - - - If you only reply to messages people send you, send your replies encrypted with `chat-xdk` — nothing else is required. To start a new 1:1 conversation yourself, set up the conversation key first with `POST /2/chat/conversations/{recipient_id}/keys`, then send. - - - - Yes — see [Endpoint mapping](#3-endpoint-mapping) above. - - - - No, X Chat has none of these. Use `chat.received` and `chat.sent` as your live feed. To catch up, list conversations changed since your last sync (`GET /2/chat/conversations?start_time=...`) and read events only for those conversations — polling every conversation on a timer exhausts per-user event limits quickly. To look up a single event later, persist events as they arrive. - - - - X Chat has its own encrypted media upload and download endpoints (see [Media](/xchat/media)). Chat media downloads are encrypted and must be decrypted with `chat-xdk`; with OAuth 2.0, downloads require the `media.write` scope. Legacy DM media IDs do not work on X Chat media endpoints and return `404`. - - Welcome messages and surveys also have X Chat versions in the API. They accept OAuth 2.0 and OAuth 1.0a user tokens; with OAuth 1.0a, your app needs the **"Read, Write and Direct Messages"** permission. - - - - Limits are set per access package, per user and per app, in 15-minute and 24-hour windows. `GET /2/chat/message_requests` is limited to 75 requests per 15 minutes, and registering public keys has a low daily limit. Responses include `x-rate-limit-*` headers, and `429` responses include `retry-after`. Contact your X account representative for your package's specific numbers. - - - - Python, JavaScript/TypeScript (browser, plus `@xdevplatform/chat-xdk-server` for Node), Go, Rust, .NET 8+, and JVM (JDK 8 or later). There is no Ruby or PHP binding — run encryption in a small service in a supported language and call it from your app. Go ships prebuilt libraries for macOS and Linux `amd64` only; on Linux `ARM64`, use the Python or Node server package. Do not write your own encryption. - - - - - - - - No. Send all messages encrypted with `chat-xdk`. Plaintext messages are refused with HTTP `403 unencrypted-send-not-allowed`. HTTP `400 encryption-required` means the chat can be encrypted: set up conversation keys if none exist, then send encrypted. - - - - HTTP `400 xchat-setup-required` means the sending account has no X Chat keys yet. HTTP `400 recipient-xchat-setup-required` means the recipient has no X Chat keys, so nothing can be sent to them (and nothing is sent unencrypted instead). Check recipients first with `GET /2/users/public_keys?ids=...` and try again after they set up X Chat. - - - - You can start an encrypted 1:1 only when both accounts have X Chat keys **and** the recipient follows you, you have messaged each other before, or they accepted a message request from you. Being verified, or the recipient allowing messages from everyone, does not change this. - - The same `403` also appears while either account still has an active legacy DM connection through an app on the legacy DM allowlist (see [Testing before cutover](#testing-before-cutover)). Treat this `403` as permanent for that pair and do not retry it in a loop. - - - - HTTP `403 message-request-not-supported` means the recipient does not follow you and has not accepted your messages, so you cannot start a chat with them. HTTP `403 recipient-not-messageable` is permanent: their settings or a block prevent messaging. HTTP `503 chat-permissions-unavailable` is temporary, so retry with backoff. - - Message requests you receive are listed at `GET /2/chat/message_requests`. Replying does not accept a request — call `POST /2/chat/message_requests/{id}/accept`. - - - - Move them together. While any of your services still uses legacy DMs for an account, new 1:1 chats for that account stay unencrypted and key setup can fail with `403`. Stop all legacy DM calls and subscriptions for that account when you switch. - - - - Once a conversation is encrypted, its new messages are only available through the X Chat API and `chat.*` events. Legacy DM endpoints and webhooks only carry unencrypted messages. - - - - - `400 INVALID_IDENTITY_KEY_PAIR` on key setup: A participant's key version changed. Fetch their public keys again, rebuild, and retry once. - - `400 ContentsTooLarge` on send: Encrypted messages are capped at 20 KB (about 11,000 bytes of text), so split long messages. - - `404` on chat media: The attachment is gone or the ID is a legacy DM media ID — do not retry. - - `429` on conversation events: You are polling every conversation. Use webhooks/stream and read only the conversations that changed. - - `429` responses include `retry-after`: Wait that long before retrying. - - - - + + Searchable answers to the questions partners ask most: timeline, sign-in and permissions, keys and PINs, events and endpoints, and common errors. + diff --git a/xchat/migrate-from-legacy-dms/faq.mdx b/xchat/migrate-from-legacy-dms/faq.mdx new file mode 100644 index 000000000..4064f9074 --- /dev/null +++ b/xchat/migrate-from-legacy-dms/faq.mdx @@ -0,0 +1,413 @@ +--- +title: "X Chat migration FAQ" +sidebarTitle: Partner FAQ +description: "Answers to the questions partners ask most about moving from legacy Direct Messages to the X Chat API: timeline, sign-in and permissions, keys and PINs, events and endpoints, and common errors." +keywords: ["X Chat FAQ", "X Chat migration FAQ", "X Chat partner FAQ", "legacy DM migration", "Direct Messages to X Chat", "X Chat PIN", "X Chat keys", "OAuth 1.0a X Chat", "chat-xdk"] +--- + +import { FaqSearch } from '/snippets/faq-search.mdx'; + +{/* FaqSearch builds its topic chips and counts from the .x-faq-topic + sections (data-topic, data-label) and .x-faq-item blocks below. + To add a question, copy an x-faq-item block into its topic + and give it a unique id (that id is the question's shareable link). */} + +
+
+
Legacy DMs end
+
Dec 9, 2026
+
Last day to move. Legacy DM endpoints turn off at 00:00 UTC on Dec 10.
+
+
+
Existing DM history
+
Nothing to move
+
Existing conversations are upgraded on X's side.
+
+
+ +
+ +
+ +
+ +## Timeline and history + +

What's changing, when it happens, and what happens to your existing DM history.

+ +
+
What is changing?
+ +X is replacing legacy Direct Messages with X Chat. Legacy DMs were unencrypted; X Chat messages are end-to-end encrypted so that only participants in the conversation can read them. Apps using legacy DM endpoints need to move to the X Chat API (`/2/chat/*`). + +
+ +
+
When does this happen?
+ +**December 9, 2026** is the last day to move. Legacy DM endpoints are turned off at **00:00:00 UTC on December 10, 2026**, and from then on the X Chat API is the only API for Direct Messages. + +
+ +
+
What day and time are the legacy DM endpoints turned off?
+ +**December 10, 2026 at 00:00:00 UTC.** + +
+ +
+
What stops working after December 9, 2026?
+ +After December 9, X stops accepting new unencrypted DMs — every new DM must be sent encrypted through X Chat. Legacy webhooks also stop sending unencrypted DM events, and new messages arrive as encrypted X Chat events instead. + +Retired surfaces: v1.1 `direct_messages/*` and `custom_profiles/*`, v2 `/2/dm_events` and `/2/dm_conversations/*` (including DM media), `media_category=dm_*` uploads, Account Activity DM events (`direct_message_events`, typing, read), and X Activity `dm.*` events. The replacements are `/2/chat/*` and X Activity `chat.received`, `chat.sent`, and `chat.conversation.join`. Your message history is not lost. + +
+ +
+
Do we need to move or archive our existing DM history?
+ +**No.** Existing conversations are upgraded on X's side, so there is nothing for you to move or archive. Older unencrypted messages stay in their conversations and remain readable through the X Chat API alongside new encrypted messages. `chat-xdk` handles both kinds, and older unencrypted messages do not require keys. + +There is no time limit on how far back you can read — page with `pagination_token` until `has_more` is `false`. A few legacy details do not carry over: edits and deletions of older messages, attachments after the first on an older message, and disappearing messages that already expired. Because `chat-xdk` rejects older unencrypted (unverified) messages by default, opt in with `set_reject_unverified(false)` and label them as unverified in your product. + +
+ +
+
Will there be backwards compatibility with DMs?
+ +**Yes.** You can still read previous unencrypted messages. They are decoded rather than decrypted, so they do not need keys. + +
+ +
+
Will my customers notice?
+ +For most customers this is a small change. At most, a customer may need to enter their X Chat PIN once. Accounts that have never set up X Chat do not need an existing PIN, because you can create encryption keys for them through the API (only do this for accounts with no X Chat keys; storing customer keys on your servers requires X's approval). + +
+ +
+
Where is the up-to-date documentation?
+ +Use the X Chat docs starting at [docs.x.com/xchat/introduction](/xchat/introduction). They are kept current — do not rely on older PDF guides. + +
+ +
+ +
+ +## Sign-in and permissions + +

OAuth versions, app permissions and scopes, and when customers need to reconnect.

+ +
+
Do I have to switch to OAuth 2.0 to use X Chat?
+ +**No.** OAuth 1.0a user tokens work with the X Chat endpoints, including welcome messages, surveys, and the endpoints that look up and register a user's public keys. Your app needs the **"Read, Write and Direct Messages"** permission. App-Only Bearer tokens do not work on X Chat endpoints, so use user-context tokens. + +OAuth 1.0a itself retires on **January 31, 2027**, so plan your move to OAuth 2.0 before then. The [OAuth 1.0a to OAuth 2.0 token exchange](/fundamentals/authentication/oauth-2-0/oauth-1-0a-token-exchange) moves existing users with DM permission over without asking them to reconnect. + +
+ +
+
What app permission or scopes do I need?
+ +- **OAuth 1.0a:** Your app needs **"Read, Write and Direct Messages"** (the legacy DM endpoints already required it). +- **OAuth 2.0:** The token needs `dm.read` and `dm.write`, plus `tweet.read` and `users.read`. Add `media.write` to download or upload chat media, and `offline.access` for refresh tokens. There are no separate X Chat scopes. If you only read and archive messages, `dm.write` is not needed. + +
+ +
+
If I change my app's permission, do my customers have to reconnect?
+ +**Yes.** A token keeps the permission it was created with. If you change the app's permission, customers must authorize your app again to get new tokens. If your app already has **"Read, Write and Direct Messages"**, nothing needs to change and existing tokens keep working. + +The same applies when exchanging OAuth 1.0a tokens for OAuth 2.0: scopes come from the original token permission. **"Read, Write and Direct Messages"** exchanges to `dm.read`, `dm.write`, and `media.write` (plus `offline.access`) with no consent screen. **"Read and Write"** gets `media.write` only, and **"Read"** gets neither, so those users must re-authorize for X Chat. + +
+ +
+
Chat XDK examples use OAuth 2.0 with PKCE. Does the Chat XDK require that?
+ +**No.** `chat-xdk` encrypts, decrypts, and signs messages locally and never calls the X API with your token. Your own code makes the HTTP calls, so you can sign them with OAuth 1.0a or OAuth 2.0. + +
+ +
+
Does Sign in with X change?
+ +**No.** The move to X Chat only affects DM access. To read or send X Chat for a user, the token needs DM access; if sign-in tokens already have it, nothing changes — otherwise users go through consent once. X Chat also needs the account's encryption keys, which are separate from sign-in. + +
+ +
+ +
+ +## Keys, PINs, and storage + +

Encryption keys, PINs, storing keys on your servers, and what happens when a customer leaves.

+ +
+
What are keys and what is the PIN?
+ +Each X Chat account has a set of private encryption keys that unlock and sign the account's messages. Anyone who holds them can read that account's messages and send as that account, so treat them like a master password. The PIN is a short code the account owner sets in the X app to recover those keys from X's secure key backup. + +
+ +
+
My customers' staff use our web app, but only an admin knows the PIN. Does that work?
+ +**Yes, with approved server-side key storage.** Your backend can hold the account's encryption keys, decrypt messages as they come in, and display them to the customer's staff in your web app — staff never need the PIN. + +The PIN is used only once, when the admin connects the company's X account. Unlock and export the keys once, save them securely in your KMS/secret manager, and never save the PIN. If the admin later changes their PIN in the X app, the saved keys keep working. They stop working only if the account owner runs **Reset Chat** or resets a forgotten PIN — watch for a change in `public_key_version`, and if it changes, stop sending from that account and ask the admin to reconnect. Key export works in the server and native editions of `chat-xdk`, not in the browser edition. + +
+ +
+
What if the account has never set a PIN, or the admin doesn't know it?
+ +- **Never set up X Chat (`GET /2/users/{id}/public_keys` returns no keys):** You can create a new keypair for the account through the API and save it. Have the admin choose the account's PIN in your connect flow rather than picking one for them, so the business can still use X Chat in the X app later. +- **Already uses X Chat, but the admin doesn't know the PIN:** Do **not** create new keys — a new keypair replaces the account's identity and breaks X Chat in the X app. The admin must find the PIN or reset it in the X app (resetting makes messages encrypted under the old keys unreadable). + +Older unencrypted DMs do not need keys at all. + +
+ +
+
How do I check whether an account already has keys or can receive encrypted chats?
+ +Call `GET /2/users/{id}/public_keys` (or batch `GET /2/users/public_keys?ids=...`). If key backup details are returned, the account already uses X Chat — recover the existing keys with the PIN instead of creating new ones. + +To check whether you can start an encrypted chat with someone, request `GET /2/users/{id}?user.fields=receives_your_chat` with the sending account's token: `encrypted` means you can, `unencrypted` means the pair cannot be encrypted yet, and `none` means you cannot message them. + +
+ +
+
Is there a limit on wrong PIN guesses?
+ +**Yes.** Secure key backup allows only a small number of wrong guesses, and that budget cannot be reset. If it runs out, the backup is deleted and older encrypted messages become unreadable. Ask the account owner to confirm their PIN in the X app first, and stop after one wrong attempt. + +Unlock once per account and reuse the result — do not unlock per message or per request. Unlocks have a separate rate limit (about 30 per minute per IP address), independent of X API rate limits. + +
+ +
+
When a recipient changes their PIN or someone is added to a group chat, do we need to do anything?
+ +**No.** The conversation key updates automatically, and you do not need to redo the handshake. + +
+ +
+
Do I need X's approval to store keys on my servers?
+ +**Yes.** Storing customers' keys on your servers requires approval from X. All of the following must be true: + +- Your customers are businesses or organizations, not individual consumers. +- You run a business messaging or automation tool on their behalf. +- Your customers knowingly give you their key material. +- Each customer's keys are used only for that customer's own X Chat account. +- You tell customers, in your product or contract, that keys are separate from sign-in access and that revoking your app's access does not revoke keys they already shared. +- Your contract with each customer covers how you store and protect keys, who can access them, breach notice, and deleting or returning keys when the relationship ends. + +To start the review, send your X account representative a Yes or No for each point above along with a short description of how your product uses X DMs. + +
+ +
+
If a customer revokes my app's access, are the keys revoked too?
+ +**No.** Revoking access only stops your app's API tokens; keys a customer already shared keep working. When a customer leaves, delete every copy and backup of their keys and instruct them to revoke your app's access and run **Reset Chat** in the X app. Reset Chat is the only way to invalidate previously shared keys — there is no app-level key revocation today. + +
+ +
+
If someone changes their keys, do we need to delete their previous messages?
+ +X is reviewing this with its policy team and will update this answer. + +
+ +
+
If we pause our DM integration for a while, can we read those messages later?
+ +**Yes**, as long as you still have the keys needed to decrypt them and the account has not run Reset Chat or reset a forgotten PIN in the meantime. You can fetch history later while the account is still in the conversation. If you cannot stay subscribed, store the encrypted events (including the conversation key-change events on each page) and decrypt them later. + +
+ +
+
Can we export keys in the browser? Can the PIN stay off our servers?
+ +The browser edition of `chat-xdk` cannot export keys. Export works in the server and native editions: Node (`@xdevplatform/chat-xdk-server`), Python, Go, .NET, JVM, and Rust. If the PIN must not touch your servers, the business can run a small local tool that unlocks and exports the keys on its own machine and uploads only the exported keys. Without approved key storage, decryption works only in the account owner's own session, so background or scheduled processing is not possible. There is no way to export keys without the PIN. + +
+ +
+
Can we capture messages now and decrypt them after the customer gives us keys?
+ +**Yes**, as long as the account keeps the same X Chat keys. Store the encrypted events now, including the conversation key-change events on each page, and decrypt them once the customer provides key access. If the owner runs Reset Chat or resets a forgotten PIN before then, messages encrypted under the old keys cannot be decrypted. Capturing alone does not let you reply; replies must be sent encrypted. + +
+ +
+ +
+ +## Events, endpoints, and SDKs + +

Replacement events and endpoints, media, rate limits, and Chat XDK languages.

+ +
+
Which events replace the old DM events?
+ +Subscribe to `chat.received` for inbound messages, `chat.sent` for outbound messages, and `chat.conversation.join` for when an account joins a conversation (plus group membership/admin/settings events as needed). Message text arrives encrypted and is decrypted with `chat-xdk`. + +Existing DM subscriptions do not carry chat events, so create new subscriptions via `POST /2/activity/subscriptions` for each account (you can point them at your existing `webhook_id`). If you use the Account Activity API, X Chat events can be enabled there instead (see the next question). While unencrypted conversations still exist, their messages arrive as `dm.received`, so subscribe to both during cutover and deduplicate. + +
+ +
+
Can we use the Account Activity API (AAA) with X Chat?
+ +**Yes.** Contact [X Developer Platform support](/support) and X can enable X Chat events in the Account Activity API for your app. + +
+ +
+
Can I create webhook subscriptions with OAuth 1.0a?
+ +**Yes.** `POST /2/activity/subscriptions` accepts OAuth 1.0a user tokens for chat events if the app has the **"Read, Write and Direct Messages"** permission (without it, `chat.*` and `dm.*` subscriptions return `403 oauth1-permissions`). With OAuth 2.0, the token needs the `dm.read` scope. + +
+ +
+
The chat events don't include the sender's name or profile. How do I get them?
+ +Chat events currently include user IDs only, not names or profiles — each event has the sender's user ID and the conversation ID. Look up profile details with `GET /2/users?ids=...`, or use `GET /2/chat/conversations` / `GET /2/chat/conversations/{id}` with `expansions=participant_ids` and `user.fields`, and cache profiles by user ID. Profile details for the sender and subscribed user are being added to chat events in an `includes.users` block, matching other X Activity API events. + +
+ +
+
Our bot only replies to messages. Do we need to do anything to start conversations?
+ +If you only reply to messages people send you, send your replies encrypted with `chat-xdk` — nothing else is required. To start a new 1:1 conversation yourself, set up the conversation key first with `POST /2/chat/conversations/{recipient_id}/keys`, then send. + +
+ +
+
Is there a full map from the old DM endpoints to the new ones?
+ +**Yes.** See [Endpoint mapping](/xchat/migrate-from-legacy-dms#3-endpoint-mapping) in the migration guide. + +
+ +
+
Is there a replacement for custom profiles, listing all DM events at once, or looking up one event by ID?
+ +**No.** X Chat has none of these. Use `chat.received` and `chat.sent` as your live feed. To catch up, list conversations changed since your last sync (`GET /2/chat/conversations?start_time=...`) and read events only for those conversations — polling every conversation on a timer exhausts per-user event limits quickly. To look up a single event later, persist events as they arrive. + +
+ +
+
What about attachments, welcome messages, and surveys?
+ +X Chat has its own encrypted media upload and download endpoints (see [Media](/xchat/media)). Chat media downloads are encrypted and must be decrypted with `chat-xdk`; with OAuth 2.0, downloads require the `media.write` scope. Legacy DM media IDs do not work on X Chat media endpoints and return `404`. + +Welcome messages and surveys also have X Chat versions in the API. They accept OAuth 2.0 and OAuth 1.0a user tokens; with OAuth 1.0a, your app needs the **"Read, Write and Direct Messages"** permission. + +
+ +
+
What are the X Chat rate limits?
+ +Limits are set per access package, per user and per app, in 15-minute and 24-hour windows. `GET /2/chat/message_requests` is limited to 75 requests per 15 minutes, and registering public keys has a low daily limit. Responses include `x-rate-limit-*` headers, and `429` responses include `retry-after`. Contact your X account representative for your package's specific numbers. + +
+ +
+
Which languages does the Chat XDK support?
+ +Python, JavaScript/TypeScript (browser, plus `@xdevplatform/chat-xdk-server` for Node), Go, Rust, .NET 8+, and JVM (JDK 8 or later). There is no Ruby or PHP binding — run encryption in a small service in a supported language and call it from your app. Go ships prebuilt libraries for macOS and Linux `amd64` only; on Linux `ARM64`, use the Python or Node server package. Do not write your own encryption. + +
+ +
+ +
+ +## Troubleshooting + +

What common X Chat errors mean, and how to fix them.

+ +
+
Can I send plain text through the X Chat API?
+ +**No.** Send all messages encrypted with `chat-xdk`. Plaintext messages are refused with HTTP `403 unencrypted-send-not-allowed`. HTTP `400 encryption-required` means the chat can be encrypted: set up conversation keys if none exist, then send encrypted. + +
+ +
+
What do the xchat-setup-required and recipient-xchat-setup-required errors mean?
+ +HTTP `400 xchat-setup-required` means the sending account has no X Chat keys yet. HTTP `400 recipient-xchat-setup-required` means the recipient has no X Chat keys, so nothing can be sent to them (and nothing is sent unencrypted instead). Check recipients first with `GET /2/users/public_keys?ids=...` and try again after they set up X Chat. + +
+ +
+
Why does conversation key setup return 403?
+ +You can start an encrypted 1:1 only when both accounts have X Chat keys **and** the recipient follows you, you have messaged each other before, or they accepted a message request from you. Being verified, or the recipient allowing messages from everyone, does not change this. + +The same `403` also appears while either account still has an active legacy DM connection through an app on the legacy DM allowlist (see [Testing before cutover](/xchat/migrate-from-legacy-dms#testing-before-cutover)). Treat this `403` as permanent for that pair and do not retry it in a loop. + +
+ +
+
What do the message-request-not-supported and recipient-not-messageable errors mean?
+ +HTTP `403 message-request-not-supported` means the recipient does not follow you and has not accepted your messages, so you cannot start a chat with them. HTTP `403 recipient-not-messageable` is permanent: their settings or a block prevent messaging. HTTP `503 chat-permissions-unavailable` is temporary, so retry with backoff. + +Message requests you receive are listed at `GET /2/chat/message_requests`. Replying does not accept a request — call `POST /2/chat/message_requests/{id}/accept`. + +
+ +
+
We have several services sending from the same brand account. Can we move them one at a time?
+ +**Move them together.** While any of your services still uses legacy DMs for an account, new 1:1 chats for that account stay unencrypted and key setup can fail with `403`. Stop all legacy DM calls and subscriptions for that account when you switch. + +
+ +
+
Some DMs no longer show up in the legacy endpoints. Why?
+ +Once a conversation is encrypted, its new messages are only available through the X Chat API and `chat.*` events. Legacy DM endpoints and webhooks only carry unencrypted messages. + +
+ +
+
What other errors might I see?
+ +- `400 INVALID_IDENTITY_KEY_PAIR` on key setup: A participant's key version changed. Fetch their public keys again, rebuild, and retry once. +- `400 ContentsTooLarge` on send: Encrypted messages are capped at 20 KB (about 11,000 bytes of text), so split long messages. +- `404` on chat media: The attachment is gone or the ID is a legacy DM media ID — do not retry. +- `429` on conversation events: You are polling every conversation. Use webhooks/stream and read only the conversations that changed. +- `429` responses include `retry-after`: Wait that long before retrying. + +
+ +
+ +
+
Still have questions?
+

Contact your X account representative if you have migration blockers or need engineering help with your timeline.

+
+ Migration guide + Error reference + Fix common X Chat problems +
+