REST API

Create, validate, share and discuss behavior trees over HTTPS.

Base URL: https://api.beetreecraft.com

Everything the website does is an API call. Specs travel as .beetree.yaml text inside JSON.

Try it without an account

The stateless tools need no account: POST /v1/validate, /v1/simulate, /v1/simulate/step, /v1/render and /v1/generate, and the catalogue they start from, GET /v1/templates and GET /v1/node-types. The MCP server offers the same tools without an account. Without credentials each address may make 60 of these calls per 10 minutes, REST and MCP counted together; past that the API answers 429 with a Retry-After header. Signing in or sending an API key lifts that limit. The limit counts against a salted hash of the address that expires within two days; the address itself is never stored.

curl -s https://api.beetreecraft.com/v1/generate \
  -H 'Content-Type: application/json' \
  -d '{"engine":"godot","spec":"version: \"1.0\"\nmetadata:\n  name: hello\ntree:\n  type: action\n  name: Wave\n"}'

Get an API key

Everything else in the API, and the MCP tools that read or write an account’s data, need an account. Those requests carry an API key.

  1. Sign up and confirm your email, then sign in.
  2. Open your profile, find API keys, give the key a name and press Create API key.
  3. Copy the key now. It starts with btc_ and is shown once; BeeTreeCraft stores only a hash of it.
  4. Keep it out of source control: put it in an environment variable or a secrets manager.
export BEETREE_API_KEY="btc_<paste your key here>"

You can have up to 5 keys. Revoke one on the same page if it leaks; it stops working immediately. Only a signed-in session can create or revoke keys, so a leaked key cannot mint new ones.

Key scopes and expiry

A key only does what its scopes allow. Scopes are resource:action, and they chain upward: delete implies write implies read. Trees, scenes and forum have read, write and delete; profile has read and write; keys has read and write (an API key can never manage keys, whatever it holds).

PresetGrants
read-onlyread on trees, scenes, forum and profile
read-writeread and write, no delete
fulleverything except keys

Creating a key requires a preset or a scopes list, and an optional expiry of 30d, 90d (default), 365d or never. Scopes cannot be changed afterwards; create a new key instead. A call outside the key’s scopes returns 403 with {"error":{"code":"insufficient_scope","required":"trees:delete","granted":[...]}}; an expired or revoked key returns 401. Keys made before scopes existed behave as full until you revoke them. MCP tools follow the same scopes (for example create_tree needs trees:write).

Send the key in either header:

curl -s https://api.beetreecraft.com/v1/me -H "X-API-Key: $BEETREE_API_KEY"
curl -s https://api.beetreecraft.com/v1/me -H "Authorization: Bearer $BEETREE_API_KEY"

To check a key before using it, GET /v1/me/key answers with its owner, its name, prefix, scopes and expiry. Any key may call it, whatever its scopes, and the secret is never returned; a signed-in session has no key to describe and gets 404. beetree login and beetree whoami use it.

curl -s https://api.beetreecraft.com/v1/me/key -H "X-API-Key: $BEETREE_API_KEY"

GET /v1/health and the OpenAPI document need no key. So does GET /v1/public/trees, a snapshot of public trees (no spec bodies) refreshed once a day, which powers the community page for visitors who have not signed in. Signed-in users and API clients should use GET /v1/trees for live results.

Usage counts

GET /v1/stats needs no key and returns counts only, from days that are over (never today), cached for five minutes:

  • daily: the page events (home viewed, builder opened, template run, code generated, sign-up started and finished, download clicked) for each UTC day of the last 90.
  • weekly: the events that follow from something an account did (first seen, first tree, trees made public, forum threads and replies, how long a thread waited for its first answer) as totals per complete ISO week, Monday to Sunday, for the last 13 weeks. A weekly total under 5, zero included, is withheld: its count is null and withheld names it.
  • capped on a day or week lists an event that reached dailyCap (2000), a suspected flood. events describes every name.
