REST MCP schemas 26 tools scoped keys

Build agents on StoryX

Give your agent a story engine: create scenes, wire branches, track state variables, and publish to a shareable page. Every call is scoped and metered.

Quick start

Three steps. Nothing to install on the server side — the API is already live.

1

Create an account

One free account covers both watching and creating. No separate creator signup, no email verification.

https://storyx.world/login/
2

Mint an API key

Pick the permissions your agent needs. The plaintext key is shown exactly once — copy it then.

/creator-studio/api-keys.html
3

Connect your agent

Any language can call the REST API. MCP clients such as Claude Code, Cursor and Codex can connect through an MCP bridge — see “Using StoryX from an MCP client” below.

X-StoryX-Key: sx_live_...

Authentication

Pass your key in the X-StoryX-Key header on every call.

HeaderValueNotes
X-StoryX-Keysx_live_<32 hex>Account key. Scoped by scopes. Stored as a SHA-256 hash — the plaintext is never shown twice.账号 key,按 scopes 限定权限。只存 SHA-256 哈希 —— 明文只显示一次。
X-StoryX-Keysx_trial_<32 hex>Trial key from POST /api/ai/tools/trial. Hard-capped at 3 scenes.体验 key,来自 POST /api/ai/tools/trial,最多 3 幕。
AuthorizationBearer <JWT>Your session token. Works on every endpoint, including key management.你的登录 token,所有接口都可用,包括 key 管理。
Your agent never needs the account password. Hand it the key; revoke the key whenever you need to cut it off.

Endpoints

Base URL https://storyx.world. All responses are JSON.

MethodPathAuthWhat it does
GET/api/ai/tools/listkey / JWTLists the tools your key can reach, with JSON-Schema inputSchema for each.列出你的 key 可调用的工具,每个附 JSON-Schema inputSchema。
POST/api/ai/tools/execkey / JWTRuns one tool. Body: { "tool": "scene_add", "args": { ... } }执行一个工具。Body:{ "tool": "scene_add", "args": { ... } }
POST/api/ai/tools/confirmkey / JWTExecutes a destructive tool after the human has approved it. Body: { "confirm_token": "..." }用户确认后执行破坏型工具。Body:{ "confirm_token": "..." }
GET/api/ai/tools/keysJWT onlyYour keys, limits and effective quota. Plaintext is never included.你的 key、限额与实际配额,不含明文。
POST/api/ai/tools/keysJWT onlyCreates a key. Body: { "name": "...", "scopes": [...] }新建 key。Body:{ "name": "...", "scopes": [...] }
POST/api/ai/tools/keys/revokeJWT onlyRevokes one of your own keys. Body: { "key_id": "..." }吊销你自己的一枚 key。Body:{ "key_id": "..." }
POST/api/ai/tools/uploadkey / JWTUploads an image or video into your asset space. multipart/form-data with one file part. Returns the OSS URL to hand to scene_add.上传图片或视频到你的素材空间:multipart/form-data,一个文件。返回可直接交给 scene_add 的 OSS 地址。
POST/api/ai/tools/trialnoneMints a trial account key. Rate limited per IP and globally.生成体验账号 key,按 IP 与全局限流。

Scopes

A key only exposes the tools its scopes cover. The server checks every call — a client cannot widen its own permissions.

ScopeToolsPurpose
stories:read6读取Read
stories:write15写入Write
stories:publish1发布Publish
agent:run0保留(未开放)Reserved (not granted)

Tools

Every tool takes JSON arguments and returns JSON. GET /api/ai/tools/list returns the live schema for your key — treat that as the source of truth.

