PostHog Artifacts
artifacts.posthog.com hosts content made in Claude sessions, such as reports, write-ups and HTML pages, behind unguessable share links. The design is MCP first: agents publish, update, share and delete artifacts through an MCP server. The web UI is a viewer. Its management features are the Share button and the folders on the artifacts page.
How it works
┌───────────────── Cloudflare Worker (artifacts.posthog.com) ─────────────────┐
Claude Code ── MCP ──▶ │ /mcp OAuth-protected MCP server (10 tools) │
(OAuth, DCR/CIMD) │ /authorize consent page → Sign in with PostHog (@posthog.com) │
│ /oauth/* token + client registration (workers-oauth-provider) │
Browser ─────────────▶ │ /a/:id viewer: PostHog-branded chrome + sandboxed iframe │
│ /c/:id/:v?t=… artifact content, CSP-sandboxed, short-lived signed grant │
Agent (curl) ────────▶ │ /a/:id/agent?t=… raw source as text/plain, for the agent handover │
└──────┬──────────────────┬───────────────────┬───────────────────────────────┘
D1 (metadata) R2 (content) KV (OAuth grants)
- Identity: "Sign in with PostHog" (PostHog OAuth, OIDC + PKCE, public client), restricted to PostHog accounts with a verified
@posthog.com email. In production the client_id is our own Client ID Metadata Document (/oauth/client-metadata.json), so there is no client secret to manage. Locally, PostHog can't fetch that document, so the Worker registers a dev client through PostHog's dynamic client registration. The same identity backs web sessions and MCP tokens, so MCP clients sign in once in the browser.
- Links:
/a/<22 base62 chars>, about 131 bits of randomness, so links can't be guessed or enumerated. Every response sends noindex and Referrer-Policy, so links don't leak through search engines or referrers.
- Sharing:
- Private (the default): only the owner can view. Everyone else gets a 404, so they can't tell the artifact exists.
- PostHog team: anyone signed in with a verified
@posthog.com account sees the latest version. Signed-out visitors are sent to sign in, exactly as for a private artifact, so a leaked team link reveals nothing. Team links get no link-preview tags.
- Specific people (
invited): for customers. The owner lists exact emails or whole company domains ([email protected], @acme.com; consumer domains like @gmail.com are refused). A visitor signs in with their own PostHog account, on US or EU Cloud, and is admitted only if the account's verified email is on the list. They get a 7-day guest cookie that opens only artifacts whose list still contains them, latest version only. The page before sign-in says nothing about the artifact. Guests are not staff and can't manage anything.
- Public with link: anyone with the link sees the latest version.
- Older versions are only ever visible to the owner.
- Unsharing, removing someone from the list, or publishing a new version revokes iframe grants that are already open.
- Versioning: each publish with an
artifact_id adds an immutable version. Every version is stored under its own R2 key, so concurrent publishes can't clobber each other. The owner sees a version picker and a banner when viewing an old version.
- Untrusted content: artifacts run in an iframe with
sandbox (no allow-same-origin). The content response also carries a Content-Security-Policy: sandbox header, so it keeps an opaque origin even when opened top-level, and can't read cookies or call the app as the viewer. To isolate it further, set CONTENT_URL to a separate hostname. That host only serves /c/*.
- Formats:
html (a page), slides, markdown and quiz (see Quizzes below). slides and markdown (rendered with PostHog typography). A slides artifact is an HTML document in which each <section> directly inside <body> is a 1280×720 slide. At serve time it's wrapped in a deck viewer (src/web/slides.ts) with a thumbnail rail, scale-to-fit, arrow-key navigation and a Present mode, all inside the same sandboxed iframe as any other content.
Quizzes
A quiz artifact is questions people answer and get scored on. Unlike every other format it is data, not HTML: the author sends JSON, we validate it at publish, render it in the viewer page ourselves and score it on the server. That keeps the answer key out of the browser and out of any script, and makes a submission an ordinary same-origin form post. The schema is in the publish_artifact tool description.