Skip to content
中文

Resolve a loose reference to a work, draft or unit

Code Mode: praxis.studio.works.resolve

HTTP: GET /studio/v1/works:resolve

Turn a loose reference into the address the other calls take: a slug, a work title, a draft key or a unit number, as a person or another tool would say it. A hit answers the work slug and, when the reference pointed deeper, the draft key and unit number; a miss answers an empty resolved value with up to three near matches instead of failing. Use it when a person names something instead of an id.

Signature

praxis.studio.works.resolve(args:{query:{/** e.g. "wu-gang" */ ref:string}}):Promise<{/** The address the reference maps to, or null when nothing matched; a null here is a normal answer, not an error. */ resolved:{/** Identifier of the matched work, from which the slug beside it is derived. e.g. "wk_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ work?:string;/** Slug of the matched work, the value later calls should use. e.g. "wu-gang" */ slug?:string;/** Draft key the reference pointed into, present only when the reference named one. e.g. "novel" */ draft?:string;/** Unit number the reference pointed at, present only when the reference named one. e.g. 12 */ unit?:number};/** Up to three near matches when resolved is null, so the caller can offer a correction instead of a dead end. */ suggestions:Array<{/** Value to use instead, already in the form the resolve call accepts. e.g. "wu-gang" */ ref?:string;/** Human-readable name of that target, shown so a person can confirm the guess. e.g. "乌江" */ label?:string}>}>;

Parameters

NameInTypeRequiredDescription
refquerystringyesWhat the caller said, such as a work slug, a work title, a draft key with a unit number like novel#12, or a title with a typo; it is matched loosely and never has to be an identifier.

Responses

StatusContent typesDescription
200application/jsonThe address a loose reference maps to, or near matches when nothing matched exactly.
400application/jsonINVALID_PARAMS means a field is missing, malformed or not allowed for this resource; correct the named field and repeat the call.
401application/jsonThe API key is missing, invalid or carries no organization; send a valid organization key in the Authorization header.
500application/jsonINTERNAL means the request could not complete; re-read the resource before retrying a write, because the write may already have landed.