ToolDescription
story_list列出我的故事 —— 列出当前用户的所有故事(含幕数与发布状态)。用户问"我有什么故事"时用。List your stories, with scene counts and publish status.
story_get读取一个故事的完整结构 —— 读取一个故事的完整现状:每一幕的标题/时长/视频是否就绪/分支/触觉。用户问"这个故事现在什么状态"时用。Read a story's full current state: each scene's title, duration, media readiness, branches, haptics, price and hidden flag.
collection_list列出合集(多集故事) —— 读取我的多集故事列表(含每集集数)。想接着做之前的多集时先调它。List your multi-episode collections with their episode counts.
collection_get读取一个合集 —— 读取一个多集故事的详情:有哪些集、每集几幕、上次更新。Read one collection: its episodes, scenes per episode and last update.
collection_exits读取合集的结局表 —— 读取多集故事的「跨集出口」:哪些分支从前面某一集直接跳到了更靠后的集。规划多集伏笔/反转时用。Read a collection's cross-episode exits: branches that jump from an earlier episode to a later one.
plan_check故事体检:分支可达性 / 环 / 缺媒体 —— 发布前自检:档位、月度额度、缺视频的幕、没有任何分支可达的孤儿幕。发布前必须先调一次。Pre-publish check: plan, monthly allowance, scenes missing media, and orphan scenes no branch can reach. Call it before publishing.
story_create新建一个故事 —— 创建一个新故事草稿。每创建一个故事只调一次。返回 story_id,后续所有操作都用它。Create a new story draft. Call once per story; returns the story_id used by every later call.
scene_add往故事里加一幕 —— 给故事追加一幕。三种形态:media_type=video(传 video_url)/ image(传 image_url+media_text,图文幕,文字压在图片上)/ text(只传 media_text,纯文字幕)。用户还没传素材时可传空字符串占位,但那样无法发布。Append a scene. media_type=video (video_url), image (image_url + media_text) or text (media_text only). Optional unlock_price makes it a paid scene.
episode_add往合集里加一集 —— 把一个已经写好的故事作为「一集」加进多集故事(自动分配集号和顺序)。写完一集、用户确认后,要开下一集时调它。Add a finished story to a collection as the next episode (episode number and order are assigned automatically).
collection_create新建合集 —— 创建一个多集故事(可以包含多集的容器)。只有当用户明确要「多集 / 分集 / 第N集」时才用。返回 collection_id。Create a multi-episode collection. Use only when the user explicitly wants episodes. Returns collection_id.
scene_add_batch批量加幕(一次最多 120 幕) —— 一次建多幕。剧本驱动流程用它把整份幕表一次写库(24 幕一次调用,不会撞工具调用上限)。每一幕按 media_type 分三种规格:video 传 video_url 且不传 media_text;image 传 image_url 且必须传 media_text(压在图上的文字,80-300 字);text 只传 media_text。写库前必须先有用户批准的 write 闸门。Create many scenes in one call (up to 120). Same per-scene fields as scene_add. In script-driven flow it needs an approved write gate first.
story_meta_set设置作品信息(封面 / 卖点 / 年龄分级) —— story_id 与 collection_id 二选一;只改传了的字段,传空字符串 = 清空(标题不能清空)。封面先用 asset_upload 上传图片,再把返回的 url 填到 cover_url(只收本站上传的 jpg / png / webp)。age_rating 取 all / 13+ / 16+ / 18+;logline 最多 120 字。多集作品的卖点和年龄分级写到第 1 集。Set a story's cover, one-line logline and age rating (and optionally title / description). Pass story_id or collection_id. Only the fields you send change; "" clears one (title can't be cleared). Upload the cover with asset_upload first and pass its url as cover_url (site-uploaded jpg / png / webp only). age_rating: all / 13+ / 16+ / 18+; logline ≤ 120 chars. For a collection, logline and age rating go on episode 1.
character_list查看聊天角色 —— 一部作品里有哪些角色、状态(没写卡 / 草稿 / 已上线 / 有改动未上线)、是否开放聊天,以及全部幕的 id(写开场白和知识要用)。List a story's chat characters: status (empty / draft / live / changed), whether chat is on, plus every scene id (needed for openers and knowledge).
character_set建角色 / 写角色卡草稿 —— 不给 character_id 就新建。字段 who / voice / cares / off_limits / deflection 只写角色在故事开头的样子;后面的剧情放进 knowledge 并标上幕 id,粉丝看过那一幕角色才知道。openers 是开场白;appears_in 是角色出场的幕(粉丝看过其中一幕才能聊);avatar_url 用 asset_upload 上传的图片。草稿粉丝看不到。Create a character or edit its draft card. Omit character_id to create. who / voice / cares / off_limits / deflection describe the character only as they are at the start; later events go in knowledge with a scene id, unlocked once the fan has seen that scene. openers are greetings; appears_in lists the scenes where the character appears (fans must have seen one to chat); avatar_url is an image from asset_upload. Drafts are not visible to fans.
character_approve角色上线(需要确认) —— 草稿上线并开放聊天;chat_enabled:false 只关聊天。卡片固定字段里写了后面剧情会返回 SPOILER_WARNING,用户确认后带 accept_spoiler_warnings:true。需要 stories:publish 权限;能开几个角色看档位(免费 0 / 专业 1 / 企业不限)。Put a draft card live and open chat (needs confirmation); chat_enabled:false only turns chat off. If the fixed fields mention later scenes you get SPOILER_WARNING; resend with accept_spoiler_warnings:true once the user agrees. Needs the stories:publish scope; the plan limits how many characters can be open (Free 0 / Pro 1 / Enterprise unlimited).
asset_upload上传图片/视频到素材库,返回可直接用的 OSS 链接 —— 把图片或视频上传到 StoryX 素材库,返回可直接用于 scene_add / scene_update 的 https 链接。两种给法二选一:① source_url —— 服务端去抓这个 http(s) 地址(适合把网上已有的视频/图片收进来,大文件首选);② content_base64 —— 直接给 base64 内容(适合小图,≤8MB)。支持图片(.png/.jpg/.jpeg/.webp,≤20MB)和视频(.mp4/.mov/.avi,≤200MB)。Upload an image or video to your asset library and get an https URL for scene_add / scene_update. Pass source_url (server fetches it) or content_base64 (≤ 8 MB). Images ≤ 20 MB, video ≤ 200 MB.
scene_update改一幕的标题/正文/媒体 —— 修改已建好的一幕,最常用来在用户后来给上视频素材后补 video_url。只传你要改的字段,没传的字段保持原样(内部会先读全量行再整行回传,不会误清空别的字段)。Change an existing scene: media, text, title, duration or unlock_price. Fields you omit stay as they are. destructive
branch_set整表设置某一幕的分支 —— 整表设置某一幕的剧情分支(会覆盖该幕原有全部分支)。next_scene_id 必须是用 scene_add 返回过的真实幕 id;留 null 表示故事在此结束。每条分支可带 condition(隐藏条件)与 effects(点击后改变变量):condition 不满足时这条分支在玩家界面上不出现,effects 在玩家点下这条分支时改变变量数值。给某条分支加 timeout_after_ms(毫秒)即可做成「决策倒计时」:观众在这一幕读完内容后必须在该时长内做选择,到点自动执行这条兜底分支(next_scene_id 留空则到点直接进结局页)。同一幕最多一条分支带时长。condition 与 effects 里用到的变量名,必须先用 state_schema_set 定义过,否则会被拦下来。Replace one scene's branches. Each branch can carry a condition, effects, and timeout_after_ms (a decision countdown; at most one per scene). next_scene_id null ends the story. destructive
branch_set_batch批量设置多幕的分支 —— 一次给多幕挂上剧情分支(每幕都是整表覆盖 —— 这一幕原来的分支会被替换掉)。跟 branch_set 一样的字段,但一次能设 40 幕:每条给出 scene_id 和该幕的完整分支列表。写很多分支时用这个,不要一幕一幕调 branch_set(单会话有工具调用次数上限,逐幕调会撞上限)。目标幕必须已经建出来。Replace branches on up to 40 scenes in one call. Same fields as branch_set. destructive
haptic_set设置触觉反馈 —— 设置某一幕的触觉事件(握手/拥抱/心跳/轻拍/亲吻/雨滴/脚步/手机,共 8 类),只在安卓 App 中生效。会覆盖该幕原有触觉。Set a scene's haptic moments (8 types: handshake, hug, heartbeat, pat, kiss, rain, footstep, phone). Felt in the Android app only. Overwrites existing haptics. destructive
interaction_set设置画面热区互动 —— 设置某一幕的局部反应热区(例如点画面下方播一段心跳反应视频再回到原时间点)。会覆盖该幕原有反应。Set a scene's tap hotspots that play a short reaction clip and return to the same moment. Overwrites existing hotspots. destructive
mode_set切换互动模式 —— 设置故事的整体互动模式:navigate=观众点热区推进剧情;explore=探索式。默认 none(AI 问答驱动)。Set the story's interaction mode: navigate (tap hotspots to advance), explore, or none (AI questions drive the story). destructive
collection_set_vars设置合集级状态变量 —— 设置多集故事级别的状态变量(跨集共享,例如「好感度」「已解锁支线」),下一集可以读取并改变它。Set collection-level state variables shared across episodes (e.g. affection, unlocked side paths). destructive
state_schema_set设置故事级状态变量(分支条件靠它) —— 定义这个故事的变量表(每个故事一份,整表覆盖:再调一次会把之前的变量定义替换掉)。变量是分支条件与点击后果的地基 —— branch_set 的 condition 里写 dependence >= 8、effects 里写 {"dependence": 1},用到的变量名必须在这里先定义过,否则会被拦下来。number 类型可以加 min / max 给数值封顶(玩家侧累加后按封顶算)。Define the story's variables (replaces the whole table). Branch conditions and effects may only use variables defined here; numbers can have min / max. destructive
endings_set设置结局表 —— 设置这个故事的全部结局(整表覆盖:再调一次会把之前的结局全部替换掉)。每个结局可以带条件表达式,读者身上的变量满足条件时就走到这个结局。code 是结局的英文标识(≤16 位字母/数字/下划线,不能重复),name 是给读者看的名字,condition 是命中条件(变量表达式,用到的变量必须已在 state_schema 里定义),copy 是结局文案,scene_id 是走到这个结局时停在哪一幕(不填就直接进结局页)。Replace the story's endings. Each ending has a code, a reader-facing name, an optional condition on variables, ending copy and an optional scene to stop on. destructive
h5_publish发布成可分享网页 —— 把故事发布成可公网访问的 H5 页面。会扣额度,且会生成对外链接。发布前必须先 plan_check。Publish the story as a public, shareable H5 page. Uses publishing allowance. Run plan_check first. destructive

