{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/stacktr-ee/json-schema/stacktr-ee-site-schema.json",
  "title": "Site",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/stacktr-ee-openapi.yml#/components/schemas/Site",
  "type": "object",
  "required": [
    "id",
    "visibility",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Stable site identifier."
    },
    "slug": {
      "type": [
        "string",
        "null"
      ],
      "description": "Public subdomain slug, if the site is public."
    },
    "visibility": {
      "type": "string",
      "enum": [
        "unlisted",
        "public",
        "burn"
      ],
      "description": "Privacy mode."
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "Canonical URL to view the site."
    },
    "created_at": {
      "type": "integer",
      "description": "Unix epoch seconds."
    },
    "updated_at": {
      "type": "integer",
      "description": "Unix epoch seconds."
    },
    "expires_at": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Unix epoch seconds; null = no expiry. Clamped to the plan ceiling at write time (Free: 7 days, anonymous: 24 hours), so this can come back sooner than you asked for."
    },
    "expires_at_iso": {
      "type": [
        "string",
        "null"
      ],
      "description": "The same instant as `expires_at`, RFC 3339 UTC, second granularity (e.g. \"2026-09-08T12:00:00Z\"). Present so a client can show a deadline without reconstructing it from the epoch."
    },
    "ttl_seconds": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Seconds from now until the page stops serving. Null when it does not expire; 0 when it is already out of time. Never negative."
    },
    "expiry_clamped": {
      "type": "boolean",
      "description": "True when the lifetime THIS request asked for was longer than the plan allows and `expires_at` is the shortened reality. Always present, false included. False on reads, which ask for no lifetime. Asking for a page that never expires on a capped plan is refused (409 `expiry_clamped`) rather than clamped, unless `accept_clamp` is sent."
    },
    "expiry_ceiling_hours": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The longest lifetime this plan allows a page, in hours: 24 anonymous, 168 on Free, null on plans with no ceiling and on the paid one-off rails."
    },
    "expiry_source": {
      "type": "string",
      "enum": [
        "request",
        "plan_ceiling",
        "plan_default",
        "stored"
      ],
      "description": "What decided the date: `request` (the caller named it), `plan_ceiling` (the plan cap did), `plan_default` (the plan default did), or `stored` (this call only read the row)."
    },
    "byte_size": {
      "type": "integer",
      "description": "Total content size in bytes."
    },
    "email_gate": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "domain": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        }
      }
    },
    "metrics_locked": {
      "type": "boolean",
      "description": "True when the plan has no viewer numbers (anonymous and Free). The three viewer fields below are then null; there is no number to reveal, blur, or approximate."
    },
    "opened": {
      "type": "boolean",
      "description": "Whether anyone has opened the page. Returned on every plan, including when metrics_locked is true, so \"someone read this\" survives the lock."
    },
    "badged": {
      "type": "boolean",
      "description": "Whether THIS page carries the \"Made with Stacktree\" footer as served on its stacktr.ee URL. Returned by GET /sites/{idOrSlug} only. A fact about the page, not about the plan: pages published before 2026-08-03, generated client portals and end-to-end encrypted pages carry no badge even on Free, and a remove_badge entitlement lifts it off one page or a whole account. Never assume it from the plan; anything offering to remove the badge should read this."
    },
    "view_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Raw view count. Null when metrics_locked."
    },
    "unique_viewers": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Distinct human viewers over the last 30 days. Null when metrics_locked."
    },
    "last_viewed_at": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Unix epoch seconds of the most recent open. Null when metrics_locked, or when never opened."
    },
    "reading": {
      "type": [
        "object",
        "null"
      ],
      "description": "Returned by GET /sites. How closely the newest named reader read this page: their visits and reading time, the sender's own previews excluded. Null when that open carried no name, or when metrics_locked. `seconds` is null on a plan without reading detail (Solo).",
      "properties": {
        "by": {
          "type": "string"
        },
        "others": {
          "type": "integer",
          "description": "How many other named readers opened it."
        },
        "visits": {
          "type": "integer"
        },
        "seconds": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "client": {
      "type": [
        "object",
        "null"
      ],
      "description": "Client space this page is filed under, or null for a floating page.",
      "properties": {
        "slug": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "client_url": {
      "type": "string",
      "description": "Present on publish when the space has a connected hostname and the page got a space_path: the page’s address on the client’s own domain (e.g. https://acme.theiragency.com/june-report). Prefer handing this link to the user."
    },
    "recipient": {
      "type": [
        "object",
        "null"
      ],
      "description": "Present on publish when the request named who the page is for (`recipient`). `link` is their own link (`?to=` on the page URL): hand that over rather than `url`, and every open through it comes back with their name. On GET /sites: the newest person the page was named for, on every plan (whether they opened it is a viewer number and is not here), or null.",
      "properties": {
        "name": {
          "type": "string"
        },
        "link": {
          "type": "string"
        },
        "added_at": {
          "type": "integer",
          "description": "GET /sites only. Unix seconds when they were named."
        },
        "others": {
          "type": "integer",
          "description": "GET /sites only. How many other people the page was named for."
        }
      }
    },
    "claim_token": {
      "type": [
        "string",
        "null"
      ],
      "description": "Anonymous publishes only. Adopts the page into an account (POST /sites/{idOrSlug}/claim) and, until then, is its keyless update credential. As sensitive as the page."
    },
    "claim_url": {
      "type": "string",
      "format": "uri",
      "description": "Anonymous publishes only. The dashboard claim screen for this page: sign in, and the page moves into that account at the same address."
    },
    "keep_url": {
      "type": "string",
      "format": "uri",
      "description": "Anonymous publishes only. Give this to the person you published for: it opens a page that says when this page stops working and offers both ways to keep it (a free account, or the link by email); opening it keeps nothing until they choose one. It also marks their browser so the page itself shows them a Keep button. It carries the claim token, so it is as sensitive as claim_url: share `url`, never this."
    },
    "credential_not_accepted": {
      "type": "object",
      "description": "POST /sites only, and only when the request sent Authorization: Bearer ... that was not accepted (mistyped, revoked or empty). The page was still published, with no account: keep its claim_token and keep_url, because no account owns it. Same code as the 401 the account-only routes give for that credential.",
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "invalid_credentials"
          ]
        },
        "message": {
          "type": "string"
        },
        "fix": {
          "type": "string"
        }
      }
    },
    "deleted_at": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Unix epoch seconds the page stopped serving; null when it is live. Non-null means the URL is dead for everyone holding it."
    },
    "delete_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why it stopped serving: `expired`, `owner` (someone deleted it), `abuse` (a takedown), or `merged` (folded into another page; see `merged_into`). null while the page is live. `abuse` and `merged` are never restorable: POST /sites/{idOrSlug}/restore refuses them, so do not offer a restore control for either."
    },
    "restorable_until": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Unix epoch seconds. A real deadline, not a hint: the hourly cleanup destroys the content at that moment and restore returns 404 from then on."
    },
    "likely_revision_of": {
      "type": "object",
      "description": "On POST /sites only, and only when the page looks like a new version of one this account already has: the same title (changed in the last 24 hours, same client or none) or the same client and client_path (last 30 days). The page was still published, as asked, at a new link; this names the earlier page and the call that would have kept its link (`hint`). Next time, PUT /sites/{id} on it instead of publishing again. When `can_merge` is true, POST /sites/{newId}/merge folds the two together now. Ignore it if this is a separate document.",
      "properties": {
        "id": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "matched_on": {
          "type": "string",
          "enum": [
            "title",
            "client_path"
          ]
        },
        "last_changed_at": {
          "type": "integer",
          "description": "Unix epoch seconds the earlier page last changed."
        },
        "last_changed_at_iso": {
          "type": [
            "string",
            "null"
          ]
        },
        "minutes_ago": {
          "type": "integer"
        },
        "client": {
          "type": "object",
          "properties": {
            "slug": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          }
        },
        "can_merge": {
          "type": "boolean",
          "description": "Whether POST /sites/{newId}/merge would fold the earlier page into this one now."
        },
        "hint": {
          "type": "string",
          "description": "The same facts in a sentence, safe to repeat."
        }
      }
    },
    "merged_into": {
      "type": [
        "object",
        "null"
      ],
      "description": "On GET /sites/{idOrSlug} for a page with delete_reason `merged`: the page that holds its content now, and that its link opens.",
      "properties": {
        "id": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}