Create work
Code Mode: praxis.media.libraries.works.create
HTTP: POST /media/v1/libraries/{library_id}/works
Create a work in a library: a gallery (图文), an article (长文), a product listing (商品图组) or a general work (blocks, 通用作品, Editor.js saved data whose image blocks name library assets in data.asset_id) that orders references to assets of this same library and adds a title and text. Upload or generate the pictures first, then send kind and body. In an article an inline image is written where it should appear. Every asset the body names must be a live image or sticker of this library (a gallery item may also be a video), or the request is refused naming every bad reference and nothing is saved. Price, stock and other unknown fields are refused. Several platform versions of one story are several works with the same series. A work copies no file and changes no asset; creating one is free. Answers 201 with the work. Example: POST /media/v1/libraries/default/works with {“kind”:“gallery”,“series”:“ai-diary-01”,“body”:{“title”:“AI 创业第一天就踩坑”,“items”:[{“asset_id”:“<asset id>”}]}}.
签名
praxis.media.libraries.works.create(args:{path:{library_id:string};body:{/** The work’s kind; it decides which body fields are accepted. */ kind:"gallery"|"article"|"product_listing"|"blocks";/** The kind’s body. */ body:{/** Title, 1 to 100 characters. */ title:string;/** Body text, at most 10000 characters. */ text?:string;/** Topics without the # sign, at most 30 of up to 40 characters. */ topics?:Array<string>;/** Optional cover: an image or sticker asset of this library; without it the first picture is the cover. */ cover?:string;/** Pictures, videos and text segments in order, 1 to 100 entries with at least one asset; each asset appears once. */ items:Array<{/** An image, sticker or video asset of this library; its position in items is its position in the gallery. */ asset_id:string;/** Optional caption for this picture, at most 1000 characters. */ caption?:string}|{/** A text segment shown between pictures, at most 1000 characters. */ text:string}>;/** Display style; defaults to xiaohongshu in the Console. */ style?:"xiaohongshu"|"wechat_mp"|"jike"|"generic"}|{/** Title, 1 to 200 characters. */ title:string;/** Optional summary or digest, at most 500 characters. */ summary?:string;/** Optional author name, at most 60 characters. */ author?:string;/** The article in Markdown, 1 to 100000 characters; every asset:<asset_id> image must be an image or sticker of this library. */ body:string;/** Optional cover: an image or sticker asset of this library. */ cover?:string;/** Display style; defaults to wechat_mp in the Console. */ style?:"xiaohongshu"|"wechat_mp"|"jike"|"generic"}|{/** Listing title, 1 to 200 characters. */ title:string;/** Selling points in order, at most 10 of up to 100 characters. */ selling_points?:Array<string>;/** Parameter rows in order, at most 50. */ attributes?:Array<{/** Parameter name such as 容量, at most 40 characters. */ name:string;/** Parameter value such as 500ml, at most 200 characters. */ value:string}>;/** Main images in order, 1 to 20 image or sticker assets of this library. */ main:Array<string>;/** Detail images in order, at most 100 image or sticker assets of this library. */ detail?:Array<string>;/** SKUs in order, at most 200. */ skus?:Array<{/** The SKU’s value on each spec axis, such as {"颜色":"白"}; 1 to 5 axes; the keys are kept as written. */ spec:{[key:string]:string};/** Optional picture of this SKU: an image or sticker asset of this library. */ asset_id?:string}>;/** Optional product element (material_type product) this listing shows. */ product?:string;/** Display style; defaults to generic in the Console. */ style?:"xiaohongshu"|"wechat_mp"|"jike"|"generic"}|{/** The work’s title, 1 to 200 characters, written explicitly as in the other kinds; lists and sorting use it. */ title:string;/** Optional Editor.js save time in milliseconds, kept as sent. */ time?:number;/** The blocks in order, 1 to 500. */ blocks:Array<{/** Block id, 1–64 letters, digits, _ or -, unique in the body. */ id:string;/** The official Editor.js block type. */ type:"paragraph"|"header"|"list"|"quote"|"delimiter"|"image"|"table"|"checklist"|"warning"|"embed";/** The block’s data in that type’s Editor.js shape. */ data:{[key:string]:unknown}}>;/** Optional Editor.js version string, kept as sent. */ version?:string};/** Groups the platform versions of one story: 1 to 64 characters of a-z, 0-9, _ and -. */ series?:string;/** Caller data such as source, published links and numbers; at most 50 keys and 16 KB as JSON. */ custom?:{[key:string]:unknown}}}):Promise<{/** Always work. */ object:"work";/** Work id (wrk_…). */ id:string;/** Library the work belongs to. */ library_id:string;/** The work’s kind. */ kind:"gallery"|"article"|"product_listing"|"blocks";/** The title, copied from body.title. */ title:string;/** Groups the platform versions of one story; null when unset. */ series:string|null;/** The kind’s body as stored. */ body:{/** Title, 1 to 100 characters. */ title:string;/** Body text, at most 10000 characters. */ text?:string;/** Topics without the # sign, at most 30 of up to 40 characters. */ topics?:Array<string>;/** Optional cover: an image or sticker asset of this library; without it the first picture is the cover. */ cover?:string;/** Pictures, videos and text segments in order, 1 to 100 entries with at least one asset; each asset appears once. */ items:Array<{/** An image, sticker or video asset of this library; its position in items is its position in the gallery. */ asset_id:string;/** Optional caption for this picture, at most 1000 characters. */ caption?:string}|{/** A text segment shown between pictures, at most 1000 characters. */ text:string}>;/** Display style; defaults to xiaohongshu in the Console. */ style?:"xiaohongshu"|"wechat_mp"|"jike"|"generic"}|{/** Title, 1 to 200 characters. */ title:string;/** Optional summary or digest, at most 500 characters. */ summary?:string;/** Optional author name, at most 60 characters. */ author?:string;/** The article in Markdown, 1 to 100000 characters; every asset:<asset_id> image must be an image or sticker of this library. */ body:string;/** Optional cover: an image or sticker asset of this library. */ cover?:string;/** Display style; defaults to wechat_mp in the Console. */ style?:"xiaohongshu"|"wechat_mp"|"jike"|"generic"}|{/** Listing title, 1 to 200 characters. */ title:string;/** Selling points in order, at most 10 of up to 100 characters. */ selling_points?:Array<string>;/** Parameter rows in order, at most 50. */ attributes?:Array<{/** Parameter name such as 容量, at most 40 characters. */ name:string;/** Parameter value such as 500ml, at most 200 characters. */ value:string}>;/** Main images in order, 1 to 20 image or sticker assets of this library. */ main:Array<string>;/** Detail images in order, at most 100 image or sticker assets of this library. */ detail?:Array<string>;/** SKUs in order, at most 200. */ skus?:Array<{/** The SKU’s value on each spec axis, such as {"颜色":"白"}; 1 to 5 axes; the keys are kept as written. */ spec:{[key:string]:string};/** Optional picture of this SKU: an image or sticker asset of this library. */ asset_id?:string}>;/** Optional product element (material_type product) this listing shows. */ product?:string;/** Display style; defaults to generic in the Console. */ style?:"xiaohongshu"|"wechat_mp"|"jike"|"generic"}|{/** The work’s title, 1 to 200 characters, written explicitly as in the other kinds; lists and sorting use it. */ title:string;/** Optional Editor.js save time in milliseconds, kept as sent. */ time?:number;/** The blocks in order, 1 to 500. */ blocks:Array<{/** Block id, 1–64 letters, digits, _ or -, unique in the body. */ id:string;/** The official Editor.js block type. */ type:"paragraph"|"header"|"list"|"quote"|"delimiter"|"image"|"table"|"checklist"|"warning"|"embed";/** The block’s data in that type’s Editor.js shape. */ data:{[key:string]:unknown}}>;/** Optional Editor.js version string, kept as sent. */ version?:string};/** Caller data such as source, published links and numbers; changed with a JSON Merge Patch. */ custom:{[key:string]:unknown};/** Asset ids the body names that have been deleted since; the body keeps them in place and the Console draws a placeholder there. */ missing:Array<string>;/** Bumped by every change; send it back as if_revision to update only an unchanged work. */ revision:number;/** Who created the work: human:<user id>, agent:<agent id> or system. */ created_by:string;/** When the work was created. */ created_at:string;/** When the work last changed. */ updated_at:string;/** Only with expand=assets: every live referenced asset by id, with its URLs and size. */ assets?:{[key:string]:{/** The asset’s material type, such as image or video. */ type:"image"|"video"|"audio"|"voice"|"sticker"|"font"|"text_style"|"text_template"|"animation_preset"|"lut"|"transition_map"|"character"|"product"|"scene"|"brand"|"file";/** Short-lived delivery URL of the asset. */ url:string;/** Short-lived URL of a small picture: the poster of a video, otherwise the asset itself. */ thumbnail_url:string;/** Width in pixels when known. */ width?:number;/** Height in pixels when known. */ height?:number;/** The asset’s display name. */ display_name:string}}}>;参数
| 名称 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| library_id | path | string | 是 | Library ID returned by creation. |
请求体
| 必填 | 内容类型 | 说明 |
|---|---|---|
| 是 | application/json |
响应
| 状态码 | 内容类型 | 说明 |
|---|---|---|
| 200 | application/json | Successful response. |
| 400 | application/json | A selector, cursor, limit or other parameter is invalid; correct the reported field before retrying. |
| 402 | application/json | Request failed; see the error code reference. |
| 403 | application/json | This credential has read-only access to the library; use a write-capable binding for mutations. |
| 404 | application/json | The library or asset is missing, deleted or belongs to another tenant; verify its identifier and owner. |
| 409 | application/json | Request failed; see the error code reference. |
| 413 | application/json | The file exceeds an input limit; provide a smaller source file. |
| 415 | application/json | This media format is unsupported; provide a supported format. |
| 422 | application/json | Request failed; see the error code reference. |
| 429 | application/json | A rate limit was reached; wait before retrying. |
| 501 | application/json | The requested operation is unsupported; choose a supported method. |
| 502 | application/json | Request failed; see the error code reference. |
| 503 | application/json | Historical projections are still being initialized, or library storage is temporarily unavailable; retry shortly and check failureSummary counts_complete. |