Uploading images and video

Scene tools take a URL, never a file. Two ways to turn a file into one.

WayHow it works
asset_upload toolGive it source_url (the server fetches that address) or content_base64 (up to 8 MB). Works from any MCP client.传 source_url(服务端去抓)或 content_base64(≤ 8 MB),任何 MCP 客户端都能用。
POST /api/ai/tools/uploadmultipart/form-data with one file part. Up to 95 MB per request.multipart/form-data,一个文件,单次最大 95 MB。
POST /api/ai/tools/exec
{ "tool": "asset_upload",
  "args": { "filename": "clip.mp4",
            "source_url": "https://example.com/clip.mp4" } }

→ 200 { "ok": true,
         "url": "https://.../uploads/42/video/..._clip.mp4",
         "ossKey": "uploads/42/video/..." }

That URL goes straight into a scene:

POST /api/ai/tools/exec
{ "tool": "scene_add",
  "args": { "story_id": "story_xxx",
            "media_type": "video",
            "video_url": "https://.../uploads/42/video/..._clip.mp4" } }
Images up to 20 MB (.png .jpg .jpeg .webp), video up to 200 MB (.mp4 .mov .avi). Trial accounts cannot upload.

Destructive tools need a human

Ten tools overwrite existing content. They never run on the first call — you get a token instead.

