{"components":{"parameters":{"Id":{"in":"path","name":"id","required":true,"schema":{"type":"string"}}},"requestBodies":{"Scene":{"content":{"application/json":{"example":{"agents":[{"model":"guard","name":"Guard","x":2,"z":-3}],"name":"Guard post","visibility":"private"},"schema":{"properties":{"agents":{"items":{"$ref":"#/components/schemas/SceneAgent"},"maxItems":24,"type":"array"},"confirm":{"description":"Accept publishing your private trees that a public scene uses. Without it the call answers 409 with a trees list and changes nothing.","type":"boolean"},"name":{"type":"string"},"visibility":{"enum":["public","private"],"type":"string"}},"required":["name"],"type":"object"}}},"required":true},"Spec":{"content":{"application/json":{"schema":{"properties":{"engine":{"enum":["unity","unreal","godot"],"type":"string"},"format":{"enum":["ascii","sigil","mermaid","dot"],"type":"string"},"overrides":{"additionalProperties":{"enum":["SUCCESS","FAILURE","RUNNING"],"type":"string"},"type":"object"},"spec":{"description":".beetree.yaml text","type":"string"}},"required":["spec"],"type":"object"}}},"required":true},"Tree":{"content":{"application/json":{"example":{"description":"Attacks when the player is in sight","name":"My guard","spec":"version: \"1.0\"\nmetadata:\n  name: guard\ntree:\n  type: sequence\n  name: root\n  children:\n    - type: condition\n      name: sees_player\n    - type: action\n      name: attack\n","tags":["enemy"],"visibility":"private"},"schema":{"properties":{"description":{"maxLength":500,"type":"string"},"name":{"maxLength":80,"type":"string"},"spec":{"type":"string"},"tags":{"items":{"type":"string"},"type":"array"},"visibility":{"enum":["public","private"],"type":"string"}},"required":["spec"],"type":"object"}}},"required":true}},"responses":{"Error":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error"},"Like":{"content":{"application/json":{"schema":{"properties":{"likeCount":{"type":"integer"},"liked":{"type":"boolean"}},"type":"object"}}},"description":"Like state"}},"schemas":{"APIKeyInfo":{"properties":{"createdAt":{"format":"date-time","type":"string"},"expiresAt":{"description":"Absent when the key never expires","format":"date-time","type":"string"},"id":{"type":"string"},"lastUsedAt":{"description":"Updated at most once an hour","format":"date-time","type":"string"},"legacy":{"description":"True for a key made before scopes existed","type":"boolean"},"name":{"type":"string"},"prefix":{"description":"First characters of the key, for recognition","type":"string"},"scopes":{"description":"Effective scopes; keys made before scopes existed show the full preset","items":{"type":"string"},"type":"array"}},"type":"object"},"Comment":{"properties":{"author":{"type":"string"},"authorId":{"type":"string"},"body":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"id":{"type":"string"},"treeId":{"type":"string"}},"type":"object"},"Error":{"properties":{"error":{"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"}},"type":"object"},"ForumCategory":{"default":"general","description":"feedback holds bug reports and feature requests; general holds everything else, including threads started before categories existed.","enum":["general","feedback"],"type":"string"},"KeyIdentity":{"properties":{"key":{"$ref":"#/components/schemas/APIKeyInfo"},"userId":{"type":"string"},"username":{"type":"string"}},"type":"object"},"Lineage":{"description":"Where a remix came from, frozen when it was copied. state is derived on read.","properties":{"ancestors":{"items":{"properties":{"at":{"format":"date-time","type":"string"},"id":{"type":"string"},"kind":{"type":"string"},"ownerId":{"type":"string"},"ownerName":{"type":"string"},"title":{"type":"string"}},"type":"object"},"type":"array"},"at":{"format":"date-time","type":"string"},"id":{"type":"string"},"kind":{"enum":["tree"],"type":"string"},"ownerId":{"type":"string"},"ownerName":{"type":"string"},"state":{"enum":["public","private","deleted"],"type":"string"},"title":{"type":"string"}},"type":"object"},"Profile":{"properties":{"avatar":{"description":"Preset picture id a001 to a100; empty for the default","example":"a017","type":"string"},"bio":{"type":"string"},"createdAt":{"format":"date-time","type":"string"},"displayName":{"type":"string"},"email":{"type":"string"},"marketingOptIn":{"description":"Consent to product news email. Returned to the owner only (GET /v1/me), never on public profiles","type":"boolean"},"marketingOptInAt":{"format":"date-time","type":"string"},"marketingSource":{"enum":["signup","profile"],"type":"string"},"moderator":{"description":"Present and true on GET /v1/me when the caller may review reports","type":"boolean"},"userId":{"type":"string"}},"type":"object"},"PulseEvent":{"additionalProperties":false,"properties":{"event":{"enum":["home_viewed","builder_opened","template_run","code_generated","signup_started","signup_finished","download_clicked"],"type":"string"}},"required":["event"],"type":"object"},"Scene":{"properties":{"agents":{"items":{"$ref":"#/components/schemas/SceneAgent"},"type":"array"},"createdAt":{"format":"date-time","type":"string"},"id":{"type":"string"},"name":{"type":"string"},"remixedFrom":{"$ref":"#/components/schemas/Lineage"},"updatedAt":{"format":"date-time","type":"string"},"visibility":{"enum":["public","private"],"type":"string"}},"type":"object"},"SceneAgent":{"properties":{"model":{"type":"string"},"name":{"type":"string"},"treeId":{"type":"string"},"x":{"type":"number"},"z":{"type":"number"}},"type":"object"},"SimulateResult":{"properties":{"root":{"type":"string"},"status":{"enum":["SUCCESS","FAILURE","RUNNING"],"type":"string"},"steps":{"items":{"properties":{"depth":{"type":"integer"},"event":{"type":"string"},"node":{"type":"string"},"status":{"type":"string"},"type":{"type":"string"}},"type":"object"},"type":"array"},"trace":{"type":"string"}},"type":"object"},"Stats":{"properties":{"comments":{"type":"integer"},"forumPosts":{"type":"integer"},"forumThreads":{"type":"integer"},"likes":{"type":"integer"},"publicTrees":{"type":"integer"},"scenes":{"type":"integer"},"trees":{"type":"integer"}},"type":"object"},"StepResult":{"properties":{"answered":{"type":"integer"},"done":{"type":"boolean"},"pending":{"properties":{"node":{"type":"string"},"type":{"type":"string"}},"type":"object"},"root":{"type":"string"},"status":{"enum":["SUCCESS","FAILURE","RUNNING"],"type":"string"},"steps":{"items":{"properties":{"depth":{"type":"integer"},"event":{"type":"string"},"node":{"type":"string"},"status":{"type":"string"},"type":{"type":"string"}},"type":"object"},"type":"array"},"trace":{"type":"string"}},"required":["done","answered","root","steps"],"type":"object"},"Thread":{"properties":{"author":{"type":"string"},"body":{"type":"string"},"category":{"$ref":"#/components/schemas/ForumCategory"},"createdAt":{"format":"date-time","type":"string"},"id":{"type":"string"},"lastActivity":{"format":"date-time","type":"string"},"postCount":{"type":"integer"},"title":{"type":"string"}},"type":"object"},"Tree":{"properties":{"commentCount":{"type":"integer"},"createdAt":{"format":"date-time","type":"string"},"description":{"type":"string"},"id":{"type":"string"},"likeCount":{"type":"integer"},"likedByMe":{"type":"boolean"},"name":{"type":"string"},"ownerId":{"type":"string"},"ownerName":{"type":"string"},"remixedFrom":{"$ref":"#/components/schemas/Lineage"},"spec":{"type":"string"},"tags":{"items":{"type":"string"},"type":"array"},"unchangedCopy":{"description":"On a single read, true for a public remix whose spec still matches its original.","type":"boolean"},"updatedAt":{"format":"date-time","type":"string"},"visibility":{"enum":["public","private"],"type":"string"}},"type":"object"},"ValidateResult":{"properties":{"errors":{"items":{"type":"string"},"type":"array"},"nodeCount":{"type":"integer"},"valid":{"type":"boolean"}},"type":"object"}},"securitySchemes":{"apiKeyAuth":{"in":"header","name":"X-API-Key","type":"apiKey"},"bearerAuth":{"bearerFormat":"JWT","description":"A Cognito token from sign-in, or an API key (btc_...) sent as a bearer token.","scheme":"bearer","type":"http"}}},"info":{"description":"Create, validate, simulate, share and discuss engine-agnostic behavior trees.\n\nThe stateless tools (`POST /v1/validate`, `/v1/simulate`, `/v1/render` and `/v1/generate`) need no\naccount: without credentials they answer up to 60 calls per 10 minutes per address, then `429`\nwith `Retry-After`; signing in or sending an API key lifts that limit. `/v1/health`,\n`/v1/openapi.json`, `/v1/public/trees` and `/v1/users/{id}` are open too.\nEvery other endpoint needs credentials. Create an API key\non your profile page and send it as `X-API-Key: btc_...` or `Authorization: Bearer btc_...`.\nA Cognito token from sign-in (`Authorization: Bearer \u003ctoken\u003e`) also works, and is the only way to\nmanage API keys. See https://beetreecraft.com/docs/api/ for setup.\nAn MCP server is available at `POST /mcp` and needs the same credentials (see the MCP docs).\n","license":{"name":"MIT"},"title":"BeeTreeCraft API","version":"1.0.0"},"openapi":"3.0.3","paths":{"/mcp":{"get":{"operationId":"mcpGet","responses":{"405":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"summary":"Not supported; use POST","tags":["MCP"]},"post":{"description":"Streamable HTTP transport, JSON responses. Supports initialize, ping, tools/list, tools/call, resources and prompts. Without an account the stateless tools answer (list_node_types, get_template, validate_tree, render_tree, simulate_tree, simulate_start, simulate_answer, diff_trees, generate_code), rate limited per address like the REST tools: past the limit the answer is 429 with Retry-After and JSON-RPC error -32029. Tools that read or write an account's data answer with an error naming where to create an API key.\n","operationId":"mcp","requestBody":{"content":{"application/json":{"schema":{"properties":{"id":{},"jsonrpc":{"enum":["2.0"],"type":"string"},"method":{"example":"tools/list","type":"string"},"params":{"type":"object"}},"required":["jsonrpc","method"],"type":"object"}}},"required":true},"responses":{"200":{"description":"JSON-RPC response"},"202":{"description":"Notification accepted"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{},{"apiKeyAuth":[]},{"bearerAuth":[]}],"summary":"Model Context Protocol endpoint (JSON-RPC 2.0)","tags":["MCP"]}},"/v1/forum/reports":{"get":{"operationId":"listRecentReports","responses":{"200":{"description":"Reports"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]}],"summary":"Most recent reports across all threads, newest first (moderators only)","tags":["Forum"]}},"/v1/forum/threads":{"get":{"description":"Every thread, or only one category with ?category=. Bug reports and feature requests go in feedback; everything else is general.","operationId":"listThreads","parameters":[{"description":"Only threads in this category. Omit for every thread. Unknown returns 400.","in":"query","name":"category","schema":{"$ref":"#/components/schemas/ForumCategory"}}],"responses":{"200":{"description":"Threads"},"400":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"summary":"List forum threads, most recently active first","tags":["Forum"]},"post":{"operationId":"createThread","requestBody":{"content":{"application/json":{"schema":{"properties":{"body":{"maxLength":5000,"type":"string"},"category":{"$ref":"#/components/schemas/ForumCategory"},"title":{"maxLength":120,"type":"string"}},"required":["title","body"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Thread"}}},"description":"Created"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Start a thread","tags":["Forum"]}},"/v1/forum/threads/{id}":{"get":{"operationId":"getThread","responses":{"200":{"description":"Thread and posts"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"summary":"A thread and its posts","tags":["Forum"]},"parameters":[{"$ref":"#/components/parameters/Id"}]},"/v1/forum/threads/{id}/posts":{"parameters":[{"$ref":"#/components/parameters/Id"}],"post":{"description":"A thread takes up to 1000 replies; past that the API answers 409 with code limit_reached.","operationId":"addPost","requestBody":{"content":{"application/json":{"schema":{"properties":{"body":{"maxLength":5000,"type":"string"}},"required":["body"],"type":"object"}}},"required":true},"responses":{"201":{"description":"Created"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Reply to a thread","tags":["Forum"]}},"/v1/forum/threads/{id}/report":{"parameters":[{"$ref":"#/components/parameters/Id"}],"post":{"operationId":"reportThread","requestBody":{"content":{"application/json":{"schema":{"properties":{"postId":{"description":"Omit to report the thread itself","type":"string"},"reason":{"maxLength":500,"type":"string"}},"required":["reason"],"type":"object"}}},"required":true},"responses":{"201":{"description":"Reported"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Report a thread, or one of its posts, for moderator review","tags":["Forum"]}},"/v1/forum/threads/{id}/reports":{"get":{"operationId":"listReports","responses":{"200":{"description":"Reports"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]}],"summary":"Reports filed against a thread and its posts (moderators only)","tags":["Forum"]},"parameters":[{"$ref":"#/components/parameters/Id"}]},"/v1/generate":{"post":{"operationId":"generateCode","requestBody":{"$ref":"#/components/requestBodies/Spec"},"responses":{"200":{"description":"Generated files"},"413":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{},{"apiKeyAuth":[]},{"bearerAuth":[]}],"summary":"Generate engine code (unity, unreal, godot)","tags":["Tools"]}},"/v1/health":{"get":{"operationId":"health","responses":{"200":{"content":{"application/json":{"schema":{"properties":{"status":{"example":"ok","type":"string"},"version":{"type":"string"}},"type":"object"}}},"description":"OK"},"429":{"$ref":"#/components/responses/Error"}},"security":[],"summary":"Service health","tags":["Tools"]}},"/v1/keys":{"get":{"description":"Needs a signed-in session. Never returns key secrets.","operationId":"listKeys","responses":{"200":{"content":{"application/json":{"schema":{"properties":{"items":{"items":{"$ref":"#/components/schemas/APIKeyInfo"},"type":"array"}},"type":"object"}}},"description":"Your keys"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]}],"summary":"List your API keys","tags":["Account"]},"post":{"description":"Needs a signed-in session. The secret is returned once; only its hash is stored. Up to 5 keys per account.\n\nA key has no scopes by default: send a `preset` or an explicit `scopes` list (not both). Scopes are `resource:action` and chain upward, so `delete` implies `write` implies `read`. Resources: trees, scenes, forum (read, write, delete); profile (read, write); keys (read, write). Presets: `read-only` (all read), `read-write` (read and write, no delete), `full` (everything except keys). Scopes cannot change after creation. A call outside the key's scopes returns 403 `insufficient_scope` with the `required` scope and the `granted` list; an expired or revoked key returns 401. Keys made before scopes existed act as `full`. A key can never manage keys, whatever its scopes.\n","operationId":"createKey","requestBody":{"content":{"application/json":{"schema":{"properties":{"expiry":{"default":"90d","enum":["30d","90d","365d","never"],"type":"string"},"name":{"maxLength":60,"type":"string"},"preset":{"enum":["read-only","read-write","full"],"type":"string"},"scopes":{"items":{"example":"trees:read","type":"string"},"type":"array"}},"required":["name"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/APIKeyInfo"},{"properties":{"key":{"description":"The secret, shown once","type":"string"},"note":{"type":"string"}},"type":"object"}]}}},"description":"Created; copy the key now"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]}],"summary":"Create an API key","tags":["Account"]}},"/v1/keys/{id}":{"delete":{"operationId":"deleteKey","responses":{"204":{"description":"Revoked"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]}],"summary":"Revoke an API key","tags":["Account"]},"parameters":[{"$ref":"#/components/parameters/Id"}]},"/v1/me":{"get":{"operationId":"getMe","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Profile"}}},"description":"Profile"},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Your profile","tags":["Account"]},"put":{"operationId":"updateMe","requestBody":{"content":{"application/json":{"schema":{"properties":{"avatar":{"description":"Preset picture id; omit to keep, empty string to clear","pattern":"^(a(00[1-9]|0[1-9][0-9]|100))?$","type":"string"},"bio":{"maxLength":500,"type":"string"},"displayName":{"pattern":"^[A-Za-z0-9_-]{3,32}$","type":"string"},"marketingOptIn":{"description":"Consent to product news email; omit to keep","type":"boolean"},"marketingSource":{"enum":["signup","profile"],"type":"string"}},"required":["displayName"],"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Profile"}}},"description":"Updated"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Update your profile","tags":["Account"]}},"/v1/me/key":{"get":{"description":"Describes the API key the request was sent with: whose it is, its name, prefix, scopes and expiry. Any key may call it, whatever its scopes, so a terminal or a script can check a key before using it (`beetree login` and `beetree whoami` do). The secret is never returned. A signed-in session has no key to describe and gets 404 no_api_key.","operationId":"myKey","responses":{"200":{"content":{"application/json":{"example":{"key":{"createdAt":"2026-11-01T12:00:00Z","id":"k1","name":"laptop terminal","prefix":"btc_AbCd","scopes":["trees:read","trees:write"]},"userId":"0f1e2d3c-example","username":"alice"},"schema":{"$ref":"#/components/schemas/KeyIdentity"}}},"description":"The key and its owner"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"apiKeyAuth":[]}],"summary":"The API key in use, its owner and its scopes","tags":["Account"]}},"/v1/me/stats":{"get":{"operationId":"myStats","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Stats"}}},"description":"Stats"},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Your engagement stats","tags":["Account"]}},"/v1/me/trees":{"get":{"description":"Lists every tree on your account, private ones included, without spec bodies; fetch a tree by id for its spec. Needs the trees:read scope. Changes nothing.","operationId":"myTrees","responses":{"200":{"description":"Trees without spec bodies"},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Your trees, public and private","tags":["Account"]}},"/v1/node-types":{"get":{"operationId":"getNodeTypes","responses":{"200":{"description":"OK"},"429":{"$ref":"#/components/responses/Error"}},"security":[{},{"apiKeyAuth":[]},{"bearerAuth":[]}],"summary":"Node types, decorators, render formats and engines","tags":["Tools"]}},"/v1/openapi.json":{"get":{"operationId":"getOpenApi","responses":{"200":{"description":"The OpenAPI document"},"429":{"$ref":"#/components/responses/Error"}},"security":[],"summary":"This document as JSON","tags":["Tools"]}},"/v1/public/trees":{"get":{"description":"A snapshot of public trees refreshed daily, without spec bodies. Signed-in users and API clients should use GET /v1/trees for live results.","operationId":"publicTrees","parameters":[{"description":"Match name, description or tags","in":"query","name":"q","schema":{"type":"string"}},{"in":"query","name":"sort","schema":{"enum":["recent","popular"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"generatedAt":{"format":"date-time","type":"string"},"items":{"items":{"$ref":"#/components/schemas/Tree"},"type":"array"},"note":{"type":"string"}},"type":"object"}}},"description":"The snapshot"},"429":{"$ref":"#/components/responses/Error"}},"security":[],"summary":"Visitor showcase of public trees (no credentials)","tags":["Trees"]}},"/v1/pulse":{"post":{"description":"Adds one to today's count of a fixed event name. It is meant for beetreecraft.com pages only: a request whose Origin is another site, or that has neither an Origin nor a Sec-Fetch-Site of same-site or same-origin (a script, the CLI), is refused with 403. The body is the event name and nothing else; any other field, or a name outside the list, is refused and nothing is stored. Nothing about the caller is kept with the count: no account, address, user agent or referrer. Each address may send 30 events per 10 minutes, counted against a salted hash of the address that expires with the window; past that the API answers 429. Each event counts at most 2000 times a day; GET /v1/stats marks a day that reached it. Pages send the body as text/plain, which avoids a CORS preflight; application/json is accepted too.\n","operationId":"pulse","requestBody":{"content":{"application/json":{"example":{"event":"builder_opened"},"schema":{"$ref":"#/components/schemas/PulseEvent"}},"text/plain":{"example":{"event":"builder_opened"},"schema":{"$ref":"#/components/schemas/PulseEvent"}}},"required":true},"responses":{"204":{"description":"Counted, or not counted because the counter could not be reached; either way there is nothing to retry"},"400":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[],"summary":"Count one thing that happened on a site page (no credentials)","tags":["Usage"]}},"/v1/render":{"post":{"operationId":"renderSpec","requestBody":{"$ref":"#/components/requestBodies/Spec"},"responses":{"200":{"description":"Rendered diagram"},"413":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{},{"apiKeyAuth":[]},{"bearerAuth":[]}],"summary":"Render a spec as ascii, sigil, mermaid or dot","tags":["Tools"]}},"/v1/scenes":{"get":{"description":"Lists every scene on your account, private ones included. Needs the scenes:read scope. Changes nothing.","operationId":"listScenes","responses":{"200":{"description":"Scenes"},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Your saved 3D scenes","tags":["Scenes"]},"post":{"description":"Saves a new scene (a named arrangement of up to 24 agents in the 3D world), private unless visibility is public, and answers 201 with its id. Needs the scenes:write scope. A public scene that uses your private trees answers 409 with a trees list and changes nothing until you repeat the call with confirm true, which publishes those trees. Each account holds up to 200 scenes; past that the API answers 409 with code limit_reached.","operationId":"createScene","requestBody":{"$ref":"#/components/requestBodies/Scene"},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Scene"}}},"description":"Created"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Save a scene","tags":["Scenes"]}},"/v1/scenes/{id}":{"delete":{"description":"Permanently deletes a scene you own; the trees its agents used stay. Needs the scenes:delete scope. Answers 404 for a scene that is not yours, so the call does not reveal whether it exists. There is no undo.","operationId":"deleteScene","responses":{"204":{"description":"Deleted"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Delete a scene you own","tags":["Scenes"]},"get":{"description":"Returns one scene with its agents. Public scenes are readable by anyone; a private scene is readable only by its owner, and for everyone else answers 404 as if it did not exist. Changes nothing.","operationId":"getScene","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Scene"}}},"description":"The scene"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"summary":"Get a scene (public, or yours)","tags":["Scenes"]},"parameters":[{"$ref":"#/components/parameters/Id"}],"put":{"description":"Replaces the name, visibility and agents of a scene you own with the body (send all of them, as with create). Needs the scenes:write scope; a scene that is not yours answers 404. Making it public while it uses your private trees answers 409 until confirm is true, as on create.","operationId":"updateScene","requestBody":{"$ref":"#/components/requestBodies/Scene"},"responses":{"200":{"description":"Updated"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Replace a scene you own","tags":["Scenes"]}},"/v1/scenes/{id}/remix":{"parameters":[{"$ref":"#/components/parameters/Id"}],"post":{"description":"Copies a public scene and every public tree its agents use into your account as private items, each with remixedFrom lineage. A tree used by two agents is copied once. Private trees in the scene are not copied and their agents lose the tree reference. The call counts as one remix toward the limit of 20 per user per day. The response is the scene plus a trees list of the copies. An account at its scene or tree limit gets 409 limit_reached.","operationId":"remixScene","responses":{"201":{"description":"The private scene copy with its trees"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Remix a public scene into your account","tags":["Scenes"]}},"/v1/simulate":{"post":{"operationId":"simulateSpec","requestBody":{"$ref":"#/components/requestBodies/Spec"},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimulateResult"}}},"description":"Execution trace"},"413":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{},{"apiKeyAuth":[]},{"bearerAuth":[]}],"summary":"Dry-run a spec","tags":["Tools"]}},"/v1/simulate/step":{"post":{"description":"Stateless. Send the spec and the answers given so far (empty to start). While done is false, pending names the leaf that needs a status; send its status appended to answers on the next call. When done is true the response carries the final status and trace.\n","operationId":"simulateStep","requestBody":{"content":{"application/json":{"schema":{"properties":{"answers":{"items":{"enum":["SUCCESS","FAILURE","RUNNING"],"type":"string"},"type":"array"},"spec":{"description":"Tree spec as YAML","type":"string"}},"required":["spec"],"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StepResult"}}},"description":"Pending leaf, or the final result"},"413":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{},{"apiKeyAuth":[]},{"bearerAuth":[]}],"summary":"Step through a simulation one leaf at a time","tags":["Tools"]}},"/v1/stats":{"get":{"description":"Aggregates only, from complete days: today is never included. daily holds the anonymous page events (the ones POST /v1/pulse accepts) for each UTC day of the last 90 that has any. weekly holds the events that follow from something a signed-in account did (first seen, first tree, trees made public, forum threads and replies) only as totals per complete ISO week (Monday to Sunday) for the last 13 weeks; a weekly total under weekly.minimum (5), zero included, is withheld: its count is null and withheld names it. Weeks do not overlap, so comparing answers over time reveals nothing finer than a week of at least five events. A day or week whose count reached dailyCap lists that event in capped (a suspected flood). events describes every name. Cached for 5 minutes.\n","operationId":"usageStats","responses":{"200":{"content":{"application/json":{"example":{"daily":{"days":[{"counts":{"builder_opened":17,"code_generated":6,"home_viewed":41},"date":"2026-11-15"}],"from":"2026-08-18","to":"2026-11-15"},"dailyCap":2000,"events":{"daily":{"home_viewed":"the home page was viewed"},"weekly":{"thread_started":"a forum thread was started"}},"weekly":{"from":"2026-08-10","minimum":5,"to":"2026-11-08","weeks":[{"counts":{"account_first_seen":6,"thread_started":null},"end":"2026-11-08","start":"2026-11-02","week":"2026-W45","withheld":{"thread_started":"fewer than 5"}}]}},"schema":{"properties":{"daily":{"properties":{"days":{"items":{"properties":{"capped":{"items":{"type":"string"},"type":"array"},"counts":{"additionalProperties":{"type":"integer"},"type":"object"},"date":{"format":"date","type":"string"}},"type":"object"},"type":"array"},"from":{"format":"date","type":"string"},"to":{"description":"Yesterday (UTC)","format":"date","type":"string"}},"type":"object"},"dailyCap":{"type":"integer"},"events":{"properties":{"daily":{"additionalProperties":{"type":"string"},"type":"object"},"weekly":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"},"weekly":{"properties":{"from":{"format":"date","type":"string"},"minimum":{"description":"Smallest weekly total that is published","type":"integer"},"to":{"description":"The Sunday that ended the last complete ISO week","format":"date","type":"string"},"weeks":{"items":{"properties":{"capped":{"items":{"type":"string"},"type":"array"},"counts":{"additionalProperties":{"nullable":true,"type":"integer"},"type":"object"},"end":{"format":"date","type":"string"},"start":{"format":"date","type":"string"},"week":{"example":"2026-W46","type":"string"},"withheld":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"},"type":"array"}},"type":"object"}},"type":"object"}}},"description":"Usage counts","headers":{"Cache-Control":{"description":"public, max-age=300","schema":{"type":"string"}}}},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"}},"security":[],"summary":"Usage counts, daily for page events and weekly for account events (no credentials)","tags":["Usage"]}},"/v1/templates":{"get":{"description":"The builder templates as valid specs; the same ones MCP serves as `beetree://templates/{name}`.","operationId":"listTemplates","responses":{"200":{"content":{"application/json":{"schema":{"properties":{"templates":{"items":{"properties":{"description":{"type":"string"},"name":{"example":"guard","type":"string"},"spec":{"description":"A valid .beetree.yaml document","type":"string"}},"type":"object"},"type":"array"}},"type":"object"}}},"description":"Templates, sorted by name"},"429":{"$ref":"#/components/responses/Error"}},"security":[{},{"apiKeyAuth":[]},{"bearerAuth":[]}],"summary":"Starter templates","tags":["Tools"]}},"/v1/trees":{"get":{"description":"Browse the public trees, newest first, without their spec bodies. Needs no scope beyond a valid key; changes nothing. Use q, tag and sort to narrow it and next_cursor to page. Fetch one tree with GET /v1/trees/{id} for its spec. A limit outside 1 to 100 or a cursor that was not returned by this call answers 400.\n","operationId":"listTrees","parameters":[{"description":"Match name, description or tags. Search, tag and popular sorting look through the newest 1000 public trees.","in":"query","name":"q","schema":{"type":"string"}},{"in":"query","name":"tag","schema":{"type":"string"}},{"in":"query","name":"sort","schema":{"enum":["recent","popular"],"type":"string"}},{"description":"Page size, default 50. Out of range returns 400.","in":"query","name":"limit","schema":{"maximum":100,"minimum":1,"type":"integer"}},{"description":"Opaque next_cursor from the previous page. Invalid returns 400.","in":"query","name":"cursor","schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"items":{"items":{"$ref":"#/components/schemas/Tree"},"type":"array"},"next_cursor":{"description":"Present when more trees follow; pass as cursor","type":"string"}},"type":"object"}}},"description":"Trees (without spec bodies)"},"400":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"summary":"List public trees","tags":["Trees"]},"post":{"description":"Saves a new tree on your account, private unless visibility is public, and answers 201 with its id. Needs the trees:write scope. The spec is validated first; an invalid one answers 422 with the problems. Each account holds up to 500 trees; past that the API answers 409 with code limit_reached.","operationId":"createTree","requestBody":{"$ref":"#/components/requestBodies/Tree"},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tree"}}},"description":"Created"},"401":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Create a tree","tags":["Trees"]}},"/v1/trees/{id}":{"delete":{"description":"Permanently deletes a tree you own. Remixes of it stay and read remixedFrom.state deleted. Needs the trees:write scope. Answers 404 for a tree that is not yours, so the call does not reveal whether it exists. There is no undo.\n","operationId":"deleteTree","responses":{"204":{"description":"Deleted"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Delete a tree you own","tags":["Trees"]},"get":{"description":"Returns one tree with its spec text. Public trees are readable by anyone; a private tree is readable only by its owner, and for everyone else answers 404 as if it did not exist. Changes nothing.\n","operationId":"getTree","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tree"}}},"description":"The tree"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"summary":"Get a tree with its spec","tags":["Trees"]},"parameters":[{"$ref":"#/components/parameters/Id"}],"put":{"description":"Replaces the name, description, visibility, tags and spec of a tree you own with the body (send all of them, as with create). Needs the trees:write scope; a tree that is not yours answers 404. A remix whose spec is identical to its public original cannot be made public; the API answers 422 with code unchanged_remix.","operationId":"updateTree","requestBody":{"$ref":"#/components/requestBodies/Tree"},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tree"}}},"description":"Updated"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Replace a tree you own","tags":["Trees"]}},"/v1/trees/{id}/comments":{"get":{"operationId":"listComments","responses":{"200":{"content":{"application/json":{"schema":{"properties":{"items":{"items":{"$ref":"#/components/schemas/Comment"},"type":"array"}},"type":"object"}}},"description":"Comments, oldest first"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"summary":"List comments","tags":["Social"]},"parameters":[{"$ref":"#/components/parameters/Id"}],"post":{"description":"A tree takes up to 500 comments; past that the API answers 409 with code limit_reached.","operationId":"addComment","requestBody":{"content":{"application/json":{"schema":{"properties":{"body":{"maxLength":2000,"type":"string"}},"required":["body"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Comment"}}},"description":"Created"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Add a comment","tags":["Social"]}},"/v1/trees/{id}/comments/{commentId}":{"delete":{"operationId":"deleteComment","responses":{"204":{"description":"Deleted"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Delete a comment (author or tree owner)","tags":["Social"]},"parameters":[{"$ref":"#/components/parameters/Id"},{"in":"path","name":"commentId","required":true,"schema":{"type":"string"}}]},"/v1/trees/{id}/like":{"delete":{"operationId":"unlikeTree","responses":{"200":{"$ref":"#/components/responses/Like"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Remove your like","tags":["Social"]},"parameters":[{"$ref":"#/components/parameters/Id"}],"put":{"operationId":"likeTree","responses":{"200":{"$ref":"#/components/responses/Like"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Like a tree (idempotent)","tags":["Social"]}},"/v1/trees/{id}/remix":{"parameters":[{"$ref":"#/components/parameters/Id"}],"post":{"description":"Copies a public tree as a new private tree named with a Remix suffix. The copy records remixedFrom (kind, id, title, ownerId, ownerName, at, ancestors) frozen at copy time. On reads, remixedFrom.state is public, private or deleted according to the original now. Private trees answer 404. Limit 20 remixes per user per day; an account at its tree limit gets 409 limit_reached.","operationId":"remixTree","responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tree"}}},"description":"The private copy"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Remix a public tree into your account","tags":["Trees"]}},"/v1/trees/{id}/report":{"parameters":[{"$ref":"#/components/parameters/Id"}],"post":{"description":"Files a report for moderators against a public tree. Private trees answer 404. Reporting twice is accepted and counted once per reporter.","operationId":"reportTree","requestBody":{"content":{"application/json":{"example":{"reason":"An unchanged copy of another tree"},"schema":{"properties":{"reason":{"maxLength":500,"type":"string"}},"required":["reason"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"type":"object"}}},"description":"The report"},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"summary":"Report a public tree, such as an unchanged copy of someone else's work","tags":["Trees"]}},"/v1/users/{id}":{"get":{"operationId":"getUser","responses":{"200":{"description":"Profile and trees"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[],"summary":"A user's public profile, public trees and public scenes (no sign-in needed)","tags":["Account"]},"parameters":[{"$ref":"#/components/parameters/Id"}]},"/v1/validate":{"post":{"operationId":"validateSpec","requestBody":{"$ref":"#/components/requestBodies/Spec"},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidateResult"}}},"description":"Validation result (valid or not)"},"413":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}},"security":[{},{"apiKeyAuth":[]},{"bearerAuth":[]}],"summary":"Validate a spec","tags":["Tools"]}}},"security":[{"apiKeyAuth":[]},{"bearerAuth":[]}],"servers":[{"description":"Production","url":"https://api.beetreecraft.com"}],"tags":[{"description":"Stateless validate, simulate, render and generate","name":"Tools"},{"name":"Trees"},{"name":"Social"},{"name":"Account"},{"name":"Forum"},{"name":"Scenes"},{"description":"Count-only usage counters and their daily totals","name":"Usage"},{"name":"MCP"}]}
