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

> ## Agent Instructions
> Checkfu is open source (https://github.com/checkfu/checkfu) and runs in the reader's own Cloudflare account. There is no shared hosted base URL: `checkfu deploy` prints the deployment's API URL (`https://<api-worker>.workers.dev` or the CHECKFU_API_DOMAIN hostname, exported as `CHECKFU_BASE_URL` for the CLI, SDK, and curl) and MCP URL (`.../mcp`). Local development serves the API on http://localhost:1337 and MCP on http://localhost:1338/mcp.
> Authenticated HTTP requests send the deployment's CHECKFU_API_KEY as `Authorization: Bearer $CHECKFU_API_KEY` (or `x-api-key`) and `Content-Type: application/json` for JSON bodies. Pass `Idempotency-Key` on retriable writes.
> Core workflow: create an Agent (`POST /v1/agents`) and an Environment (`POST /v1/environments`), create a Session that references both (`POST /v1/sessions`), send a `user.message` event (`POST /v1/sessions/{session_id}/events`), and follow `GET /v1/sessions/{session_id}/events/stream` until `session.status_idle`.
> Other resources: Memory stores (`/v1/memory_stores`), Files (`/v1/files`), Artifacts (`/v1/artifacts`), Vaults and credentials (`/v1/vaults`), Provider credentials (`/v1/provider_credentials`), Automations (`/v1/automations`), Inbound bindings (`/v1/inbound_bindings`), and Webhooks (`/v1/webhooks`). The deployment serves its OpenAPI 3.1 specification at `GET /openapi.json`.

# Publish an Artifact

> Share an Artifact with a viewing link, publish it as a site, and take it down.

This script creates an [Artifact](https://docs.checkfu.com/concepts/artifacts.md), adds a second version, creates a temporary viewing link, publishes it to a permanent URL, and unpublishes it.

## Install the SDK

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
npm install @checkfu/sdk
```

Export `CHECKFU_BASE_URL` and `CHECKFU_API_KEY`. Save the following as `publish.mts` and run `npx tsx publish.mts`.

```ts publish.mts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import Checkfu, { PublicationAddress } from "@checkfu/sdk"

const client = new Checkfu()
const page = (text: string) =>
	`<!doctype html><meta charset="utf-8"><link rel="stylesheet" href="style.css"><h1>Launch notes</h1><p>${text}</p>`

// 1. Create the Artifact. This is version 1.
const artifact = await client.waitForPending(
	await client.artifacts.create(
		{
			name: "Launch notes",
			files: [
				{ path: "index.html", content: page("Uploads are faster.") },
				{
					path: "style.css",
					content: "body { font-family: system-ui; max-width: 40rem; margin: 3rem auto }",
				},
			],
		},
		{ idempotencyKey: crypto.randomUUID() },
	),
)

// 2. Add version 2. Keep style.css by its hash instead of sending it again.
const style = artifact.files.find((file) => file.path === "style.css")!
const v2 = await client.waitForPending(
	await client.artifacts.versions.create(artifact.id, {
		version: artifact.version,
		files: [
			{ path: "index.html", content: page("Uploads are faster, and dashboards are new.") },
			{ path: "style.css", sha256: style.sha256 },
		],
	}),
)

// 3. Share version 2 for one hour.
const link = await client.artifacts.versions.link(artifact.id, v2.version, { expires_in: 3600 })
console.log("link:", link.url)

// 4. Publish. The address serves the latest version.
const published = await client.artifacts.publish(
	artifact.id,
	{},
	{ idempotencyKey: crypto.randomUUID() },
)
console.log("published:", published.publication?.url)

// 5. Unpublish that address.
await client.artifacts.unpublish(artifact.id, {
	if_current: PublicationAddress.make(published.publication!.address),
})
console.log("unpublished")
```

Comment out step 5 if you want to open the published URL before taking it down. If the address has changed by then, the unpublish request returns a conflict and leaves the replacement published. The viewing link stays pinned to version 2 even after you add version 3, while the publication follows each new version.

To pin a publication to a specific version, publish again with `{ version: 1 }` (the public address stays the same; see [Publish an artifact](https://docs.checkfu.com/api-reference/artifacts/publish-an-artifact.md)). Publishing again after unpublishing assigns a new address.

## Publish a live dashboard

The starter `dashboard` type renders one card per document in the `numbers` collection and refreshes every 30 seconds. The script reads the three template files from the checkout at `./checkfu`, creates a dashboard from the type, and publishes it with `read` access so the page can query its data.

Save this as `dashboard.mts` in your npm project and run `npx tsx dashboard.mts` from the project root.

```ts dashboard.mts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { readFile } from "node:fs/promises"
import Checkfu, { ArtifactId } from "@checkfu/sdk"

const client = new Checkfu()
const dir = "checkfu/packages/domain/src/Artifact/types/dashboard"

const type = await client.waitForPending(
	await client.artifacts.create({
		name: "dashboard",
		files: await Promise.all(
			["index.html", "artifact.json", "README.md"].map(async (path) => ({
				path,
				content: await readFile(`${dir}/${path}`, "utf8"),
			})),
		),
	}),
)

const dashboard = await client.waitForPending(
	await client.artifacts.create({
		name: "Weekly numbers",
		made_from: { artifact_id: ArtifactId.make(type.id), version: type.version },
	}),
)

await client.artifacts.data.put(dashboard.id, "numbers", "title", { data: "Weekly numbers" })
await client.artifacts.data.put(dashboard.id, "numbers", "revenue", {
	data: { label: "Revenue", value: 1200, unit: "USD" },
})

const published = await client.artifacts.publish(
	dashboard.id,
	{ access: "read" },
	{ idempotencyKey: crypto.randomUUID() },
)
console.log(published.publication?.url)
```

To update a number, `put` its document again under the same ID; the live page refreshes within 30 seconds.

The CLI uses `--at-version` to create a viewing link for a specific version.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
checkfu artifacts:versions link --artifact-id "$ARTIFACT_ID" --at-version 2
checkfu artifacts publish --artifact-id "$ARTIFACT_ID"
checkfu artifacts unpublish --artifact-id "$ARTIFACT_ID" --if-current "$ADDRESS"
```

Set `ADDRESS` to the `publication.address` returned by publish before taking it down.


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