curl -s https://api.beetreecraft.com/v1/stats
# {"daily":{"from":"2026-08-18","to":"2026-11-15","days":[{"date":"2026-11-15","counts":{"home_viewed":41,"builder_opened":17}}]},
#  "weekly":{"from":"2026-08-10","to":"2026-11-08","minimum":5,"weeks":[{"week":"2026-W45","start":"2026-11-02","end":"2026-11-08",
#   "counts":{"account_first_seen":6,"thread_started":null,...},"withheld":{"thread_started":"fewer than 5"}}]},"dailyCap":2000,"events":{...}}

The site’s own pages add to the daily counts with POST /v1/pulse and a body of {"event":"<name>"} and nothing else, sent as text/plain (application/json works too). A name outside the list, any other field, or a request that does not come from a beetreecraft.com page (by its Origin or Sec-Fetch-Site header) is refused. Each address may send 30 events per 10 minutes. The privacy page says what is and is not counted.

Quick start

Validate a tree:

curl -s https://api.beetreecraft.com/v1/validate \
  -H "X-API-Key: $BEETREE_API_KEY" \
  -H 'content-type: application/json' \
  -d '{"spec":"version: \"1.0\"\nmetadata:\n  name: demo\ntree:\n  type: action\n  name: hello\n"}'

Render, simulate and generate use the same body shape:

EndpointExtra fieldReturns
POST /v1/validate{valid, errors, nodeCount}
POST /v1/renderformat: ascii sigil mermaid dot{output}
POST /v1/simulateoverrides: {"node_name": "FAILURE"}{status, trace, steps}
POST /v1/generateengine: unity unreal godot{files: [{path, content, isStub}]}

Start from a template

GET /v1/templates returns the five builder templates as {templates: [{name, description, spec}]}. Each spec is a valid .beetree.yaml you can send to POST /v1/trees or the endpoints above. MCP clients read the same files as beetree://templates/{name}.

Step through a simulation

POST /v1/simulate evaluates a whole tree with fixed overrides. To answer leaf by leaf instead, call POST /v1/simulate/step. It is stateless: send the spec and every answer so far (empty to start). While done is false, pending is the leaf that needs a status; append SUCCESS, FAILURE or RUNNING to answers and call again. The last response carries status and trace.

A patrol tree with a has_waypoint condition and a move action under a sequence:

# 1. start
curl -s https://api.beetreecraft.com/v1/simulate/step -H 'content-type: application/json' \
  -d '{"spec":"<yaml>","answers":[]}'
# {"done":false,"pending":{"node":"has_waypoint","type":"condition"},"answered":0,...}

# 2. has_waypoint succeeded
curl -s ... -d '{"spec":"<yaml>","answers":["SUCCESS"]}'
# {"done":false,"pending":{"node":"move","type":"action"},"answered":1,...}

# 3. move failed
curl -s ... -d '{"spec":"<yaml>","answers":["SUCCESS","FAILURE"]}'
# {"done":true,"answered":2,"status":"FAILURE","trace":"enter root\n  ...","steps":[...]}

MCP clients get the same flow as two tools: simulate_start (spec) returns the first pending leaf, and simulate_answer (spec, status, plus earlier answers) returns the next one or the final result.

Browse public trees: GET /v1/trees?q=patrol&sort=popular.

Authentication

Use an API key for scripts, servers and MCP clients. A sign-in token from Amazon Cognito also works, lasts about an hour, and is the only credential that can manage API keys.

A short-lived token from a script:

aws cognito-idp initiate-auth --region us-east-1 \
  --client-id 7i6a8ab6aidb93b4g91sisa2ev \
  --auth-flow USER_PASSWORD_AUTH \
  --auth-parameters USERNAME=<you>,PASSWORD=<password> \
  --query AuthenticationResult.IdToken --output text

Tokens last about an hour. Use the returned RefreshToken with the REFRESH_TOKEN_AUTH flow to get a new one.