POST /api/ai/tools/exec
{ "tool": "h5_publish", "args": { ... } }

→ 200 { "ok": false, "needs_confirm": true,
         "confirm_token": "pt_xxx", "expires_at": "..." }

Show that token to your user. Only after they say yes:

POST /api/ai/tools/confirm
{ "confirm_token": "pt_xxx" }

→ 200 { "ok": true, ... }
Tokens are single use and expire after 10 minutes. The token is also bound to the tool and arguments that produced it.

Using StoryX from an MCP client

We don’t offer a downloadable MCP connector yet. Claude Code, Cursor, Codex and other MCP clients can still use every tool: the API already returns each tool in MCP format, so an MCP bridge only has to forward a few calls.

Map the MCP methods to these endpoints, sending your key in the X-StoryX-Key header:

tools/list  →  GET  /api/ai/tools/list
               returns { tools: [{ name, description, inputSchema, destructive }] }
tools/call  →  POST /api/ai/tools/exec     { "tool": name, "args": arguments }
confirm     →  POST /api/ai/tools/confirm  { "confirm_token": "..." }
Expose confirm as a tool of its own in your bridge (for example storyx_confirm) and call it only after your user approves. Without it, branch overrides, ending overrides and publishing can never run.

Limits and quotas

Enforced server-side. Account keys have no daily call or cost ceiling — request more and you simply have more.

FieldValueMeaning
1010每个账号最多持有的未吊销 Key 数Max unrevoked keys per account
max_daily_calls_per_keyunlimited单枚 Key 的每日调用天花板Daily call ceiling per key
max_daily_cost_usd_per_keyunlimited单枚 Key 的每日成本天花板Daily cost ceiling per key
default_daily_callsunlimited不声明时的默认每日调用数Default daily calls
quota_scopeper-user额度按账号汇总,不是按 KeyQuota is pooled per account
trial_call_quota_day200体验账号(免注册)的每日调用上限Daily calls for a trial (no signup) account
key_create_per_user_per_hour5同账号每小时最多建 5 枚Keys created per account per hour
key_create_per_ip_per_hour20同 IP 每小时最多建 20 枚Keys created per IP per hour
Account keys are unlimited. There is no daily call ceiling and no daily cost ceiling. The only caps that remain are the number of keys you may hold (10) and how fast you may create them. Trial accounts keep a 200 calls/day ceiling because they need no signup.

Status codes

CodeMeaning
400Bad request — unknown tool, malformed arguments, invalid quota value.请求错误 —— 工具不存在、参数格式错误或配额值非法。
401Missing or invalid key / token.缺少或无效的 key / token。
403Authenticated but not allowed — key lacks the scope, or the tool would touch someone else's story.已认证但无权限 —— key 缺少 scope,或工具会动到别人的故事。
404Not found — unknown key id, or the feature is disabled.未找到 —— key id 不存在,或该功能未开启。
429Rate limited or out of daily quota. The body carries quota with usage and limit.被限流或当日配额用完,返回体里的 quota 有用量与上限。
StoryX Developer API · base URL https://storyx.world
API Keys · Creator studio · Home · Terms · Privacy