{"openapi":"3.1.0","info":{"title":"Charming API","version":"0.1.0","description":"Public HTTP surface for the Charming app runtime. The narrative agent guide lives at https://charm.ing/docs/llms-full.txt; this spec is the machine-readable source of truth for routes, request/response shapes, and error kinds.\n\nTimeout SLAs (`info[\"x-charming-sla\"]` + per-operation `x-charming-timeout-ms`) are targets the server tries to hit, not guarantees. Use them to set sensible client read timeouts. One of them is also enforced: an App operation is stopped at `call_ms` (30 s) and answered with a 504 `timeout` error whose `details` name the limit.","x-charming-sla":{"read_ms":2000,"mutate_ms":10000,"call_ms":30000,"description":"Target SLAs the server tries to hit, in milliseconds. `read_ms` covers GET reads (source, describe, diag, activity, list, resolve). `mutate_ms` covers POST/PUT/PATCH/DELETE writes (create, update, source patch, delete, claim, secrets, remixable, starter-prompt, icon, feedback). `call_ms` covers `POST /app/{id}/api/{operation}` (the executor app-code budget). `read_ms` and `mutate_ms` are targets, not enforced ceilings — see `info.description`. `call_ms` is also the enforced operation time limit: an operation still running at `call_ms` is stopped and answered with a 504 `timeout` error. Per-operation overrides ride on the operation object as `x-charming-timeout-ms`."}},"servers":[{"url":"https://charm.ing"}],"components":{"securitySchemes":{"sessionCookie":{"type":"apiKey","in":"cookie","name":"__Secure-better-auth.session_token","description":"Authenticated Better Auth session cookie. HTTPS uses __Secure-better-auth.session_token; local HTTP uses better-auth.session_token. Personal access tokens cannot replace this cookie on operations that list only `sessionCookie`."},"appToken":{"type":"http","scheme":"bearer","bearerFormat":"chrm_app_*","description":"Per-app token returned once by `POST /app` for anonymous creates. Authorises mutations and `/api/*` calls on that one app only."},"userToken":{"type":"http","scheme":"bearer","bearerFormat":"chrm_user_*","description":"User-scoped personal access token. Mint via `POST /api/token` after signing in, or via the device-pairing flow at `POST /api/pair/start`. Accepted by every operation that lists `userToken` in its `security`; operations that list only `sessionCookie` refuse it with 401 `unauthorized`."},"renderToken":{"type":"http","scheme":"bearer","bearerFormat":"chrm_render_*","description":"Short-lived per-app token used by null-origin sandboxed iframes (Claude Desktop, ChatGPT Apps) to call back into the app without cookies. Minted server-side at render time and embedded in the runtime closure; not user-mintable. Bound to one app id."},"renderTokenQuery":{"type":"apiKey","in":"query","name":"t","description":"URL-signed render token, equivalent to `renderToken` but carried in the query string for GET /app/{id} loads where iframes cannot attach Authorization headers (the MCP viewer fetch+srcdoc path). Bound to one app id; expires after ~24 hours."}},"headers":{"RateLimit-Limit":{"description":"Total capacity of the most-restrictive bucket gating this request (draft IETF `RateLimit` header field). Pair with `RateLimit-Remaining` and `RateLimit-Reset` to project headroom; the legacy `X-RateLimit-Limit` alias carries the same value for older agent tooling.","schema":{"type":"integer","minimum":0}},"RateLimit-Remaining":{"description":"Whole tokens still available in the most-restrictive bucket. Floored, never negative. Drops to `0` on the response that exhausts the bucket.","schema":{"type":"integer","minimum":0}},"RateLimit-Reset":{"description":"Seconds until the next whole token is available in the most-restrictive bucket. `0` while remaining > 0. On a 429 this equals `Retry-After`.","schema":{"type":"integer","minimum":0}},"X-RateLimit-Limit":{"description":"Legacy alias of `RateLimit-Limit` — same value, kept for older tooling.","schema":{"type":"integer","minimum":0}},"X-RateLimit-Remaining":{"description":"Legacy alias of `RateLimit-Remaining` — same value, kept for older tooling.","schema":{"type":"integer","minimum":0}},"X-RateLimit-Reset":{"description":"Legacy alias of `RateLimit-Reset` — same value, kept for older tooling.","schema":{"type":"integer","minimum":0}},"Retry-After":{"description":"Integer seconds the client should wait before retrying. Mirrors `RateLimit-Reset` on 429 so generic HTTP clients can back off without parsing the body.","schema":{"type":"integer","minimum":0}}},"schemas":{"AppTransferResponse":{"type":"object","required":["ok","userId","teamId"],"description":"Post-transfer owner scope: exactly one of userId/teamId is set.","properties":{"ok":{"type":"boolean","enum":[true]},"userId":{"type":["string","null"]},"teamId":{"type":["string","null"]}}},"TeamListResponse":{"type":"object","required":["ok","teams"],"properties":{"ok":{"type":"boolean","enum":[true]},"teams":{"type":"array","items":{"$ref":"#/components/schemas/TeamSummary"}}}},"TeamCreateResponse":{"type":"object","required":["ok","team"],"properties":{"ok":{"type":"boolean","enum":[true]},"team":{"type":"object","required":["id","slug"],"properties":{"id":{"type":"string"},"slug":{"type":"string"}}}}},"TeamAppDefaultsResponse":{"type":"object","required":["ok","defaults"],"properties":{"ok":{"type":"boolean","enum":[true]},"defaults":{"$ref":"#/components/schemas/TeamAppDefaults"}}},"TeamAppListResponse":{"type":"object","required":["ok","apps","hasMore","nextCursor"],"properties":{"ok":{"type":"boolean","enum":[true]},"apps":{"type":"array","items":{"$ref":"#/components/schemas/TeamAppSummary"}},"hasMore":{"type":"boolean","description":"True when the team owns more apps than this page returned."},"nextCursor":{"type":["string","null"],"description":"Pass back as `cursor`, with the same `sort`, for the next page. Null on the last page."}}},"TeamAuditResponse":{"type":"object","required":["ok","audit","hasMore","nextCursor"],"properties":{"ok":{"type":"boolean","enum":[true]},"audit":{"type":"array","items":{"$ref":"#/components/schemas/TeamAuditRow"}},"hasMore":{"type":"boolean","description":"True when more rows follow this page under the active sort."},"nextCursor":{"type":["string","null"],"description":"Pass back as `cursor`, with the same `sort`, for the next page. Null on the last page."}}},"TeamConnectorsResponse":{"type":"object","required":["ok","connectors"],"properties":{"ok":{"type":"boolean","enum":[true]},"connectors":{"type":"array","items":{"$ref":"#/components/schemas/TeamConnector"}}}},"TeamConnectorAppsResponse":{"type":"object","required":["ok","apps","nextCursor"],"properties":{"ok":{"type":"boolean","enum":[true]},"apps":{"type":"array","items":{"type":"object","required":["id","name","appName","icon"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"appName":{"type":["string","null"],"description":"The App’s name in its settings URL, `/<team-handle>/~/apps/<appName>/settings`."},"icon":{"description":"The App’s home-screen icon, or null when it has none.","oneOf":[{"type":"object","required":["emoji","bg"],"properties":{"emoji":{"type":"string"},"bg":{"type":"string"}}},{"type":"null"}]}}}},"nextCursor":{"type":["string","null"],"description":"Pass back as `cursor` for the next page. Null on the last page."}}},"TeamEgressResponse":{"type":"object","required":["ok","destinations","hasMore","scanTruncated"],"properties":{"ok":{"type":"boolean","enum":[true]},"destinations":{"type":"array","items":{"$ref":"#/components/schemas/TeamEgressDestination"}},"hasMore":{"type":"boolean","description":"True when the team has more destinations than this page returned."},"scanTruncated":{"type":"boolean","description":"True when the underlying event scan hit its row cap before grouping — every `api-op` destination’s `calls`/`failedCalls` in this response is a lower bound, not the true count."}}},"TeamExposureResponse":{"type":"object","required":["ok","exposure"],"properties":{"ok":{"type":"boolean","enum":[true]},"exposure":{"type":"object","required":["public","signed-in","template","shared","private","externalShares"],"description":"Counts every team app exactly once, by the widest audience `deriveAppVisibility` assigns it, plus the count of shares whose grantee classifies external.","properties":{"public":{"type":"integer"},"signed-in":{"type":"integer"},"template":{"type":"integer"},"shared":{"type":"integer"},"private":{"type":"integer"},"externalShares":{"type":"integer"}}}}},"TeamInvitationCreateResponse":{"type":"object","required":["ok","invitation"],"properties":{"ok":{"type":"boolean","enum":[true]},"invitation":{"type":"object","required":["id","email","role","status"],"properties":{"id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string"}}}}},"TeamMemberAddResponse":{"type":"object","required":["ok","userId","role"],"properties":{"ok":{"type":"boolean","enum":[true]},"userId":{"type":"string"},"role":{"type":"string","enum":["owner","admin","member"]}}},"TeamPeopleResponse":{"type":"object","required":["ok","people","hasMore"],"properties":{"ok":{"type":"boolean","enum":[true]},"people":{"type":"array","items":{"$ref":"#/components/schemas/TeamPerson"}},"hasMore":{"type":"boolean","description":"True when the team has more members than this page returned."}}},"TeamSecurityResponse":{"type":"object","required":["ok","security"],"properties":{"ok":{"type":"boolean","enum":[true]},"security":{"$ref":"#/components/schemas/TeamSecurity"}}},"ShareLedgerResponse":{"type":"object","required":["ok","shares","hasMore","nextCursor"],"properties":{"ok":{"type":"boolean","enum":[true]},"shares":{"type":"array","items":{"$ref":"#/components/schemas/ShareLedgerRow"}},"hasMore":{"type":"boolean","description":"True when the team has more matching shares than this page returned."},"nextCursor":{"type":["string","null"],"description":"Pass back as `cursor`, with the same `sort`, for the next page. Null on the last page."}}},"AppRevisionListResponse":{"type":"object","required":["ok","appId","currentRevision","activeRevision","historyLimit","items","nextBefore"],"properties":{"ok":{"type":"boolean","enum":[true]},"appId":{"type":"string","format":"uuid"},"currentRevision":{"type":"integer","minimum":0,"description":"The desired revision. Send it as If-Match to restore."},"activeRevision":{"type":"integer","minimum":0},"historyLimit":{"type":"integer","minimum":0,"description":"How many prior revisions the owner’s plan keeps in History."},"items":{"type":"array","items":{"$ref":"#/components/schemas/AppRevisionSummary"}},"nextBefore":{"type":["integer","null"],"description":"Pass as `before` to read the next page. Null when the plan’s window has no older revisions."}}},"AppRevisionResponse":{"allOf":[{"$ref":"#/components/schemas/AppRevisionSummary"},{"type":"object","required":["ok","appId","description","source"],"properties":{"ok":{"type":"boolean","enum":[true]},"appId":{"type":"string","format":"uuid"},"description":{"type":["string","null"]},"source":{"oneOf":[{"type":"object","required":["files"],"properties":{"files":{"type":"object","additionalProperties":{"type":"string"},"description":"The package file tree, keyed by relative path."}}},{"type":"object","required":["module","ui","styles"],"properties":{"module":{"type":"string"},"ui":{"type":["string","null"]},"styles":{"type":["string","null"]}}}]}}}]},"AppRevisionRestoreResponse":{"description":"The restored revision, or the published build operation that produced it.","anyOf":[{"type":"object","required":["ok","appId","sourceRevision","revision"],"properties":{"ok":{"type":"boolean","enum":[true]},"appId":{"type":"string","format":"uuid"},"sourceRevision":{"type":"integer","minimum":1},"revision":{"type":"integer","minimum":0},"manifestVersion":{"type":"string"}}},{"allOf":[{"$ref":"#/components/schemas/AppBuildResponse"},{"type":"object","required":["sourceRevision"],"properties":{"sourceRevision":{"type":"integer","minimum":1}}}]}]},"AppBuildResponse":{"type":"object","required":["ok","buildId","intent","state","sourceEtag","statusUrl","attempts","acceptedAt","updatedAt","finishedAt","elapsedMs","lockState","inputDigest","queueDeadline","deadline","inspectionExpiresAt","idempotencyExpiresAt"],"properties":{"ok":{"type":"boolean","enum":[true]},"buildId":{"type":"string"},"intent":{"type":"string","enum":["create","update","migrate","restore","copy"]},"state":{"type":"string","enum":["queued","resolving","building","validating","published","failed","superseded","canceled","expired"]},"sourceEtag":{"type":"string","description":"The ETag of the revision this build saved once an App exists, usable as `If-Match` on the next save. It doesn't change after a later save; `GET /app/{id}/source` returns the current one. Before a creation publishes, the digest of the accepted input."},"statusUrl":{"type":"string","format":"uri"},"retryAfterSeconds":{"type":"integer"},"appId":{"type":"string","format":"uuid"},"revision":{"type":"integer","minimum":1,"description":"Published app source revision. Present only after successful publication."},"desiredRevision":{"type":"integer"},"activeRevision":{"type":"integer"},"url":{"type":"string","format":"uri"},"attempts":{"type":"integer"},"acceptedAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"finishedAt":{"type":["string","null"],"format":"date-time"},"elapsedMs":{"type":"integer"},"lockState":{"type":"string","enum":["locked","unresolved"]},"inputDigest":{"type":"string"},"lockDigest":{"type":"string"},"resolvedDependencies":{"type":"object","additionalProperties":{"type":"string"},"description":"Exact versions of the top-level npm packages the retained lock installs, by package name. Absent while the build is unresolved and for builds whose lock predates the package resolution."},"queueDeadline":{"type":"string","format":"date-time"},"deadline":{"type":"string","format":"date-time"},"inspectionExpiresAt":{"type":["string","null"],"format":"date-time"},"idempotencyExpiresAt":{"type":["string","null"],"format":"date-time"},"source":{"type":"object","required":["files"],"description":"The exact accepted package tree, when include_source=true and the inspection window is open.","properties":{"files":{"type":"object","additionalProperties":{"type":"string"}}}},"error":{"type":"object","required":["kind","message","retryable"],"properties":{"kind":{"type":"string"},"message":{"type":"string"},"retryable":{"type":"boolean"},"details":{"anyOf":[{"type":"object","additionalProperties":false,"required":["execution","operationId"],"properties":{"execution":{"type":"string","enum":["not_started","may_have_run"]},"operationId":{"type":"string","minLength":1},"reservationId":{"type":"string","minLength":1}}},{"type":"object","additionalProperties":false,"required":["execution"],"properties":{"execution":{"type":"string","enum":["may_have_run"]}}}]},"stage":{"type":"string","enum":["source","dependencies","compile"],"description":"A stage only when the author's package caused the failure. `source`: the package was refused (its files, imports, or package.json, a size cap, a refused `connect-src` origin, a package name another App holds or that differs from the App's, or accepted source the current contract refuses); fix what the message names, in the file `path` names when given. `dependencies`: npm could not resolve or install the declared dependencies, or the tree has more packages than the limit; fix the package `specifier` names when given, its range in package.json, or trim the dependencies. `compile`: the compiler, or the check of the built server module, refused the App's code; fix the file and position named when given. Every other failure has no stage, because nothing in the package would fix it: a build sandbox, provider, executor, or database failing, a busy host, a cancellation, lost authority, an expired build or one that used up its attempts, an input Charming could not load, or a copy whose requested manifest id was taken. Save again."},"target":{"type":"string"},"specifier":{"type":"string"},"path":{"type":"string","description":"The App file the failure points at, relative to the package root, when it points at one of the App's own files."},"line":{"type":"integer","description":"The 1-based line in `path`."},"column":{"type":"integer","description":"The 1-based column in `line`."}}}}},"AppSharesListResponse":{"type":"object","required":["ok","shares"],"properties":{"ok":{"type":"boolean","enum":[true]},"shares":{"type":"array","items":{"type":"object","required":["id","grantee","status","role","canInvite"],"properties":{"id":{"type":"string","format":"uuid"},"grantee":{"type":"object","required":["kind","label"],"properties":{"kind":{"type":"string","enum":["account","email"]},"label":{"type":"string"},"handle":{"type":"string","description":"The account grantee’s handle, which names their avatar at `/<handle>.png`. Absent for email invitations and accounts without a handle."},"badges":{"$ref":"#/components/schemas/NameBadges","description":"The marks shown beside the account grantee’s name. Absent for email invitations and accounts with no badges."}}},"status":{"type":"string","enum":["pending","accepted","invited"]},"role":{"type":"string","enum":["collaborator","end-user","viewer"]},"canInvite":{"type":"boolean","description":"The owner let this person invite others at or below their own role."},"invitedBy":{"type":"object","required":["label"],"description":"Who invited this person. Absent when the caller invited them.","properties":{"label":{"type":"string"}}}}}}}},"ShareInviteResponse":{"type":"object","required":["ok","status"],"description":"`pending` = an existing user must accept; `invited` = an email-keyed invitation that materializes when that address registers.","properties":{"ok":{"type":"boolean","enum":[true]},"status":{"type":"string","enum":["pending","invited"]}}},"ShareRoleResponse":{"type":"object","required":["ok","role"],"properties":{"ok":{"type":"boolean","enum":[true]},"role":{"type":"string","enum":["collaborator","end-user","viewer"]}}},"ShareAcceptResponse":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean","enum":[true]},"alreadyAccepted":{"type":"boolean","enum":[true]}}},"ShareRemovedResponse":{"type":"object","required":["ok","removed"],"properties":{"ok":{"type":"boolean","enum":[true]},"removed":{"type":"boolean"}}},"ShareUpdateResponse":{"type":"object","required":["ok","role","canInvite"],"properties":{"ok":{"type":"boolean","enum":[true]},"role":{"type":"string","enum":["collaborator","end-user","viewer"]},"canInvite":{"type":"boolean"}}},"AppSignedInAccessResponse":{"type":"object","additionalProperties":false,"required":["ok","signedInAccess"],"properties":{"ok":{"type":"boolean","enum":[true]},"signedInAccess":{"type":["string","null"],"enum":["viewer","end-user",null]}}},"TemplateListingResponse":{"type":"object","required":["ok","listing"],"properties":{"ok":{"type":"boolean","enum":[true]},"listing":{"$ref":"#/components/schemas/TemplateListing"}}},"WidgetRuntimeIssueHandoffResponse":{"type":"object","additionalProperties":false,"required":["version","prompt"],"properties":{"version":{"type":"integer","enum":[1]},"prompt":{"type":"string"}}},"AppBuildPage":{"type":"string","description":"Authenticated browser build progress or terminal result page."},"AppActivityResponse":{"type":"object","required":["ok","appId","items","hasMore","retention","recentFailures"],"properties":{"ok":{"type":"boolean","enum":[true]},"appId":{"type":"string","format":"uuid"},"hasMore":{"type":"boolean","description":"True when older entries exist. Fetch them with `before` and `beforeId` set from the oldest entry returned."},"recentFailures":{"type":"object","required":["count","windowHours"],"description":"How many calls failed for people using the live version over the last 7 days, or the plan window when it is shorter. Counts recipients’ failed calls and refusals at the App’s run ceiling, not a Routine’s own failures.","properties":{"count":{"type":"integer","minimum":0},"windowHours":{"type":"integer","description":"The hours counted back from now."}}},"retention":{"type":"object","required":["tier","hours","since","truncated"],"description":"The plan window this read used. Older events are hidden, not deleted.","properties":{"tier":{"type":"string","enum":["free","pro","business","enterprise"]},"hours":{"type":"integer","description":"Length of the plan window."},"since":{"type":"string","format":"date-time","description":"The cutoff this read used."},"truncated":{"type":"boolean","description":"True when the plan window set the cutoff."}}},"items":{"type":"array","items":{"type":"object","required":["id","ts","kind","summary","data"],"properties":{"id":{"type":"string","format":"uuid","description":"Pass back as `beforeId` (with `before`) to page further."},"ts":{"type":"string","format":"date-time"},"kind":{"type":"string"},"version":{"type":["integer","null"]},"summary":{"type":"string"},"data":{"type":"object"}}}}}},"TeamSummary":{"type":"object","required":["teamId","name","slug","role","memberCount","appCount","paid","blockedByTwoFactor","members"],"description":"One row in the caller’s team list.","properties":{"teamId":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"role":{"type":"string","description":"The caller’s own role in this team."},"memberCount":{"type":"integer"},"appCount":{"type":"integer"},"paid":{"type":"boolean","description":"True while the team is on a live paid plan."},"blockedByTwoFactor":{"type":"boolean","description":"True while the team requires two-factor authentication and the caller has not turned it on. The caller can reach none of the team’s apps or settings until they do, and can still leave the team."},"members":{"type":"array","description":"The team’s roster. Empty while `blockedByTwoFactor` is true.","items":{"$ref":"#/components/schemas/TeamMemberSummary"}}}},"TeamAppDefaults":{"type":"object","required":["teamId","generalAccessTier","templateEnabled","createdAt","updatedAt"],"properties":{"teamId":{"type":"string"},"generalAccessTier":{"type":"string","enum":["invited-only","public-view","public-and-signed-in-use"]},"templateEnabled":{"type":"boolean"},"createdAt":{"type":["string","null"],"format":"date-time"},"updatedAt":{"type":["string","null"],"format":"date-time"}}},"TeamAppSummary":{"type":"object","required":["id","appName","displayName","visibility","createdByLabel","shareCount","linkCount","updatedAtMs","lastPublishedAtMs"],"description":"One row in the team apps inventory.","properties":{"id":{"type":"string","format":"uuid"},"appName":{"type":["string","null"],"description":"Friendly-URL slug."},"displayName":{"type":"string"},"visibility":{"type":"string","enum":["public","signed-in","template","shared","private"],"description":"The widest audience that can reach the app."},"createdByLabel":{"type":["string","null"],"description":"Display name of the account that created the app, null when no creator was recorded, and \"Former member\" when the creator has left the team or deleted their account."},"shareCount":{"type":"integer","description":"Share grants (accepted and pending) plus pending email invitations."},"linkCount":{"type":"integer","description":"Active share links: created, not yet redeemed or revoked."},"updatedAtMs":{"type":"integer","description":"When the app row last changed for any reason, including someone opening the app."},"lastPublishedAtMs":{"type":"integer","description":"When the newest revision was published, or when the app was created if no revision records a publish time."}}},"TeamAuditRow":{"type":"object","required":["id","kind","appId","appDisplayName","actor","actorBadges","client","createdAtMs","summary"],"properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string"},"appId":{"type":"string","format":"uuid"},"appDisplayName":{"type":"string"},"actor":{"type":["string","null"],"description":"Null for an anonymous/public end-user viewer."},"actorBadges":{"oneOf":[{"$ref":"#/components/schemas/NameBadges"},{"type":"null"}],"description":"The marks beside the actor’s name, or null for none."},"client":{"type":["string","null"],"enum":["Web","MCP",null]},"createdAtMs":{"type":"integer"},"summary":{"type":"string"}}},"TeamConnector":{"type":"object","required":["service","allowed","appCount","apps"],"properties":{"service":{"type":"string","description":"A connector catalog service slug, such as `gmail`."},"allowed":{"type":"boolean","description":"False while the team has turned the service off: every call to it from the team’s Apps refuses with `connector_blocked_by_team`, and each approval is kept for when it is turned back on."},"appCount":{"type":"integer","description":"How many of the team’s Apps call the service in their live version."},"apps":{"type":"array","description":"The first three of those Apps by name. `GET /api/v1/teams/{teamId}/connectors/{service}/apps` pages through every one.","items":{"type":"object","required":["id","name"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}}}}}},"TeamEgressDestination":{"type":"object","required":["destination","kind","calls","lastSeenMs","failedCalls","callers"],"description":"One egress destination, discriminated by `kind`.","properties":{"destination":{"type":"string","description":"The declared host origin, or the `requestedOp` string."},"kind":{"type":"string","enum":["outbound-host","api-op"]},"calls":{"type":["integer","null"],"description":"Null for `outbound-host` — config, not traffic."},"lastSeenMs":{"type":["integer","null"],"description":"Null for `outbound-host`."},"failedCalls":{"type":["integer","null"],"description":"Count of calls with a 4xx/5xx status or a non-null errorKind. Null for `outbound-host`."},"callers":{"type":"array","items":{"$ref":"#/components/schemas/TeamEgressCaller"}}}},"TeamPerson":{"type":"object","required":["userId","label","badges","role","appsOwned","appsCreated","lastActiveMs","externalShareCount","twoFactorEnabled"],"description":"One row in the People tab — a current team member with their app footprint.","properties":{"userId":{"type":"string"},"label":{"type":"string"},"badges":{"oneOf":[{"$ref":"#/components/schemas/NameBadges"},{"type":"null"}],"description":"The marks beside the member’s name, or null for none."},"role":{"type":"string"},"appsOwned":{"type":"integer"},"appsCreated":{"type":"integer"},"lastActiveMs":{"type":["integer","null"],"description":"Null (never epoch zero) for a member with no attributable events."},"externalShareCount":{"type":"integer"},"twoFactorEnabled":{"type":"boolean","description":"Whether the member’s account has two-factor authentication on."}}},"TeamSecurity":{"type":"object","required":["requireTwoFactor","membersWithoutTwoFactor"],"properties":{"requireTwoFactor":{"type":"boolean","description":"While true, a member whose account does not have two-factor authentication on can reach none of the team’s apps or settings until they turn it on."},"membersWithoutTwoFactor":{"type":"integer","description":"Members whose accounts do not have two-factor authentication on."}}},"ShareLedgerRow":{"type":"object","required":["id","kind","appId","appDisplayName","grantee","granteeBadges","role","scope","status","createdAtMs"],"description":"One row in the shares ledger — a grant, an invitation, or a live share link, normalized to one shape.","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["person","invite","link"]},"appId":{"type":"string","format":"uuid"},"appDisplayName":{"type":"string"},"grantee":{"type":["string","null"],"description":"Handle or email; null for a link (nobody is behind the door yet)."},"granteeBadges":{"oneOf":[{"$ref":"#/components/schemas/NameBadges"},{"type":"null"}],"description":"The marks beside the grantee’s name for a `person` row; null for an invite, a link, or none."},"role":{"type":"string"},"scope":{"type":"string","enum":["internal","external"]},"status":{"type":"string","enum":["pending","accepted","active","redeemed","revoked"]},"createdAtMs":{"type":"integer"}}},"AppRevisionSummary":{"type":"object","required":["revision","createdAt","manifestVersion","current","live","restorable"],"properties":{"revision":{"type":"integer","minimum":0},"createdAt":{"type":"string","format":"date-time"},"manifestVersion":{"type":["string","null"],"description":"The contract this revision was written against: `2026-10-25` for a package, an earlier date such as `2026-10-16` for a module contract. Null for an App written before dated contracts."},"current":{"type":"boolean","description":"True for the desired revision, the newest source Charming accepted."},"live":{"type":"boolean","description":"True for the active revision, the one serving visitors. A package App’s desired revision is not live until its build publishes."},"restorable":{"type":"boolean","description":"True when the revision passes the checks restore runs on its stored source. The current and live revisions are never restorable. Restore runs the checks again, so a marked revision can still be refused."}}},"NameBadges":{"type":"object","required":["pro","affiliation"],"description":"The marks Charming shows beside a person’s name, derived from live plans at read time.","properties":{"pro":{"type":"boolean","description":"True while the person pays for a plan on their own account."},"affiliation":{"type":["object","null"],"required":["name","logoUrl"],"description":"The paid team the person shows beside their name, or null for none.","properties":{"name":{"type":"string"},"logoUrl":{"type":"string","format":"uri"}},"additionalProperties":false}},"additionalProperties":false},"TemplateListing":{"type":"object","required":["appId","creator","builders","draft","resolved","templateEnabled","listed","validation","publicUrl"],"properties":{"appId":{"type":"string","format":"uuid"},"creator":{"type":"object","required":["handle"],"properties":{"handle":{"type":"string"}}},"builders":{"type":"integer","minimum":0},"draft":{"allOf":[{"$ref":"#/components/schemas/TemplateListingFields"},{"type":"object","required":["legacyFallback"],"properties":{"legacyFallback":{"type":"boolean"}}}]},"resolved":{"$ref":"#/components/schemas/TemplateListingFields"},"templateEnabled":{"type":"boolean"},"listed":{"type":"boolean"},"validation":{"type":"object","required":["complete","missingFields"],"properties":{"complete":{"type":"boolean"},"missingFields":{"type":"array","items":{"type":"string","enum":["title","summary"]}}}},"publicUrl":{"type":["string","null"]}}},"TeamMemberSummary":{"type":"object","required":["userId","memberId","name","image","handle","role","isYou","badges"],"description":"One member in a team roster. `memberId` is the membership-row id used by the member PATCH/DELETE endpoints (distinct from `userId`).","properties":{"userId":{"type":"string"},"memberId":{"type":"string"},"name":{"type":"string"},"image":{"type":["string","null"]},"handle":{"type":["string","null"]},"role":{"type":"string","description":"Comma-joined role string (e.g. `owner`)."},"isYou":{"type":"boolean"},"badges":{"oneOf":[{"$ref":"#/components/schemas/NameBadges"},{"type":"null"}],"description":"The marks beside the member’s name, or null for none."}}},"TeamEgressCaller":{"type":"object","required":["appId","appDisplayName"],"properties":{"appId":{"type":"string","format":"uuid"},"appDisplayName":{"type":"string"}}},"TemplateListingFields":{"type":"object","required":["title","summary","contentMarkdown","category","cover","gallery"],"properties":{"title":{"type":["string","null"]},"summary":{"type":["string","null"]},"contentMarkdown":{"type":["string","null"]},"category":{"type":["string","null"],"enum":["business","developer-tools","education","entertainment","lifestyle","productivity","utilities",null]},"cover":{"oneOf":[{"$ref":"#/components/schemas/TemplateListingMedia"},{"type":"null"}]},"gallery":{"type":"array","items":{"$ref":"#/components/schemas/TemplateListingMedia"}}}},"TemplateListingMedia":{"type":"object","required":["id","kind","assetKey","url","alt","caption","position"],"properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["cover","screenshot"]},"assetKey":{"type":"string"},"url":{"type":"string","format":"uri"},"alt":{"type":"string"},"caption":{"type":["string","null"]},"position":{"type":"integer","minimum":0}}},"Error":{"type":"object","required":["ok","error"],"properties":{"ok":{"type":"boolean","enum":[false]},"error":{"type":"object","required":["kind"],"properties":{"kind":{"type":"string","description":"Stable enum-shaped error key. Branch on this for recovery flows.","enum":["not_found","unknown_operation","operation_not_found","method_not_allowed","operation_failed","timeout","app_busy","visitor_rate_limited","service_busy","unauthorized","sign_in_required","token_expired","forbidden","account_not_joined","staff_only","two_factor_required","reauthentication_required","forbidden_write","view_as_read_only","email_not_verified","email_needs_sign_in","stored_value_too_large","storage_full","too_many_keys","storage_method_unavailable","invalid_module","invalid_ui","invalid_files","bearer_required","unpinned_cdn_script","invalid_route_schema","invalid_routes_shape","contract_migration_required","invalid_manifest_schema","invalid_manifest_exports","invalid_request","invalid_input","invalid_output","unexpected_keys","capability_denied","capability_error","executor_error","invalid_call_shape","already_claimed","manifest_not_found","payload_too_large","module_too_large","ui_too_large","styles_too_large","description_too_long","missing_description","invalid_description","rate_limited","image_origin_denied","too_many_requests","expired","already_approved","anon_not_remixable","template_listing_incomplete","template_media_invalid","template_listing_too_large","forbidden_template_edit","invalid_if_match","precondition_required","expected_revision_required","idempotency_key_required","idempotency_conflict","app_build_capacity","app_build_failed","app_build_expired","app_build_authority_lost","app_build_unavailable","app_build_unsupported","version_history_unavailable","version_not_restorable","revision_mismatch","invalid_revision","candidate_effects_unsupported","old_string_not_found","old_string_not_unique","invalid_bucket","bucket_unset","empty_edits","edits_too_large","manifest_id_conflict","manifest_id_immutable","text_too_large","structured_data_too_large","app_not_found","feedback_not_found","feedback_has_no_reply_recipient","asset_too_large","asset_count_exceeded","asset_quota_exceeded","asset_invalid_key","asset_invalid_content_type","asset_error","invalid_id","sse_cookie_expired","invalid_secret_name","secret_too_large","secret_already_exists","secret_not_found","invalid_icon","team_slug_taken","already_member","two_factor_required","recent_login_required","grantee_not_found","invite_cap_reached","invite_sender_blocked","role_above_own","invite_delegation_owner_only","not_your_invite","read_only","handle_taken","invalid_handle","name_taken","invalid_domain","domain_taken","domain_exists","domain_provider_unavailable","app_unclaimed","link_cap_reached","grantee_is_owner","grantee_is_self","grantee_already_has_access","already_invited","routine_limit_exceeded","invalid_interval","op_requires_input","duplicate_routine","webhook_limit_exceeded","duplicate_webhook","webhook_disabled","version_limit_exceeded","plan_required","connector_call_limit_exceeded","connector_rate_limited","connector_not_granted","connector_action_not_declared","connector_no_person","connector_reconnect_required","connector_unavailable","connector_tool_failed","connector_cross_site","connector_blocked_by_team","connector_route_not_declared","connector_function_not_approved","connector_version_retired","connector_holder_only","storage_limit_exceeded","copy_data_forbidden","copy_data_too_large"]},"message":{"type":"string"},"reason":{"type":"string","description":"Set on 401s to distinguish token failure modes when finer detail is needed. `token_revoked_post_claim` is the post-#1284 surface for a chrm_app_* that was invalidated by a claim — the `recovery` field on the same `error` object carries the self-contained pairing-recovery hint the agent should follow instead of creating a new app.","enum":["token_malformed","token_unknown","token_revoked","token_revoked_post_claim"]},"plan":{"type":"string","enum":["free","pro","business","enterprise"],"description":"Present on every plan refusal: the tier the caller was refused under. Its presence is what marks an error as a plan refusal rather than a validation or permission failure."},"limit":{"type":["string","integer"],"description":"Which ceiling the call met, keyed by `kind`. A plan refusal (`*_limit_exceeded`) names the countable that ran out — `version_history`, `routines_per_app`, `routines_per_owner`, `webhooks_per_app`, `webhooks_per_owner`, `connector_calls_per_month` — and pairs it with `max`. An `app_busy` refusal names the bound it met and pairs it with `observed` and `allowed`; no plan lifts any of them. Two are per-app run bounds, `concurrent_runs` and `runs_per_window`; the third, `render_token_refresh`, is the page render asking for a new render-token secret, held by 10 per app per client IP and 60 per app across every address in a 60 second window, and `observed`/`allowed` name whichever of those two refused. An `edits_too_large` rejection carries the numeric cap that was exceeded instead of a name."},"rung":{"type":"string","enum":["throttled","parked","closed"],"description":"On an `app_busy` refusal, how hard the app's own refusal ladder is refusing: `throttled` is the plain ceiling breach above; `parked` means a caller kept calling inside a wait it was given, so the server mints its own `Retry-After` (doubling from 60s to a 300s cap) and refuses until a quiet window passes even once the ceiling clears; `closed` is the same, plus the response closes the connection. Absent on every other `kind`."},"max":{"type":"integer","minimum":0,"description":"On a `*_limit_exceeded` refusal, that limit's number on the caller's plan."},"feature":{"type":"string","enum":["custom_domain","watermark_removal","teams"],"description":"On a `plan_required` refusal, the capability the plan does not include. Never paired with `limit` / `max`."},"upgradeUrl":{"type":"string","format":"uri","description":"Absolute link to the owner's own billing page, where the refusal is lifted — the team's page for a team-owned app. Omitted only when the owner has no handle and therefore no settings page of their own, so treat it as optional and fall back to your own copy. MCP appends it as an `Upgrade: <url>` last line; the CLI prints it under the message."},"missingLevels":{"type":"array","items":{"type":"string","enum":["read","write","delete"]},"description":"On a `connector_not_granted` refusal, the access levels (in the order `read`, `write`, `delete`) the App's declared tools for the service need and the caller has not approved. Present only when approving would add something: call `charming.connect(service)` then. Absent means approving again would not help. On a refused `PATCH /api/v1/apps/{appId}/connectors/{service}`, the shared levels the holder's approval lacks instead."},"recovery":{"description":"Self-contained recovery hint, branching on `kind`. Attached to error envelopes the agent can self-correct on: `pair` for `token_revoked_post_claim` 401s (#1284), `retry` for 429s, `shrink` for too-large / quota-exceeded 413s, `refetch` for 412 `revision_mismatch` / `invalid_if_match` / 428 `precondition_required`, `fix_route_label` for 403 `forbidden_write`, `rename` for 409 `manifest_id_immutable` / `manifest_id_conflict`, and `migrate_contract` for 422 `contract_migration_required`. Every `instructions` string is a single-paragraph, action-first walk-through. Inlined per ADR 2026-05-06-agent-facing-error-surfaces-self-contain-the-fix.","oneOf":[{"$ref":"#/components/schemas/RecoveryPair"},{"$ref":"#/components/schemas/RecoveryRetry"},{"$ref":"#/components/schemas/RecoveryShrink"},{"$ref":"#/components/schemas/RecoveryRefetch"},{"$ref":"#/components/schemas/RecoveryFixRouteLabel"},{"$ref":"#/components/schemas/RecoveryRename"},{"$ref":"#/components/schemas/RecoveryMigrateContract"}],"discriminator":{"propertyName":"kind"}}},"additionalProperties":true}}},"RecoveryPair":{"type":"object","required":["kind","start","verification_url","instructions"],"properties":{"kind":{"type":"string","enum":["pair"]},"start":{"type":"string","format":"uri"},"verification_url":{"type":"string","format":"uri"},"instructions":{"type":"string"}},"additionalProperties":false},"RecoveryRetry":{"type":"object","required":["kind","retry_after_sec","retry_after_url","instructions"],"properties":{"kind":{"type":"string","enum":["retry"]},"retry_after_sec":{"type":"integer","minimum":0,"description":"Seconds to wait before retrying. Matches the `RateLimit-Reset` and `Retry-After` headers on the same response."},"retry_after_url":{"type":"string","format":"uri","description":"Absolute URL to retry verbatim once the wait elapses."},"instructions":{"type":"string"}},"additionalProperties":false},"RecoveryShrink":{"type":"object","required":["kind","field","size_bytes","cap_bytes","instructions"],"properties":{"kind":{"type":"string","enum":["shrink"]},"field":{"type":"string","enum":["module","ui","styles","description","text","structured_data","asset","edits","secret","payload"],"description":"Which input tripped the cap."},"size_bytes":{"type":"integer","minimum":0},"cap_bytes":{"type":"integer","minimum":0},"instructions":{"type":"string"}},"additionalProperties":false},"RecoveryRefetch":{"type":"object","required":["kind","refetch_url","instructions"],"properties":{"kind":{"type":"string","enum":["refetch"]},"refetch_url":{"type":"string","format":"uri","description":"Absolute URL to GET for the fresh ETag before retrying with a corrected If-Match."},"instructions":{"type":"string"}},"additionalProperties":false},"RecoveryFixRouteLabel":{"type":"object","required":["kind","instructions"],"properties":{"kind":{"type":"string","enum":["fix_route_label"]},"instructions":{"type":"string","description":"App-code recovery: the fix is in the route declaration, NOT in the request. Retrying the same request will fail again."}},"additionalProperties":false},"RecoveryRename":{"type":"object","required":["kind","instructions"],"properties":{"kind":{"type":"string","enum":["rename"]},"instructions":{"type":"string"}},"additionalProperties":false},"RecoveryMigrateContract":{"type":"object","required":["kind","instructions"],"properties":{"kind":{"type":"string","enum":["migrate_contract"]},"instructions":{"type":"string"}},"additionalProperties":false},"Icon":{"type":"object","description":"Optional home-screen / favicon icon. The server composes a colored rounded-square PNG/SVG from `emoji + bg` — NOT a list of image URLs like a W3C web manifest. Omit it to get the default icon. If `emoji` or `bg` is invalid the whole icon is silently dropped (stored as unset, so the default renders) and the create/update response carries a `warnings[]` entry. This warn-and-drop contract is the `manifest.icon` publish path only (`PUT /app/{id}` and its create counterpart) — `PUT /app/{id}/icon` uses the stricter `IconStrict` schema instead.","required":["emoji","bg"],"properties":{"emoji":{"type":"string","description":"A single emoji, rendered centered (e.g. `⚽`). Extra glyphs are dropped."},"bg":{"type":"string","pattern":"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$","description":"Background color as a hex string (`#rgb`, `#rrggbb`, or `#rrggbbaa`). Named colors (`\"green\"`), `rgb()`/`hsl()`, and image URLs are rejected."}},"additionalProperties":false},"IconStrict":{"type":"object","description":"Home-screen / favicon icon for `PUT /app/{id}/icon`. Same shape as `Icon`, but validated strictly: an invalid `emoji` or `bg` is rejected with 400 `invalid_icon` rather than silently dropped (the dashboard icon picker needs a hard rejection; `Icon`'s warn-and-drop contract is for agent publishes, where a typo must never fail).","required":["emoji","bg"],"properties":{"emoji":{"type":"string","description":"A single emoji, rendered centered (e.g. `⚽`). Must contain at least one grapheme, or the request is rejected with 400 `invalid_icon`. A value with more than one grapheme (e.g. `⚽⚾`) is accepted, not rejected — only the first grapheme renders and the rest are silently dropped, the same truncation `Icon.emoji` discloses (`Extra glyphs are dropped.`); this endpoint is strict about invalid input, not about single-glyph input."},"bg":{"type":"string","pattern":"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$","description":"Background color as a hex string (`#rgb`, `#rrggbb`, or `#rrggbbaa`). Named colors (`\"green\"`), `rgb()`/`hsl()`, and image URLs are rejected."}},"additionalProperties":false},"Manifest":{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://charm.ing/schema/app-manifest/2026-10-16.json","type":"object","required":["id","meta"],"additionalProperties":false,"properties":{"$schema":{"const":"https://charm.ing/schema/app-manifest/2026-10-16.json"},"id":{"type":"string","pattern":"^[a-z0-9][a-z0-9-]{0,63}$"},"meta":{"type":"object","required":["name"],"additionalProperties":false,"properties":{"name":{"type":"string","minLength":1},"icon":{"type":"object","required":["emoji","bg"],"additionalProperties":false,"properties":{"emoji":{"type":"string","minLength":1},"bg":{"type":"string","pattern":"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"}}}}},"capabilities":{"type":"object","additionalProperties":false,"properties":{"imports":{"type":"array","uniqueItems":true,"items":{"oneOf":[{"enum":["charming:storage/kv@1.0","charming:storage/blob@1.0","charming:logging/emit@1.0","charming:network/fetch@1.0","charming:secrets/fetch@1.0","charming:browser/microphone@1.0","charming:browser/camera@1.0","charming:browser/geolocation@1.0","charming:browser/clipboard-read@1.0","charming:browser/display-capture@1.0","charming:browser/midi@1.0","charming:browser/device-motion@1.0","charming:browser/ambient-light@1.0","charming:browser/storage@1.0"]},{"type":"string","pattern":"^charming:app/[a-z0-9][a-z0-9-]{0,63}@[0-9]+\\.[0-9]+(?:\\.[0-9]+)?$"}]}}}},"permissions":{"type":"object","additionalProperties":false,"properties":{"browser":{"type":"object","additionalProperties":false,"properties":{"img-src":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1,"pattern":"^https://[^/?#@*]+$"}},"frame-src":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1,"pattern":"^https://[^/?#@*]+$"}},"connect-src":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1,"pattern":"^(?:https|wss)://[a-z0-9.-]+(?::[0-9]+)?$"}}}},"server":{"type":"object","additionalProperties":false,"properties":{"fetch":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1,"pattern":"^https://[^/?#@*]+$"}}}}}}}},"AppPackage":{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://charm.ing/schema/app-package/2026-10-25.json","type":"object","required":["name"],"properties":{"$schema":{"const":"https://charm.ing/schema/app-package/2026-10-25.json"},"name":{"type":"string","pattern":"^[a-z0-9][a-z0-9-]{0,63}$"},"version":{"type":"string","pattern":"^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$"},"description":{"type":"string","maxLength":500},"type":{"const":"module"},"dependencies":{"type":"object","propertyNames":{"type":"string","format":"npm-package-name"},"additionalProperties":{"type":"string","minLength":1,"format":"npm-semver-range"}},"devDependencies":{"type":"object"},"charming":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","minLength":1},"icon":{"type":"object","required":["emoji","bg"],"additionalProperties":false,"properties":{"emoji":{"type":"string","minLength":1},"bg":{"type":"string","pattern":"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"}}},"permissions":{"type":"object","additionalProperties":false,"properties":{"browser":{"type":"object","additionalProperties":false,"properties":{"img-src":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1,"pattern":"^https://[^/?#@*]+$"}},"frame-src":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1,"pattern":"^https://[^/?#@*]+$"}},"connect-src":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1,"pattern":"^(?:https|wss)://[a-z0-9.-]+(?::[0-9]+)?$"}}}},"server":{"type":"object","additionalProperties":false,"properties":{"fetch":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1,"pattern":"^https://[^/?#@*]+$"}},"connectors":{"type":"object","additionalProperties":{"type":"array","minItems":1,"uniqueItems":true,"items":{"type":"string","minLength":1}}}}}}}}}}},"AppFiles":{"type":"object","description":"An App as a package: each key is a relative path, each value that file's text. Holds package.json (see AppPackage) and the server entry server.js; optionally ui.js, styles.css, and any other .js, .mjs, or .json files the entries import with relative paths, and on the 2026-11-09 contract .ts files, read with their types erased. package.json may declare `\"$schema\": \"https://charm.ing/schema/app-package/2026-10-25.json\"`.","required":["package.json","server.js"],"properties":{"package.json":{"type":"string"},"server.js":{"type":"string"},"ui.js":{"type":"string"},"styles.css":{"type":"string"}},"additionalProperties":{"type":"string"}},"AppCreateBody":{"type":"object","properties":{"files":{"$ref":"#/components/schemas/AppFiles","description":"Create the App as a package. Requires an enabled authenticated user and Idempotency-Key, and accepts a background build. Mutually exclusive with module, ui, styles, description, pair, and label."},"module":{"type":"string","description":"Server ES module source for the canonical contract, which publishes synchronously. Must export a literal canonical `manifest` and a `routes` array. A route handler returns exactly the value declared by `outputSchema`; for `outputSchema: { type: \"array\", items: ... }`, return the array directly. Charming adds the HTTP transport envelope, so do not add `{ ok, value }` or `{ value }` unless those fields belong to `outputSchema` itself. `default.fetch` is an optional unmatched-request fallback; when absent, Charming supplies a generic 404 handler. Required unless files is sent."},"ui":{"type":["string","null"],"description":"Optional browser source populating #app, a classic script for the canonical contract."},"styles":{"type":["string","null"],"description":"Optional CSS injected alongside ui."},"description":{"type":["string","null"],"description":"Optional app description, shown to the owner and to callers who read it back. A package describes itself in package.json."},"migrate_contract":{"type":"boolean","description":"With files only: true explicitly moves an existing same-owner App onto the package contract. Supply its desired revision in If-Match. The existing app remains active until the build publishes."},"pair":{"type":"boolean","description":"Existing-contract anonymous POST only; rejected on package saves. Silently ignored on existing-contract authenticated upserts. When true, server mints a bound device_code alongside the app token; claiming the app approves the pairing, and approving the pairing code at `/pair` claims the app, so either gesture gives the agent a `chrm_user_*` for the claimed app."},"label":{"type":"string","maxLength":80,"description":"Existing-contract anonymous POST only; rejected on package saves. Silently ignored on existing-contract authenticated upserts. Human-readable label for the agent, surfaced to the user on the `/pair` approval page when `pair: true`."}},"additionalProperties":false},"AppFileFromSource":{"type":"object","description":"Migration saves only: a file built from a field of the App's current source, at the If-Match revision, with exact edits applied in order. Edits across all files count toward one cap of 100.","required":["from"],"properties":{"from":{"type":"string","enum":["module","ui","styles"],"description":"The field of the current source the file starts from."},"edits":{"type":"array","items":{"type":"object","required":["old_string","new_string"],"properties":{"old_string":{"type":"string"},"new_string":{"type":"string"},"replace_all":{"type":"boolean"}},"additionalProperties":false},"description":"Omit to copy the field unchanged."}},"additionalProperties":false},"AppUpdateBody":{"type":"object","properties":{"files":{"type":"object","description":"The whole replacement tree of a package App, as in AppFiles. Required for an App on the package contract; statically checked and built after acceptance. When the save migrates an App saved before packages, a file may be an AppFileFromSource instead of its text, so the request carries only the changes. Mutually exclusive with module, ui, styles, and description.","required":["package.json","server.js"],"additionalProperties":{"anyOf":[{"type":"string"},{"$ref":"#/components/schemas/AppFileFromSource"}]}},"module":{"type":"string","description":"Replacement server ES module source for a canonical App. Must export a literal canonical `manifest` and a `routes` array. A route handler returns exactly the value declared by `outputSchema`; for `outputSchema: { type: \"array\", items: ... }`, return the array directly. Charming adds the HTTP transport envelope, so do not add `{ ok, value }` or `{ value }` unless those fields belong to `outputSchema` itself. `default.fetch` is an optional unmatched-request fallback; when absent, Charming supplies a generic 404 handler. Keep the stored contract’s exact schema. Required unless files is sent."},"ui":{"type":["string","null"],"description":"Replacement browser script for a canonical App."},"styles":{"type":["string","null"],"description":"Replacement CSS for a canonical App."},"description":{"type":["string","null"],"description":"Omit to preserve the desired description; pass null to clear."},"migrate_contract":{"type":"boolean","description":"Required as true when changing a stored contract. Moving to the package contract requires files, Idempotency-Key and desired-source If-Match; it publishes only after a successful build. Source submissions do not roll back contracts. History can explicitly restore a retained validated existing-contract revision through POST /api/v1/apps/{appId}/revisions/{revision}/restore."}},"additionalProperties":false},"AppCreateResponse":{"type":"object","required":["id","manifestId","displayName","url","capabilities","claimed","revision"],"properties":{"id":{"type":"string","format":"uuid"},"manifestId":{"type":"string"},"displayName":{"type":"string"},"url":{"type":"string","format":"uri"},"capabilities":{"$ref":"#/components/schemas/Manifest/properties/capabilities"},"icon":{"anyOf":[{"$ref":"#/components/schemas/Icon"},{"type":"null"}]},"claimed":{"type":"boolean"},"revision":{"$ref":"#/components/schemas/Revision","example":4},"token":{"type":"string","description":"Anonymous-create only. `chrm_app_*` plaintext, returned exactly once — irrecoverable."},"expiresAt":{"type":"string","format":"date-time","description":"Anonymous-create only. 7-day TTL unless claimed."},"mcpHint":{"type":"object","properties":{"setupUrl":{"type":"string","format":"uri"},"snippets":{"type":"object","additionalProperties":{"type":"string"}}}},"pairing":{"type":"object","description":"Present only when the request body included `pair: true`. Agent should poll `POST /api/pair/poll` with `device_code` until status flips to `approved`.","properties":{"device_code":{"type":"string"},"user_code":{"type":"string","pattern":"^CHRM-[A-Z2-9]{6}$","description":"Show verbatim to the user; they type it on `verification_url`."},"verification_url":{"type":"string","format":"uri"},"polling_interval":{"type":"integer"},"expires_in":{"type":"integer"}}},"warnings":{"type":"array","items":{"type":"string"},"description":"Non-blocking publish feedback (#1126), present only when static validation found UI/backend contract mismatches — e.g. the UI calls an operation this version does not expose. The write succeeded; fix by adding the backend op or renaming the UI call."}}},"AppUpdateResponse":{"type":"object","required":["id","manifestId","displayName","url","capabilities","claimed","revision"],"properties":{"id":{"type":"string","format":"uuid"},"manifestId":{"type":"string"},"displayName":{"type":"string"},"description":{"type":["string","null"]},"url":{"type":"string","format":"uri"},"capabilities":{"$ref":"#/components/schemas/Manifest/properties/capabilities"},"icon":{"anyOf":[{"$ref":"#/components/schemas/Icon"},{"type":"null"}]},"claimed":{"type":"boolean"},"revision":{"$ref":"#/components/schemas/Revision","example":4},"warnings":{"type":"array","items":{"type":"string"},"description":"Non-blocking publish feedback (#1126), present only when static validation found UI/backend contract mismatches. The write succeeded."}}},"AppListResponse":{"type":"object","required":["apps"],"properties":{"apps":{"type":"array","items":{"type":"object","required":["revision"],"properties":{"id":{"type":"string","format":"uuid"},"role":{"type":"string","enum":["owner","collaborator","end-user","viewer","team-admin","team-member"],"description":"`owner` = your app. `collaborator` = shared with you via an accepted invite (edit and run, never share/delete/transfer). `end-user` = shared use-and-write-data (run the app and write its data, but cannot edit the app source). `viewer` = shared read-only. `team-admin` / `team-member` = owned by a team you belong to. Non-owner rows carry the UUID-form `url`, which redirects to the owner-canonical URL."},"manifestId":{"type":"string"},"displayName":{"type":"string"},"revision":{"$ref":"#/components/schemas/Revision","example":4},"capabilities":{"$ref":"#/components/schemas/Manifest/properties/capabilities"},"url":{"type":"string","format":"uri"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}}},"nextCursor":{"type":["string","null"],"description":"Pass back as `cursor` query param to fetch the next page."}}},"DescribeResponse":{"type":"object","required":["id","manifestId","displayName","revision","capabilities","ui","styles","claimed","expiresAt","api","storageKeys"],"properties":{"id":{"type":"string","format":"uuid"},"manifestId":{"type":"string"},"displayName":{"type":"string"},"revision":{"$ref":"#/components/schemas/Revision","example":4},"capabilities":{"$ref":"#/components/schemas/Manifest/properties/capabilities"},"ui":{"type":"boolean"},"styles":{"type":"boolean"},"claimed":{"type":"boolean"},"expiresAt":{"type":["string","null"],"format":"date-time"},"api":{"type":"object","description":"Machine-readable app API summary for agents. Raw module source is intentionally omitted; operations are derived from manifest exports and literal /api/<operation> routes.","required":["baseUrl","operations"],"properties":{"baseUrl":{"type":"string","format":"uri"},"operations":{"type":"array","items":{"type":"object","required":["op","method","path","url","tool","discoveredFrom"],"properties":{"op":{"type":"string"},"method":{"type":"string","enum":["GET","POST","PUT","PATCH","DELETE"]},"path":{"type":"string"},"url":{"type":"string","format":"uri"},"tool":{"type":"string","enum":["query_app","mutate_app"],"description":"MCP tool to invoke this op: query_app for read-only, mutate_app otherwise."},"callers":{"type":"string","enum":["members","signed-in","anyone"],"description":"Who, among the people who can view the App, may call the operation at `url`. A read-only operation reports `anyone`, because every viewer may call it whatever its route declares. A write reports its route's `callers` declaration, `members` when unset. `mutate_app` and the App's MCP tools need run access for every write whatever this says."},"discoveredFrom":{"type":"array","items":{"type":"string","enum":["manifest_export","module_route"]}},"manifestExport":{"type":"string"}}}}}},"storageKeys":{"type":"array","items":{"type":"string"}}}},"AppDescriptorResponse":{"oneOf":[{"$ref":"#/components/schemas/AppDescriptor"},{"$ref":"#/components/schemas/AppDescriptorStub"}]},"AppDescriptor":{"type":"object","required":["type","schema_version","id","revision","display_name","app_name","visibility","authorized","canonical_url","when_to_use","author_provided","operations","http_api","mcp","auth"],"properties":{"type":{"type":"string","const":"charming.app-descriptor"},"schema_version":{"type":"string","const":"v1"},"id":{"type":"string","format":"uuid"},"revision":{"$ref":"#/components/schemas/Revision","example":4},"display_name":{"type":"string"},"app_name":{"type":["string","null"]},"visibility":{"type":"string","enum":["public","remixable","private"]},"authorized":{"type":"boolean"},"canonical_url":{"type":"string","format":"uri"},"when_to_use":{"type":"string"},"author_provided":{"type":"object","additionalProperties":true},"operations":{"type":"array","items":{"type":"object","additionalProperties":true}},"http_api":{"type":"object","additionalProperties":true},"mcp":{"type":"object","additionalProperties":true},"auth":{"type":"object","additionalProperties":true},"advisories":{"type":"array","items":{"type":"object","additionalProperties":true}}}},"AppDescriptorStub":{"type":"object","description":"Fail-closed descriptor for a private app when the caller lacks app:read. It omits the app ID, revision, source state, and operations.","required":["type","schema_version","visibility","authorized","message","auth"],"properties":{"type":{"type":"string","const":"charming.app-descriptor"},"schema_version":{"type":"string","const":"v1"},"visibility":{"type":"string","const":"private"},"authorized":{"type":"boolean","const":false},"message":{"type":"string"},"auth":{"type":"object","additionalProperties":true}}},"Revision":{"type":"integer","minimum":0,"example":4,"examples":[0,4],"description":"Server-owned app source revision. New apps start at 1, each successful source write advances it once, and historical null counters project as 0. `If-Match: \"<N>\"` and `expected_revision` carry this revision through its canonical concurrency grammar."},"AppSourceResponse":{"type":"object","required":["id","url","manifestId","sourceManifestId","displayName","description","revision","activeRevision","build","publication","appVersion","manifestVersion","capabilities","claimed","expiresAt","source"],"properties":{"id":{"type":"string","format":"uuid"},"url":{"type":"string","format":"uri"},"manifestId":{"type":"string"},"sourceManifestId":{"type":"string"},"displayName":{"type":"string"},"description":{"type":["string","null"]},"revision":{"$ref":"#/components/schemas/Revision","example":4,"description":"The latest saved revision: the source in this response, and the value the `ETag` carries. A save is stored before it goes live, so this can be ahead of `activeRevision`."},"activeRevision":{"type":"integer","minimum":0,"example":4,"description":"The revision visitors are served. Equal to `revision` once the latest save is live. When lower, the source in this response is not live yet; `build` says why. While `build.state` is queued, resolving, building, or validating, wait for it to finish. When it is failed or expired, read `build.error`: `stage` names the build stage that failed and `path`, `line`, and `column` the file position when known; fix that save and save again, or restore the active revision. When it is canceled, save again to build it, or restore the active revision. When it is superseded, read the source again. When `build` is null, Charming has no build on record for this save: a save before packages stored without one, or a package save whose build record is gone. Save it again to build and publish it. `publication` names the state: `unpublished` means Charming holds the save without a runnable build while `activeRevision` keeps serving. `activeRevision` and `build` are read separately, so a build that publishes between them can show a lower `activeRevision` with `build.state` published; the next read agrees."},"build":{"type":["object","null"],"description":"The build a save accepted for `revision`. Null when no build is recorded against this revision: a save made before packages, a revision that a create, copy, or migration published, or a live revision whose build record has expired. The build behind a revision that is not live yet is kept until a later save or publish. `error` is present when the build failed or expired. Read `statusUrl` for the full status.","required":["buildId","state","statusUrl"],"properties":{"buildId":{"$ref":"#/components/schemas/AppBuildResponse/properties/buildId"},"state":{"$ref":"#/components/schemas/AppBuildResponse/properties/state"},"statusUrl":{"$ref":"#/components/schemas/AppBuildResponse/properties/statusUrl"},"error":{"$ref":"#/components/schemas/AppBuildResponse/properties/error"}}},"publication":{"type":"string","enum":["published","pending","unpublished"],"description":"Whether `revision` is what visitors are served. `published`: it is the active revision. `pending`: its build is still running, so wait for it; or a newer save superseded it, so read the source again. `unpublished`: Charming holds this save without a runnable build, and `activeRevision` keeps serving until a later save publishes. That is a state the App can stay in, not an outage: read `build.error` for the stage and file position that failed, fix the source and save again, or restore the active revision. When `build` is null Charming has no build on record for this save; save it again to build it."},"appVersion":{"type":"string","description":"Canonical and migrated apps return decimal `String(revision)`. Legacy apps return their stored effective SemVer."},"manifestVersion":{"type":["string","null"],"deprecated":true,"description":"Required compatibility field. Canonical and migrated apps return null; legacy apps return their stored contract date."},"$schema":{"type":"string","format":"uri","enum":["https://charm.ing/schema/app-manifest/2026-07-31.json","https://charm.ing/schema/app-manifest/2026-10-16.json","https://charm.ing/schema/app-package/2026-10-25.json"],"description":"Exact schema URL: the dated canonical manifest schema, or the package.json schema for a package App. Legacy source responses omit this field."},"capabilities":{"$ref":"#/components/schemas/Manifest/properties/capabilities"},"claimed":{"type":"boolean"},"expiresAt":{"type":["string","null"],"format":"date-time"},"source":{"type":"object","required":["module","ui","styles"],"properties":{"module":{"type":"string"},"ui":{"type":["string","null"]},"styles":{"type":["string","null"]},"files":{"$ref":"#/components/schemas/AppFiles","description":"The authored tree of a package App. module, ui, and styles project its server.js, ui.js, and styles.css."}}}},"oneOf":[{"title":"2026-07-31 app source","required":["$schema"],"properties":{"$schema":{"const":"https://charm.ing/schema/app-manifest/2026-07-31.json"},"manifestVersion":{"type":"null"}}},{"title":"2026-10-16 app source","required":["$schema"],"properties":{"$schema":{"const":"https://charm.ing/schema/app-manifest/2026-10-16.json"},"manifestVersion":{"type":"null"}}},{"title":"Package app source","required":["$schema"],"properties":{"$schema":{"const":"https://charm.ing/schema/app-package/2026-10-25.json"},"manifestVersion":{"type":"null"}}},{"title":"Legacy app source","not":{"required":["$schema"]},"properties":{"manifestVersion":{"type":"string"}}}]},"ActivityResponse":{"type":"object","required":["ok","value"],"properties":{"ok":{"type":"boolean","enum":[true]},"value":{"type":"object","required":["items","retention"],"properties":{"retention":{"type":"object","required":["tier","hours","since","truncated"],"description":"The plan window this read used: 24 hours on Free, 30 days on Pro, 90 days on Business. Older events are hidden, not deleted.","properties":{"tier":{"type":"string","enum":["free","pro","business","enterprise"]},"hours":{"type":"integer","description":"Length of the plan window."},"since":{"type":"string","format":"date-time","description":"The cutoff this read used."},"truncated":{"type":"boolean","description":"True when the plan window set the cutoff."}}},"items":{"type":"array","description":"Newest-first durable runtime-failure events for this app, inside the plan window. Bounded by per-kind insert caps and a 90-day prune.","items":{"type":"object","required":["ts","kind","revision","summary","data"],"properties":{"ts":{"type":"string","format":"date-time"},"kind":{"type":"string","enum":["api_proxy_result","visitor_calls_refused","image_proxy_result","diag_report","contract_validation","app_load_error","render_token_revoked"]},"revision":{"$ref":"#/components/schemas/Revision","description":"App source revision recorded with the event. Historical null event counters project as 0 and never borrow the app current revision.","example":0},"summary":{"type":"string","description":"Compact one-line description of the event."},"data":{"type":"object","description":"Kind-specific redacted payload (no stacks, no tokens, no source bytes)."}}}}}}}},"DiagResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"value":{"type":"object","properties":{"entries":{"type":"array","description":"Most-recent-first ring buffer (50-entry cap per app).","items":{"type":"object","properties":{"ts":{"type":"string","format":"date-time"},"message":{"type":"string"},"source":{"type":"string"},"line":{"type":"integer"},"col":{"type":"integer"},"stack":{"type":"string"}}}}}}}},"FeedbackSubmitBody":{"type":"object","required":["category"],"properties":{"category":{"type":"string","enum":["bug","crash","enhancement","praise","other"],"description":"Feedback category. `crash` requires `crashData` (or its snake_case alias) carrying at least `message`."},"source":{"type":"string","enum":["user","agent","auto-crash"],"description":"Optional origin tag. Defaults to `user`. The MCP `submit_feedback` tool forces `agent` server-side; direct REST callers may pass `user` / `auto-crash` explicitly."},"text":{"type":"string","maxLength":16384,"description":"Free-form feedback body. 16384-character cap; oversize bodies return `text_too_large` (413)."},"structuredData":{"type":"object","additionalProperties":true,"description":"Caller-supplied JSON payload (e.g. route, repro inputs). Serialized payload is capped at 65536 bytes; oversize payloads return `structured_data_too_large` (413). Snake_case alias `structured_data` is also accepted."},"crashData":{"type":"object","required":["message"],"properties":{"message":{"type":"string"},"stack":{"type":"string"},"url":{"type":"string"},"userAgent":{"type":"string"},"traceId":{"type":"string"}},"description":"Crash details. Required when `category=crash`; optional otherwise. Snake_case alias `crash_data` is also accepted."}}},"FeedbackSubmitResponse":{"type":"object","required":["ok","value"],"properties":{"ok":{"type":"boolean","enum":[true]},"value":{"type":"object","required":["id","createdAt"],"properties":{"id":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"}}}}},"AppEventStateChanged":{"type":"object","required":["kind","appId","op","source","ts","result"],"description":"JSON payload of a `state-changed` SSE frame. Emitted after a write lands (`source: \"agent\"`) or as a synthetic catch-up signal (`source: \"reconnect-resync\"`, `op: null`, `result: null`) when the client reconnects with a stale `Last-Event-ID`.","properties":{"kind":{"type":"string","enum":["state-changed"]},"appId":{"type":"string"},"op":{"type":["string","null"],"description":"Operation name that produced the state change, or `null` on synthetic `reconnect-resync` events."},"source":{"type":"string","enum":["agent","reconnect-resync"],"description":"`agent` for writes routed through the runtime; `reconnect-resync` for the server-generated catch-up signal."},"ts":{"type":"integer","description":"Unix milliseconds at the time the frame was written."},"result":{"description":"Operation result body when JSON-shaped, `null` on `reconnect-resync` events and on operations whose response was non-JSON or exceeded the 32 KiB cap."}}},"AppEventOvercapacity":{"type":"object","required":["message"],"description":"JSON payload of the `overcapacity` SSE frame emitted when the per-app subscriber cap is reached. The server closes the stream immediately after writing this frame; clients should back off before retrying.","properties":{"message":{"type":"string","enum":["too_many_subscribers"]}}},"OkResponse":{"type":"object","required":["ok"],"description":"Minimal success acknowledgement. `ok: true` confirms the mutation landed.","properties":{"ok":{"type":"boolean","enum":[true]}}},"PairApproveResponse":{"type":"object","required":["ok","claimed"],"description":"Pairing approved. `claimed` is true when the code's bound app (`POST /app {pair: true}`) belongs to the approver after this approval, whether this approval moved it or it was already theirs.","properties":{"ok":{"type":"boolean","enum":[true]},"claimed":{"type":"boolean"}}},"AppClaimResponse":{"type":"object","required":["ok","id","manifestId","claimedAt"],"description":"Acknowledgement returned by POST /app/{id}/claim once ownership transfers.","properties":{"ok":{"type":"boolean","enum":[true]},"id":{"type":"string","format":"uuid"},"manifestId":{"type":"string"},"claimedAt":{"type":"string","format":"date-time"}}},"AppCopyResponse":{"type":"object","required":["ok","id","url","manifestId","appName","displayName","revision","sourceAppId","copyKind"],"description":"The private copy POST /app/{id}/copy created.","properties":{"ok":{"type":"boolean","enum":[true]},"id":{"type":"string","format":"uuid"},"url":{"type":"string","format":"uri"},"manifestId":{"type":"string"},"appName":{"type":["string","null"]},"displayName":{"type":"string"},"revision":{"type":"integer"},"sourceAppId":{"type":"string","format":"uuid"},"copyKind":{"type":"string","enum":["app","template"]},"copiedData":{"type":"object","required":["keys","assets"],"description":"Present when include_data copied the data on this call. Absent on an idempotency replay, which returns the earlier copy without recounting.","properties":{"keys":{"type":"integer","minimum":0},"assets":{"type":"integer","minimum":0}}},"secretsNotCopied":{"type":"array","items":{"type":"string"},"description":"Names of source secrets the copy does not have."}}},"AppPublicResponse":{"type":"object","required":["public","public_url"],"description":"New public state plus the public URL when public is true.","properties":{"public":{"type":"boolean"},"public_url":{"type":["string","null"],"description":"Public URL when `public: true` (friendly `/{handle}/{app-name}` form when available, `/app/{id}` otherwise). Anyone can open the live hosted App Viewer with no login and read its data, but cannot change data or source. `null` when `public: false`."}}},"AppRemixableResponse":{"type":"object","required":["remixable","public_url","listed"],"description":"New remixable/listed state plus the shareable URL when remixable is true.","properties":{"remixable":{"type":"boolean"},"public_url":{"type":["string","null"],"description":"Shareable URL when `remixable: true` (friendly `/{handle}/{app-name}` form when available, `/app/{id}` otherwise); `null` when `remixable: false`."},"listed":{"type":"boolean","description":"Whether the app is listed in the public template directory, reflecting the actual resulting state — not necessarily the request's `listed` field, since an omitted `listed` leaves the prior state unchanged. A listed app is always also `remixable: true`; always `false` when `remixable: false`."}}},"AppStarterPromptResponse":{"type":"object","required":["starter_prompt"],"description":"New starter-prompt value (or `null` after clearing).","properties":{"starter_prompt":{"type":["string","null"]}}},"AppSecretListResponse":{"type":"object","required":["ok","names"],"description":"Owner-visible list of secret NAMES (values are never echoed).","properties":{"ok":{"type":"boolean","enum":[true]},"names":{"type":"array","items":{"type":"string"}}}},"ManifestResolveResponse":{"type":"object","required":["appId"],"description":"Resolved app id for the supplied manifestId in the caller’s scope. `appId` is omitted when no match exists (404).","properties":{"appId":{"type":"string","format":"uuid"}}},"AssetUploadResponse":{"type":"object","required":["ok","key","url","sizeBytes"],"description":"Confirmation that an asset was stored, with a signed URL for direct access.","properties":{"ok":{"type":"boolean","enum":[true]},"key":{"type":"string"},"url":{"type":"string","description":"Signed URL for direct access."},"sizeBytes":{"type":"integer"}}},"AssetListResponse":{"type":"object","required":["ok","assets"],"description":"Stored assets for the app (newest-first).","properties":{"ok":{"type":"boolean","enum":[true]},"assets":{"type":"array","items":{"type":"object","required":["key","contentType","sizeBytes"],"properties":{"key":{"type":"string"},"contentType":{"type":"string"},"sizeBytes":{"type":"integer"}}}}}},"PairStartResponse":{"type":"object","required":["device_code","user_code","verification_url","polling_interval","expires_in"],"description":"RFC 8628-shaped device-code response. Poll `POST /api/pair/poll` until the user approves.","properties":{"device_code":{"type":"string","description":"Agent-private — store securely, never display or log. Anyone with the device_code can poll for the token."},"user_code":{"type":"string","pattern":"^CHRM-[A-Z2-9]{6}$"},"verification_url":{"type":"string","format":"uri"},"verification_url_complete":{"type":"string","format":"uri"},"polling_interval":{"type":"integer"},"expires_in":{"type":"integer"}}},"PairPollResponse":{"type":"object","required":["status"],"description":"Poll result for a previously-minted device_code. `token` is delivered exactly once.","properties":{"status":{"type":"string","enum":["pending","expired","approved"]},"token":{"type":"string","description":"Only on the first poll after approval. `chrm_user_*` plaintext, irrecoverable."},"tokenPrefix":{"type":"string"},"already_delivered":{"type":"boolean"}}},"TokenCreateResponse":{"type":"object","required":["token","tokenPrefix","expiresAt"],"description":"Minted personal access token. `token` plaintext is returned exactly once.","properties":{"token":{"type":"string"},"tokenPrefix":{"type":"string"},"label":{"type":["string","null"]},"expiresAt":{"type":"string","format":"date-time"}}},"TokenInfo":{"type":"object","required":["id","tokenPrefix","expiresAt","createdAt"],"description":"Public metadata for one personal access token row. Plaintext and hash are never echoed.","properties":{"id":{"type":"string","format":"uuid"},"tokenPrefix":{"type":"string"},"label":{"type":["string","null"]},"expiresAt":{"type":"string","format":"date-time"},"lastUsedAt":{"type":["string","null"],"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}}},"TokenListResponse":{"type":"object","required":["tokens"],"description":"List of the caller's personal access tokens.","properties":{"tokens":{"type":"array","items":{"$ref":"#/components/schemas/TokenInfo"}}}},"Routine":{"type":"object","description":"A declared op scheduled to run on a timer. The op is invoked with empty input, so it must declare no required input fields.","required":["id","app_id","op","interval","enabled","disabled_reason","next_run_at","last_run_at","last_outcome","last_error","consecutive_failures"],"properties":{"id":{"type":"string","description":"Public id, `routine_<uuid>` form."},"app_id":{"type":"string","format":"uuid"},"op":{"type":"string"},"interval":{"type":"string","enum":["hourly","daily","weekly"]},"enabled":{"type":"boolean"},"disabled_reason":{"type":["string","null"],"enum":["owner","auto",null]},"next_run_at":{"type":["string","null"],"format":"date-time","description":"`null` while the Routine is disabled — the underlying schedule is preserved and reappears here once re-enabled, with no recomputation."},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_outcome":{"type":["string","null"]},"last_error":{"type":["object","null"],"required":["kind","message"],"properties":{"kind":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","description":"Present when `kind` is `timeout`: which time limit stopped the run, the limit in ms, how long the run went in ms, and where the time went.","required":["limit","limitMs","elapsedMs"],"properties":{"limit":{"type":"string","enum":["operation","sealed_fetch"]},"limitMs":{"type":"number"},"elapsedMs":{"type":"number"},"timings":{"type":"object","description":"Where the run spent its time, when the host measured it: `wallMs`, the storage calls it made and the ms at least one was in flight, the sealed fetch calls the host made for it and their ms (a fetch from `charming:network/fetch@1.0` is not counted), and how many other Routines of the same App ran alongside it and for how many ms.","required":["wallMs","storage","fetch","overlappingRoutines"],"properties":{"wallMs":{"type":"number"},"storage":{"type":"object","required":["calls","ms"],"properties":{"calls":{"type":"number"},"ms":{"type":"number"}}},"fetch":{"type":"object","required":["count","ms"],"properties":{"count":{"type":"number"},"ms":{"type":"number"}}},"overlappingRoutines":{"type":"object","required":["count","ms"],"properties":{"count":{"type":"number"},"ms":{"type":"number"}}}}}}}}},"consecutive_failures":{"type":"integer"}}},"RoutineResponse":{"type":"object","required":["ok","routine"],"properties":{"ok":{"type":"boolean","enum":[true]},"routine":{"$ref":"#/components/schemas/Routine"}}},"Webhook":{"type":"object","description":"A declared op an external sender invokes by POSTing to `url` with the Webhook secret. The body is the op’s input.","required":["id","app_id","op","name","url","secret_prefix","enabled","disabled_reason","last_run_at","last_outcome","last_error","consecutive_failures"],"properties":{"id":{"type":"string","description":"Public id, `webhook_<uuid>` form."},"app_id":{"type":"string","format":"uuid"},"op":{"type":"string"},"name":{"type":"string","description":"The owner’s label; defaults to the op’s title, description, or identifier."},"url":{"type":"string","description":"The delivery URL an external sender POSTs to."},"secret_prefix":{"type":"string","description":"First characters of the secret, for matching a stored copy by eye."},"enabled":{"type":"boolean"},"disabled_reason":{"type":["string","null"],"enum":["owner",null]},"last_run_at":{"type":["string","null"],"format":"date-time"},"last_outcome":{"type":["string","null"]},"last_error":{"type":["object","null"],"required":["kind","message"],"properties":{"kind":{"type":"string"},"message":{"type":"string"}}},"consecutive_failures":{"type":"integer"}}},"WebhookTarget":{"type":"object","description":"The target op’s contract: the body a sender must POST (as JSON or form fields) and the value it gets back, read from the app’s active code.","required":["op","input_schema","output_schema"],"properties":{"op":{"type":"string"},"input_schema":{"type":["object","null"]},"output_schema":{"type":["object","null"]}}},"WebhookCreatedResponse":{"type":"object","required":["ok","webhook","secret","target"],"properties":{"ok":{"type":"boolean","enum":[true]},"webhook":{"$ref":"#/components/schemas/Webhook"},"secret":{"type":"string","description":"The `chrm_hook_*` secret. Shown once; only its hash is stored."},"target":{"$ref":"#/components/schemas/WebhookTarget"}}},"WebhookResponse":{"type":"object","required":["ok","webhook"],"properties":{"ok":{"type":"boolean","enum":[true]},"webhook":{"$ref":"#/components/schemas/Webhook"},"secret":{"type":"string","description":"Present only when the update rotated the secret. Shown once."}}},"WebhookDeliveryBody":{"type":"object","additionalProperties":true,"description":"The target op's input. Its shape is the op's declared input schema, returned as `target.input_schema` when the Webhook was created, so it cannot be closed here."},"WebhookDeliveryResponse":{"type":"object","required":["ok","value"],"description":"The op's own result envelope, validated against its declared output schema.","properties":{"ok":{"type":"boolean","enum":[true]},"value":{"description":"The op's return value."}}},"WebhookListResponse":{"type":"object","required":["ok","webhooks","limits"],"description":"The caller's Webhooks, and the Webhook ceilings their plan allows.","properties":{"ok":{"type":"boolean","enum":[true]},"webhooks":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}},"limits":{"type":"object","description":"The caller's own Webhook ceilings, resolved from their plan. Read these rather than assuming a tier.","required":["webhooks_per_app","webhooks_per_owner"],"properties":{"webhooks_per_app":{"type":"integer"},"webhooks_per_owner":{"type":"integer"}}}}},"ConnectorToolSchemasResponse":{"type":"object","required":["ok","service","version","tools"],"properties":{"ok":{"type":"boolean","enum":[true]},"service":{"type":"string"},"version":{"type":"string"},"tools":{"type":"array","items":{"type":"object","required":["tool","function","inputSchema","outputSchema"],"properties":{"tool":{"type":"string","description":"The tool slug."},"function":{"type":"string","description":"The name the toolkit module exports the tool under."},"inputSchema":{"description":"The JSON Schema of the tool's input."},"outputSchema":{"description":"The JSON Schema of the tool's result."}}}}}},"RoutineListResponse":{"type":"object","required":["ok","routines","limits"],"description":"The caller's Routines, and the Routine ceilings their plan allows.","properties":{"ok":{"type":"boolean","enum":[true]},"routines":{"type":"array","items":{"$ref":"#/components/schemas/Routine"}},"limits":{"type":"object","description":"The caller's own Routine ceilings, resolved from their plan. Read these rather than assuming a tier: a client that hardcodes the free numbers disables its create control for a paying owner the server would allow.","required":["routines_per_app","routines_per_owner"],"properties":{"routines_per_app":{"type":"integer"},"routines_per_owner":{"type":"integer"}}}}}}},"x-charming-app-build-policy":{"version":"app-build-v1","concurrency":2,"actorConcurrency":1,"pendingLimit":16,"actorPendingLimit":3,"queueMs":600000,"attemptMs":600000,"totalMs":1200000,"leaseMs":30000,"heartbeatMs":10000,"retryBackoffMs":10000,"attempts":2,"pollMs":2000,"inspectionMs":604800000,"idempotencyMs":2592000000},"paths":{"/api/v1/apps/{appId}/transfer":{"post":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"App transferred.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppTransferResponse"}}}},"400":{"description":"Malformed app id, malformed body, or a no-op/cross-scope transfer.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not manage the app / cannot create in the team, or is an App account that has not joined Charming.","x-error-kinds":["forbidden","account_not_joined"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The destination already owns an app with this name.","x-error-kinds":["name_taken"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"transfer-app","summary":"Transfer an app between the caller and a team","description":"User-gated (`chrm_user_*` or session). With `teamId`: user→team (caller must hold `app:manage` on the app and be owner/admin of the team). Without: team→user transfer to the caller.","security":[{"userToken":[]},{"sessionCookie":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"teamId":{"type":["string","null"],"description":"Destination team. Absent or null = transfer to the caller."},"keepExistingAppMembers":{"type":"boolean","default":true,"description":"Keep direct grants, pending invitations, and active single-use links. Omitted means true."}},"additionalProperties":false}}}}}},"/api/v1/team-invitations/{invitationId}":{"delete":{"tags":["TeamInvitations"],"parameters":[{"name":"invitationId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Invitation cancelled."},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Refused by the plugin gate, or the invitation’s team requires two-factor authentication and the caller has not turned it on (`two_factor_required`).","x-error-kinds":["forbidden","two_factor_required"],"x-error-kinds-relayed":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"cancel-team-invitation","summary":"Cancel an outgoing team invitation","description":"Session cookie required. Personal access tokens are not accepted; owner/admin of the invitation’s team only (plugin gate, relayed). Removes the invitation from the pending set.","security":[{"sessionCookie":[]}]}},"/api/v1/team-invitations/{invitationId}/accept":{"post":{"tags":["TeamInvitations"],"parameters":[{"name":"invitationId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Invitation accepted; the caller is now a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Refused by the plugin gate (wrong recipient, expired, …), or the caller is an App account that has not joined Charming.","x-error-kinds":["forbidden","account_not_joined"],"x-error-kinds-relayed":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"accept-team-invitation","summary":"Accept a team invitation","description":"Session cookie required. Personal access tokens are not accepted. The Better Auth org plugin validates the caller is the invitation’s recipient and creates the membership; refusals are relayed verbatim.","security":[{"sessionCookie":[]}]}},"/api/v1/team-invitations/{invitationId}/decline":{"post":{"tags":["TeamInvitations"],"parameters":[{"name":"invitationId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Invitation declined.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Refused by the plugin gate (wrong recipient, expired, …).","x-error-kinds":["forbidden"],"x-error-kinds-relayed":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"decline-team-invitation","summary":"Decline a team invitation","description":"Session cookie required. Personal access tokens are not accepted. The Better Auth org plugin validates the caller is the invitation’s recipient and marks it rejected; refusals are relayed verbatim.","security":[{"sessionCookie":[]}]}},"/api/v1/team-invitations/{invitationId}/resend":{"post":{"tags":["TeamInvitations"],"parameters":[{"name":"invitationId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Invitation re-sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Refused by the plugin gate, or the invitation’s team requires two-factor authentication and the caller has not turned it on (`two_factor_required`).","x-error-kinds":["forbidden","two_factor_required"],"x-error-kinds-relayed":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"resend-team-invitation","summary":"Re-send a team invitation","description":"Session cookie required. Personal access tokens are not accepted; owner/admin only (plugin gate, relayed). Issues a fresh invitation with a new expiry and re-fires the email, keeping one pending invite per address.","security":[{"sessionCookie":[]}]}},"/api/v1/teams":{"get":{"tags":["Teams"],"parameters":[],"responses":{"200":{"description":"The caller’s teams.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamListResponse"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"list-teams","summary":"List the caller’s teams","description":"User-gated (`chrm_user_*` or session). Every team the caller belongs to, with their role, member roster (owners first, caller flagged via `isYou`), and app-count rollup. A team that requires two-factor authentication the caller has not turned on is flagged with `blockedByTwoFactor` and carries no roster.","security":[{"userToken":[]},{"sessionCookie":[]}]},"post":{"tags":["Teams"],"parameters":[],"responses":{"201":{"description":"Team created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamCreateResponse"}}}},"400":{"description":"Invalid body or invalid slug.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller's plan does not include teams, or the caller is an App account that has not joined Charming.","x-error-kinds":["plan_required","account_not_joined"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The slug is already taken.","x-error-kinds":["team_slug_taken"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"create-team","summary":"Create a team","description":"User-gated (`chrm_user_*` or session). Creates a team; the caller becomes its owner. The slug shares the handle namespace with user handles. Refused with 403 `plan_required` (`feature: 'teams'`) unless the caller's plan includes teams; teams come with the Business plan and are set up with Charming.","security":[{"userToken":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","slug"],"properties":{"name":{"type":"string","minLength":1,"maxLength":100},"slug":{"type":"string","description":"Team handle (kebab-case, shared namespace)."}},"additionalProperties":false}}}}}},"/api/v1/teams/{teamId}/app-defaults":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The defaults applied to new and transferred team Apps.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamAppDefaultsResponse"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner or admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"get-team-app-defaults","summary":"Get team App defaults","description":"User-gated (`chrm_user_*` or session); the caller must be an owner or admin of the team.","security":[{"userToken":[]},{"sessionCookie":[]}]},"patch":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Defaults updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamAppDefaultsResponse"}}}},"400":{"description":"Invalid body or default value.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner or admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"update-team-app-defaults","summary":"Update team App defaults","description":"User-gated (`chrm_user_*` or session); the caller must be an owner or admin of the team. Changes apply only to later App creates and transfers.","security":[{"userToken":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","minProperties":1,"properties":{"generalAccessTier":{"type":"string","enum":["invited-only","public-view","public-and-signed-in-use"]},"templateEnabled":{"type":"boolean"}},"additionalProperties":false}}}}}},"/api/v1/teams/{teamId}/apps":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Defaults to 100, capped at 500."},{"name":"sort","in":"query","required":false,"schema":{"type":"string","enum":["lastPublishedAt:desc","lastPublishedAt:asc","updatedAt:desc","updatedAt:asc","name:asc","name:desc"]},"description":"Order of the whole inventory. Defaults to `lastPublishedAt:desc` (most recently published first); `updatedAt` orders by the last change to the app row, opening the app included; `name` sorts case-insensitively by display name. Ties break by `id` in the same direction. An unknown value is rejected, not ignored."},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"The load-more cursor: the `nextCursor` of the previous page, sent with the same `sort`. A cursor from a different sort, or one that does not decode, is rejected with a 400."}],"responses":{"200":{"description":"The team’s app inventory.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamAppListResponse"}}}},"400":{"description":"Invalid `limit`, `sort`, or `cursor`.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner/admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"list-team-apps","summary":"List a team’s app inventory","description":"User-gated (`chrm_user_*` or session); the caller must be an owner/admin of the team. Never includes a personal (user-owned) app, even one owned by a team member.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/teams/{teamId}/audit":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Defaults to 100, capped at 500."},{"name":"appId","in":"query","required":false,"schema":{"type":"string","format":"uuid"},"description":"Narrows to one app."},{"name":"actor","in":"query","required":false,"schema":{"type":"string"},"description":"A user id — narrows to events where that person is the actor OR the end-user viewer."},{"name":"kind","in":"query","required":false,"schema":{"type":"string"},"description":"Narrows to one event kind. An unrecognized kind is rejected, not ignored."},{"name":"range","in":"query","required":false,"schema":{"type":"integer","enum":[7,30,90]},"description":"Trailing days to include. Defaults to 7."},{"name":"sort","in":"query","required":false,"schema":{"type":"string","enum":["createdAt:desc","createdAt:asc"]},"description":"Order of the whole trail. Defaults to `createdAt:desc` (newest first); ties break by `id` in the same direction. An unknown value is rejected, not ignored. CSV exports honour it too."},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"The load-more cursor: the `nextCursor` of the previous page, sent with the same `sort`. A cursor from a different sort, or one that does not decode, is rejected with a 400. CSV exports ignore it."},{"name":"format","in":"query","required":false,"schema":{"type":"string","enum":["csv"]},"description":"When `csv`, returns `text/csv` instead of JSON, at a higher row cap. Any other value falls through to JSON."}],"responses":{"200":{"description":"The team’s audit trail, as JSON or (with `format=csv`) as `text/csv`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamAuditResponse"}},"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Invalid `limit`, `appId`, `kind`, `range`, `sort`, or `cursor`.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner/admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"get-team-audit","summary":"Get a team’s audit trail","description":"User-gated (`chrm_user_*` or session); the caller must be an owner/admin of the team. Newest-first (unless `sort` says otherwise) feed of share/publish lifecycle events AND end-user activity (renders, API calls) for every app the team owns. Defaults to the trailing 7 days.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/teams/{teamId}/connectors":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Every catalog service, in catalog order.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamConnectorsResponse"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner or admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"list-team-connectors","summary":"List the connectors a team allows","description":"User-gated (`chrm_user_*` or session); the caller must be an owner or admin of the team. Lists every catalog service, whether the team’s Apps may call it, how many team Apps call it in their live version, and the first three of them by name. Every service is allowed until an owner or admin turns it off.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/teams/{teamId}/connectors/{service}":{"patch":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"service","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The team’s connectors after the change.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamConnectorsResponse"}}}},"400":{"description":"Invalid body.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner or admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The connector catalog does not list this service.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"update-team-connector","summary":"Turn a connector on or off for a team","description":"User-gated (`chrm_user_*` or session); the caller must be an owner or admin of the team. Turning a service off refuses every call to it from the team’s Apps with `connector_blocked_by_team` and keeps each approval, so turning it back on restores them.","security":[{"userToken":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["allowed"],"properties":{"allowed":{"type":"boolean"}},"additionalProperties":false}}}}}},"/api/v1/teams/{teamId}/connectors/{service}/apps":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"service","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Defaults to 50, capped at 200."},{"name":"q","in":"query","required":false,"schema":{"type":"string"},"description":"Only Apps whose name contains this text, case-insensitively."},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"The `nextCursor` of the previous page. A cursor that does not decode is rejected with a 400."}],"responses":{"200":{"description":"One page of the team Apps that call the service.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamConnectorAppsResponse"}}}},"400":{"description":"Invalid `limit` or `cursor`.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner or admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The connector catalog does not list this service.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"list-team-connector-apps","summary":"List the team Apps that call a connector","description":"User-gated (`chrm_user_*` or session); the caller must be an owner or admin of the team. Pages through the team’s Apps whose live version calls the service, by name, case-insensitively, with ties broken by id.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/teams/{teamId}/egress":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Defaults to 100, capped at 500."},{"name":"appId","in":"query","required":false,"schema":{"type":"string"},"description":"Narrow to destinations the given app declares or calls."},{"name":"sort","in":"query","required":false,"schema":{"type":"string","enum":["lastSeen:desc","lastSeen:asc","destination:asc","destination:desc"]},"description":"Order of the whole list before `limit` cuts it. Defaults to `lastSeen:desc` (most recently called first); an `outbound-host` destination has no `lastSeenMs` and sorts last either way. An unknown value is rejected, not ignored. CSV exports honour it too."},{"name":"failedOnly","in":"query","required":false,"schema":{"type":"boolean"},"description":"When true, keeps only `api-op` destinations with a 4xx/5xx or errored call — an all-200 op vanishes. Never hides `outbound-host` destinations."},{"name":"range","in":"query","required":false,"schema":{"type":"integer","enum":[7,30,90]},"description":"Restricts the `api-op` group to events within this many days."},{"name":"format","in":"query","required":false,"schema":{"type":"string","enum":["csv"]},"description":"When `csv`, returns `text/csv` instead of JSON, at a higher row cap. Any other value falls through to JSON."}],"responses":{"200":{"description":"The team’s egress ledger, as JSON or (with `format=csv`) as `text/csv`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamEgressResponse"}},"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Invalid `limit`, `range`, `failedOnly`, or `sort`.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner/admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"list-team-egress","summary":"List a team’s egress ledger (declared hosts and API ops)","description":"User-gated (`chrm_user_*` or session); the caller must be an owner/admin of the team. `outbound-host` destinations are declared config with no call counts; `api-op` destinations are grouped `api_proxy_result` events with real counts.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/teams/{teamId}/exposure":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"format","in":"query","required":false,"schema":{"type":"string","enum":["csv"]},"description":"When `csv`, returns `text/csv` (a single summary row) instead of JSON. Any other value falls through to JSON."}],"responses":{"200":{"description":"The team’s exposure summary, as JSON or (with `format=csv`) as `text/csv`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamExposureResponse"}},"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Invalid `limit`.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner/admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"get-team-exposure","summary":"Get a team’s exposure summary","description":"User-gated (`chrm_user_*` or session); the caller must be an owner/admin of the team. Tallies the same `deriveAppVisibility` counters the team app inventory shows, plus an `externalShares` attention count.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/teams/{teamId}/invitations":{"post":{"tags":["TeamInvitations"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"Invitation created and emailed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamInvitationCreateResponse"}}}},"400":{"description":"Invalid body.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Refused by the plugin gate (caller is not an owner/admin), or the team requires two-factor authentication and the caller has not turned it on (`two_factor_required`).","x-error-kinds":["forbidden","two_factor_required"],"x-error-kinds-relayed":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"create-team-invitation","summary":"Invite a user to a team by email","description":"Session cookie required. Personal access tokens are not accepted; the Better Auth org plugin gates the invite (owner/admin caller) and sends the email. Invitation actions live under /api/v1/team-invitations/{invitationId}.","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["owner","admin","member"]}},"additionalProperties":false}}}}}},"/api/v1/teams/{teamId}/members":{"post":{"tags":["TeamMembers"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"Member added.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamMemberAddResponse"}}}},"400":{"description":"Invalid body or role.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller may not add members (or may not grant owner), or the person to add is an App account that has not joined Charming.","x-error-kinds":["forbidden","account_not_joined"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No Charming account for the grantee.","x-error-kinds":["grantee_not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Already a member.","x-error-kinds":["already_member"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"add-team-member","summary":"Add a member to a team","description":"User-gated (`chrm_user_*` or session); caller must be a team owner/admin, and only an owner may grant the `owner` role. The grantee (handle or email) must already hold a Charming account.","security":[{"userToken":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["grantee"],"properties":{"grantee":{"type":"string","description":"Handle or email of the new member."},"role":{"type":"string","enum":["owner","admin","member"]}},"additionalProperties":false}}}}}},"/api/v1/teams/{teamId}/members/me":{"delete":{"tags":["TeamMembers"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Left the team."},"400":{"description":"Refused — e.g. the caller is the sole owner.","x-error-kinds":["invalid_request"],"x-error-kinds-relayed":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"leave-team","summary":"Leave a team","description":"Session cookie required. Personal access tokens are not accepted. Removes the caller’s membership. Refused (relayed verbatim) when the caller is the team’s sole owner.","security":[{"sessionCookie":[]}]}},"/api/v1/teams/{teamId}/members/{memberId}":{"patch":{"tags":["TeamMembers"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"memberId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Role changed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"description":"Invalid body or role.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Refused by the owner-mint guard or the plugin gate, or the team requires two-factor authentication and the caller has not turned it on (`two_factor_required`).","x-error-kinds":["forbidden","two_factor_required"],"x-error-kinds-relayed":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"update-team-member","summary":"Change a team member’s role","description":"Session cookie required. Personal access tokens are not accepted. Only an owner may grant the `owner` role; everything else is the Better Auth org plugin’s gate, relayed verbatim.","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["owner","admin","member"]}},"additionalProperties":false}}}}},"delete":{"tags":["TeamMembers"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"memberId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Member removed."},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Refused by the plugin gate, or the team requires two-factor authentication and the caller has not turned it on (`two_factor_required`).","x-error-kinds":["forbidden","two_factor_required"],"x-error-kinds-relayed":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"remove-team-member","summary":"Remove a member from a team","description":"Session cookie required. Personal access tokens are not accepted. The Better Auth org plugin gates the removal and its refusal is relayed verbatim. Use `DELETE …/members/me` to leave.","security":[{"sessionCookie":[]}]}},"/api/v1/teams/{teamId}/people":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Defaults to 500, the cap, so one response carries the whole roster of all but the largest teams."},{"name":"q","in":"query","required":false,"schema":{"type":"string"},"description":"Case-insensitive match against the member label (name, handle, or email)."},{"name":"sort","in":"query","required":false,"schema":{"type":"string","enum":["label:asc","label:desc","role:asc","role:desc","appsOwned:asc","appsOwned:desc","appsCreated:asc","appsCreated:desc","lastActive:asc","lastActive:desc","externalShares:asc","externalShares:desc","twoFactor:asc","twoFactor:desc"]},"description":"Order of the whole roster before `limit` cuts it. Defaults to `label:asc`. Ties fall to the member label, then the user id, ascending; a member with no recorded activity sorts as the earliest `lastActive`, and `twoFactor:asc` leads with members who do not have two-factor on. An unknown value is rejected, not ignored. CSV exports honour it, and `q`, too."},{"name":"format","in":"query","required":false,"schema":{"type":"string","enum":["csv"]},"description":"When `csv`, returns `text/csv` instead of JSON, at a higher row cap. Any other value falls through to JSON."}],"responses":{"200":{"description":"The team’s people, as JSON or (with `format=csv`) as `text/csv`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamPeopleResponse"}},"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Invalid `limit` or `sort`.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner/admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"list-team-people","summary":"List a team’s people","description":"User-gated (`chrm_user_*` or session); the caller must be an owner/admin of the team. Every CURRENT team member with role, apps owned, apps created, last activity, external shares granted, and whether their account has two-factor authentication on.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/teams/{teamId}/security":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Whether the team requires two-factor authentication.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamSecurityResponse"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner or admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"get-team-security","summary":"Get team security settings","description":"User-gated (`chrm_user_*` or session); the caller must be an owner or admin of the team.","security":[{"userToken":[]},{"sessionCookie":[]}]},"patch":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Security settings updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamSecurityResponse"}}}},"400":{"description":"Invalid body.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner or admin of this team (`forbidden`), is turning the requirement on without two-factor authentication on their own account (`two_factor_required`), or is turning it off without a login from the last 10 minutes (`recent_login_required`).","x-error-kinds":["forbidden","two_factor_required","recent_login_required"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"update-team-security","summary":"Update team security settings","description":"User-gated (`chrm_user_*` or session); the caller must be an owner or admin of the team. Turning `requireTwoFactor` on also needs two-factor authentication on the caller’s own account. Turning it off needs a session from a login in the last 10 minutes; a personal access token cannot turn it off.","security":[{"userToken":[]},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["requireTwoFactor"],"properties":{"requireTwoFactor":{"type":"boolean"}},"additionalProperties":false}}}}}},"/api/v1/teams/{teamId}/shares":{"get":{"tags":["Teams"],"parameters":[{"name":"teamId","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Defaults to 100, capped at 500."},{"name":"appId","in":"query","required":false,"schema":{"type":"string"}},{"name":"q","in":"query","required":false,"schema":{"type":"string"},"description":"Case-insensitive match against the grantee handle/email."},{"name":"scope","in":"query","required":false,"schema":{"type":"string","enum":["internal","external"]}},{"name":"kind","in":"query","required":false,"schema":{"type":"string","enum":["person","invite","link"]}},{"name":"range","in":"query","required":false,"schema":{"type":"integer","enum":[7,30,90]}},{"name":"sort","in":"query","required":false,"schema":{"type":"string","enum":["createdAt:desc","createdAt:asc","app:asc","app:desc","grantee:asc","grantee:desc","status:asc","status:desc"]},"description":"Order of the whole ledger, as `<column>:<direction>`. Defaults to `createdAt:desc` (newest first). Ties break by `id` in the same direction; a row with no grantee sorts last either way. An unknown value is rejected, not ignored. CSV exports honour it too."},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"The load-more cursor: the `nextCursor` of the previous page, sent with the same `sort`. A cursor from a different sort, or one that does not decode, is rejected with a 400. CSV exports ignore it."},{"name":"format","in":"query","required":false,"schema":{"type":"string","enum":["csv"]},"description":"When `csv`, returns `text/csv` instead of JSON, at a higher row cap. Any other value falls through to JSON."}],"responses":{"200":{"description":"The team’s shares ledger, as JSON or (with `format=csv`) as `text/csv`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareLedgerResponse"}},"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Invalid `limit`, `scope`, `kind`, `range`, `sort`, or `cursor`.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is not an owner/admin of this team.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"list-team-shares","summary":"List a team’s shares ledger","description":"User-gated (`chrm_user_*` or session); the caller must be an owner/admin of the team. Unions grants, invitations, and live share links across every app the team owns, newest first unless `sort` says otherwise.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/apps/{appId}/revisions":{"get":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"before","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Return revisions older than this one. Pass the previous page’s `nextBefore`."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"description":"Page size. Defaults to 50, at most 200."}],"responses":{"200":{"description":"A page of the App’s revisions, newest first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppRevisionListResponse"}}}},"400":{"description":"Invalid app id, `before`, or `limit`.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller can open the App but cannot change it.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found, or the caller cannot open it.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"list-app-revisions","summary":"List an App’s revisions","description":"Requires a personal access token or session cookie and permission to change the App (its owner, a member of its team, or an editor). Lists the App’s History newest first. The first page opens with the desired revision (`current: true`); `live` marks the revision serving visitors; `restorable` marks the revisions POST /api/v1/apps/{appId}/revisions/{revision}/restore accepts. `manifestVersion` names each revision’s contract, so a package revision and a dated module-contract revision are told apart. The list stops at the plan’s History window: `historyLimit` is how many prior revisions the plan keeps. Page with `before` set to `nextBefore`.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/apps/{appId}/revisions/{revision}":{"get":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"revision","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"The revision and its source.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppRevisionResponse"}}}},"400":{"description":"Invalid app id or revision.","x-error-kinds":["invalid_request","invalid_revision"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller can open the App but cannot change it.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App or revision not found, or the caller cannot open the App.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The revision is older than the plan’s History window.","x-error-kinds":["version_limit_exceeded"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"get-app-revision","summary":"Get an App revision and its source","description":"Requires a personal access token or session cookie and permission to change the App. Returns the revision’s History entry and its source: a package revision returns `source.files`, the file tree it was saved with; a module-contract revision returns `source.module`, `source.ui`, and `source.styles`. A revision older than the plan’s History window answers 429 `version_limit_exceeded`.","security":[{"userToken":[]},{"sessionCookie":[]}]}},"/api/v1/apps/{appId}/revisions/{revision}/restore":{"post":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"revision","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"If-Match","in":"header","required":false,"schema":{"type":"string","pattern":"^(W/)?\"(0|[1-9][0-9]*)\"$"},"description":"The desired revision the restore replaces. Required unless the body carries `expectedRevision`."},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":1},"description":"Repeating a package restore with the same key returns the same build. A repeated module-contract restore answers 412 because the desired revision has moved."}],"responses":{"200":{"description":"Revision restored, or the build that restored it already published.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppRevisionRestoreResponse"}}}},"202":{"description":"Restore accepted as a build. Poll the build status URL.","headers":{"Location":{"schema":{"type":"string","format":"uri"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppBuildResponse"}}}},"400":{"description":"Invalid app id, revision, body, or If-Match, or a missing Idempotency-Key.","x-error-kinds":["invalid_request","invalid_revision","invalid_if_match","idempotency_key_required"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller can open the App but cannot change it, or a cookie-backed request came from another origin.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found, or the caller cannot open it.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The App has no History that can be restored, or the Idempotency-Key was used for a different restore.","x-error-kinds":["version_history_unavailable","idempotency_conflict"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"412":{"description":"The desired revision moved. The ETag header carries the current one; list History again.","x-error-kinds":["revision_mismatch"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The revision cannot be restored, or its build failed.","x-error-kinds":["version_not_restorable","app_build_failed","app_build_unsupported"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"428":{"description":"Neither If-Match nor expectedRevision was sent.","x-error-kinds":["precondition_required"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The revision is older than the plan’s History window, or the build service is at capacity.","x-error-kinds":["version_limit_exceeded","app_build_capacity"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The build service is unavailable.","x-error-kinds":["app_build_unavailable"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"restore-app-revision","summary":"Restore an App revision","description":"Requires a personal access token or session cookie and permission to change the App. Saves the selected revision’s source as a new revision; History keeps every revision, including the one restored over. Send the desired revision from the list as `If-Match: \"<N>\"` (or as `expectedRevision` in the body) and an `Idempotency-Key`. A module-contract revision publishes at once and answers 200. A package revision is rebuilt from its retained build and answers 202 with the build; poll its `statusUrl` until it publishes. Restoring a module-contract revision into an App now on the package contract moves the App back to that contract. Connector approvals the restored source does not declare are removed. A revision older than the plan’s History window answers 429 `version_limit_exceeded`. Live App data does not change.","security":[{"userToken":[]},{"sessionCookie":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"expectedRevision":{"type":"integer","minimum":0}}}}}}}},"/api/v1/apps/{appId}/shares":{"get":{"tags":["AppShares"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Direct shares visible to the caller.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppSharesListResponse"}}}},"400":{"description":"Invalid app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot manage shares.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"list-app-shares","summary":"List an app’s direct shares","description":"User-gated (`chrm_user_*` or session); requires `app:share`, or `app:invite` for a delegate, who sees only the people they invited. Returns stable share ids and display labels without internal account ids or mutation authority.","security":[{"userToken":[]}]},"post":{"tags":["AppShares"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"201":{"description":"Invitation created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareInviteResponse"}}}},"400":{"description":"Invalid body or app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot invite, or is a delegate inviting above their own role or passing on the ability to invite.","x-error-kinds":["forbidden","role_above_own","invite_delegation_owner_only","not_your_invite"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found, or no account for the grantee handle.","x-error-kinds":["not_found","grantee_not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Unshareable state (unclaimed app, self-share, existing access, or pending invitation).","x-error-kinds":["app_unclaimed","grantee_is_self","grantee_is_owner","grantee_already_has_access","already_invited"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Share-lookup rate limit or invitation cap.","x-error-kinds":["rate_limited","invite_cap_reached","invite_sender_blocked"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"create-app-share","summary":"Invite a user to an app","description":"User-gated (`chrm_user_*` or session); owner or team admin (`app:share`), or a delegate (`app:invite`) inviting at or below their own role. Only the owner or a team admin may set `canInvite`. Creates a pending invitation — `status: \"pending\"` for an existing account, `\"invited\"` for an email with no account yet. No access is granted until the grantee accepts.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["grantee"],"properties":{"grantee":{"type":"string","description":"Handle or email of the invitee."},"role":{"type":"string","enum":["collaborator","end-user","viewer"]},"canInvite":{"type":"boolean","description":"Owner-only: let this person invite others at or below their own role. Their invitees cannot invite anyone."}},"additionalProperties":false}}}}},"patch":{"tags":["AppShares"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Role changed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareRoleResponse"}}}},"400":{"description":"Invalid body, app id, or missing role.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot manage shares, or is a delegate acting outside their limits.","x-error-kinds":["forbidden","role_above_own","not_your_invite"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found, or no share for the grantee.","x-error-kinds":["not_found","grantee_not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Unshareable state (unclaimed app).","x-error-kinds":["app_unclaimed"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Share-lookup rate limit.","x-error-kinds":["rate_limited"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"update-app-share","summary":"Change an existing share’s role by grantee","description":"User-gated (`chrm_user_*` or session); owner or team admin (`app:share`), or a delegate. Re-roles an existing grant or outstanding email invitation; never creates one. A delegate (an accepted grantee the owner let invite others, `app:invite`) may act only on the people they invited. A delegate cannot raise anyone above their own role.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["grantee","role"],"properties":{"grantee":{"type":"string","description":"Handle or email of the grantee."},"role":{"type":"string","enum":["collaborator","end-user","viewer"]}},"additionalProperties":false}}}}}},"/api/v1/apps/{appId}/shares/accept":{"post":{"tags":["AppShares"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Accepted (or already accepted).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareAcceptResponse"}}}},"400":{"description":"Invalid app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No invitation for this app.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"accept-app-share","summary":"Accept a share invitation","description":"User-gated (`chrm_user_*` or session). Accepts the CALLER’s pending invitation for this app; idempotent (`alreadyAccepted: true` on a repeat).","security":[{"userToken":[]}]}},"/api/v1/apps/{appId}/shares/decline":{"post":{"tags":["AppShares"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Declined / left (or nothing to remove).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareRemovedResponse"}}}},"400":{"description":"Invalid app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"decline-app-share","summary":"Decline or leave a share","description":"User-gated (`chrm_user_*` or session). Declines the CALLER’s pending invite or leaves an accepted share; idempotent (`removed: false` when there was nothing).","security":[{"userToken":[]}]}},"/api/v1/apps/{appId}/shares/revoke":{"post":{"tags":["AppShares"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Revoked (or nothing to revoke).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareRemovedResponse"}}}},"400":{"description":"Invalid body or app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot manage shares, or did not invite this person.","x-error-kinds":["forbidden","not_your_invite"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found, or no account for the grantee handle.","x-error-kinds":["not_found","grantee_not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Share-lookup rate limit.","x-error-kinds":["rate_limited"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"revoke-app-share","summary":"Revoke a share by grantee","description":"User-gated (`chrm_user_*` or session); owner or team admin (`app:share`), or a delegate. Removes a pending or accepted grant; idempotent (`removed: false` when nothing was there). A delegate (an accepted grantee the owner let invite others, `app:invite`) may act only on the people they invited.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["grantee"],"properties":{"grantee":{"type":"string","description":"Handle or email of the grantee."}},"additionalProperties":false}}}}}},"/api/v1/apps/{appId}/shares/{shareId}":{"patch":{"tags":["AppShares"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"shareId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Share updated; the body is its current role and invite permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareUpdateResponse"}}}},"400":{"description":"Invalid app id, share id, or body.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot manage shares, or is a delegate acting outside their limits.","x-error-kinds":["forbidden","role_above_own","not_your_invite","invite_delegation_owner_only"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App or share not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The app has no owner.","x-error-kinds":["app_unclaimed"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"update-app-share-by-id","summary":"Change an existing share’s role or invite permission","description":"User-gated (`chrm_user_*` or session). Updates the grant or email invitation addressed by its opaque share id. Changing `canInvite` needs `app:share` (the owner or a team admin). A delegate (`app:invite`) may change only the `role` of someone they invited, at or below their own role.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","minProperties":1,"properties":{"role":{"type":"string","enum":["collaborator","end-user","viewer"]},"canInvite":{"type":"boolean","description":"Owner-only: let this person invite others at or below their own role."}},"additionalProperties":false}}}}}},"/api/v1/apps/{appId}/shares/{shareId}/revoke":{"post":{"tags":["AppShares"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"shareId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Revoked, or no matching share remained.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareRemovedResponse"}}}},"400":{"description":"Invalid app id or share id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot manage shares.","x-error-kinds":["forbidden","not_your_invite"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"revoke-app-share-by-id","summary":"Revoke a share","description":"User-gated (`chrm_user_*` or session); requires `app:share`, or `app:invite` for a delegate removing someone they invited. Idempotently removes the grant or email invitation addressed by its opaque share id.","security":[{"userToken":[]}]}},"/api/v1/apps/{appId}/signed-in-access":{"patch":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Signed-in access updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppSignedInAccessResponse"}}}},"400":{"description":"Invalid app id or request body.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"App management permission required.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"update-app-signed-in-access","summary":"Update signed-in app access","description":"User-gated (`chrm_user_*` or session). Sets the role granted to signed-in visitors without changing anonymous Viewer access.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["signedInAccess"],"properties":{"signedInAccess":{"type":["string","null"],"enum":["viewer","end-user",null]}}}}}}}},"/api/v1/apps/{appId}/template-listing":{"get":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Editable Template listing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListingResponse"}}}},"400":{"description":"Invalid app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot edit this Template.","x-error-kinds":["forbidden_template_edit"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"get-app-template-listing","summary":"Get an editable Template listing","description":"User-gated (`chrm_user_*` or session); requires `app:template-edit`. Returns authored listing fields, resolved legacy fallbacks, signed media URLs, validation state, and Template flags.","security":[{"userToken":[]}]},"patch":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Updated editable Template listing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListingResponse"}}}},"400":{"description":"Invalid app id or request body.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot edit this Template.","x-error-kinds":["forbidden_template_edit"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"A listing field is past its limit.","x-error-kinds":["template_listing_too_large"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Listing content or media is invalid.","x-error-kinds":["template_listing_incomplete","template_media_invalid"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"update-app-template-listing","summary":"Update a Template listing draft","description":"User-gated (`chrm_user_*` or session); requires `app:template-edit`. Changes only supplied listing content fields and does not enable, disable, publish, or unpublish the Template.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":["string","null"],"maxLength":120},"summary":{"type":["string","null"],"maxLength":300},"contentMarkdown":{"type":["string","null"],"maxLength":20000},"category":{"type":["string","null"],"enum":["business","developer-tools","education","entertainment","lifestyle","productivity","utilities",null]},"cover":{"oneOf":[{"type":"object","required":["assetKey","alt"],"properties":{"assetKey":{"type":"string","maxLength":128},"alt":{"type":"string","maxLength":300},"caption":{"type":["string","null"],"maxLength":300}},"additionalProperties":false},{"type":"null"}]},"gallery":{"oneOf":[{"type":"array","maxItems":12,"items":{"type":"object","required":["assetKey","alt"],"properties":{"assetKey":{"type":"string","maxLength":128},"alt":{"type":"string","maxLength":300},"caption":{"type":["string","null"],"maxLength":300}},"additionalProperties":false}},{"type":"null"}]}},"additionalProperties":false}}}}}},"/api/v1/apps/{appId}/template-listing/disable":{"post":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Disabled Template.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListingResponse"}}}},"400":{"description":"Invalid app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot edit this Template.","x-error-kinds":["forbidden_template_edit"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"disable-app-template","summary":"Disable a Template","description":"User-gated (`chrm_user_*` or session); requires `app:template-edit`. Disables copying and unlists the Template while preserving draft content.","security":[{"userToken":[]}]}},"/api/v1/apps/{appId}/template-listing/enable":{"post":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Enabled Template.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListingResponse"}}}},"400":{"description":"Invalid app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot edit this Template.","x-error-kinds":["forbidden_template_edit"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"enable-app-template","summary":"Enable a Template","description":"User-gated (`chrm_user_*` or session); requires `app:template-edit`. Enables copying while preserving listing state and draft content.","security":[{"userToken":[]}]}},"/api/v1/apps/{appId}/template-listing/publish":{"post":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Published Template listing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListingResponse"}}}},"400":{"description":"Invalid app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot edit this Template.","x-error-kinds":["forbidden_template_edit"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"A listing field is past its limit.","x-error-kinds":["template_listing_too_large"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The resulting listing content or media is invalid.","x-error-kinds":["template_listing_incomplete","template_media_invalid"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"publish-app-template-listing","summary":"Publish a Template listing","description":"User-gated (`chrm_user_*` or session); requires `app:template-edit`. Validates the resulting title and summary, then enables and lists the Template atomically.","security":[{"userToken":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":["string","null"],"maxLength":120},"summary":{"type":["string","null"],"maxLength":300},"contentMarkdown":{"type":["string","null"],"maxLength":20000},"category":{"type":["string","null"],"enum":["business","developer-tools","education","entertainment","lifestyle","productivity","utilities",null]},"cover":{"oneOf":[{"type":"object","required":["assetKey","alt"],"properties":{"assetKey":{"type":"string","maxLength":128},"alt":{"type":"string","maxLength":300},"caption":{"type":["string","null"],"maxLength":300}},"additionalProperties":false},{"type":"null"}]},"gallery":{"oneOf":[{"type":"array","maxItems":12,"items":{"type":"object","required":["assetKey","alt"],"properties":{"assetKey":{"type":"string","maxLength":128},"alt":{"type":"string","maxLength":300},"caption":{"type":["string","null"],"maxLength":300}},"additionalProperties":false}},{"type":"null"}]}},"additionalProperties":false}}}}}},"/api/v1/apps/{appId}/template-listing/unpublish":{"post":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Unpublished Template listing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListingResponse"}}}},"400":{"description":"Invalid app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot edit this Template.","x-error-kinds":["forbidden_template_edit"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"unpublish-app-template-listing","summary":"Unpublish a Template listing","description":"User-gated (`chrm_user_*` or session); requires `app:template-edit`. Removes the public listing while preserving Template enablement and draft content.","security":[{"userToken":[]}]}},"/api/v1/widget/apps/{appId}/overview/handoffs/{token}":{"get":{"tags":["Widget"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Short-lived private agent prompt.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WidgetRuntimeIssueHandoffResponse"}}}},"400":{"description":"Invalid app id.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Authenticated agent token required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The handoff is invalid, expired, or belongs to another owner.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App or active runtime issue not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"get-widget-runtime-issue-handoff","summary":"Resolve a private runtime issue handoff","description":"Requires a personal access token (`chrm_user_*`) and `app:manage`. Browser sessions are refused. Resolves an unexpired handoff for the same user and app into a private agent prompt.","security":[{"userToken":[]}]}},"/api/v1/app-builds/{buildId}":{"get":{"tags":["Apps"],"parameters":[{"name":"buildId","in":"path","required":true,"schema":{"type":"string"}},{"name":"include_source","in":"query","required":false,"schema":{"type":"boolean"}}],"responses":{"200":{"description":"Current build operation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppBuildResponse"}},"text/html":{"schema":{"$ref":"#/components/schemas/AppBuildPage"}}}},"303":{"description":"Browser navigation to the actual published app URL.","headers":{"Location":{"schema":{"type":"string","format":"uri"}}}},"400":{"description":"Invalid source inclusion query.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User authentication required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}},"text/html":{"schema":{"$ref":"#/components/schemas/AppBuildPage"}}}},"404":{"description":"Build not found or inaccessible.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}},"text/html":{"schema":{"$ref":"#/components/schemas/AppBuildPage"}}}}},"operationId":"get-app-build","summary":"Read an app build and its accepted source","description":"Read progress or the retained terminal result using current user source access. Set include_source=true to inspect the exact accepted input. Only published means the app is live. Status stays readable after the build finishes. Accept: text/html renders progress and terminal results; pending pages refresh this status resource and published pages redirect to the actual app URL.","security":[{"userToken":[]}]}},"/api/v1/app-builds/{buildId}/cancel":{"post":{"tags":["Apps"],"parameters":[{"name":"buildId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Current build operation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppBuildResponse"}},"text/html":{"schema":{"$ref":"#/components/schemas/AppBuildPage"}}}},"303":{"description":"Browser navigation to the actual published app URL.","headers":{"Location":{"schema":{"type":"string","format":"uri"}}}},"401":{"description":"User authentication required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}},"text/html":{"schema":{"$ref":"#/components/schemas/AppBuildPage"}}}},"403":{"description":"Cookie-backed mutations must come from the Charming origin.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}},"text/html":{"schema":{"$ref":"#/components/schemas/AppBuildPage"}}}},"404":{"description":"Build not found or inaccessible.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}},"text/html":{"schema":{"$ref":"#/components/schemas/AppBuildPage"}}}}},"operationId":"cancel-app-build","summary":"Cancel a pending app build","description":"Cancel pending work using current user source access. Repeated cancellation is safe. A canceled operation cannot publish even if remote work finishes later; the active app stays unchanged. Browser form submissions render the terminal result as HTML.","security":[{"userToken":[]}]}},"/api/v1/apps/{appId}/activity":{"get":{"tags":["Apps"],"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"kinds","in":"query","required":false,"schema":{"type":"string"},"description":"Comma-separated allow-list of event kinds. Kinds outside the owner-readable set are ignored."},{"name":"since","in":"query","required":false,"schema":{"type":"string","format":"date-time"},"description":"Inclusive ISO-8601 cutoff."},{"name":"before","in":"query","required":false,"schema":{"type":"string","format":"date-time"},"description":"Exclusive ISO-8601 cutoff — the load-more cursor. Pass the `ts` of the oldest entry you already have, together with `beforeId`, for an exact page boundary."},{"name":"beforeId","in":"query","required":false,"schema":{"type":"string","format":"uuid"},"description":"The `id` of the oldest entry you already have. Pairs with `before` for an exact keyset cursor — without it, entries sharing `before`’s exact millisecond can be skipped. Ignored if `before` is absent."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Defaults to 100, capped at 500."}],"responses":{"200":{"description":"Merged activity timeline for the app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppActivityResponse"}}}},"400":{"description":"Invalid app id, `since`, `before`, or `limit`.","x-error-kinds":["invalid_request"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","x-error-kinds":["unauthorized"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot manage this app.","x-error-kinds":["forbidden"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","x-error-kinds":["not_found"],"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"operationId":"get-app-activity-timeline","summary":"Get an app’s activity timeline","description":"Requires a personal access token or session cookie and `app:manage`. Newest-first feed merging published versions, renders/runs, API-call outcomes, sharing changes, and feedback. Each entry carries only the fields its kind allows — never a viewer id, an actor, a grantee, or an email address. A failed App action carries the App’s own `errorMessage` and the `path` it was called at. `recentFailures` counts failed calls for people using the live version. The feed covers the plan’s window: 24 hours on Free, 30 days on Pro, 90 days on Business. `retention` gives the cutoff used. Retention is a rolling window, not a compliance audit log.","security":[{"userToken":[]}]}},"/app":{"post":{"operationId":"create-app","summary":"Create an app or accept a package build","description":"Existing-contract callers receive a published app synchronously; anonymous creation returns a chrm_app_* token and may request pair: true. A body with files creates the App as a package: it requires an enabled authenticated user and Idempotency-Key, validates package.json and every import without evaluation, and returns 202 before dependency resolution or compilation. A same-owner package name target is frozen at acceptance; an absent target cannot later become an overwrite. Use PUT for a known app. Every existing package destination requires its desired revision in If-Match; moving an App onto the package contract also requires migrate_contract: true. pair and label are not package fields.","security":[{},{"userToken":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","minLength":8,"maxLength":128,"pattern":"^[!-~]+$"},"description":"Required for package saves. Reuse the same key, body, target and If-Match after response loss; a changed request with that key returns idempotency_conflict. Use a fresh key for each intentional save."},{"name":"If-Match","in":"header","required":false,"schema":{"type":"string"},"description":"Desired-source revision in double quotes for a package upsert or migration. Read GET /app/{id}/source first."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppCreateBody"}}}},"responses":{"201":{"description":"App created or upserted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppCreateResponse"}}}},"202":{"description":"Package source accepted for a background build. This response does not mean the app has published. Poll statusUrl until a terminal state; new creation has no runnable app or URL until published.","headers":{"Location":{"schema":{"type":"string","format":"uri"},"description":"Authorized build status URL."},"Retry-After":{"schema":{"type":"integer"},"description":"Seconds before polling a pending build."},"ETag":{"schema":{"type":"string"},"description":"Identity of this operation’s immutable source input."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppBuildResponse"}}}},"400":{"description":"Invalid source syntax, body, or required package idempotency key. See error.kind.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Package creation requires a valid user credential.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller is an App account that has not joined Charming (account_not_joined), or a browser session tried to save a package (bearer_required): save with a chrm_user_* bearer token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict or frozen manifest identity conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"412":{"description":"The desired source revision changed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Source exceeds a limit. Package body (`files`): the code files together, every file except `styles.css`, over 1024 KiB, or over 2048 KiB once JSON-escaped for the build (`payload_too_large`); `styles.css` over 256 KiB (`styles_too_large`). Any body over 1536 KiB is refused unread (`payload_too_large`). Apps saved before packages (`module`, `ui`, `styles` body): `module` over 256 KiB (`module_too_large`), `ui` over 256 KiB (`ui_too_large`), `styles` over 256 KiB (`styles_too_large`). On `PUT`, an App saved before packages gets a `shrink` recovery for `module` or `ui` that names a migration needing no resend.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Manifest, import/dependency mismatch, or explicit migration validation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"428":{"description":"A required desired-source revision is missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Build capacity is full (`app_build_capacity`), or the caller is over the creation rate (`rate_limited`): 60 creates and copies a minute for a signed-in account, 10 a minute from one address for an anonymous caller. Retry-After gives the retry delay.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Charming cannot build packages right now (`app_build_unavailable`); retry later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"list-apps","summary":"List your owned and shared apps, newest first","description":"Paginated newest-first listing of apps the caller owns or has been granted access to. Use `cursor` (from the previous page) and `limit` to iterate. Each row carries its server revision, the `role` (owner | collaborator | end-user | viewer | team-admin | team-member), and a UUID-form `url` that redirects to the friendly owner-canonical URL.","security":[{"userToken":[]}],"parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"cursor","in":"query","schema":{"type":"string"},"description":"Opaque cursor returned as `nextCursor` from the previous page."}],"responses":{"200":{"description":"Page of apps","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppListResponse"}}}},"401":{"description":"Listing requires user-scoped auth (`chrm_user_*` or session).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"put":{"operationId":"update-app","summary":"Update an existing app","description":"Storage survives updates. Existing contracts retain synchronous PUT and optional If-Match. A package App takes its whole tree as files and requires Idempotency-Key and If-Match carrying the current desired source revision; a migration may build a file from the current source with AppFileFromSource instead of resending it; accepted source advances desired while active remains the last working build. Successful builds publish automatically; later saves supersede pending builds.","security":[{"appToken":[]},{"userToken":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","minLength":8,"maxLength":128,"pattern":"^[!-~]+$"},"description":"Required for package saves. Reuse the same key, body, target and If-Match after response loss; a changed request with that key returns idempotency_conflict. Use a fresh key for each intentional save."},{"name":"If-Match","in":"header","required":false,"schema":{"type":"string"},"description":"Validator \"<N>\" for revision N from desired GET /app/:id/source. Required for package saves and migrations; optional for existing-contract PUT. The weak form W/\"<N>\" is also accepted so clients can return the response ETag verbatim."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppUpdateBody"}}}},"responses":{"200":{"description":"Updated","headers":{"ETag":{"description":"New strong validator `\"<N>\"` where N is the committed server revision.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppUpdateResponse"}}}},"202":{"description":"Package source accepted for a background build. This response does not mean the app has published. Poll statusUrl until a terminal state; new creation has no runnable app or URL until published.","headers":{"Location":{"schema":{"type":"string","format":"uri"},"description":"Authorized build status URL."},"Retry-After":{"schema":{"type":"integer"},"description":"Seconds before polling a pending build."},"ETag":{"schema":{"type":"string"},"description":"Identity of this operation’s immutable source input."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppBuildResponse"}}}},"400":{"description":"Invalid module/ui/styles, unexpected body keys, or malformed If-Match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token mismatch or wrong scope; a package save without a user credential (unauthorized).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Bearer is for a different app, or a browser session tried to save a package (bearer_required): save with a chrm_user_* bearer token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency or manifest identity conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"412":{"description":"If-Match did not match the current server revision; response carries the current ETag.","headers":{"ETag":{"description":"Current strong validator `\"<N>\"`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Source exceeds a limit. Package body (`files`): the code files together, every file except `styles.css`, over 1024 KiB, or over 2048 KiB once JSON-escaped for the build (`payload_too_large`); `styles.css` over 256 KiB (`styles_too_large`). Any body over 1536 KiB is refused unread (`payload_too_large`). Apps saved before packages (`module`, `ui`, `styles` body): `module` over 256 KiB (`module_too_large`), `ui` over 256 KiB (`ui_too_large`), `styles` over 256 KiB (`styles_too_large`). On `PUT`, an App saved before packages gets a `shrink` recovery for `module` or `ui` that names a migration needing no resend.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Invalid manifest, import/dependency mismatch, or required explicit migration.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"428":{"description":"Package saves require desired-source If-Match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Build capacity is full; retry after the returned delay.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Charming cannot build packages right now (`app_build_unavailable`); retry later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"delete-app","summary":"Delete an app","description":"Permanently removes the app row. Bearer must authorize this app (`chrm_app_*` for the same id, or the owning user). Pass `?purge=storage` to also wipe the app’s key-value rows and secrets; without it, the secrets are kept and an hourly cleanup clears the key-value rows.","security":[{"appToken":[]},{"userToken":[]}],"parameters":[{"name":"purge","in":"query","schema":{"type":"string","enum":["storage"]},"description":"Pass `?purge=storage` to also wipe the app’s key-value rows and secrets."}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Bearer is for a different app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/api/{operation}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"operation","in":"path","required":true,"schema":{"type":"string"}}],"post":{"operationId":"call-app-operation","summary":"Call a declared app route or its unmatched-request fallback","description":"External callers must use Bearer auth. The platform strips `/app/<id>` so the app sees `/api/<operation>`. A declared route handler returns exactly its `outputSchema` value without adding a transport envelope unless those fields belong to the schema; Charming validates it and wraps HTTP success as `{ ok: true, value }`. `window.charming.api` uses `renderToken` and unwraps that envelope, so in-page callers receive the value directly. If no declared route matches, the optional `default.fetch` handles the request and its `Response` passes through unchanged; without that fallback, Charming returns a 404. A request body over 1 MiB is refused with 413 `payload_too_large` before the app sees it. Direct callers should use `appToken` or `userToken`. Every response to a caller the App admits carries `x-charming-app-version`, the App's live revision. A page may send `x-charming-page-version`, the revision it was built from; a call that fails because the page is out of date is not counted as a fault in the App.","security":[{"appToken":[]},{"userToken":[]},{"renderToken":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"description":"Input defined by the selected app operation. Fetch the app-specific `/app/{id}/openapi.json` document for its typed schema before generating a function input."}}}},"responses":{"200":{"description":"A declared route returns `{ ok: true, value }`, where `value` matches its `outputSchema`. A custom unmatched-request fallback response passes through unchanged.","content":{"application/json":{"schema":{"type":"object","description":"Declared route success uses `{ ok: true, value }`; the route handler returns exactly the `outputSchema` value and does not add a transport envelope unless those fields belong to the schema. The open object schema also permits the author-defined body from an unmatched request handled by `default.fetch`.","additionalProperties":true}}}},"401":{"description":"Authentication required. A page whose token expired gets error kind `token_expired` with `error.recovery`; reloading the page mints a fresh token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Either the app id is unknown, or the app has no handler for that operation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"405":{"description":"The app declares this operation under a different method (`method_not_allowed`). Retry with a method from the `Allow` header, which `error.allowedMethods` repeats.","headers":{"Allow":{"description":"Comma-separated methods the app declares for this operation.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The request body is larger than 1 MiB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"App handler threw or violated the capability contract.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/claim":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"operationId":"claim-app","summary":"Claim an unclaimed app for the authenticated user","description":"Body must include the app’s `chrm_app_*` token. On success, ownership transfers and a bound pairing (if any) is approved for the caller. The paired token lasts 30 days when a browser session claims the app and 7 days for any other credential.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["token"],"properties":{"token":{"type":"string"}}}}}},"responses":{"200":{"description":"Claimed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppClaimResponse"}}}},"400":{"description":"Body is not JSON or is missing `token`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Already claimed by someone (possibly the caller).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/copy":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"operationId":"copy-app","summary":"Copy an app into a new private app owned by the caller","description":"Creates the caller a private copy of an app they can edit, or of a Template they may copy, without sending its source. A Template copy records the source as its origin (`copyKind: \"template\"`). The copy keeps the source code, styles, icon, and network settings; it never carries sharing, Public, signed-in access, Template or Listed state, tokens, secrets, Routines, Webhooks, custom domains, or version history. Without `manifest_id` the copy takes the next free manifest id after the source's (`<id>-2`, `<id>-3`); a `manifest_id` the caller already holds is refused with 409 rather than replacing that app. `include_data: true` also copies the stored data and assets in the same transaction that creates the copy, so a copy exists with all of its data or not at all; it needs owner access to a personally owned source (a team app's data is not copied into a personal account), and the data must fit the 24 MiB a copy carries, the per-app caps, and the caller's storage allowance. Without `idempotency_key` every call creates a new copy and answers 200 with it; a retry with the same key answers with the copy, or the pending build, the first call made, and the same key with a different source, `include_data`, or `manifest_id` answers 409 `idempotency_conflict`. A 409 `manifest_id_conflict` names the app holding the id in `existingAppId` when one does. A package App copies through a build; a build that does not publish at once answers 202 with its build status, and the data copies when it publishes. `secretsNotCopied` names the source secrets to set on the copy; it is reported only to callers who can manage the source's secrets.","security":[{"userToken":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"manifest_id":{"type":"string","pattern":"^[a-z0-9][a-z0-9-]{0,63}$","description":"Manifest id for the copy. Must be free for the caller. Omit it to take the next free id."},"display_name":{"type":"string","minLength":1,"description":"Display name for the copy. Defaults to the source's. Refused for package Apps, which name themselves in package.json."},"idempotency_key":{"type":"string","pattern":"^[!-~]{8,100}$","description":"Names this copy so a retry returns it instead of making another. The same key with a different source, include_data, or manifest_id answers 409 idempotency_conflict."},"include_data":{"type":"boolean","description":"Also copy the stored data and assets. Defaults to false. Needs owner access to a personally owned source; a team app’s data is not copied."}}}}}},"responses":{"200":{"description":"The copy.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppCopyResponse"}}}},"202":{"description":"Package source accepted for a background build. This response does not mean the app has published. Poll statusUrl until a terminal state; new creation has no runnable app or URL until published.","headers":{"Location":{"schema":{"type":"string","format":"uri"},"description":"Authorized build status URL."},"Retry-After":{"schema":{"type":"integer"},"description":"Seconds before polling a pending build."},"ETag":{"schema":{"type":"string"},"description":"Identity of this operation’s immutable source input."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppBuildResponse"}}}},"400":{"description":"Body is not a JSON object, carries an unexpected key, or names an invalid manifest_id or display_name. See error.kind.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"`forbidden`: the caller can open the app but may not copy it. `copy_data_forbidden`: include_data needs owner access to a personally owned source, and a team app’s data is not copied.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found, or the caller cannot open it.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`manifest_id_conflict`: the caller already holds the requested manifest_id; `existingAppId` names the app when one holds it. `idempotency_conflict`: the idempotency_key already copied a different app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The source data exceeds the 24 MiB a copy carries (`copy_data_too_large`) or a per-app cap (`storage_full`, `asset_count_exceeded`, `asset_quota_exceeded`). Copy it without include_data.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"`rate_limited`: the account made more than 60 creates and copies in a minute; retry after the returned delay. `storage_limit_exceeded`: the data would put the caller over their storage allowance. `app_build_capacity`: retry after the returned delay.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Charming cannot build packages right now (`app_build_unavailable`); retry later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/openapi.json":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"get-app-openapi","summary":"Per-app OpenAPI document derived from `export const routes`","description":"Owner-only OpenAPI 3.1 document with one method-specific path entry per route. requestBody schema comes from route.inputSchema; the 200 response schema wraps route.outputSchema as `{ ok: true, value }`. Apps that do not declare `routes` get an empty `paths: {}` document.","security":[{"appToken":[]},{"userToken":[]}],"responses":{"200":{"description":"Per-app OpenAPI document.","content":{"application/json":{"schema":{"type":"object","description":"OpenAPI 3.1 document describing this app’s `routes`. Conforms to https://spec.openapis.org/oas/v3.1.0 — the per-app shape is too dynamic to enumerate inline."}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/agent.json":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"get-app-agent-descriptor","summary":"Get an app's agent description without changing the app","description":"Side-effect-free sibling of the page gate: no auto-claim, no token mint, no cookie, no mutating telemetry. A public App or listed Template returns the full descriptor to anyone, with `operations[].input`/`output`/`examples` gated on `app:read` (owner, accepted share grant, team membership, or a bearer token) — an anonymous caller sees discovery-level operation fields only. An enabled-unlisted Template remains private without `app:read`, as does any other private App. Those callers — including an unclaimed app's claim-cookie holder, which grants `app:run` but never `app:read` — get the minimal stub (`AppDescriptorStub`). Reachable via both the `/app/{id}` UUID form and the `/{handle}/{app-name}` friendly form (byte-identical `id` + `canonical_url`), and advertised from the served page's `<link rel=\"alternate\" type=\"application/json\">` and matching `Link:` HTTP header.","security":[{},{"appToken":[]},{"userToken":[]}],"responses":{"200":{"description":"The full descriptor (manifest, operations, http_api, mcp, auth) or, for an unauthorized caller on a private app, the minimal `AppDescriptorStub`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppDescriptorResponse"}}}},"400":{"description":"`id` is not a well-formed app id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/describe":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"describe-app","summary":"Owner-only metadata + storage key inventory","description":"Returns the resolved app envelope (manifest, capabilities, revision), whether `ui`/`styles` are present, the persisted storage keys, and a machine-readable API summary so an agent can plan calls without reading the module source. Use a fresh `GET /app/{id}/source` response or ETag for write preconditions; a cached descriptor revision is informational.","security":[{"appToken":[]},{"userToken":[]}],"responses":{"200":{"description":"Metadata","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DescribeResponse"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/source":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"get-app-source","summary":"Read the exact persisted source for an app","description":"Returns the desired authored `module`, `ui`, and `styles` exactly as persisted, plus `files` for a package App, including pending or failed package edits, plus the required server revision and contract-aware metadata. Requires a real bearer token for the app or its owning user; render tokens and claim cookies are rejected. The `ETag: \"<N>\"` header carries revision N; pass it back as `If-Match` on PUT or PATCH to gate optimistic concurrency.","security":[{"appToken":[]},{"userToken":[]}],"responses":{"200":{"description":"Exact persisted source payload","headers":{"ETag":{"description":"Strong validator `\"<N>\"` carrying server revision N.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppSourceResponse"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"patch-app-source","summary":"Apply exact-string find/replace edits to the persisted source","description":"Applies an edits[] array to desired source. Package saves require Idempotency-Key, return 202, and preserve active output until publication. An exact request-key replay returns the original operation before stale revision or edit matching checks. Each edit names a `bucket` (canonical Apps) or a file `path` (package Apps), an exact `old_string` to match, and a `new_string` replacement. Requires `If-Match: \"<N>\"` carrying revision N from a fresh source response or ETag. A stale value returns 412 and surfaces the current ETag. Same auth as PUT.","security":[{"appToken":[]},{"userToken":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","minLength":8,"maxLength":128,"pattern":"^[!-~]+$"},"description":"Required for package saves. Reuse the same key, body, target and If-Match after response loss; a changed request with that key returns idempotency_conflict. Use a fresh key for each intentional save."},{"name":"If-Match","in":"header","required":true,"schema":{"type":"string"},"description":"Validator `\"<N>\"` returned by a fresh GET /source, where N is its revision. The weak form `W/\"<N>\"` is accepted too, so a client can pass back the ETag verbatim even when a CDN rewrote it in transit."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["edits"],"additionalProperties":false,"properties":{"migrate_contract":{"type":"boolean","description":"Explicitly migrate when the edited source selects a new contract. Package saves require a request key and If-Match."},"edits":{"type":"array","minItems":1,"items":{"type":"object","required":["old_string","new_string"],"properties":{"bucket":{"type":"string","enum":["module","ui","styles"],"description":"Canonical Apps: the source bucket the edit applies to."},"path":{"type":"string","description":"Package Apps: the file the edit applies to, such as server.js or lib/save.js. The file must already exist."},"old_string":{"type":"string"},"new_string":{"type":"string"},"replace_all":{"type":"boolean"}}}}}}}}},"responses":{"200":{"description":"Edits applied; committed server revision returned.","headers":{"ETag":{"description":"New strong validator `\"<N>\"` after the edit committed.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"type":"object","required":["ok","id","revision"],"properties":{"ok":{"type":"boolean"},"id":{"type":"string"},"revision":{"$ref":"#/components/schemas/Revision","example":4},"warnings":{"type":"array","items":{"type":"string"},"description":"Non-blocking publish feedback (#1126), present only when static validation found UI/backend contract mismatches. The write succeeded."}}}}}},"202":{"description":"Package source accepted for a background build. This response does not mean the app has published. Poll statusUrl until a terminal state; new creation has no runnable app or URL until published.","headers":{"Location":{"schema":{"type":"string","format":"uri"},"description":"Authorized build status URL."},"Retry-After":{"schema":{"type":"integer"},"description":"Seconds before polling a pending build."},"ETag":{"schema":{"type":"string"},"description":"Identity of this operation’s immutable source input."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppBuildResponse"}}}},"400":{"description":"Body malformed (missing edits, invalid bucket, malformed If-Match).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app, or a browser session tried to save a package (bearer_required): save with a chrm_user_* bearer token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, or old_string matched more than once; refine or set replace_all.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"412":{"description":"If-Match did not match the current server revision; response carries the current ETag.","headers":{"ETag":{"description":"Current strong validator `\"<N>\"`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Payload too large: too many edits, an oversize old_string/new_string (`edits_too_large`), or the post-edit module/ui/styles breaches its cap (`module_too_large` / `ui_too_large` / `styles_too_large`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Edit match failed, source/import validation failed, or explicit migration is required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"428":{"description":"If-Match header required; GET /source for the fresh revision and ETag.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Build capacity is full; retry after the returned delay.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Charming cannot build packages right now (`app_build_unavailable`); retry later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/remixable":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"put":{"operationId":"set-app-remixable","summary":"Toggle Template copying and public listing","description":"Owner-only legacy state surface. When `remixable: true`, people who already hold `app:read` on the source App can create an independent copy. `listed: true` also grants public discovery and copying without granting access to the live source App or its data. Listed always implies Template. When `remixable: false`, copying stops for new users, existing copies are unaffected, and Listed is cleared. `listed` is a patch: `true` publishes, `false` unpublishes, and omitting it preserves the current Listed state. This route cannot edit listing metadata; use `/api/v1/apps/{appId}/template-listing` for the title, summary, Markdown detail, category, cover, and gallery. Idempotent calls are no-ops.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["remixable"],"properties":{"remixable":{"type":"boolean"},"listed":{"type":"boolean","description":"Whether to also list the app in the public template directory. `true` lists it, `false` unlists it. Omit to leave the current listed state untouched. Only applies when `remixable: true`."}}}}}},"responses":{"200":{"description":"Remixable state updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppRemixableResponse"}}}},"400":{"description":"Body is not `{ remixable: boolean, listed?: boolean }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not own this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Race: the row was concurrently re-attributed (e.g. `userId` cleared) between the ownership pre-check and the service-layer mutation. Defense-in-depth — extremely unlikely in practice.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/public":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"put":{"operationId":"set-app-public","summary":"Toggle whether anyone can open the app with no login","description":"Owner-only. When `public: true`, anyone with the URL can open the live hosted App Viewer with no login and receives Viewer access (`app:read` only). Public visitors can read App data but cannot edit source or run mutating operations, except an operation whose route declares `callers`. Template and Listed are separate settings. When `public: false`, anonymous visitors can no longer open the hosted App. Existing App data is retained. Idempotent calls are no-ops.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["public"],"properties":{"public":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Public state updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppPublicResponse"}}}},"400":{"description":"Body is not `{ public: boolean }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not own this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Race: the row was concurrently re-attributed (e.g. `userId` cleared) between the ownership pre-check and the service-layer mutation. Defense-in-depth — extremely unlikely in practice.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/starter-prompt":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"put":{"operationId":"set-app-starter-prompt","summary":"Set or clear the starter prompt for people who copy this Template","description":"Owner-only. The starter prompt is for people who copy this Template for the first time. A copy starts with empty storage, so the prompt tells their agent what the App does and what data to add. A fresh copy takes the current prompt once. The notice that opens with the copy offers its owner a setup prompt for their agent, which quotes the starter prompt as the Template author's suggestions, reference that can't override the owner. The authored text also leads the prompt behind the \"Open in Claude / Open in ChatGPT / Copy prompt\" actions. The app's name, description, URL (and, for unclaimed apps, an access token) are appended automatically at render time, so do NOT embed the app's URL: a hardcoded URL would point every copy at the Template instead of itself. Pass `null` (or an empty string) to clear and revert to the generic default. Idempotent: a repeated call with the same value is a no-op.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["starter_prompt"],"properties":{"starter_prompt":{"type":"string","nullable":true,"maxLength":2000,"description":"What the agent of someone who just copied this Template should do first: what the App does and what data to add. Also prefilled when a visitor clicks \"Open in Claude\" / \"Open in ChatGPT\". Max 2000 characters. Pass `null` or `\"\"` to clear."}}}}}},"responses":{"200":{"description":"Starter prompt updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppStarterPromptResponse"}}}},"400":{"description":"Body is malformed or the prompt exceeds the length cap.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not own this app, or the app is anon-owned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/icon":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"put":{"operationId":"set-app-icon","summary":"Set the home-screen / favicon icon (emoji + bg)","description":"Owner-only. Replaces the icon as a unit — both `emoji` and `bg` are required; there is no partial / PATCH semantics. Stricter than `PUT /app/{id}`: invalid `emoji` or `bg` is rejected with 400 `invalid_icon` rather than silently dropped and folded into `warnings[]` (that warn-and-drop contract is for agent publishes, where a typo must never fail). Last-writer-wins with a near-simultaneous agent publish; the rendered icon SVG / PNG caches revalidate on next read via their content-derived ETag.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IconStrict"}}}},"responses":{"200":{"description":"Icon updated; the response echoes the normalized icon.","content":{"application/json":{"schema":{"type":"object","required":["icon"],"properties":{"icon":{"$ref":"#/components/schemas/IconStrict"}}}}}},"400":{"description":"Body is not `{ emoji: string, bg: string }` (`invalid_request`), or `emoji`/`bg` failed the icon validators (`invalid_icon`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not own this app, or the app is anon-owned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"clear-app-icon","summary":"Clear the icon and fall back to the default icon","description":"Owner-only. Sets `icon` to `null` so the SVG / PNG renderers fall back to the default icon. Idempotent.","security":[{"userToken":[]}],"responses":{"200":{"description":"Icon cleared.","content":{"application/json":{"schema":{"type":"object","required":["icon"],"properties":{"icon":{"type":"null"}}}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not own this app, or the app is anon-owned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/secrets":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"list-app-secrets","summary":"List the app secret NAMES (never values)","description":"Owner-only. Returns the names of the secrets stored for this app so the owner can see what is set. Values are never returned by any endpoint — secrets are write-only from the dashboard and are only decrypted host-side when an app references one. Requires the owner's user token; app/render tokens are rejected.","security":[{"userToken":[]}],"responses":{"200":{"description":"The secret names for this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppSecretListResponse"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not own this app, or the app is anon-owned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"create-app-secret","summary":"Create a new secret value","description":"Owner-only, write-only. Creates a new encrypted secret value under a name. The name must match `^[A-Z][A-Z0-9_]*$` (the same charset a `{{secret:NAME}}` reference uses, so a settable name is always referenceable); values are capped at 8 KiB. The value is never echoed back. Returns 409 `secret_already_exists` if a secret with the same name already exists for this scope; use PUT to replace it. Requires the owner's user token; app/render tokens are rejected.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string","pattern":"^[A-Z][A-Z0-9_]*$","description":"Env-var-shaped secret name (referenceable via `{{secret:NAME}}`)."},"value":{"type":"string","maxLength":8192,"description":"Plaintext secret value (max 8 KiB). Stored encrypted; never returned."}}}}}},"responses":{"200":{"description":"Secret stored.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"description":"Body is not JSON, name/value missing, name invalid, or value too large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not own this app, or the app is anon-owned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A secret with this name already exists; use PUT to replace, or DELETE it first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"upsert-app-secret","summary":"Create or replace a secret value","description":"Owner-only, write-only. Stores an encrypted secret value under a name, replacing any existing secret with the same name. The name must match `^[A-Z][A-Z0-9_]*$` (the same charset a `{{secret:NAME}}` reference uses, so a settable name is always referenceable); values are capped at 8 KiB. The value is never echoed back. Requires the owner's user token; app/render tokens are rejected.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string","pattern":"^[A-Z][A-Z0-9_]*$","description":"Env-var-shaped secret name (referenceable via `{{secret:NAME}}`)."},"value":{"type":"string","maxLength":8192,"description":"Plaintext secret value (max 8 KiB). Stored encrypted; never returned."}}}}}},"responses":{"200":{"description":"Secret stored.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"description":"Body is not JSON, name/value missing, name invalid, or value too large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not own this app, or the app is anon-owned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"delete-app-secret","summary":"Delete a secret by name","description":"Owner-only. Removes the named secret. The name is passed as the `name` query parameter. Requires the owner's user token; app/render tokens are rejected.","security":[{"userToken":[]}],"parameters":[{"name":"name","in":"query","required":true,"schema":{"type":"string"},"description":"The secret name to delete."}],"responses":{"200":{"description":"Secret deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"description":"The `name` query parameter is required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not own this app, or the app is anon-owned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Secret not found (or app not found).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/activity":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"get-app-activity","summary":"Read the app's durable runtime-failure events","description":"Owner-only. Returns the app's own `api_proxy_result`, `visitor_calls_refused` (calls from people who are not members, refused at their limits and summarized per 10 seconds; not runtime failures), `image_proxy_result` (external image failures), `diag_report` (runtime JS errors, CSP violations), `contract_validation`, `app_load_error`, and `render_token_revoked` events from durable storage — use this after publishing to learn what broke at runtime. Unlike `GET /app/{id}/diag` (in-memory ring buffer, always lost on deploy), these rows are meant to survive deploys, but most kinds here are telemetry the server can shed under sustained load rather than block a request on: `api_proxy_result` and `render_token_revoked` at the telemetry lane's in-flight write budget, and `diag_report`, `image_proxy_result`, `app_load_error` in the in-process queue those flood-prone kinds share. Only `contract_validation` (and the audit kinds this endpoint does not return) write synchronously and are never shed. Requires the app token or the owner's user token; render tokens and claim cookies are rejected. Not to be confused with `GET /app/{id}/events`, the live-state SSE stream.","security":[{"appToken":[]},{"userToken":[]}],"parameters":[{"name":"kinds","in":"query","required":false,"schema":{"type":"string"},"description":"Comma-separated subset of `api_proxy_result,visitor_calls_refused,image_proxy_result,diag_report,contract_validation,app_load_error,render_token_revoked`. Unknown kinds are a 400."},{"name":"since","in":"query","required":false,"schema":{"type":"string","format":"date-time"},"description":"ISO-8601 cutoff; only events at or after this instant are returned. Clamped to the plan window."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":100,"maximum":500},"description":"Max events to return. Default 100, capped at 500."}],"responses":{"200":{"description":"Newest-first runtime-failure events","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityResponse"}}}},"400":{"description":"Invalid app id, unknown kind, or malformed since/limit.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Authentication required (render tokens and claim cookies rejected).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/events":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"subscribe-app-events","summary":"Subscribe to the live-state SSE stream for an app","description":"Server-Sent Events stream of `state-changed` notifications. Each event id is `<server-epoch>:<rev>`; the browser `EventSource` replays via `Last-Event-ID` on reconnect, and the server emits a synthetic `state-changed` event with `source: \"reconnect-resync\"` and `result: null` whenever the client's id belongs to an older epoch or claims an unseen revision. The `overcapacity` event is emitted (and the stream closed) when the per-app subscriber cap is reached. Heartbeats are SSE comment lines (`: ping`) every 15s.\n\nAuth posture is broader than the owner endpoints: appToken, userToken, renderToken (bearer or `?t=` query), or the path-scoped `charming_sse_<id>` HMAC cookie minted by the `/app/{id}` render-bridge when a render-token rendered the page. The `{}` (no-auth) option in `security` covers the cookie path — OpenAPI cannot model a per-app cookie name as a fixed scheme.","x-charming-timeout-ms":null,"x-charming-timeout-note":"Long-lived SSE stream — do not set a client read timeout below the 15s heartbeat interval. The stream stays open until the client disconnects, the per-app subscriber cap is hit, or the server shuts down.","security":[{"appToken":[]},{"userToken":[]},{"renderToken":[]},{"renderTokenQuery":[]},{}],"parameters":[{"name":"Last-Event-ID","in":"header","required":false,"schema":{"type":"string"},"description":"Last event id the client saw, in the `<epoch>:<rev>` form the server emits. Triggers a synthetic `reconnect-resync` event when the epoch differs or the rev is forward-jumped."},{"name":"t","in":"query","required":false,"schema":{"type":"string"},"description":"URL-signed render token, equivalent to the `renderToken` bearer but carried in the query string for SSE connections from null-origin iframes that cannot attach Authorization headers."}],"responses":{"200":{"description":"Open SSE stream. Frames arrive as `event: state-changed` (or `event: overcapacity`) with a JSON `data:` payload. The stream stays open until the client disconnects, the per-app capacity cap is hit, or the server shuts down.","content":{"text/event-stream":{"schema":{"oneOf":[{"$ref":"#/components/schemas/AppEventStateChanged"},{"$ref":"#/components/schemas/AppEventOvercapacity"}]}}}},"400":{"description":"Invalid app id. Error kind: `invalid_id`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Anonymous caller's `charming_sse_<id>` cookie was once valid but its 1-hour TTL elapsed. Error kind: `sse_cookie_expired` — reload `/app/{id}` so the render-token bridge re-issues a fresh cookie. A page whose signed token expired gets error kind `token_expired` with `error.recovery`; reload the page.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Caller does not have access to this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/diag":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"get-app-diag","summary":"Read the per-app runtime error ring buffer","description":"Owner-only. Use this after a deploy to see whether the iframe surfaced runtime errors. 50-entry ring buffer; oldest entries roll off. Accepts `renderToken` so the in-page shell can fetch its own diag without cookies.","security":[{"appToken":[]},{"userToken":[]},{"renderToken":[]}],"responses":{"200":{"description":"Ring buffer contents","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DiagResponse"}}}},"400":{"description":"Invalid app id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/diag/report":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"operationId":"report-app-diag","summary":"Report a runtime error from the in-page shell (anonymous)","description":"Public ingress for the rendered iframe’s `error` / `unhandledrejection` listeners. Body is capped at 16 KiB and rate-limited per (appId, IP). Agents normally read errors via `GET /app/{id}/diag`; they should not call this endpoint directly.","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"},"source":{"type":"string"},"line":{"type":"integer"},"col":{"type":"integer"},"stack":{"type":"string"}}}}}},"responses":{"204":{"description":"Recorded","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}}},"400":{"description":"Invalid app id or malformed body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Body exceeds 16 KiB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded.","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/load-error/report":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"operationId":"report-app-load-error","summary":"Report a caught app load failure from the in-page bridge (anonymous)","description":"Public ingress for app load failures the bridge caught before they became an unhandled rejection — e.g. `bridge.resolve(manifestId)` 404s when the requested manifest does not exist in the caller’s scope. Body is capped at 2 KiB and rate-limited per (appId, IP). Agents normally read events via `GET /app/{id}/events`; they should not call this endpoint directly.","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["manifestId"],"properties":{"manifestId":{"type":"string"},"status":{"type":"integer"},"errorKind":{"type":"string"}}}}}},"responses":{"204":{"description":"Recorded","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}}},"400":{"description":"Invalid app id or malformed body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Body exceeds 2 KiB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded.","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/feedback":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"operationId":"submit-app-feedback","summary":"Submit durable feedback for an app","description":"Owner-only durable feedback ingest. Auth posture matches `GET /app/{id}/diag` (`requireAppAccess`): app token, user token, render token, or claim cookie. Body is capped at 96 KiB wire / 16 KiB text / 64 KiB serialized `structuredData`. The MCP `submit_feedback` tool forces `source=\"agent\"` server-side; direct REST callers may set `source` to `user` or `auto-crash`.","security":[{"appToken":[]},{"userToken":[]},{"renderToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeedbackSubmitBody"}}}},"responses":{"201":{"description":"Feedback recorded.","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeedbackSubmitResponse"}}}},"400":{"description":"Invalid app id, malformed body, or category=crash without crashData.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Body exceeds the 96 KiB wire cap, `text` exceeds 16 KiB, or `structuredData` exceeds 64 KiB serialized. Error kinds: `payload_too_large`, `text_too_large`, `structured_data_too_large`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (30/min/app/ip, 200/min/app).","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/assets":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"operationId":"upload-app-asset","summary":"Upload an asset for an app","description":"Multipart upload of a single file asset. Auth posture: `requireAppAccess` (app token, user token, render token, or claim cookie). Hard caps: 10 MiB/asset, 50 assets/app, 100 MiB/app total.","x-charming-timeout-ms":20000,"security":[{"appToken":[]},{"userToken":[]},{"renderToken":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["key","file"],"properties":{"key":{"type":"string","description":"Asset key (filename). Must be non-empty and valid."},"file":{"type":"string","format":"binary","description":"File bytes. Max 10 MiB."}}}}}},"responses":{"201":{"description":"Asset uploaded.","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetUploadResponse"}}}},"400":{"description":"Missing or invalid field. Error kinds: `invalid_request`, `asset_invalid_key`, `asset_invalid_content_type`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"File or quota exceeded. Error kinds: `asset_too_large` (file > 10 MiB), `asset_count_exceeded` (50 asset cap), `asset_quota_exceeded` (100 MiB app cap).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Asset write rate limit exceeded. Error kind: `too_many_requests`.","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"list-app-assets","summary":"List assets for an app","description":"Returns all stored assets for the app. Auth posture: `requireAppAccess` (app token, user token, render token, or claim cookie).","security":[{"appToken":[]},{"userToken":[]},{"renderToken":[]}],"responses":{"200":{"description":"Asset list.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetListResponse"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/{id}/assets/{key}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"delete":{"operationId":"delete-app-asset","summary":"Delete an asset","description":"Deletes one asset by key. Returns `{ok:true}` when deleted, `{ok:false}` (404) when the asset does not exist. Auth posture: `requireAppAccess` (app token, user token, render token, or claim cookie).","security":[{"appToken":[]},{"userToken":[]},{"renderToken":[]}],"responses":{"200":{"description":"Asset deleted. A missing asset returns 404 (not 200).","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Token does not authorize this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found or asset not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Asset write rate limit exceeded. Error kind: `too_many_requests`.","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/app/resolve/{manifestId}":{"parameters":[{"name":"manifestId","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"resolve-app-manifest","summary":"Resolve a manifestId to an appId in the caller’s scope","description":"Owner-only lookup: returns the `appId` for the caller’s app whose manifest `id` matches `manifestId`. Used by `window.charming.api(manifestId)` / `bridge.resolve()` to turn a manifest reference into a routable UUID.","security":[{"appToken":[]},{"userToken":[]}],"responses":{"200":{"description":"Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ManifestResolveResponse"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No app with that manifestId in the caller’s scope.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/pair/start":{"post":{"operationId":"start-pairing","summary":"Mint a device_code for an unauthenticated agent (RFC 8628-shaped)","description":"Returns a `device_code` (agent-private) and a `user_code` (`CHRM-XXXXXX`, displayed to the user). Codes expire after 10 minutes. Agent then polls `POST /api/pair/poll` until status flips to `approved`. The legacy `/pair/start` path 308s here.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string","maxLength":80,"description":"Optional human-readable label. Surfaced to the user on the approval page so they know which agent they’re connecting."}}}}}},"responses":{"200":{"description":"Codes minted","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PairStartResponse"}}}},"429":{"description":"Rate limited (per-IP).","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/pair/poll":{"post":{"operationId":"poll-pairing","summary":"Poll a device_code until the user approves","description":"Plaintext `chrm_user_*` token is returned exactly once when status flips to `approved`. Subsequent polls return `approved` with `already_delivered: true` and no token. The legacy `/pair/poll` path 308s here.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["device_code"],"properties":{"device_code":{"type":"string"}}}}}},"responses":{"200":{"description":"Poll result","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PairPollResponse"}}}},"400":{"description":"Body is not JSON or `device_code` is missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (per-IP / per-device_code).","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/pair/approve":{"post":{"operationId":"approve-pairing","summary":"Approve a pairing (browser-side, signed-in user)","description":"Idempotent. The plaintext token is delivered to the agent via `/api/pair/poll`, never returned here. It lasts 30 days when a browser session approves and 7 days for any other credential. If the code belongs to an app created with `pair: true` that nobody has claimed, approving also claims that app for the approver, best-effort. The legacy `/pair/approve` path 308s here.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["user_code"],"properties":{"user_code":{"type":"string","pattern":"^CHRM-[A-Z2-9]{6}$"}}}}}},"responses":{"200":{"description":"Approved","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PairApproveResponse"}}}},"400":{"description":"Body is not JSON or `user_code` is missing/malformed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign in required to approve a pairing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No pairing matches that code.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Pairing already approved, or another user claimed its bound app first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"410":{"description":"Pairing expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited: too many codes from this account or address, or, for a code bound to an unclaimed app, claims are paused this minute after too many missed codes. Retry after `Retry-After`.","headers":{"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/token":{"post":{"operationId":"create-token","summary":"Mint a personal access token (`chrm_user_*`)","description":"Plaintext returned exactly once. 7-day TTL unless `expiresInDays` picks another lifetime. The legacy `/token` path 308s here.","security":[{"userToken":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string","maxLength":80},"expiresInDays":{"type":["integer","null"],"minimum":1,"maximum":365,"default":7,"description":"Whole days until the token expires. Choose a longer lifetime for a client that can only hold a static bearer token. A caller using a personal access token can create only default-lifetime tokens; a longer one needs a sign-in session."}}}}}},"responses":{"200":{"description":"Token minted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenCreateResponse"}}}},"400":{"description":"`label` is longer than 80 characters, or `expiresInDays` is not a whole number from 1 to the maximum (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"User-scoped auth required to mint a token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"A caller using a personal access token asked for a lifetime other than the default (`forbidden`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"list-tokens","summary":"List the caller’s tokens (no plaintext, no hash)","description":"Returns the caller's personal access token metadata: stable `id`, public `tokenPrefix`, optional `label`, `expiresAt`, last-used timestamp, and `createdAt`. Plaintext and hashed values are never echoed — store the plaintext returned by `POST /api/token`; if it's lost, revoke and mint a new one.","security":[{"userToken":[]}],"responses":{"200":{"description":"Tokens","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenListResponse"}}}},"401":{"description":"User-scoped auth required to list tokens.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/token/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"delete":{"operationId":"revoke-token","summary":"Revoke a token","description":"The legacy `/token/{id}` path 308s here.","security":[{"userToken":[]}],"responses":{"200":{"description":"Revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"User-scoped auth required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Token not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/routines":{"get":{"operationId":"list-routines","summary":"List the caller's Routines","description":"Session-gated. Lists every Routine on an app the caller can edit (holds `app:write` on): their own apps, their teams' apps, and apps shared with them as a collaborator.","security":[{"userToken":[]}],"responses":{"200":{"description":"The caller's Routines.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoutineListResponse"}}}},"401":{"description":"Sign-in required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/connectors/{service}/versions/{version}/tools":{"parameters":[{"name":"service","in":"path","required":true,"schema":{"type":"string"},"description":"A connector catalog service slug, such as `gmail`."},{"name":"version","in":"path","required":true,"schema":{"type":"string","pattern":"^\\d{8}_\\d{2}$"},"description":"A Composio toolkit version, such as `20261029_00`."}],"get":{"operationId":"get-connector-tool-schemas","summary":"Read the schemas of connector tools at a toolkit version","description":"Returns the JSON Schema of each named tool's input and output at one Composio toolkit version, the version an App's `charming:connectors/<service>@<version>` import names. Charming reads a version's schemas from Composio the first time anyone asks and keeps them. Name up to 50 tools, by slug in `slugs` or by the name an App imports in `functions`. Each caller may cause up to 200 reads from Composio an hour; schemas already stored cost nothing.","security":[{"userToken":[]}],"x-charming-timeout-ms":20000,"parameters":[{"name":"slugs","in":"query","required":false,"schema":{"type":"string"},"description":"Comma-separated tool slugs, such as `GMAIL_FETCH_EMAILS,GMAIL_SEND_EMAIL`; at most 50. Pass this or `functions`."},{"name":"functions","in":"query","required":false,"schema":{"type":"string"},"description":"Comma-separated names an App imports the tools under, such as `gmailFetchEmails,gmailSendEmail`; at most 50. Pass this or `slugs`."}],"responses":{"200":{"description":"Each named tool with its schemas, in the order asked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorToolSchemasResponse"}}}},"400":{"description":"The version or a tool slug is not one Charming accepts.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The service is not in the catalog, or Composio has no such tool at that version or retired the version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The caller has used its hourly allowance of 200 schema reads from Composio. Schemas already stored cost nothing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Composio could not answer, or connectors are off on this server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/apps/{appId}/routines":{"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"post":{"operationId":"create-routine","summary":"Schedule a Routine on an app","description":"Session-gated; requires `app:write`. Schedules a declared op to run on its own, on a timer (`hourly` | `daily` | `weekly`). The op is invoked with empty input, so it must declare no required input fields. Rejects a duplicate (app, op) pair, and enforces a per-app and a per-owner cap from the app owner's plan, which for a team app is the team's plan rather than the caller's. `limits` on `GET /api/v1/routines` reports the caller's own plan, so it matches only their personal apps. The free defaults are 3 per app and 25 per owner.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["op","interval"],"properties":{"op":{"type":"string"},"interval":{"type":"string","enum":["hourly","daily","weekly"]}},"additionalProperties":false}}}},"responses":{"201":{"description":"Routine created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoutineResponse"}}}},"400":{"description":"Invalid body, app id, or the op has required input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot manage this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found, or the op is not declared on it.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A Routine already exists for this (app, op) pair.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Per-app or per-owner Routine cap reached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/routines/{routineId}":{"parameters":[{"name":"routineId","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"operationId":"update-routine","summary":"Update a Routine's interval or enabled state","description":"Session-gated; requires `app:write` on the routine's app. Re-enable is `{enabled: true}` — not a separate action. Re-enabling resets the consecutive-failure counter.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"interval":{"type":"string","enum":["hourly","daily","weekly"]},"enabled":{"type":"boolean"}},"minProperties":1,"additionalProperties":false}}}},"responses":{"200":{"description":"Routine updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoutineResponse"}}}},"400":{"description":"Invalid body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Routine not found, or the caller lacks `app:write` on its app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"delete-routine","summary":"Delete a Routine","description":"Session-gated; requires `app:write` on the routine's app. Stops and removes the Routine.","security":[{"userToken":[]}],"responses":{"204":{"description":"Routine deleted."},"401":{"description":"Sign-in required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Routine not found, or the caller lacks `app:write` on its app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/webhooks":{"get":{"operationId":"list-webhooks","summary":"List the caller's Webhooks","description":"Session-gated. Lists every Webhook on an app the caller can edit (holds `app:write` on): their own apps, their teams' apps, and apps shared with them as a collaborator.","security":[{"userToken":[]}],"responses":{"200":{"description":"The caller's Webhooks.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookListResponse"}}}},"401":{"description":"Sign-in required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/apps/{appId}/webhooks":{"parameters":[{"name":"appId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"post":{"operationId":"create-webhook","summary":"Declare a Webhook on an app","description":"Session-gated; requires `app:write`. Declares one of the app’s ops as a Webhook target an external sender can invoke by POSTing to the returned `url` with the returned `secret` (shown once). Unlike a Routine, the op may declare required input: the sender supplies the body. Rejects a duplicate (app, op) pair and enforces a per-app and a per-owner cap from the app owner's plan, which for a team app is the team's plan rather than the caller's. `limits` on `GET /api/v1/webhooks` reports the caller's own plan, so it matches only their personal apps. The free defaults are 3 per app and 25 per owner.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["op"],"properties":{"op":{"type":"string"},"name":{"type":"string","maxLength":80}},"additionalProperties":false}}}},"responses":{"201":{"description":"Webhook created. `secret` appears only in this response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookCreatedResponse"}}}},"400":{"description":"Invalid body or app id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The caller cannot manage this app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"App not found, or the op is not declared on it.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A Webhook already exists for this (app, op) pair.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Per-app or per-owner Webhook cap reached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/webhooks/{webhookId}":{"parameters":[{"name":"webhookId","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"operationId":"update-webhook","summary":"Rename a Webhook, change its enabled state, or rotate its secret","description":"Session-gated; requires `app:write` on the webhook's app. Re-enable is `{enabled: true}` — not a separate action — and resets the consecutive-failure counter. `{rotate_secret: true}` replaces the secret immediately and returns the new one once. `name` relabels the Webhook.","security":[{"userToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"},"rotate_secret":{"type":"boolean"},"name":{"type":"string","maxLength":80}},"minProperties":1,"additionalProperties":false}}}},"responses":{"200":{"description":"Webhook updated. `secret` is present only after a rotation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookResponse"}}}},"400":{"description":"Invalid body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Sign-in required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Webhook not found, or the caller lacks `app:write` on its app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"delete-webhook","summary":"Delete a Webhook","description":"Session-gated; requires `app:write` on the webhook's app. Removes the Webhook; its secret stops working at once.","security":[{"userToken":[]}],"responses":{"204":{"description":"Webhook deleted."},"401":{"description":"Sign-in required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Webhook not found, or the caller lacks `app:write` on its app.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/hooks/{webhookId}":{"parameters":[{"name":"webhookId","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"query","required":false,"schema":{"type":"string"},"description":"The Webhook secret, for senders that cannot set an Authorization header."}],"post":{"operationId":"deliver-webhook","summary":"Deliver an event to a Webhook","description":"The URL an external sender calls. Present the Webhook's secret as `Authorization: Bearer chrm_hook_…` or `?key=chrm_hook_…`. The body is the target op's input, validated against its declared input schema: a JSON object, or a `multipart/form-data` or `application/x-www-form-urlencoded` form whose text fields become the input, each converted to the type the schema declares. File parts are dropped and listed in the delivery record. The body is read up to 1 MiB; a longer one is refused with 413 and the op does not run. The response is the op's own result envelope, validated against its output schema. Tagged `x-charming-trigger: webhook` for the handler.","security":[{}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDeliveryBody"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/WebhookDeliveryBody"}},"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/WebhookDeliveryBody"}}}},"responses":{"200":{"description":"The op's result envelope, `{ ok: true, value }`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDeliveryResponse"}}}},"400":{"description":"Body is not a JSON object, or fails the op's input schema.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or wrong secret.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The owner disabled this Webhook.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No Webhook with this id, or its op is no longer declared.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is larger than 1 MiB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many deliveries from this address or to this Webhook, or the app is at its run ceiling; retry after `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/prompts/charming-app-guide":{"get":{"operationId":"get-app-guide-prompt","summary":"Fetch the canonical Charming authoring guide as Markdown","description":"Same prose served as the `charming:app-guide` MCP prompt. Useful for agents that want the full authoring contract without going through MCP. The compatibility prompt paths redirect here.","responses":{"200":{"description":"Markdown","content":{"text/markdown":{"schema":{"type":"string"}}}}}}},"/api/prompts/charming-design-guide":{"get":{"operationId":"get-design-guide-prompt","summary":"Fetch the Charming design guide as Markdown","description":"Same prose served as the `charming:design-guide` MCP prompt — the default visual look for generated app UIs (override when the user asks for a different vibe). Fetch before authoring or restyling an app. The compatibility prompt paths redirect here.","responses":{"200":{"description":"Markdown","content":{"text/markdown":{"schema":{"type":"string"}}}}}}},"/.well-known/openapi.json":{"get":{"operationId":"get-openapi-spec","summary":"This document","description":"Serves the canonical machine-readable OpenAPI 3.1 spec for the Charming API. The unversioned `/openapi.json` path 308s here.","responses":{"200":{"description":"OpenAPI 3.1 spec","content":{"application/json":{"schema":{"type":"object","description":"OpenAPI 3.1 document. Conforms to https://spec.openapis.org/oas/v3.1.0 — the spec is too deep to enumerate inline."}}}}}}},"/.well-known/oauth-authorization-server":{"get":{"operationId":"get-oauth-authorization-server","summary":"OAuth/MCP discovery metadata (delegated to better-auth)","description":"Returns the RFC 8414 authorization-server metadata document for the Charming auth surface. Consumed by MCP clients during the OAuth handshake. The base payload shape is owned by better-auth; Charming splices a WorkOS-style `agent_auth` extension block carrying `register_uri` (`/api/pair/start`), `claim_uri` (`/app/{id}/claim`), `revocation_uri` (`/api/token/{id}`), `skill` (`https://charm.ing/docs/technical-reference/authentication.md`), `identity_types_supported` (`[\"anonymous\"]`), and an `anonymous` sibling block with `credential_types_supported` (`[\"api_key\"]`).","responses":{"200":{"description":"OAuth authorization-server discovery JSON.","content":{"application/json":{"schema":{"type":"object","description":"RFC 8414 authorization-server metadata (issuer, authorization_endpoint, token_endpoint, jwks_uri, …) plus the Charming `agent_auth` extension. Base schema is delegated to better-auth."}}}}}}},"/.well-known/oauth-authorization-server/mcp/chatgpt":{"get":{"operationId":"get-oauth-authorization-server-mcp-chatgpt","summary":"OAuth authorization-server metadata for the ChatGPT MCP surface","description":"Returns the RFC 8414 authorization-server metadata for the `/mcp/chatgpt` surface, at the path-inserted well-known URL a client derives from an issuer carrying that path. Reached only when that surface's protected-resource document names the surface as its own authorization server, which `CHARMING__SERVER__CHATGPT_AUTH_PROXY_ADVERTISED` decides. The same switch decides whether this document is served, so the pointer and its target appear together: while it is off nothing names this URL and asking for it answers 404. Differs from the origin-wide document in `issuer`, which claims the surface, and in `authorization_endpoint`, which names the marketing-site login proxy while the switch is on. Token, registration, and JWKS endpoints stay on this origin.","responses":{"200":{"description":"OAuth authorization-server discovery JSON scoped to /mcp/chatgpt.","content":{"application/json":{"schema":{"type":"object","description":"RFC 8414 authorization-server metadata (issuer, authorization_endpoint, token_endpoint, jwks_uri, …) plus the Charming `agent_auth` extension. Base schema is delegated to better-auth; `issuer` and `authorization_endpoint` are overridden."}}}}}}},"/.well-known/http-message-signatures-directory":{"get":{"operationId":"get-http-message-signatures-directory","summary":"Web Bot Auth signing-key directory (RFC 9421)","description":"Returns a JWK Set advertising the Ed25519 public key Charming uses to sign outbound HTTP messages. Single-entry today: `{ keys: [{ kty: \"OKP\", crv: \"Ed25519\", kid, x, nbf, exp }] }`. `Content-Type: application/jwk-set+json`, `Cache-Control: public, max-age=600`. Storage v0: key is pinned via env vars or generated ephemerally per boot until `WEB_BOT_AUTH_PUBLIC_JWK`/`WEB_BOT_AUTH_KID`/`WEB_BOT_AUTH_NBF` are set on Railway.","responses":{"200":{"description":"JWK Set with the active Web Bot Auth signing key(s).","content":{"application/jwk-set+json":{"schema":{"type":"object","description":"RFC 7517 JWK Set carrying RFC 9421 / Web Bot Auth signing keys. Each entry has `kty: \"OKP\"`, `crv: \"Ed25519\"`, `kid`, `x` (base64url public key bytes), `nbf`, `exp`."}}}}}}},"/.well-known/oauth-protected-resource":{"get":{"operationId":"get-oauth-protected-resource","summary":"OAuth protected-resource metadata (delegated to better-auth)","description":"Returns the RFC 9728 protected-resource metadata for the Charming API origin. Read by clients that treat the origin as the protected resource; a client asking about one MCP surface reads the path-scoped document under this path instead, which is what that surface names in its 401 `WWW-Authenticate` header.","responses":{"200":{"description":"OAuth protected-resource discovery JSON.","content":{"application/json":{"schema":{"type":"object","description":"RFC 9728 protected-resource metadata (resource, authorization_servers, scopes_supported, …). Schema is delegated to better-auth."}}}}}}},"/.well-known/oauth-protected-resource/mcp":{"get":{"operationId":"get-oauth-protected-resource-mcp","summary":"OAuth protected-resource metadata for the default MCP surface","description":"Returns the RFC 9728 path-scoped protected-resource metadata for the `/mcp` MCP surface, which is what its `WWW-Authenticate` challenge names on a 401. Identical to the origin-wide document except that `resource` names `/mcp` on this origin rather than the origin itself, so a client can check the document answers for the endpoint it called.","responses":{"200":{"description":"OAuth protected-resource discovery JSON scoped to /mcp.","content":{"application/json":{"schema":{"type":"object","description":"RFC 9728 protected-resource metadata (resource, authorization_servers, scopes_supported, …). Schema is delegated to better-auth; only `resource` is overridden."}}}}}}},"/.well-known/oauth-protected-resource/mcp/chatgpt":{"get":{"operationId":"get-oauth-protected-resource-mcp-chatgpt","summary":"OAuth protected-resource metadata for the ChatGPT MCP surface","description":"Returns the RFC 9728 path-scoped protected-resource metadata for the `/mcp/chatgpt` MCP surface, which is what its `WWW-Authenticate` challenge names on a 401. `resource` names `/mcp/chatgpt` on this origin rather than the origin itself, so a client can check the document answers for the endpoint it called. `authorization_servers` names the surface too while `CHARMING__SERVER__CHATGPT_AUTH_PROXY_ADVERTISED` is on, which is what sends this surface's clients to their own authorization-server document; otherwise it matches the origin-wide document.","responses":{"200":{"description":"OAuth protected-resource discovery JSON scoped to /mcp/chatgpt.","content":{"application/json":{"schema":{"type":"object","description":"RFC 9728 protected-resource metadata (resource, authorization_servers, scopes_supported, …). Schema is delegated to better-auth; only `resource` is overridden."}}}}}}},"/.well-known/oauth-protected-resource/mcp/inline":{"get":{"operationId":"get-oauth-protected-resource-mcp-inline","summary":"OAuth protected-resource metadata for the inline MCP surface","description":"Returns the RFC 9728 path-scoped protected-resource metadata for the `/mcp/inline` MCP surface, which is what its `WWW-Authenticate` challenge names on a 401. Identical to the origin-wide document except that `resource` names `/mcp/inline` on this origin rather than the origin itself, so a client can check the document answers for the endpoint it called.","responses":{"200":{"description":"OAuth protected-resource discovery JSON scoped to /mcp/inline.","content":{"application/json":{"schema":{"type":"object","description":"RFC 9728 protected-resource metadata (resource, authorization_servers, scopes_supported, …). Schema is delegated to better-auth; only `resource` is overridden."}}}}}}}}}