curl -s https://api.beetreecraft.com/v1/me -H "Authorization: Bearer $TOKEN"

Manage keys over the API with a sign-in token (a key cannot do this):

curl -s https://api.beetreecraft.com/v1/keys -H "Authorization: Bearer $TOKEN"
curl -s -X POST https://api.beetreecraft.com/v1/keys -H "Authorization: Bearer $TOKEN" \
  -H 'content-type: application/json' -d '{"name":"laptop","preset":"read-only"}'
curl -s -X DELETE https://api.beetreecraft.com/v1/keys/<id> -H "Authorization: Bearer $TOKEN"

Save and share a tree

curl -s https://api.beetreecraft.com/v1/trees \
  -H "X-API-Key: $BEETREE_API_KEY" -H 'content-type: application/json' \
  -d '{"name":"My guard","visibility":"public","tags":["enemy"],"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"}'

The response is 201 with the saved tree, including its id.

PUT /v1/trees/{id} replaces a tree you own (send the whole body again), and DELETE /v1/trees/{id} deletes it for good; both need the trees:write scope and answer 404 for a tree that is not yours. GET /v1/me/trees lists every tree on your account, private ones included, without spec bodies. Every request body on these calls is shown with an example in the OpenAPI reference.

Trees are private by default. A private tree is invisible, even by id, to everyone but its owner.

Social

ActionRequest
Like / unlikePUT / DELETE /v1/trees/{id}/like (idempotent)
Remix a public treePOST /v1/trees/{id}/remix makes a private copy with remixedFrom credit (20 per day)
Save a sceneGET/POST /v1/scenes list and save your scenes; GET/PUT/DELETE /v1/scenes/{id} read, replace or delete one (scopes scenes:read, scenes:write, scenes:delete). A public scene that uses your private trees answers 409 with a trees list until you repeat the call with "confirm": true
Remix a public scenePOST /v1/scenes/{id}/remix copies the scene and its public trees as private items, each with remixedFrom credit (counts as one of the 20 per day)
Report a public treePOST /v1/trees/{id}/report with a reason flags it for moderators, for example an unchanged copy of someone else’s work. A public remix whose spec still matches its original reads with unchangedCopy: true
CommentPOST /v1/trees/{id}/comments with {"body": "..."}
Delete a commentDELETE /v1/trees/{id}/comments/{commentId}, allowed to the comment’s author and the tree’s owner
ForumGET/POST /v1/forum/threads, POST /v1/forum/threads/{id}/posts; a thread’s category is general (the default) or feedback
Your statsGET /v1/me/stats

Bug reports and feature requests

They go in the forum’s feedback category. List what has been reported before adding to it:

curl -s 'https://api.beetreecraft.com/v1/forum/threads?category=feedback' -H "X-API-Key: $BEETREE_API_KEY"

Report a bug or ask for a feature:

curl -s https://api.beetreecraft.com/v1/forum/threads \
  -H "X-API-Key: $BEETREE_API_KEY" -H 'content-type: application/json' \
  -d '{"title":"Export drops my blackboard","body":"What I did, what I expected, what happened.","category":"feedback"}'

Errors

Errors are JSON: {"error": {"code": "invalid_spec", "message": "..."}}.

StatusMeaning
400Bad request body
401Missing, invalid, revoked or expired key or token
403Not allowed (for example deleting someone else’s comment, managing API keys with an API key, or a key without the needed scope: code insufficient_scope)
404Not found, or private and not yours
413Request body too large (512 KB limit)
422The spec is invalid; the message lists why
429Too many writes (60 POST, PUT or DELETE requests per minute per user), or too many tool calls without an account (60 per 10 minutes per address, REST and MCP together); wait the Retry-After seconds, or sign in or send an API key

Limits

Specs are limited to 128 KB and 500 nodes. Requests are rate limited. Browsers may call the API from any origin (CORS is open) because credentials travel in the Authorization header, never cookies.

MCP

Prefer to let an AI agent drive? See the MCP server.