# Iceberg > Iceberg is Katalyst's self-hosted asset CDN: media is stored in Cloudflare R2, catalogued by a small Go API, and served from Cloudflare's edge at stable public URLs. Upload once, store the `id`, and render `delivery_url` for public assets. API base: `https://dashboard.katalyst-crm.com` (JSON). Delivery base: `https://cdn.katalyst-crm.com` (bytes, no auth). Version 1.0.0. ## Auth Send `Authorization: Bearer kic_…` on every API call. Mint a token in the dashboard ("API tokens" in the sidebar) or with `POST /auth/tokens` from a signed-in session; the plaintext is shown once. ## The one rule **Store `id`; render `delivery_url` for public assets; never build a URL.** Private asset bodies omit `delivery_url`; request an authenticated, expiring link with `POST /assets/{assetID}/delivery-links`. Do not read `StorageKey` (deprecated, removed 60 days after 1.0.0). Do not join a host with a key. The bucket layout is not a contract and has already changed once. ## Upload (three calls) ```sh API=https://dashboard.katalyst-crm.com; TOKEN=kic_… # 1. Reserve the key, get a presigned R2 PUT URL (valid 60 min). id and delivery_url are final here. curl -sS -X POST $API/assets/init-upload -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" -d '{"key":"hero/welcome.webp","content_type":"image/webp"}' # -> {"id":"387f…","delivery_url":"https://cdn.katalyst-crm.com/a/387f…","upload_url":"https://…","expires_at":"…"} # 2. PUT the bytes straight to R2 with the same Content-Type. The API never sees them. curl -sS -X PUT "$UPLOAD_URL" -H "Content-Type: image/webp" --upload-file ./welcome.webp # 3. Mark ready. Iceberg HEADs storage, records size and ETag, and delivery_url starts serving. curl -sS -X POST $API/assets/complete -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" -d '{"key":"hero/welcome.webp"}' # -> full asset body, Status "ready" ``` `409 asset already exists` on step 1 means the key is taken; use `POST /assets/replace` (multipart) to overwrite bytes at the same URL. `409 object not in storage yet` on step 3 means the PUT has not landed; retry it. ## List and page `GET /assets` returns a bare JSON array, newest first. Filters (anything else is `400 unknown_query_param`): `prefix`, `folder` (exact, `folder=` for root), `content_type` (prefix, e.g. `video/`), `status` (`ready` default, `pending`, `trashed`), `limit` (1..1000, default 100), `after` (cursor), `tenant_id` (super_admin only). Paging is in headers: `X-Iceberg-Next-Cursor: ` and `Link: <…&after=>; rel="next"`, both absent on the final page. `X-Iceberg-Filters` echoes what was applied. Walk a tenant by repeating the query with `after=` until the header is gone. ```sh curl -sS -D - "$API/assets?prefix=hero/&limit=100" -H "Authorization: Bearer $TOKEN" ``` ## Trash and permanent delete - `POST /assets/trash {"key"}` soft-deletes: `Status` becomes `trashed`, the CDN answers 404 at once, the row and URL are kept. `POST /assets/restore {"key"}` undoes it. Roles: owner, tenant_admin, or the member who uploaded it. - `GET /assets/trash` lists trashed rows with `PurgeEligibleAt`. - `DELETE /assets/{key}` permanently deletes one trashed asset. Four gates: role `owner` (or super_admin); credential minted with `can_purge: true` (or a dashboard session elevated by `POST /auth/purge-session`, 15 min); asset already trashed; retention window passed (30 days after trashing by default, never under 7). Refusals: `403 purge_capability_required`, `409 {"error":"asset_in_retention","eligible_at":"…"}`, `429 purge_throttled` after 20 single deletes in 10 minutes (`Retry-After: 600`). - `POST /assets/purge-batch {"keys":[…],"approval_ref":"TICKET-1"}` purges up to 100 with an approval reference (exempt from the budget, written to audit). Answers 200 with per-key `status`: `deleted`, `asset_in_retention`, `not_found`, `not_trashed`, `failed`. ## URL forms | Form | Status | |---|---| | `https://cdn.katalyst-crm.com/a/{id}` | Canonical. What `delivery_url` returns. Derived: `/a/{id}/poster.jpg`, `/a/{id}/hls/master.m3u8`, `/a/{id}/variants/{width}` (images; 256, 1024, 2048), `/a/{id}/playback.json`, `/a/{id}?download=1`. | | `https://cdn.katalyst-crm.com/{tenant}/{key}` | Legacy alias, kept permanently, slower (authority lookup + 308 to `/a/{id}`). Do not create new ones. | | `https://cdn.katalyst-crm.com/objects/{id}` | Compatibility only: 308 to `/a/{id}` until 2026-12-31, then 404. Backfill stored HTML to `delivery_url` before then. | ## Errors Every error is JSON `{"error": ""}`. Query errors add `"param"` and `"detail"`. Common: `400 invalid json`, `400 key is required`, `400 tenant_id is required` (super_admin without a tenant), `401 invalid api token`, `403 forbidden`, `403 tenant suspended`, `404 asset not found`, `429 rate limit exceeded`. ## Asset body Keys are PascalCase plus `id` and, for public assets, `delivery_url`: `ID`, `TenantID`, `OwnerID`, `Key`, `StorageKey` (deprecated), `AssetFolder`, `Size`, `ContentType`, `ETag`, `Status` (`ready`|`pending`|`trashed`|`deleting`), `TrashedAt`, `Width`, `Height`, `DurationMillis`, `Bitrate`, `Codec`, `MediaProbeStatus` (`not_attempted`|`available`|`unavailable`), `MediaProbeUnavailableReason`, `PublishedBundleID`, `DeliveryRevision`, `DesiredSourceGenerationID`, `CreatedAt`. Trash rows add `PurgeEligibleAt`. ## Every endpoint, one curl each Set once: ```sh API=https://dashboard.katalyst-crm.com TOKEN=kic_… # from the dashboard "API tokens" page or POST /auth/tokens H=(-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json") ``` `tenant_id` is optional everywhere for tenant-scoped roles; a `super_admin` must pass it (query or body). ### OAuth for installed MCP clients Discover the OAuth endpoints from `/.well-known/oauth-authorization-server`. The document advertises `revocation_endpoint` and `revocation_endpoint_auth_methods_supported: ["none", "client_secret_basic"]`. ```sh # POST /oauth/revoke: RFC 7009 revocation for a public DCR client. # token may be an access or refresh token; either one invalidates the full grant. curl -sS -X POST $API/oauth/revoke \ -H "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "token=$OAUTH_TOKEN" \ --data-urlencode "token_type_hint=refresh_token" \ --data-urlencode "client_id=$OAUTH_CLIENT_ID" # -> 200 with an empty body for success, unknown/already-revoked tokens, or a token owned by another client. # Confidential clients authenticate with HTTP Basic instead of the client_id-only public-client mode. # -> 503 {"error":"temporarily_unavailable",...} means the atomic revoke did not complete: retain both credentials and retry. # /oauth is IP-rate-limited and may return 429 with Retry-After: 1. ``` ### Auth ```sh # POST /auth/login: dashboard sign-in, sets the katalyst_session cookie (12 h). Machine clients use a token instead. curl -sS -c cookies.txt -X POST $API/auth/login -H "Content-Type: application/json" \ -d '{"email":"you@example.com","password":"…"}' # -> {"id":"…","email":"…","role":"owner","tenant_id":"t1","can_purge":false} # POST /auth/logout: clear the cookie. 204. curl -sS -b cookies.txt -X POST $API/auth/logout # GET /auth/memberships: teams available to this dashboard session and the role in each. curl -sS -b cookies.txt $API/auth/memberships # POST /auth/active-tenant: select a team and replace the dashboard session cookie. curl -sS -b cookies.txt -c cookies.txt -X POST $API/auth/active-tenant \ -H "Content-Type: application/json" -d '{"tenant_id":"t2"}' # POST /accounts/memberships: grant an existing account access to a team. # A team admin's active tenant is used; a platform admin must provide tenant_id. curl -sS -b cookies.txt -X POST $API/accounts/memberships \ -H "Content-Type: application/json" -d '{"email":"colleague@example.com","role":"member"}' # GET /auth/whoami: the account behind this credential; check a token works, read can_purge. curl -sS $API/auth/whoami "${H[@]}" # -> {"id":"…","email":"…","role":"owner","tenant_id":"t1","can_purge":true,"purge_until":"…"} # POST /auth/tokens: mint an API token (usually from a session). token is shown once. curl -sS -b cookies.txt -X POST $API/auth/tokens -H "Content-Type: application/json" \ -d '{"name":"ci-uploader","can_purge":false}' # -> 201 {"id":"…","name":"ci-uploader","prefix":"kic_a7q2m9xk","token":"kic_…","created_at":"…","can_purge":false} # GET /auth/tokens: the caller's tokens, without secrets. curl -sS $API/auth/tokens "${H[@]}" # DELETE /auth/tokens/{id}: revoke. 204; another account's id is 404 token not found. curl -sS -X DELETE $API/auth/tokens/$TOKEN_ID "${H[@]}" # POST /auth/purge-session: elevate a dashboard session for 15 min of permanent deletes (owner/super_admin). curl -sS -b cookies.txt -c cookies.txt -X POST $API/auth/purge-session -H "Content-Type: application/json" \ -d '{"password":"…"}' # -> {"can_purge":true,"purge_until":"…"} ``` ### Upload ```sh # POST /assets/init-upload: step 1, reserve the key, get a 60 min presigned PUT URL. 201. curl -sS -X POST $API/assets/init-upload "${H[@]}" \ -d '{"key":"hero/welcome.webp","content_type":"image/webp"}' # -> {"id":"…","delivery_url":"https://cdn.katalyst-crm.com/a/…","asset_id":"…","key":"hero/welcome.webp", # "tenant_id":"t1","upload_url":"https://…","content_type":"image/webp","expires_at":"…"} # 409 asset already exists: key taken, use /assets/replace. # PUT upload_url: step 2, bytes straight to R2. Same Content-Type as signed. curl -sS -X PUT "$UPLOAD_URL" -H "Content-Type: image/webp" --upload-file ./welcome.webp # POST /assets/complete: step 3, promote pending to ready. 200 with the asset body. curl -sS -X POST $API/assets/complete "${H[@]}" -d '{"key":"hero/welcome.webp"}' # 409 object not in storage yet: the PUT has not landed, retry it. # POST /assets (multipart): legacy upload through the API. Small files and backwards compat only. 201. curl -sS -X POST $API/assets -H "Authorization: Bearer $TOKEN" \ -F key=hero/welcome.webp -F content_type=image/webp -F file=@./welcome.webp ``` ### Assets ```sh # GET /assets: one page, newest first, bare array. Paging in headers (-D - prints them). curl -sS -D - "$API/assets?prefix=hero/&content_type=image/&status=ready&limit=100" "${H[@]}" # X-Iceberg-Filters: content_type=image%2F&limit=100&prefix=hero%2F&status=ready&tenant_id=t1 # X-Iceberg-Next-Cursor: (absent on the final page) # Link: >; rel="next" # next page curl -sS -D - "$API/assets?prefix=hero/&content_type=image/&status=ready&limit=100&after=$NEXT" "${H[@]}" # root folder only curl -sS "$API/assets?folder=" "${H[@]}" # GET /assets/summary: totals, by content type, largest, oldest, monthly growth, stale. curl -sS $API/assets/summary "${H[@]}" # POST /assets/replace (multipart): overwrite bytes at the same key, id and delivery_url. Old bytes become a version. curl -sS -X POST $API/assets/replace -H "Authorization: Bearer $TOKEN" \ -F key=hero/welcome.webp -F file=@./welcome-v2.webp # GET /assets/versions?key=: version history, newest first. curl -sS "$API/assets/versions?key=hero/welcome.webp" "${H[@]}" # -> [{"id":"","asset_id":"…","delivery_url":"…","version_number":2,"size":…,"archived_at":"…"}, …] # POST /assets/rollback: serve an older version's bytes at the live key. Append-only; URL unchanged. curl -sS -X POST $API/assets/rollback "${H[@]}" \ -d '{"key":"hero/welcome.webp","version_id":""}' # POST /assets/presign-download: public-asset compatibility route; private assets answer 404. curl -sS -X POST $API/assets/presign-download "${H[@]}" -d '{"key":"hero/welcome.webp"}' # -> {"asset_id":"…","key":"…","tenant_id":"t1","download_url":"https://cdn.katalyst-crm.com/a/…?download=1","content_type":"image/webp"} ``` ### Tags ```sh # POST /assets/tags: add a tag, returns the asset's tags. curl -sS -X POST $API/assets/tags "${H[@]}" -d '{"key":"hero/welcome.webp","tag":"homepage"}' # -> ["homepage"] # GET /assets/tags?key=: an asset's tags. curl -sS "$API/assets/tags?key=hero/welcome.webp" "${H[@]}" # DELETE /assets/tags?key=&tag=: remove a tag, returns the remaining tags. curl -sS -X DELETE "$API/assets/tags?key=hero/welcome.webp&tag=homepage" "${H[@]}" # GET /assets/tags/tenant: distinct tags in the tenant. curl -sS $API/assets/tags/tenant "${H[@]}" # GET /assets/tags/keys?tag=: keys carrying a tag. curl -sS "$API/assets/tags/keys?tag=homepage" "${H[@]}" ``` ### Folders ```sh # GET /folders: the display tree. A folder is a label; it is never part of a delivery URL. curl -sS $API/folders "${H[@]}" # -> [{"TenantID":"t1","Path":"hero"},{"TenantID":"t1","Path":"courses/intro"}] # POST /folders: create an empty folder. 201. Uploading a key with slashes creates folders on its own. curl -sS -X POST $API/folders "${H[@]}" -d '{"path":"courses/intro"}' # POST /folders/move: move assets. 204. id and delivery_url do not change, so published URLs keep working. curl -sS -X POST $API/folders/move "${H[@]}" \ -d '{"keys":["hero/welcome.webp"],"path":"courses/intro"}' # "path":"" moves to the root. # POST /folders/delete: remove the folder only. 204. Its assets stay where they are; move them first. curl -sS -X POST $API/folders/delete "${H[@]}" -d '{"path":"courses/intro"}' ``` ### Trash and permanent delete ```sh # POST /assets/trash: soft delete. 204. CDN answers 404 at once; row and URL kept. curl -sS -X POST $API/assets/trash "${H[@]}" -d '{"key":"hero/welcome.webp"}' # GET /assets/trash: trashed rows with PurgeEligibleAt. curl -sS $API/assets/trash "${H[@]}" # -> [{"id":"…","delivery_url":"…","Status":"trashed","TrashedAt":"…","PurgeEligibleAt":"…", …}] # POST /assets/restore: undo. 204. curl -sS -X POST $API/assets/restore "${H[@]}" -d '{"key":"hero/welcome.webp"}' # DELETE /assets/{key}: permanent, one trashed asset. Needs owner role + can_purge credential + retention passed. # Slashes in the key may be sent raw or percent-encoded. curl -sS -X DELETE "$API/assets/hero/welcome.webp" "${H[@]}" # 204 gone, audit row written # 400 asset must be trashed before permanent deletion # 403 purge_capability_required token minted without can_purge # 409 {"error":"asset_in_retention","eligible_at":"…"} # 429 purge_throttled, Retry-After: 600 20 single deletes per 10 min spent # POST /assets/purge-batch: up to 100 trashed keys with an approval reference. 200 with per-key status. curl -sS -X POST $API/assets/purge-batch "${H[@]}" \ -d '{"keys":["hero/welcome.webp","hero/old.webp"],"approval_ref":"ICE-95"}' # -> {"approval_ref":"ICE-95","results":[{"key":"hero/welcome.webp","status":"deleted"}, # {"key":"hero/old.webp","status":"asset_in_retention","eligible_at":"…"}]} ``` ### Audit ```sh # GET /assets/audit: tenant audit trail, newest first, up to 500 rows. owner / tenant_admin / super_admin. curl -sS $API/assets/audit "${H[@]}" # -> [{"id":"…","actor_id":"…","actor_email":"…","action":"delete","target_key":"hero/welcome.webp", # "detail":"ip=… ua=… approval_ref=ICE-95","created_at":"…"}] ``` ### Delivery (no auth) ```sh # Canonical: what delivery_url returns. curl -sSI https://cdn.katalyst-crm.com/a/$ID # Derived media, when the asset has them. curl -sSI https://cdn.katalyst-crm.com/a/$ID/poster.jpg curl -sSI https://cdn.katalyst-crm.com/a/$ID/hls/master.m3u8 curl -sSI https://cdn.katalyst-crm.com/a/$ID/variants/1024 # 256, 1024 or 2048 curl -sS https://cdn.katalyst-crm.com/a/$ID/playback.json # For public original-only videos, bundle_id, hls_url, and poster_url are null. # Legacy alias (permanent, 308 to /a/{id}) and compat (/objects, 308 until 2026-12-31, then 404): curl -sSI https://cdn.katalyst-crm.com/t1/hero/welcome.webp curl -sSI https://cdn.katalyst-crm.com/objects/$ID ``` ## Reference - MCP endpoint: `POST /mcp` with OAuth or an Iceberg API token. `tools/list` includes named workflows for the public asset, folder, and token operations. Browser login, logout, and purge-session remain in the browser/OAuth flow. The `search_assets` result includes `assets`, `next_cursor`, and `filters`; permanent-delete tools require a `can_purge` API token. The complete tool contract is `docs/mcp-v1.md` in the source repository. - [OpenAPI 3.1 spec](https://cdn.katalyst-crm.com/openapi.json): every endpoint, schema and error code. - [Interactive reference](https://cdn.katalyst-crm.com/docs): the same spec rendered with Scalar. - [Short version](https://cdn.katalyst-crm.com/llms.txt) - [Source](https://github.com/IRCHrocks25/katalyst-iceberg) Private delivery (ICE-19, feature flag default off): authenticated clients can issue a four-hour link with POST /assets/{assetID}/delivery-links and optional JSON {"lifetime_seconds":3600,"referrer_origin":"https://course.example"}; the response has delivery_url, embed_url and expires_at. Private links can be revoked for the whole asset with POST /assets/{assetID}/delivery-links/revoke. Set per-file privacy with PUT /assets/{assetID}/privacy and a folder default for new uploads with PUT /folders/privacy. The dashboard offers 1-hour, 4-hour (default), 24-hour, and custom lifetimes up to 86,400 seconds, plus an optional HTTPS referrer origin. It copies the issued delivery link or an iframe using embed_url; the embed token also covers HLS playlists and segments. The dashboard disables these controls when private delivery is off or the account lacks authority. Suite provisioning S06 is an inactive privileged handler factory, not a public route. Browser sessions and business runtime tokens cannot provision tenants. See docs/contracts/suite-provisioning.md in the repository.