Project Σ API

API version 1 · OpenAPI 3.0.3 · live spec at /api/openapi.json

DB-native character library server. Clients do zero heavy lifting: querying, filtering, sorting, and windowing all happen server-side. All timestamps are unix milliseconds. Every collection GET says what it answers in its x-collection: a page ({items, total, limit, nextCursor}: 100 rows unless limit asks, at most 1000 unless the operation names its own numbers, a limit outside them refused by name; a reader that needs the whole set walks nextCursor with after, and count=false skips the total), the whole set as a plain array or document with what bounds it. info.version is the API's own version (apiVersion on /api/health): it moves only when a route is removed or a shape a client reads changes. From the first public release on, an operation marked deprecated here leaves in a later release, and a form a list still answers until a later API version is named in its x-collection deprecated, with that version in until. Multi-user mode (server.yaml multiUser: true) gates every user surface behind an HttpOnly SameSite=Strict session cookie from /api/auth/login; single-user mode needs no auth and everything resolves to the default user. A 401 that means "sign in" carries X-CL-Auth: required. A 401 without it is no request to sign in: a refused login or password change under /api/auth, or a site's refusal a provider route passes through (a wrong password at a site's login, an expired site token). While the app updates itself, from its merge to its restart, every write (a non-GET request outside /api/app/update, extension routes included) is answered 503 with words: try it again after the reload. A request may send X-UTC-Offset, the reader's clock in minutes east of UTC, and X-Time-Zone, its IANA zone (Europe/Paris): the time macros a prompt or a sent message holds ({{time}}, {{date}}) answer in the offset, and a stored date written without a zone (a message's createdAt, {{idle_duration}}) is read in the zone, else at the offset, else in the server's own.

characters

Cards, avatars, import/export

GET /api/characters Query the library (windowed, sorted, filtered server-side)
CollectionA page: 100 unless limit asks, at most 1000, walked by its cursor (after, nextCursor).
Parameters
ParameterInTypeDescription
q query string search over the fields qIn names. name, nickname, creator, tags, listingName and tagline match q as one substring. The card-text fields (notes, description, firstMessage, altGreetings) match it word by word: every word must appear inside some word of those fields ("agon" finds "dragon"), capitals and accents ignored ("cafe" finds "café"), and a "quoted run" must appear as those whole words in that order. Punctuation separates words, so a q of punctuation alone matches no card text. The fields qIn names are ORed
qIn query string fields q searches: name, nickname, creator, notes, tags, listingName, tagline, description, firstMessage, altGreetings (default: name,nickname,creator). The card-text fields answer from the full-text index, except a word found inside too many indexed words (most words of one or two letters), which reads the text of every card instead and is slower
match query string full-text search in FTS5 query syntax over name/creator/nickname/creator_notes/description/personality/scenario/first_mes/mes_example/system_prompt/alternate_greetings/post_history_instructions/depth_prompt: words AND by default, OR/NOT, "phrases", prefix*, column filters like description:dragon. Composable with every other filter
words query string plain text in place of match, over the same full-text columns: every word of two letters or more required, each matching as a prefix ("drag" finds "dragon"; a lone letter is passed over); a text with no such words matches no character. A filter takes it too
ids query string restrict to these character uuids (bulk resolve/existence check)
notIds query string leave out these character uuids (a selection over a filter that the reader deselected some of)
creator query string exact creator (case-insensitive)
tag query string must carry EVERY listed tag (AND, case-insensitive)
anyTag query string must carry at least one listed tag (OR)
excludeTag query string must carry none of the listed tags
excludeTagAll query string rejected only when carrying EVERY listed tag (the exclude-all mode)
provider query string linked to this provider id (chub, wyvern, ...)
linked query 1 | true | yes | 0 | false | no linked to any provider (true) / to none (false)
hasUrl query 1 | true | yes | 0 | false | no the card holds an http substring anywhere: a cheap SUPERSET of every card with remote media, in any field (the media-localization prefilter)
fav query 1 | true | yes | 0 | false | no favorites only / non-favorites only
locked query 1 | true | yes | 0 | false | no update-locked only / unlocked only
mediaLocalized query 1 | true | yes | 0 | false | no media localization completed (the bulk sweep skips these) / not yet
loreDismissed query 1 | true | yes | 0 | false | no the embedded-lorebook hint was dismissed for this character / not
world query string exact primary lorebook name
hasWorld query 1 | true | yes | 0 | false | no has a primary lorebook REFERENCE (extensions.world)
hasLorebook query 1 | true | yes | 0 | false | no has an EMBEDDED character_book in the card
hasSystemPrompt query 1 | true | yes | 0 | false | no card carries a non-empty system_prompt
altGreetingsMin query integer at least this many alternate greetings; also altGreetingsMax
specVersion query string exact card spec version, for example '3.0' or '2.0'
tokensMin query integer token estimate lower bound
tokensMax query integer token estimate upper bound
createdAfter query integer createdAt >= (ms); also createdBefore
importedAfter query integer importedAt >= (ms); also importedBefore
updatedAfter query integer updatedAt >= (ms); also updatedBefore
sort query name | created | imported | updated | tokens | relevance | random | string matching ^ext\.[a-z0-9][a-z0-9-]*\.[a-z][a-zA-Z0-9_]*$ an unknown value is refused 400 naming the set; default name; relevance (bm25, best first) requires match or words and ranks at most 10000 characters: a match the filter leaves broader is refused 400 (narrow it, or sort by another key); random = uniform sample (offset-only, no cursor). An extension the account has on adds its declared sort keys as ext.<id>.<key> (listed in its inventory row's serverQuery): the characters with a value first, in its order, then the rest by name ascending whichever the order; offset-only, no cursor
order query asc | desc default asc
limit query integer page size: default 100 (an ids request: its id count), at most 1000, or 10000 with idsOnly; past it, walk nextCursor with after. A whole library is never one answer
offset query integer page start (with limit); cost grows with depth - prefer after for scrolling
after query string keyset cursor from a prior response nextCursor: O(page) at any depth. Not available with sort=relevance, sort=random or an extension's sort key
count query 1 | true | yes | 0 | false | no count=false skips the total (null in the envelope): the count leg dominates broad queries on huge libraries; scroll clients use nextCursor for has-more
rules query string URL-encoded JSON array of structured filter rules [{field, op, value}] - the advanced-filter model evaluated server-side. Identity and library: name, nickname, creator, creatorNotes, version, listingName, tags, favorite, providerLink, playlist, playlistName, nameOverride, uid (the id of the character itself: contains or equals), tokens, cardSpec. Card text (unindexed: a rule reads the card of each character it tests, so it costs more the broader the set): description, personality, scenario, firstMessage, exampleDialogue, systemPromptText, postHistoryInstructions, depthPrompt. Presence: embeddedLorebook, systemPrompt, altGreetings, linkedLorebook. Dates: dateAdded, dateCreated, dateModified, lastChat. An extension the account has on adds its declared fields as ext.<id>.<key> (their ops are in its inventory row's serverQuery). Unknown field/op fails 400 naming the valid set
idsOnly query 1 | true | yes | 0 | false | no project only {id, fav} per item (no tags or links) - select-all-matching, whose toolbar star reads fav, and cheap id enumeration; fields= adds more of each character to it
fields query string a projection the verb names: with idsOnly, the fields to carry beside id and fav (name, creator, characterVersion, mediaLocalized, links); on a list, creatorNotes to carry the notes whole and creatorNotesExcerpt their plain-text excerpt, neither of which a row carries unless named. An unknown name is 400
Responses
200 CharacterEnvelope OK
400 Error invalid parameter, match and words both, or sort=relevance over more than 10000 matching characters
POST /api/characters/match In-library match probe (max 500 candidates): per remote card, the library's namesakes and how likely the card is already here. The name is read as the duplicate check reads it (version and edit suffixes and edge decoration stripped, compatibility-folded, lowercased, the part before a || as a name of its own) and matched against the exact name, names starting with it as a word (a space, dash, pipe, colon, comma or period after it) and names that are a word of it, the same over the page names provider links carry (answered with the page name as the row name); each row graded exact or prefix, a row the rule does not relate left out, a name under three characters relating to nothing. One row per (id, name). The score, 0 to 100: a namesake by the same creator 95 (a word prefix 70); a text within reach of a namesake's description, first message or creator notes 90 (70); otherwise the name alone, worth more the longer it is and the fewer authors hold it here, less when the card's creator is a known other one. Placeholder creators (anonymous, unknown and the like) are no author
Request body application/json
FieldTypeDescription
candidates required array<object>
Responses
200 array<object> aligned by candidate index
400 Error bad candidates
503 Error the library closed while the probe ran
GET /api/characters/duplicates The duplicate scan over the library, on the server: every pair whose names relate (exactly, as a word of the other, or within a few letters) or whose description and first message are one text under two names, scored on both full cards. A pair by two different authors whose texts are far apart is never scored: a shared name alone is no duplicate. Two cards linked to different listings on one site are weighed by their own text (description or first message: at 0.6 word overlap the same card, under 0.3 another), else their creator notes (0.4 and 0.3); another card is never listed, one the text cannot place is listed with that reason. Characters linked to one provider path group at 100. Answers groups of ids with their scores, never the characters; a client reads the members it shows by id. One scan per library at a time, a second request joins it
CollectionThe whole set: a scan: groups of ids and scores, never rows.
Responses
200 object groups best first: by confidence, then by the best score in the group
POST /api/characters/duplicates/match One incoming card against the library (the pre-import check): the link arm (its provider path or id already linked here: inside providerId, exact or a path prefix either way; under the other providers, exact and only for a uuid key, which names one card wherever it is linked; with no providerId, exact under every provider), the name arm (every namesake, matched as POST /api/characters/match matches them), the creator arm (a creator the probe begins, its characters whose names relate loosely) and the text arm (a description that is the same text under another name), every candidate scored as the scan scores it (a candidate linked to another listing on the site the probe names, providerId with fullPath or externalId, is weighed as the scan weighs two listings: another card is left out, one its text cannot place is answered with that reason; textCompared says whether the two cards had their own text to compare). Answers matches by id with their scores, best first; a link hit scores 100
Request body application/json
FieldTypeDescription
name string
creator string
fullPath string
externalId string
providerId string
definition object
Responses
200 object OK
400 Error no name, fullPath or externalId
503 Error the library closed while the match ran
POST /api/characters/import Import a card PNG (raw body). Never overwrites: triages to new (adopting a free embedded cl.uid as the id), identical-skip (content hash), or diverged-skip (uuid taken / provider link matched), with onExisting=copy as the force-new override
Parameters
ParameterInTypeDescription
name query string source filename hint, used for logging and the import summary. NOT an identity: two unrelated cards sharing a filename import as two characters. Identity heals through the embedded cl.uid / version_uid aliases and the provider link
onExisting query string only 'copy' is accepted: force a new character that claims nothing. Absent runs the no-overwrite triage (new / identical-skip / diverged-skip); anything else is 400
source query string the provider namespace this import came through. One link per character: a card embedding several provider namespaces keeps only one link, the source's, else the first in the namespaces order GET /api/extensions answers
Request body image/png
string (binary)
Request body application/octet-stream
string (binary)
Responses
200 object {id, created, name, row}; created:false means it resolved onto an existing character; row is the character as GET /characters?ids= answers it, so the importer takes it in without a second read; the picture is /avatars/{id}.png
400 Error empty body, a bad onExisting, or a source that is not a provider namespace
415 Error not a PNG (other card files go through /import/stage)
422 Error no embedded card
POST /api/characters/import/stage Stage any card file for import: a card PNG, or a charx (Character Card V3's container: a zip with card.json at its root, or one written after a JPEG, as RisuAI downloads can be). The raw body streams to the account's staging folder and the card is read, not imported; a client may amend it (tags, a provider link) and commit with POST /import/stage/{stageId}. A stage keeps an hour. For a charx the card is answered as the import will store it: data.assets keeps the main icon as ccdefault: and drops the other embedded files, which become gallery rows
Parameters
ParameterInTypeDescription
name query string source filename hint, as on /import: carried to the import as its sourceName, never an identity
Request body application/octet-stream
string (binary)
Responses
200 object OK
400 Error empty body; or a charx the archive reader refuses: a member past the import cap, members unpacking past the archive budget, or a corrupt member (its local header, its checksum, or inflating past its declared size)
413 Error a card PNG past 100 MB
415 Error a Content-Type other than application/octet-stream, image/png, image/webp or image/jpeg (a form or JSON post is refused before it is read); or a body that is neither a card PNG nor a charx
422 Error no card in the file, or a card.json that is not JSON
POST /api/characters/import/stage/{stageId} Import a staged card file, once: the card as staged, or the amended card from the body, with the file's picture as the avatar (a PNG minus its card chunks, any other image converted, a placeholder when a charx has none) and a charx's other embedded files as gallery rows. Triages exactly as /import does (new / identical-skip / diverged-skip; an identical skip still gains the gallery rows it lacks, a diverged one gains nothing). The stage is claimed first and gone once the import ran; a refusal (a bad amended card, or an extension's store guard) leaves it for another try
Parameters
ParameterInTypeDescription
stageId path string the id the stage call answered
Request body application/json
FieldTypeDescription
card object the amended card (V1, V2 or V3 shape); omitted, the staged card imports. A charx card's embedded data.assets entries are folded again, so the stored card never points into the container
onExisting copy as on /import
source string as on /import: the provider namespace this import came through
Responses
200 object {id, created, name, media, row} (media: the gallery rows added; mediaFailed, when any: the files that could not be written, the import standing; row: the character as GET /characters?ids= answers it; the picture is /avatars/{id}.png), or {skipped, reason, id, created:false, name, media}
400 Error a stage id outside the uuid grammar, bad onExisting or source, or an amended card that is not a card
404 Error no such stage: committed, dropped, or kept past its hour
422 Error no card in the file
DELETE /api/characters/import/stage/{stageId} Drop a stage without importing it
Parameters
ParameterInTypeDescription
stageId path string the id the stage call answered
Responses
200 Ok OK
400 Error a stage id outside the uuid grammar
404 Error no such stage
POST /api/characters/{id}/replace Write an incoming card onto an existing character (the browse import's Replace): the import lands on this id, so the character keeps its id, favourite, update lock, chats, linked lorebooks, gallery, versions and every extension's data about it, its tags gain the card's (the Import Rules applied), the importing provider's link replaces its link, and the card (its embedded book included) and the picture are the incoming ones. The card as it stood, with its picture, is snapshotted first when either changes, the snapshot and the replace landing together or not at all ("Before Replace from <source>", a regular snapshot). The import routes never overwrite; this one names its target. Its aliases are recorded without taking one another character holds, and when the card changes its mediaLocalized flag is cleared (the incoming card brings its own remote media). A character whose regex scripts were allowed goes back to unanswered when the incoming card's scripts are not the ones allowed, so they wait for a new answer. An incoming card and picture equal to the ones held write nothing: no snapshot, no stamp, no report; a picture alone is written and reported without moving updatedAt. A card PNG body (image/png, ?source=), or JSON { stage, card?, source? } for a staged card file (the stage is claimed and gone once the replace ran; a refusal before the write hands it back; a charx's embedded files join the gallery under names it lacks, and a file that cannot be written is counted in mediaFailed, never a failed replace)
Parameters
ParameterInTypeDescription
id path string character uuid
source query string with a PNG body: the provider namespace the card came through, as on /import
Request body image/png
string (binary)
Request body application/octet-stream
string (binary)
Request body application/json
FieldTypeDescription
stage required string a stage id from /import/stage
card object the amended card, as on the stage commit
source string as on /import
Responses
200 object {id, created:false, replaced:true, name, snapshot, row} (row: the character as GET /characters?ids= answers it; snapshot: the version id of the card as it stood, null when the card and the picture were the ones held; media with a staged charx: the gallery rows added; mediaFailed, when any: its files that could not be written)
400 Error no PNG and no stage, a stage id outside the uuid grammar, a bad source, or an amended card that is not a card
404 Error no such character, or no such stage
415 Error an image or octet-stream body that is not a card PNG (a charx is staged and sent as { stage }); any other body without a stage is a 400
422 Error no card in the file
GET /api/characters/{id} Full card (tags, links and the per-character flags composed in)
Parameters
ParameterInTypeDescription
id path string character uuid
Responses
200 Character OK
404 Error not found
PATCH /api/characters/{id} Dot-path card field updates and/or the per-character flags. Only what changes is written and reported: a patch that changes nothing writes nothing and reports nothing, and a change to the flags alone (fav, update lock, mediaLocalized, loreDismissed) leaves updatedAt where it was. updatedAt moves only when the content of the card itself changes: a change to its tags, its provider link or its lorebooks is written and reported but never moves it
Parameters
ParameterInTypeDescription
id path string character uuid
Request body application/json
FieldTypeDescription
fields object dot-path updates, for example {'name': 'X', 'extensions.chub.tagline': 'Y'}; the root key must be a V2 or V3 card field or extensions (anything else is refused 400 naming the path, so a mistyped path never mints a junk key; custom data belongs under extensions); extensions.fav and extensions.update_locked set the favourite and update-lock flags (never stored in the card); an extensions.{provider} write sets the character's provider link (one link per character: a whole-namespace object REPLACES any existing link, null unlinks, and a nested write requires that namespace's link to exist), and tags sets its tags
fav boolean
mediaLocalized boolean a per-character flag, like fav; never card content
loreDismissed boolean a per-character flag, like fav; never card content
Responses
200 Character OK
400 Error bad update, incl. a card that would lose its name
404 Error not found
DELETE /api/characters/{id} Delete a character with everything that is its own: chats, gallery, snapshots, its tag, lorebook, playlist and provider links, avatar and thumbnails
Parameters
ParameterInTypeDescription
id path string character uuid
Responses
200 Ok OK
404 Error not found
POST /api/characters/link-match The ranking of /api/characters/{id}/link-match for a card that is not in the library, such as a card file about to be imported: the site's search hits (max 500) are judged against the card sent, by the same rule and with the same answer. Nothing is stored
Request body application/json
FieldTypeDescription
card required object the card's name and the texts the rule scores; anything else on it is ignored
hits required array<object>
Responses
200 object every hit once, best first
400 Error no card or a card with no name; no hits, more than the maximum, or not an array
503 Error the library closed while the ranking ran
POST /api/characters/{id}/link-match A provider site's search hits (max 500) ranked against this character by the duplicate check's rule, for linking it to a listing: each hit is read as a card with its name, its creator and its public text as creator notes, its listing title a name of it too, and scored as Find Duplicates scores a pair. A hit is confident, sure enough to link without asking, when its name or listing title is the character's exact name (version and edit suffixes folded) and either both carry the same real creator, or one side has no real creator (none, or a placeholder such as anonymous) and the hit's text reads as the character's creator notes, description or first message over its length (four in ten of their distinct words shared, or more). Ranked confident first, then a hit by the character's own creator, then a name as written before a suffixed one, then by score, then in the order sent. Text shows whose words a listing holds and not which listing it is, so two hits that are confident by text alone are both ranked confident and neither is the one to link
Parameters
ParameterInTypeDescription
id path string character uuid
Request body application/json
FieldTypeDescription
hits required array<object>
Responses
200 object every hit once, best first
400 Error no hits, more than the maximum, or not an array
404 Error not found
503 Error the library closed while the ranking ran
PUT /api/characters/{id}/avatar Replace the avatar image (PNG bodies get card chunks stripped; other formats are converted to PNG server-side - avatars are pure images)
Parameters
ParameterInTypeDescription
id path string character uuid
Request body image/*
string (binary)
Request body application/octet-stream
string (binary)
Responses
200 Ok OK
400 Error empty body
404 Error not found
415 Error not a decodable image
GET /api/characters/{id}/export The character as a card file freshly built from the library (tags/links/identity re-emitted): a card PNG, or a CHARX holding the card as V3 with its picture and every gallery file
Parameters
ParameterInTypeDescription
id path string character uuid
format query png | charx png (the default) or charx. A charx of a V2 card says V3 in its card.json and records what the export added in extensions.cl.charx, so importing that file back gives the card as stored (identical); a file another app has changed since comes in as the V3 card it became
Responses
200 image/png string (binary)
application/zip string (binary)
the file as an attachment
400 Error a format other than png or charx
404 Error not found
POST /api/characters/tally How many characters a set holds and how many of them are favourites: a selection's count and its star in one read. The set is charIds (at most 10000 a request, so a larger selection is counted in parts, which add up, or by its filter) or filter (a GET /api/characters query string, read the list's way; sort, order, paging and count ignored; notIds leaves out the ids a reader deselected), never both. A POST so the filter rides the body
Request body application/json
FieldTypeDescription
charIds array<string> at most 10000
filter string a GET /api/characters query string
Responses
200 object OK
400 Error neither charIds nor a filter, both, more than 10000 charIds, a filter parameter refused in the list's words, or a filter parameter the list does not take
POST /api/characters/fav Bulk favourite flip, the set named by charIds or by filter, never both. A favourite never moves a character's updatedAt. By charIds, all or nothing, touching only the characters whose favourite moves: those are counted (touched) and listed in affected in the order named, an unknown id in skipped, and a named character that already held the value in neither, answered {ok, touched, affected, skipped}; at most 10000 ids a request, so a larger selection is sent as several requests, each landing whole, or as its filter. By filter (a GET /api/characters query string, read the list's way; notIds leaves out the ids a reader deselected): the set is fixed, then a job writes it in batches of a thousand characters, each batch landing whole, touching only the characters whose favourite moves and reporting them by id; answered at once (202) with the job, whose answer {changed} (GET /api/jobs/{id}) counts the characters that moved, the rest of its total already were
Request body application/json
FieldTypeDescription
charIds array<string> at most 10000
filter string a GET /api/characters query string
fav required boolean
Responses
200 object by charIds {ok, touched, affected, skipped}
202 object by filter: the job
400 Error no charIds, more than 10000 of them, charIds and a filter both, fav not a boolean, a filter parameter refused in the list's words, or one the list does not take
POST /api/characters/flags Bulk per-character flags (mediaLocalized, loreDismissed), touching only the characters whose value changes; a flag never moves a character's updatedAt. charIds names the characters, all or nothing, at most 10000 a request, so a larger selection is sent as several requests, each landing whole (answered like /fav: the ids that moved in affected, an unknown id in skipped). all: true sets the flags across the whole library: the characters whose value moves are fixed, then a job writes them in batches of a thousand, each batch landing whole and reporting its characters by id; answered at once (202) with the job, whose answer {changed} (GET /api/jobs/{id}) counts the characters that moved
Request body application/json
FieldTypeDescription
charIds array<string> at most 10000
all boolean
mediaLocalized boolean
loreDismissed boolean
Responses
200 object by charIds {ok, touched, affected, skipped}
202 object all: true: the job
400 Error bad body: exactly one of charIds or all, at least one flag, at most 10000 charIds
POST /api/characters/delete Bulk delete: each character with everything that is its own (as DELETE /api/characters/{id}), the set named by charIds or by filter, never both. By charIds, all or nothing, so an extension's store guard refusing any id deletes none; missing ids reported, the rest proceed; at most 100 ids a request, so a larger selection is sent as several requests, each landing whole. By filter (a GET /api/characters query string, read the list's way; notIds leaves out the ids a reader deselected): the set is fixed, then a job deletes it in batches of 100 characters, each landing whole and reporting its ids deleted with no origin (every tab lets go of them, the starting one included); answered at once (202) with the job, whose answer {changed, missing} (GET /api/jobs/{id}) counts the characters deleted and the ones gone before their batch. A store guard refusing a batch fails the job in its words, the batches before it deleted. expect, the count the reader confirmed, refuses a set whose size moved since (409 with its total; nothing deleted)
Request body application/json
FieldTypeDescription
charIds array<string>
filter string a GET /api/characters query string
expect integer with filter: the count of characters the reader confirmed
Responses
200 object by charIds {ok, touched, deleted, missing}
202 object by filter: the job
400 Error bad body, more than 100 ids, charIds and a filter both, expect not a count, a filter parameter the list refuses or does not take, or an extension's store guard refused an id: nothing was deleted, the error is the guard's words
409 object by filter with expect: the set holds another count of characters now (total); nothing was deleted
POST /api/characters/fields-apply Bulk dot-path field writes: each entry applies as PATCH /api/characters/{id} applies it (provider links, lorebooks and tags included) and lands whole on its own; failures are reported per item, never fatal. At most 5000 entries a request, so a longer list is sent as several requests
Request body application/json
FieldTypeDescription
updates required array<object> at most 5000
Responses
200 object {ok, touched, affected, failed: [{id, error}]}
400 Error bad body, or more than 5000 entries: nothing was written

media

Per-character gallery media (uid-keyed files), chat attachments and media download jobs

GET /api/characters/{id}/media A page of a character's gallery, in the order its rows were added (by id); a reader that needs the whole gallery walks nextCursor
CollectionA page: 100 unless limit asks, at most 1000, walked by its cursor (after, nextCursor).
Parameters
ParameterInTypeDescription
id path string character uuid
limit query integer rows a page: default 100, at most 1000; past it, walk nextCursor with after
after query string the nextCursor of the page before: the rows after it, O(page) at any depth
count query 1 | true | yes | 0 | false | no count=false skips the total (null in the answer); a walk reads nextCursor for has-more
Responses
200 object OK
400 Error a limit outside 1 to 1000, an after that is not a cursor, or a count that is not a boolean word
404 Error character not found
POST /api/characters/{id}/media Upload media (raw body). A content-hash duplicate is not stored again ({skipped:true, reason: "content", duplicateOf}), and when that item has no sourceUrl the supplied one is recorded on it ({adopted:true}), so a later lookup by that url finds it
Parameters
ParameterInTypeDescription
id path string character uuid
name query string display name; when the bytes are another kind of file than its extension says (a video named .png), the stored name takes the bytes' extension
sourceUrl query string origin url; dedupes by url hash
Request body */*
string (binary)
Responses
200 Media row, or {skipped:true} when already present
400 Error empty body, or a name with nothing usable as a filename
404 Error character not found
POST /api/characters/{id}/media/copy Copy another character's whole gallery into this one, on the server: each file gets a new row and a new stored file, a file whose bytes or source url this character already holds is skipped, and a row whose file is gone is counted as missing. Display names are kept unless this character holds one already, and source urls ride along, so a later download of the same url is a skip
Parameters
ParameterInTypeDescription
id path string character uuid
Request body application/json
FieldTypeDescription
from required string the character whose gallery is copied
Responses
200 object {copied, skipped, missing}
400 Error from missing, or the same character
404 Error character not found (either one)
POST /api/characters/{id}/media/from-url Server-side media download (no CORS, no proxy chain); dedupes by url hash, then by content hash. A content duplicate with no sourceUrl takes this url ({adopted:true} in the skip), so the next download of it is a url-hash skip; one already naming a different url keeps it. The download stops when the request is dropped
Parameters
ParameterInTypeDescription
id path string character uuid
Request body application/json
FieldTypeDescription
url required string
answerMs integer how long the host gets to start answering, 1000 to 60000 (the default); the whole download keeps its 60 second limit
Responses
200 Media row, or {skipped:true} when already present
400 Error http(s) url required
403 Error the net guard refuses the url: an empty host, or one resolving to a private or local address
404 Error character not found
413 Error file too large
415 Error not media
502 Error upstream failed, answered empty, or timed out; kind "no-answer" rides along when the host itself gave no answer (silence, a dropped connection, or a 502, 503 or 504)
DELETE /api/media/{mediaId} Delete a media row + file
Parameters
ParameterInTypeDescription
mediaId path string media row id
Responses
200 Ok OK
404 Error not found
GET /api/chats/{id}/attachments A chat's own gallery: the pictures and video it holds beside its character's, in the order they were added, each with how many of its messages show it
CollectionThe whole set: one chat's gallery.
Parameters
ParameterInTypeDescription
id path string character uuid
Responses
200 object OK
404 Error chat not found
POST /api/chats/{id}/attachments Add a picture or video to the chat's gallery (raw body). Bytes the chat holds already answer that attachment, created false, and nothing is stored again. An image's size is read and kept
Parameters
ParameterInTypeDescription
id path string character uuid
name query string display name; when the bytes are another kind of file than its extension says (a video named .png), the stored name takes the bytes' extension
Request body */*
string (binary)
Responses
200 object OK
400 Error empty body, or a name with nothing usable as a filename
404 Error chat not found
415 Error neither a picture nor video
DELETE /api/attachments/{attachmentId} Remove an attachment and its file. Every message that showed it stops showing it; their ids are answered
Parameters
ParameterInTypeDescription
attachmentId path string attachment id
Responses
200 object OK
400 Error an id that is not a positive integer
404 Error not found
GET /api/media-jobs A page of the media download queue: pending and active jobs, one per character, oldest first by id, so a job enqueued later lands past any cursor held (a job goes with its character). An active job carries stale: true once its worker stopped renewing the lease, so a resuming tab may take it, and leaseLeftMs, the milliseconds until its lease runs out as the server counts them (0 once stale; null on a pending job), so a tab that skipped it looks again then
CollectionA page: 100 unless limit asks, at most 1000, walked by its cursor (after, nextCursor).
Parameters
ParameterInTypeDescription
limit query integer rows a page: default 100, at most 1000; past it, walk nextCursor with after
after query string the nextCursor of the page before: the jobs after it, O(page) at any depth
count query 1 | true | yes | 0 | false | no count=false skips the total (null in the answer); a walk reads nextCursor for has-more
ids query string job ids, at most 1000: those jobs alone, a page at their own count (limit defaults to it)
Responses
200 object OK
400 Error a limit outside 1 to 1000, an after that is not a cursor, ids that are not job ids or more than 1000 of them, or a count that is not a boolean word
POST /api/media-jobs Enqueue (or re-enqueue) the one job a character can hold: a pending job takes the new name and phases, an active job is left to the worker
Request body application/json
FieldTypeDescription
charId required string
name string
phases array<string>
Responses
200 object the job
400 Error charId must be a character uuid; phases must be an array of strings
404 Error character not found
POST /api/media-jobs/batch Queue a set's characters for a media download: those with a remote url in the card or a provider link get one pending job each (a pending job is kept, an active one left to its worker). The set is charIds, a selection's filter, or all: true for the library. rescan (default true, false with all) scans the set again: the processed mark of each character queued is cleared and comes back as its job finishes; false leaves the characters processed before out. Runs to its end once begun
Request body application/json
FieldTypeDescription
charIds array<string>
filter string
all true
rescan boolean
Responses
200 object total: the set (less the processed when rescan is false); queued: the characters with a pending job now; noMedia: those with no remote url and no provider link; active: those whose job a worker is running
400 Error charIds, filter or all, one of them; at most 10000 charIds a request; a filter the list cannot read; rescan or all of the wrong kind
503 Error the library closed while the set was queued
PATCH /api/media-jobs/{id} The worker's claim and its lease: { status: 'active' } takes a pending job, or an active one whose worker stopped renewing the lease; { touch: true } renews the lease of an active job; { status: 'pending' } hands a job back
Parameters
ParameterInTypeDescription
id path string job id
Request body application/json
FieldTypeDescription
status pending | active
touch boolean
Responses
200 Ok OK
400 Error bad status
404 Error job not found, or no active job to touch
409 Error another worker holds this job
DELETE /api/media-jobs/{id} Drop a job (finished, failed, aborted or removed by the user)
Parameters
ParameterInTypeDescription
id path string job id
Responses
200 Ok OK
400 Error numeric id required
404 Error job not found

backgrounds

Chat wallpapers: a flat image library plus the bindings that decide which chat wears which

GET /api/backgrounds The wallpaper library, newest first. Flat and NOT character-scoped: a background outlives the gallery it was promoted from. usedBy counts the bindings pointing at each row
CollectionThe whole set: the reader's wallpaper library.
Responses
200 array<Background> OK
POST /api/backgrounds Upload image bytes (raw body). Deduped library-wide by content hash, and by url hash when ?sourceUrl= is given
Parameters
ParameterInTypeDescription
name query string display name; the bytes decide what the file is (a video named .png is refused), and the stored name takes their extension
sourceUrl query string provenance, and makes a re-run idempotent
Request body application/octet-stream
string (binary)
Responses
200 Background row, or {skipped:true, reason:"url"|"content", duplicateOf} when the bytes are already held
400 Error empty body
415 Error not an image
POST /api/backgrounds/from-url Server-side download into the library. Images only; same dedup ladder as the upload
Request body application/json
FieldTypeDescription
url required string
Responses
200 Background row, or {skipped:true}
400 Error http(s) url required
403 Error the net guard refuses the url: an empty host, or one resolving to a private or local address
413 Error file too large
415 Error not an image
502 Error upstream failed or timed out; kind "no-answer" when the host itself gave none
POST /api/backgrounds/from-media/{mediaId} Promote a gallery image into the library. The bytes are COPIED server-side, never shared with the media row, because media cascades away with its character
Parameters
ParameterInTypeDescription
mediaId path string media row id
Responses
200 Background row, or {skipped:true} when those bytes are already held
404 Error media or file not found
415 Error not an image
PATCH /api/backgrounds/{id} Rename: the display name alone changes; the file, its url and its format stay as they are
Parameters
ParameterInTypeDescription
id path string background row id
Request body application/json
FieldTypeDescription
displayName required string
Responses
200 Background OK
400 Error bad name
404 Error not found
DELETE /api/backgrounds/{id} Delete the row + file. Refused while any binding points at it unless ?force=true, which deletes it and returns those scopes to inherited
Parameters
ParameterInTypeDescription
id path string background row id
force query 1 | true | yes | 0 | false | no delete even though it is in use
Responses
200 object {ok, unbound}
404 Error not found
409 Error in use; body carries usedBy
GET /api/backgrounds/resolve What this chat actually wears. Walks chat > character > global and stops at the FIRST binding, including one whose background is null (an explicit "nothing here" is an answer, not an absence)
Parameters
ParameterInTypeDescription
chatId query string chat uuid (required)
Responses
200 ResolvedBackground OK
400 Error chatId is required
GET /api/backgrounds/bindings/{scope} The binding at exactly ONE scope, unresolved. A null binding means this scope INHERITS, which is a different answer from a binding whose background is null (a deliberate "nothing here" that stops inheritance)
Parameters
ParameterInTypeDescription
scope path string global | character | chat
Responses
200 object OK
400 Error bad scope, or a character or chat scope without its id
PUT /api/backgrounds/bindings/{scope} Write one binding. Omitted fields KEEP their stored value; an explicit null backgroundId means "no wallpaper here", which stops inheritance rather than falling through
Parameters
ParameterInTypeDescription
scope path string global | character | chat
Request body application/json
FieldTypeDescription
backgroundId integer | null null means explicitly none
fit cover | contain | stretch | center | tile
opacity number 0 to 1
blur integer 0 to 40 px
brightness number 0 to 2
saturate number 0 to 2
renderWidth | 0 | 768 | 1280 | 1920 which tier the client should request; null is auto, 0 is the original
Responses
200 BackgroundBinding OK
400 Error bad scope, or a character or chat scope without its id; or an unknown enum value or out-of-range knob (the message names the valid set)
404 Error scope target or background not found
DELETE /api/backgrounds/bindings/{scope} Clear the binding at this scope, returning it to inherited
Parameters
ParameterInTypeDescription
scope path string global | character | chat
Responses
200 Ok OK
400 Error bad scope, or a character or chat scope without its id
404 Error no binding at this scope
GET /api/backgrounds/bindings/{scope}/{id} The binding at exactly ONE scope, unresolved. A null binding means this scope INHERITS, which is a different answer from a binding whose background is null (a deliberate "nothing here" that stops inheritance)
Parameters
ParameterInTypeDescription
scope path string global | character | chat
id path string character or chat uuid (the global scope takes the path without it)
Responses
200 object OK
400 Error bad scope, or an id on the global scope
PUT /api/backgrounds/bindings/{scope}/{id} Write one binding. Omitted fields KEEP their stored value; an explicit null backgroundId means "no wallpaper here", which stops inheritance rather than falling through
Parameters
ParameterInTypeDescription
scope path string global | character | chat
id path string character or chat uuid (the global scope takes the path without it)
Request body application/json
FieldTypeDescription
backgroundId integer | null null means explicitly none
fit cover | contain | stretch | center | tile
opacity number 0 to 1
blur integer 0 to 40 px
brightness number 0 to 2
saturate number 0 to 2
renderWidth | 0 | 768 | 1280 | 1920 which tier the client should request; null is auto, 0 is the original
Responses
200 BackgroundBinding OK
400 Error bad scope, or an id on the global scope; or an unknown enum value or out-of-range knob (the message names the valid set)
404 Error scope target or background not found
DELETE /api/backgrounds/bindings/{scope}/{id} Clear the binding at this scope, returning it to inherited
Parameters
ParameterInTypeDescription
scope path string global | character | chat
id path string character or chat uuid (the global scope takes the path without it)
Responses
200 Ok OK
400 Error bad scope, or an id on the global scope
404 Error no binding at this scope

chats

Chats and their messages: browse, search, edit, branch and export, the prompt a chat would send, and generation on the server, streamed as SSE

POST /api/characters/{id}/chats Create a chat. Bare: header from card + settings, message 0 = first_mes with macros applied, it and its alternate greetings then passing the chat's regex scripts that rewrite a message as it is written (alterSaved), chat_metadata holding the default Author's Note (note_prompt, note_interval, note_depth, note_position, note_role). With messages/header: stored as given (import/restore)
Parameters
ParameterInTypeDescription
id path string character uuid
Request body application/json
FieldTypeDescription
name string optional; default "{charName} - {timestamp}"
header object optional; merged over the card/settings defaults (user_name, character_name, chat_metadata)
messages array<object> optional; SillyTavern rows, stored verbatim when present (the greeting is NOT seeded). A ChatMessage is not a row: send its raw. seq and raw are refused on a row, since a stored row is exported as JSONL
Responses
200 ChatDetail OK
400 Error messages must be an array of objects, or an element carrying seq or raw (the native shape's keys: send each message's raw)
404 Error character not found
409 Error name clash
GET /api/chats All chats (newest first by default), windowed on the server: search, rules, sort, grouping and keyset paging all run here. lastMes is truncated to a 200-char preview
CollectionA page: 100 unless limit asks, at most 1000, walked by its cursor (after, nextCursor).
Parameters
ParameterInTypeDescription
charId query string filter to one character
world query string bound-world filter: exact name, or 'any' for bound-to-anything
q query string substring match on the chat name or its character name
rules query string URL-encoded JSON array of structured filter rules [{field, op, value}], the chats view's advanced-filter model evaluated server-side. Chat fields: chatName, charName, messageCount, messageText (contains / not_contains: a message's shown text holds every word of the value of two letters or more, each word a prefix; a value of no such words matches no message), lastMessage, chatLorebook. Character-scoped, read off the chat's character as the character list's rules read them: charFavorite, charTags, charProviderLink, charPlaylist. Unknown field/op fails 400 naming the valid set
sort query string recent | oldest | name | messages | created | character | chats (default recent). recent is the newest message, else the creation. character and chats order the characters (by name, by chat count; ties by their newest chat) and list each character's chats newest first
order query asc | desc flips the sort's own key (oldest is recent with order=asc); default is the sort's natural direction
grouped query 1 | true | yes | 0 | false | no rows contiguous per character, ordered by a per-character key for the sort (its name for character, its chat count for chats, its newest chat for every other sort, flipped with recent/oldest), then the sort within the character; every row carries charChatCount
limit query integer rows a page: default 100, at most 1000; past it, walk nextCursor with after
offset query integer ignored when after is given
after query string keyset cursor from a prior response nextCursor, over the sort's whole key (ties included): O(page) at any depth
count query 1 | true | yes | 0 | false | no count=false skips the total (null in the envelope); scroll clients use nextCursor for has-more
Responses
200 ChatEnvelope OK
400 Error invalid parameter, a limit outside 1 to 1000, unknown sort, order, rule field or op, or a junk cursor
GET /api/chats/active The chat the client currently has open (the activeChatId setting) resolved to its character, for an external integration (the ComfyUI gallery send). 404 when no chat is open or it is gone
Responses
200 object OK
404 Error no chat open, or the chat is gone
GET /api/chats/{id} Chat detail with messages (windowable), each a ChatMessage (its id, its seq, its time, who said it, its text, and the stored row as raw)
Parameters
ParameterInTypeDescription
id path string chat uuid
msgLimit query integer message page size
msgOffset query integer message page start
msgTail query integer the LAST n messages, returned in ascending seq order; wins over msgLimit/msgOffset (msgLimit=1 answers with the greeting, which is the other end)
Responses
200 ChatDetail OK
400 Error msgLimit, msgOffset or msgTail is not a number
404 Error not found
PATCH /api/chats/{id} Rename and/or merge chatMetadata (null value deletes a key; chatMetadata.extensions merges one level deeper, by extension id, so a writer names only its own key and null removes it). chatMetadata.world_info is the chat lore binding: it sets the head of the chat worlds list (null or empty unlinks the head) and is never kept in chatMetadata itself, exactly like extensions.world on a card PATCH. chatMetadata.scenario, mes_example and system_prompt are the chat's own card texts (SillyTavern's Chat Character Settings Override, under its keys): each is read before the card's wherever the card's is (the prompt, every macro, the lore scan), an empty one is none, null removes it, and anything but text is refused
Parameters
ParameterInTypeDescription
id path string chat uuid
Request body application/json
FieldTypeDescription
name string
draft string | null the composer text not yet sent; null or empty clears it. Never exported, never moves updatedAt
chatMetadata object
personaId string | null per-chat persona override; null CLEARS it so the chat follows the global persona again, omitted leaves it alone
profileId string | null this chat's own connection; null CLEARS it so the chat follows the default for chats again, omitted leaves it alone. Never moves updatedAt
presetId string | null this chat's own prompt preset; null CLEARS it so the chat follows the active preset again, omitted leaves it alone. Never moves updatedAt
Responses
200 Ok OK
400 Error a persona, a connection or a preset that does not exist or is named by something other than a string, a chat card text that is not text, or a draft that is not
404 Error not found
409 Error name clash
DELETE /api/chats/{id} Delete a chat + its messages
Parameters
ParameterInTypeDescription
id path string chat uuid
Responses
200 Ok OK
404 Error not found
GET /api/chats/{id}/prompt The prompt this chat would send right now: the real assembled messages with macros expanded and lore injected, plus the budget figures. Built on demand and stored nowhere (a dry build: nothing its macros set is kept); a debug surface for seeing what the model is actually given. A build error carries the {error, kind} envelope the generate and llm routes use; a bad firstShown is a plain {error} 400
Parameters
ParameterInTypeDescription
id path string chat uuid
firstShown query integer the first message the reader's screen shows, which {{firstDisplayedMessageId}} answers
Responses
200 object OK
400 Error a firstShown that is not a message seq ({error}); or a build the server refuses ({error, kind: bad_request}), for example the over-budget refusal
404 Error not found
GET /api/chats/{id}/authors-note The chat's Author's Note as the next build reads it. The note lives in chatMetadata under ST's keys (note_prompt, note_interval, note_depth, note_position, note_role) and is written through PATCH /chats/{id} chatMetadata; a part the chat does not hold reads the default's (settings chatAuthorsNoteDefault*), until a reply's commit stores them. position: 0 after the main prompt, 1 in the chat at depth, 2 before the main prompt; role: 0 system, 1 user, 2 assistant. due and untilNext count the reader's messages over the whole chat (interval 1 every one, 0 never; untilNext the true count left, null at a frequency of 0)
Parameters
ParameterInTypeDescription
id path string chat uuid
Responses
200 object OK
404 Error chat not found
GET /api/chats/{id}/lore The lore state for a chat: every book in force (character links, the chat binding, the resolved persona's books, then the global list), all of their entries, and which entries FIRE against the current history as the next build on the chat's own connection reads it (a message of pictures alone counts only when that connection sees pictures). Evaluated as a DRY RUN of the same scan the prompt uses (probability counts as pass and is reported as probabilityPending; a weighted inclusion group keeps every member that can win, each reported with its odds as groupPending; sticky/cooldown state is read, never advanced), so it cannot disagree with what gets sent. Per entry: fired, probabilityPending, groupPending, suppressedReason (why the engine held it back this scan), timed (remaining sticky/cooldown turns), advanced (the honoured ST fields: probability, sticky/cooldown/delay, groups, recursion flags, triggers, character filter, extra match sources) outlet (the outlet a fired outlet entry is held for, placed where {{outlet::name}} is written) and notHonoured (vectorized, automationId, which nothing here implements). sources says how a book is reached; an entry is addressed by world + uid, never uid alone
Parameters
ParameterInTypeDescription
id path string chat uuid
Responses
200 ChatLoreState OK
404 Error not found
POST /api/chats/{id}/branch Branch the chat at one message, as SillyTavern branches: a new chat for the same character holding every message up to it as stored, the chat metadata whole with main_chat naming this chat (its own card texts, variables, timed lore and pick hash with it), its lorebook list, persona and wallpaper, never its draft nor its assistant sessions (conversations about this chat as it stood). Named "<this chat> - Branch #n", the first free n. Its created record carries branchOf { chatId, seq }
Parameters
ParameterInTypeDescription
id path string chat uuid
Request body application/json
FieldTypeDescription
seq required integer the message the branch ends on
swipeId integer optional: the alternate the branch's last message shows, selected as a swipe pick selects it (its generation record with it), in the same write
messageId integer optional: the id of the message the reader branched from; another message at that seq now refuses the branch (409), no chat made
Responses
200 ChatDetail OK
400 Error seq is not a message seq, swipeId is not an alternate of that message, or a messageId that is not a message id
404 Error chat or message not found
409 Error another message than the one named holds that seq now (a delete renumbered the chat since it was read): that message changed since it was shown; nothing was written
POST /api/chats/{id}/messages Append one user turn (server stamps name/date/seq). The chat's regex scripts that rewrite a message as it is written (alterSaved) apply to the text first, at the reader's placement; then its macros are expanded once, now, and it is stored as expanded, as SillyTavern stores a sent message: a roll is rolled and a variable set once, and a prompt sends the stored text
Parameters
ParameterInTypeDescription
id path string chat uuid
Request body application/json
FieldTypeDescription
mes string the text; empty is allowed when attachments name pictures
attachments array<integer> pictures from the chat's own gallery this turn shows, in order
firstShown integer the first message the reader's screen shows, which {{firstDisplayedMessageId}} answers
Responses
200 object OK
400 Error neither mes nor attachments, an attachment that is not this chat's picture, or firstShown is not a message seq
404 Error not found
PUT /api/chats/{id}/messages Replace the full message array; the chat's message count and preview follow. The messages are NEW: each gets a new id, and what was keyed on the old ids (an extension's records about a message) goes with them
Parameters
ParameterInTypeDescription
id path string chat uuid
Request body application/json
FieldTypeDescription
messages required array<object> SillyTavern rows; a ChatMessage is not a row: send its raw
Responses
200 Ok OK
400 Error messages is not an array of objects, an element carrying seq or raw (the native shape's keys: send each message's raw), or a message whose extra.attachments names a picture that is not this chat's or is not a picture
404 Error not found
PATCH /api/chats/{id}/messages/{seq} Patch ONE message by row seq (shallow merge; null value deletes a key). extra MERGES key by key, a null leaf deleting it, because the bag is shared with the server's own generation record (reasoning, usage, interrupted, edited, guidance) and a whole-object write would put back whatever the caller's copy predates; extra.hidden is boolean or null, extra: null drops the bag, and a dotted key is refused (message fields are not dot-paths). mes always tracks the active alternate: a supplied mes is written into swipes[swipe_id], otherwise mes is re-read from it. A supplied mes that differs from the stored text first passes the chat's regex scripts that rewrite a message as it is written and run on edit (alterSaved with runOnEdit), and the active alternate is stamped extra.edited (ms epoch): from then on a regex script changing the text itself (neither markdownOnly nor promptOnly) and not set to runOnEdit leaves that message as written, on screen and in the prompt. So does the generation record of each alternate (extra.reasoning, usage, interrupted, edited and guidance): when another alternate becomes the active one (a swipe_id picked, one added, the active draft dropped), the one left keeps its record in the extra of its swipe_info entry and the record of the chosen one comes into extra, none when it has none; an edit of the active text moves nothing. The body is SillyTavern row fields: a seq or raw key is refused (the native shape's keys; a stored row is exported verbatim as JSONL). shown is not a field: it names the active alternate the reader was shown, and a message holding another refuses the patch with 409, so an edit from a screen that is behind the server never rewrites an alternate it did not show. Message 0, when it is the character's and not hidden, is stored with its macros expanded (SillyTavern expands a chat's first message as it shows), whatever the patch changed
Parameters
ParameterInTypeDescription
id path string chat uuid
seq path string message row seq
messageId query integer the id of the message the reader was shown at this seq: another message there now refuses the write (409). Left out, the write goes to whichever message holds the seq
Request body application/json
FieldTypeDescription
mes string
swipes array<string> alternates; index swipe_id is the active one
swipe_id integer
swipe_info array<object> one entry per alternate, as SillyTavern keeps them; the extra of an entry holds the generation record of its alternate (reasoning, usage, interrupted, edited, guidance)
extra object | null per-message flags, MERGED key by key: { hidden: true } hides the row from the prompt, { hidden: null } deletes that leaf and touches nothing else; hidden must be boolean or null; null for the whole field drops the bag
name string
is_system boolean
shown object optional: what the reader was shown of this message, never written as a field of it: its active alternate's place, the alternates counted and that alternate's text. When the stored message differs in any of them the request is refused with 409 and nothing is written; left out, it acts on whatever alternate is active
Responses
200 object OK
400 Error bad seq / empty patch / seq or raw in body / a dotted key / extra not an object / extra.hidden not boolean / extra.attachments naming a picture that is not this chat's or is not a picture / a messageId that is not a message id / a shown that is not { index, count, text } (an index outside the count, a count under 1, a text that is not a string)
404 Error chat or message not found
409 Error another message than the one named holds that seq now (a delete renumbered the chat since it was read): that message changed since it was shown; nothing was written; or the message holds another active alternate, count of alternates or active text than the one named as shown (an alternate added, dropped, picked or rewritten since it was read): that message changed since it was shown; nothing was written
DELETE /api/chats/{id}/messages/{seq} Delete ONE message and close the gap so seqs stay 0..n-1 (every later message moves down one, its id kept); returns the NEW seq list so a client can re-key without a refetch
Parameters
ParameterInTypeDescription
id path string chat uuid
seq path string message row seq
messageId query integer the id of the message the reader was shown at this seq: another message there now refuses the write (409). Left out, the write goes to whichever message holds the seq
Responses
200 object OK
400 Error bad seq, or a messageId that is not a message id
404 Error chat or message not found
409 Error another message than the one named holds that seq now (a delete renumbered the chat since it was read): that message changed since it was shown; nothing was written
POST /api/chats/{id}/messages/{seq}/swipes Add ONE alternate to a message and make it the active one (mes is its text), as a swipe adds one; a message with none first takes its text as its first alternate. The alternate left keeps its generation record (extra.reasoning, usage, interrupted, edited and guidance) in its swipe_info entry, and the new one starts with none. count names the alternates the reader was shown: when the message holds another count now (an alternate added or dropped elsewhere since it was read), the write is refused with 409 and nothing is written. Message 0, when it is the character's and not hidden, is stored with its macros expanded, as a patch stores it
Parameters
ParameterInTypeDescription
id path string chat uuid
seq path string message row seq
Request body application/json
FieldTypeDescription
text required string the alternate added, not blank
count required integer the alternates the reader was shown: swipes.length, 1 for a message with none
messageId integer optional: the id of the message the reader was shown at this seq; another message there now refuses the write (409)
Responses
200 object OK
400 Error bad seq, a blank or missing text, a count that is not a positive integer, or a messageId that is not a message id
404 Error chat or message not found
409 Error another message than the one named holds that seq now (a delete renumbered the chat since it was read): that message changed since it was shown; nothing was written; or the message holds another count of alternates than the one named: that message's alternates changed since they were shown; nothing was written
POST /api/chats/{id}/messages/{seq}/swipes/delete Drop ONE alternate of a message, named by its index AND the text it holds, beside the alternates count the reader was shown: when any of the three differs from the stored message (an alternate added, dropped or rewritten elsewhere since it was read) the write is refused with 409 and nothing is removed, so a reader is never made to drop an alternate it did not see. The selection stays on its alternate; dropping the active one makes the next the active one (the new last when it was last), mes follows it, and its generation record (extra.reasoning, usage, interrupted, edited and guidance) comes into extra while the dropped one's goes with it. A message keeps one alternate: the last goes only with the message (DELETE /api/chats/{id}/messages/{seq}). Message 0, when it is the character's and not hidden, is stored with its macros expanded, as a patch stores it
Parameters
ParameterInTypeDescription
id path string chat uuid
seq path string message row seq
Request body application/json
FieldTypeDescription
index required integer the alternate dropped, 0 to count - 1
text required string the text that alternate held as shown
count required integer the alternates the reader was shown, 2 or more
messageId integer optional: the id of the message the reader was shown at this seq; another message there now refuses the write (409)
Responses
200 object OK
400 Error bad seq, a count under 2, an index outside the count, a text that is not a string, or a messageId that is not a message id
404 Error chat or message not found
409 Error another message than the one named holds that seq now (a delete renumbered the chat since it was read): that message changed since it was shown; nothing was written; or the message holds another count of alternates, or another text at that index: that message's alternates changed since they were shown; nothing was written
POST /api/chats/{id}/generate Generate the next assistant turn: server-side prompt assembly (card + history + persona + lore) streamed as normalized SSE (chunk/done/error). The reply and its reasoning pass the chat's regex scripts that rewrite a message as it is written (alterSaved) before they are stored; a continue stores the text so far and the new part as the message's text scripts write them. The row is stored server-side before the done event, which carries {message, id, seq, swipeId, budget} on top of the usual finishReason/usage (message a ChatMessage; firstMessage, when the build expanded and stored the greeting, the same). An impersonation stores nothing; its done carries draft, the text with the chat's regex scripts for user input applied. budget is {tokens, trimmed, maxContext, reserve, firstSeq, windowed}; firstSeq is the seq of the oldest message that still fit, which is the only value a client can draw a context marker from. A timed-out or mid-stream-failed generation stores what streamed, marked extra.interrupted with the error kind (timeout | upstream | network | rate_limit | auth | context | quota | bad_request | error). A client hang-up (the stop button, or a dropped socket: the server cannot tell them apart) DISCARDS the fragment by default, because stopping usually means the reply was going wrong; set the chatKeepInterrupted setting to keep it instead, stored with reason "stopped". Sampling params are the profile defaults under this request body; a preset never contributes them, because samplers belong to the connection. Chat messages go to the model as stored, through the chat's regex scripts for the prompt; the chat's first message is expanded again and the expansion stored. What the prompt's macros set (variables, the pick hash) is kept, with the lore's timed state and the first message in context, before the stream. A build that would send nothing (a preset whose blocks in force all send nothing for the mode) is refused with a 400 before any of that is kept, as a chat that does not fit its budget is
Parameters
ParameterInTypeDescription
id path string chat uuid
Request body application/json
FieldTypeDescription
profileId string the connection that answers this one request; omitted, the chat's own connection answers, else the default for chats, else the first
params object
mode append | regenerate | swipe | continue | impersonate append (default) adds a message; regenerate rewrites targetSeq in place (without a targetSeq, the trailing message when it is a reply; a chat ending on the user's turn gains a new reply); swipe pushes an alternate onto targetSeq and excludes it from the prompt; continue appends into targetSeq and clears its interrupted marker; impersonate writes the USER's next line as a draft: it streams back and stores NOTHING
targetSeq integer regenerate/swipe/continue; defaults to the trailing row. Must be a non-user, non-system message
targetId integer optional, beside targetSeq: the id of the message the reader was shown there (without targetSeq, of the trailing message). Another message there now refuses the generation with a 409 before the model is asked; left out, the target is whichever message holds the seq at the resolve
targetShown object optional: what the reader was shown of the target message (regenerate/swipe/continue), checked before the model is asked, so a reroll, a swipe or a continue from a screen that is behind the server never rewrites or grows an alternate it did not show: its active alternate's place, the alternates counted and that alternate's text. When the stored message differs in any of them the request is refused with 409 and nothing is written; left out, it acts on whatever alternate is active
firstShown integer the first message the reader's screen shows, which {{firstDisplayedMessageId}} answers
guidance string steering text that rides as a trailing budget-measured system instruction, never as transcript content. On impersonate it directs the user-side draft; on append it makes a GUIDED REPLY: the character's next turn follows the direction (template: the preset's guidedInstruction setting), and the reply stores it as extra.guidance. A swipe or a regenerate that sends none follows its target's own (the shown alternate's extra.guidance), so another take on a directed reply is directed the same way; one that sends its own uses that. Ignored by continue
Responses
200 text/event-stream
400 Error bad chat/profile/mode/target, firstShown is not a message seq, a targetId that is not a message id, or a targetShown that is not { index, count, text }
404 Error chat or target message not found
409 Error another message than the one named holds that seq now (a delete renumbered the chat since it was read): that message changed since it was shown; nothing was written; or the message holds another active alternate, count of alternates or active text than the one named as shown (an alternate added, dropped, picked or rewritten since it was read): that message changed since it was shown; nothing was written
502 Error upstream failure
GET /api/chats/{id}/export ST-shaped JSONL (header line + messages)
Parameters
ParameterInTypeDescription
id path string chat uuid
Responses
200 JSONL attachment
404 Error not found

assistant

Out-of-character assistant sessions bound to a chat

GET /api/assistant/defaults The built-in assistant role text, as the server sends it, so a settings panel can offer it as the starting point for a custom prompt
Responses
200 object OK
GET /api/assistant/sessions The assistant sessions bound to one chat, newest first, WITHOUT their transcripts (messageCount only)
CollectionThe whole set: one chat's sessions, without transcripts.
Parameters
ParameterInTypeDescription
chatId query string chat uuid
Responses
200 array<AssistantSession> OK
400 Error chatId required
POST /api/assistant/sessions Start a session on a chat; the name defaults to a numbered one
Request body application/json
FieldTypeDescription
chatId required string
name string
Responses
201 AssistantSession OK
400 Error chatId required
404 Error chat not found
GET /api/assistant/sessions/{sid} One session WITH its transcript
Parameters
ParameterInTypeDescription
sid path string session uuid
Responses
200 AssistantSession OK
404 Error not found
500 Error this session's transcript could not be read
PATCH /api/assistant/sessions/{sid} Rename a session or bind it to an LLM profile. A rename deliberately does NOT move updatedAt, because the session list is ordered by it and renaming something should not reshuffle the list
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
name string
profileId string | null
Responses
200 AssistantSession OK
400 Error blank name / nothing to change
404 Error not found
DELETE /api/assistant/sessions/{sid} Delete a session
Parameters
ParameterInTypeDescription
sid path string session uuid
Responses
200 Ok OK
404 Error not found
POST /api/assistant/sessions/{sid}/messages Append ONE message. There is deliberately no whole-transcript write: the server does the read-modify-write, so a client holding stale state can never overwrite real history with its own copy of it
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
role user | assistant
content string the text; empty is allowed when pictures are named
pictures array<object> a reader turn's pictures, in order: { kind, id } of the chat's character (its portrait or a gallery image) or the chat's own pictures, each held to it; stored on the turn with its name and size
retry object a Try again on a reader turn: the reply by its stamp (at) and the changes of it to try again (ids). While it is the last reader turn, the model is sent each change as written and where it stands now
Responses
200 object OK
400 Error a bad role, neither content nor pictures, pictures on a reply, a picture the session may not show, or a retry on a reply
404 Error not found
409 Error session changed underneath the write, or a retry naming a reply, or a change of it, that changed since it was shown
500 Error this session's transcript could not be read
PATCH /api/assistant/sessions/{sid}/messages/{seq} Patch one transcript message. extra MERGES rather than replacing, so recording that one proposal was applied cannot drop the context snapshot stored beside it
Parameters
ParameterInTypeDescription
sid path string session uuid
seq path string transcript index
at query integer the stamp (at) of the turn the reader was shown; when given and the turn now at seq carries another, the write is refused with 409
Request body application/json
FieldTypeDescription
content string
extra object
Responses
200 object OK
400 Error bad seq / bad at / nothing to change
404 Error not found
409 Error the turn at seq is not the one the reader was shown (the transcript changed since)
500 Error this session's transcript could not be read
DELETE /api/assistant/sessions/{sid}/messages/{seq} Remove a turn: mode=one splices just that message, for tidying a stray turn; the default TRUNCATES from there, since the only reason to remove an assistant turn is to ask for a different one and the turns that answered it would otherwise be left behind as non sequiturs
Parameters
ParameterInTypeDescription
sid path string session uuid
seq path string transcript index
mode query one | truncate default truncate
at query integer the stamp (at) of the turn the reader was shown; when given and the turn now at seq carries another, the write is refused with 409
Responses
200 object OK
400 Error bad seq / bad mode / bad at
404 Error not found
409 Error the turn at seq is not the one the reader was shown (the transcript changed since)
500 Error this session's transcript could not be read
POST /api/assistant/sessions/{sid}/generate Stream the assistant's next reply as normalized SSE (chunk/row/done/error), storing it server-side before the done event. When a shown roleplay message carries alternate drafts (swipes), the excerpt marks it and a cl-read directive is taught; a reply may then end with a cl-read block naming message seqs, and the route answers it once (depth cap 1): the request turn and a quarantined data turn carrying those drafts are stored and emitted as row events, then the model is called again and the follow-up is the reply the done event carries. Only seqs inside the shown excerpt are served; others get an honest refusal line. The prompt is assembled here: an out-of-character system prompt, then the story material (card, the context sources switched on in assistantContextSources, lorebooks, recent messages) as user-role DATA inside a fence sized past any fence run in the content, then the session transcript. Story text is never system text, because a card is a stranger's file. Editable things carry an ANCHOR (8 hex of sha256 over the exact content shown) and the reply is stored with a context snapshot naming what was shown in full; the apply path validates against that snapshot and never against a fresh build, or a model naming its own target would authorise a blind rewrite. Capability directives are only present for engines the assistantLoreEdits / assistantChatEdits / assistantCardEdits / assistantNotesEdits / assistantPersonaEdits settings turn on, and the assistantSystemPrompt setting replaces the ROLE description only: the quarantine note, the rule that the reader's character is theirs alone and the directives are always appended, so a custom prompt cannot switch any of them off. Interrupt semantics match /chats/{id}/generate, including chatKeepInterrupted
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
profileId string
params object
Responses
200 text/event-stream
404 Error not found
500 Error this session's transcript could not be read
502 Error upstream failure
GET /api/assistant/sessions/{sid}/proposals/{seq} The proposed edits in one reply, each judged against the world as it is NOW and carrying the before/after text a review card diffs. status is ready | applied | superseded (an applied proposal from this reply already made or overrode this change; judged via the anchors our own applies produced, so a batch never reads its own writes as the target drifting) | blind (it was never shown that content in full) | gone | ambiguous (the find text is not unique) | invalid | off (a card, notes or persona change from a reply written while that kind of edit was switched off). A card, notes or persona verdict carries label (the field as the material named it), reach ({ kind: card | persona, name }: the write reaches every chat with the character, or every chat using the persona) and makesOwn (a notes field this chat does not yet hold of its own). A target changed by anything OUTSIDE the reply stays READY with changed: true: the diff renders against the current text and the reviewer decides. Recomputed per request, never stored: a card reporting "ready" because it was ready when it was written is exactly what the anchors exist to prevent. An already-applied proposal is not re-judged, since applying it is what changed the content. A lore verdict that read its entry carries title (the entry name as it is NOW; a blind verdict reads nothing and carries none) and, on an update, fields (each non-content key the set moves, with before and after as the write will land them); an applied lore proposal carries title too, read live, else as the write recorded it. A lore edit whose world/uid was not shown resolves on its anchor (resolved on the verdict), because the anchor is proof-of-read; one whose world/uid WAS shown but whose anchor belongs to a different shown entry is ambiguous, refused naming both, since nothing can tell which half the model got wrong. A chat replace is placed exact, then with quotes, dashes and whitespace folded, then (approximate: true on the verdict) with markup tags read as spaces and on the best word window (at least 80% of the words on both sides, the find's first and last words at the edges, one window only); the after is always the exact live span replaced. A find nowhere in the named message but in exactly one other message of the shown excerpt is judged and applied there (resolved: {seq}); one that sits in a non-active draft says which
Parameters
ParameterInTypeDescription
sid path string session uuid
seq path string transcript index of the assistant turn
Responses
200 object OK
400 Error bad seq
404 Error session or message not found
500 Error this session's transcript could not be read
POST /api/assistant/sessions/{sid}/apply Apply chosen proposals from one reply. The ONLY write in this feature, and always explicit. Every proposal is re-checked immediately before its own write, so a batch where two of five went stale reports exactly that instead of failing whole or succeeding as a lie. Order is fixed and load-bearing: in-place changes first, then deletes, and message deletes DESCENDING, because a message address is its position and deleting one renumbers everything after it. Card, notes and persona changes land as one write each: the card with a version snapshot of it as it stood taken first, in the same transaction; the persona that was shown, whichever one the chat points at now. Results are recorded on the message, and touched says what the client must refresh (world names, whether the messages moved, the character whose card moved, the persona that moved, whether the chat's note or own texts moved)
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
seq required integer
ids required array<string> proposal ids from the proposals route
at integer optional: the reply's stamp as the client showed it; a reply at seq carrying another stamp answers 409
shown array<object> optional: each change as the client showed it, aligned with ids; one the reply now holds otherwise under that id answers 409
overrides object reviewer touch-ups keyed by proposal id, merged before apply and never stored: a key is accepted only where the change already carries it with the same shape (amend, never widen), plus world on a CREATE to redirect the entry to another book
Responses
200 object OK
400 Error bad seq / no ids / an at that is no number / a shown list of another length than ids / nothing left to apply
404 Error session or message not found
409 Error the reply changed since it was shown: its stamp, or a change under one of the ids
500 Error this session's transcript could not be read
GET /api/assistant/sessions/{sid}/prompt What the assistant would be sent right now, plus the context snapshot and budget. Built on demand, stored nowhere: the reader can inspect the quarantined document and the anchors before trusting a proposal built from them
Parameters
ParameterInTypeDescription
sid path string session uuid
Responses
200 object OK
404 Error not found
500 Error this session's transcript could not be read
GET /api/assistant/context The context summary the assistant panel shows before any session exists: what a session over this chat would see, plus engine availability and the budget. Built on demand, stored nowhere
Parameters
ParameterInTypeDescription
chatId required query string
Responses
200 object OK
400 Error chatId query required

creator

The creator studio: sessions over a character draft, their messages and generation, the edits it proposes and applies, and tag suggestions

GET /api/creator/sessions/{id}/attachments A studio session's own pictures, the references its author shows the partner, in the order they were added
CollectionThe whole set: one session's pictures.
Parameters
ParameterInTypeDescription
id path string session uuid
Responses
200 object OK
404 Error no such session
POST /api/creator/sessions/{id}/attachments Add a picture to the session (raw body), for a turn to name. Bytes the session holds already answer that attachment, created false. An image's size is read and kept; the pictures go with the session when it is deleted
Parameters
ParameterInTypeDescription
id path string session uuid
name query string display name; when the bytes are another kind of file than its extension says (a video named .png), the stored name takes the bytes' extension
Request body */*
string (binary)
Responses
200 object OK
400 Error empty body, or a name with nothing usable as a filename
404 Error no such session
415 Error neither a picture nor video
GET /api/creator/defaults The built-in studio role text, as the server sends it, so the panel's settings view can offer it as a starting point
Responses
200 object OK
POST /api/creator/context What the studio partner would SEE over the posted draft, for the panel's context view: every filled field with its length, the empty ones, the tags and greetings counts, the references size, the budget. Built by the real assembler, stored nowhere. A POST because the draft is unsaved and only the form holds it
Request body application/json
FieldTypeDescription
draft required object the unsaved card as the form holds it: name, tagline, description, personality, scenario, first_mes, mes_example, system_prompt, post_history_instructions, creator_notes as strings; tags and alternate_greetings as lists of strings
references string the reference cards block the panel built from a playlist (the inspiration pool)
scope array<string> the fields the author is working on; the rest of the draft is context
selection object a passage the author selected to revise: { field, text }
Responses
200 object OK
400 Error a draft field of the wrong shape
POST /api/creator/tags The tag wand beside the tag field of the form: one non-streaming call over the posted draft (the draft as fenced data with the head of the library vocabulary by usage, the tags craft as the role), the answer the names the model gave, cleaned: trimmed, deduped case-insensitively, minus the tags the draft already carries, at most twenty, casing as the model wrote it. The client runs the author import rules over them and asks POST /api/tags/resolve for the library spellings and counts. No session, no transcript. An unparseable answer is an empty list, never an error
Request body application/json
FieldTypeDescription
draft required object the unsaved card as the form holds it: name, tagline, description, personality, scenario, first_mes, mes_example, system_prompt, post_history_instructions, creator_notes as strings; tags and alternate_greetings as lists of strings
profileId string the LLM profile to ask; the default profile when omitted
params object per-call sampler overrides in the neutral vocabulary (temperature, maxTokens, reasoning)
Responses
200 object OK
400 Error a draft field of the wrong shape, or no LLM profile configured
502 Error the model call failed
GET /api/creator/sessions The studio sessions bound to one character (charId omitted = the drafts bucket, sessions bound to no character), newest first, WITHOUT transcripts (messageCount only)
CollectionThe whole set: one character's studio sessions (or the drafts), without transcripts.
Parameters
ParameterInTypeDescription
charId query string character uuid; omit for drafts
Responses
200 array<StudioSession> OK
POST /api/creator/sessions Start a studio session over a draft, bound to the character the form was filled from or to the drafts bucket; the name defaults to a numbered one
Request body application/json
FieldTypeDescription
charId string | null
name string
draft object the unsaved card as the form holds it: name, tagline, description, personality, scenario, first_mes, mes_example, system_prompt, post_history_instructions, creator_notes as strings; tags and alternate_greetings as lists of strings
profileId string
Responses
201 StudioSession OK
400 Error a draft field of the wrong shape
404 Error character not found
GET /api/creator/sessions/{sid} One session WITH its transcript and the draft it is about
Parameters
ParameterInTypeDescription
sid path string session uuid
Responses
200 StudioSession OK
404 Error not found
500 Error this session's transcript could not be read
PATCH /api/creator/sessions/{sid} Rename, bind to an LLM profile, rebind to a character (charId; null = the drafts bucket; the creator does this when a draft becomes a saved character), or store the draft the conversation is about. A draft write moves updatedAt (a working event); a rename deliberately does not, because the list is recency-ordered. Transcripts are never writable here
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
name string
profileId string | null
charId string | null the character to bind the session to; null moves it back to the drafts bucket
draft object the unsaved card as the form holds it: name, tagline, description, personality, scenario, first_mes, mes_example, system_prompt, post_history_instructions, creator_notes as strings; tags and alternate_greetings as lists of strings
Responses
200 StudioSession OK
400 Error blank name / nothing to change / a draft field of the wrong shape
404 Error not found
500 Error this session's transcript could not be read
DELETE /api/creator/sessions/{sid} Delete a session
Parameters
ParameterInTypeDescription
sid path string session uuid
Responses
200 Ok OK
404 Error not found
POST /api/creator/sessions/{sid}/messages Append ONE message. No whole-transcript write exists; the server does the read-modify-write. An assistant turn is parsed for cl-card-edits blocks here as well as on generate, so a reply arriving any other way carries its proposals
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
role user | assistant
content string the text; empty is allowed when pictures are named
pictures array<object> a reader turn's pictures, in order: { kind, id } of the session's character, when it has one (its portrait or a gallery image), or the session's own pictures, each held to it; stored on the turn with its name and size
retry object a Try again on a reader turn: the reply by its stamp (at) and the changes of it to try again (ids). While it is the last reader turn, the model is sent each change as written and where it stands now
Responses
200 object OK
400 Error a bad role, neither content nor pictures, pictures on a reply, a picture the session may not show, or a retry on a reply
404 Error not found
409 Error session changed underneath the write, or a retry naming a reply, or a change of it, that changed since it was shown
500 Error this session's transcript could not be read
PATCH /api/creator/sessions/{sid}/messages/{seq} Patch one transcript message. extra MERGES rather than replacing, so recording an applied proposal cannot drop the snapshot stored beside it; an edited reply re-parses and drops its previous verdicts
Parameters
ParameterInTypeDescription
sid path string session uuid
seq path string transcript index
at query integer the stamp (at) of the turn the reader was shown; when given and the turn now at seq carries another, the write is refused with 409
Request body application/json
FieldTypeDescription
content string
extra object
Responses
200 object OK
400 Error bad seq / bad at / nothing to change
404 Error not found
409 Error the turn at seq is not the one the reader was shown (the transcript changed since)
500 Error this session's transcript could not be read
DELETE /api/creator/sessions/{sid}/messages/{seq} Remove a turn: mode=one splices just that message, the default TRUNCATES from there (re-asking leaves no non sequiturs behind)
Parameters
ParameterInTypeDescription
sid path string session uuid
seq path string transcript index
mode query one | truncate default truncate
at query integer the stamp (at) of the turn the reader was shown; when given and the turn now at seq carries another, the write is refused with 409
Responses
200 object OK
400 Error bad seq / bad mode / bad at
404 Error not found
409 Error the turn at seq is not the one the reader was shown (the transcript changed since)
500 Error this session's transcript could not be read
POST /api/creator/sessions/{sid}/generate Stream the studio partner's next reply as normalized SSE (chunk/done/error), storing it server-side before the done event with the SNAPSHOT of the draft it was shown (an anchor per field, over the tags and per greeting). The draft rides the request because it is unsaved: the server builds the prompt from it (the design-partner role, the cast note, the quarantine note, the craft, the cl-card-edits grammar; then the whole draft as fenced user-role DATA with the references; then the transcript with the app note on each reply), and writes it to the session as the draft the conversation is about. scope and selection steer this turn only. profileId falls back to the session's own; params override the profile per the normal request-params merge and never write the profile; when neither names maxTokens a roomy ceiling is asked for. Interrupt semantics match /chats/{id}/generate, including chatKeepInterrupted
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
draft required object the unsaved card as the form holds it: name, tagline, description, personality, scenario, first_mes, mes_example, system_prompt, post_history_instructions, creator_notes as strings; tags and alternate_greetings as lists of strings
references string the reference cards block the panel built from a playlist (the inspiration pool)
scope array<string> the fields the author is working on; the rest of the draft is context
selection object a passage the author selected to revise: { field, text }
profileId string
params object
Responses
200 text/event-stream
400 Error a draft field of the wrong shape, or a typed pre-stream LLM refusal
404 Error not found
500 Error this session's transcript could not be read
502 Error upstream failure before the stream opened
POST /api/creator/sessions/{sid}/judge The proposals in one reply, each judged against the draft the client posts NOW and carrying the before/after text a review card diffs. A POST because what the judge reads is the posted draft. status is ready | applied | superseded (an applied proposal from this reply already rewrote this target) | gone (a greeting number the draft does not have) | ambiguous (a replace whose passage is not in the field exactly once, or tags already as proposed) | invalid. A target changed OUTSIDE the reply stays READY with changed: true: the diff renders against the current text and the author decides. Recomputed per request, never stored
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
seq required integer
draft required object the unsaved card as the form holds it: name, tagline, description, personality, scenario, first_mes, mes_example, system_prompt, post_history_instructions, creator_notes as strings; tags and alternate_greetings as lists of strings
Responses
200 object OK
400 Error bad seq / a draft field of the wrong shape
404 Error session or message not found
500 Error this session's transcript could not be read
POST /api/creator/sessions/{sid}/apply Apply chosen proposals from one reply over the posted draft and answer the draft that results, for the client to write into the form. Nothing here writes a character: the draft is unsaved. Every proposal is re-judged against the draft as the earlier ones in the batch left it; new greetings run LAST so a numbered greeting keeps its number. Results are recorded on the message, the session keeps the resulting draft, and touched says which fields, the tags and the greetings moved. overrides are reviewer touch-ups keyed by proposal id, merged before apply and never stored: a key is accepted only where the change already carries it with the same shape
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
seq required integer
ids required array<string>
at integer optional: the reply's stamp as the client showed it; a reply at seq carrying another stamp answers 409
shown array<object> optional: each change as the client showed it, aligned with ids; one the reply now holds otherwise under that id answers 409
draft required object the unsaved card as the form holds it: name, tagline, description, personality, scenario, first_mes, mes_example, system_prompt, post_history_instructions, creator_notes as strings; tags and alternate_greetings as lists of strings
overrides object
Responses
200 object OK
400 Error bad seq / no ids / an at that is no number / a shown list of another length than ids / nothing left to apply / a draft field of the wrong shape
404 Error session or message not found
409 Error the reply changed since it was shown: its stamp, or a change under one of the ids
500 Error this session's transcript could not be read
POST /api/creator/sessions/{sid}/prompt What the studio partner would be sent right now over the posted draft: the same builder, nothing stored, so the author can read the quarantined draft and the snapshot before trusting anything built from them
Parameters
ParameterInTypeDescription
sid path string session uuid
Request body application/json
FieldTypeDescription
draft required object the unsaved card as the form holds it: name, tagline, description, personality, scenario, first_mes, mes_example, system_prompt, post_history_instructions, creator_notes as strings; tags and alternate_greetings as lists of strings
references string the reference cards block the panel built from a playlist (the inspiration pool)
scope array<string> the fields the author is working on; the rest of the draft is context
selection object a passage the author selected to revise: { field, text }
Responses
200 object OK
400 Error a draft field of the wrong shape
404 Error not found
500 Error this session's transcript could not be read

worlds

Lorebooks: the whole-book document plus entry-by-entry writes

GET /api/chats/{id}/worlds The chat's own lorebooks, ordered (head = world_info in the exported JSONL header)
CollectionThe whole set: the chat's ordered book list, written whole by its PUT.
Parameters
ParameterInTypeDescription
id path string chat uuid
Responses
200 array<string> OK
404 Error chat not found
PUT /api/chats/{id}/worlds Replace the whole list (a name with no book is refused with 400)
Parameters
ParameterInTypeDescription
id path string chat uuid
Request body application/json
FieldTypeDescription
worlds required array<string>
Responses
200 object {ok, worlds}
400 Error bad list
404 Error chat not found
POST /api/chats/{id}/worlds/apply Atomic add/remove on the chat list (appends after the tail; reports only actual changes, plus the resulting list)
Parameters
ParameterInTypeDescription
id path string chat uuid
Request body application/json
FieldTypeDescription
add array<string>
remove array<string>
Responses
200 object {ok, added, removed, worlds}
400 Error nothing to add or remove
404 Error chat not found
POST /api/chats/worlds/apply Add/remove books on a set of chats, all or nothing (the /api/char-worlds/apply sibling, at most 1000 chatIds a request). Appends land after each chat's tail; unknown chatIds are skipped and reported; deltas count only actual changes, each with the chat's resulting list; a name with no book is refused with 400 before anything is written
Request body application/json
FieldTypeDescription
chatIds required array<string>
add array<string>
remove array<string>
Responses
200 object {ok, touched, affected, skipped, deltas: [{chatId, added, removed, worlds}]}
400 Error no chatIds, more than 1000, nothing to add or remove, or a name with no book
GET /api/characters/{id}/worlds A character's linked lorebook names, ordered (head = extensions.world in exported cards)
CollectionThe whole set: the character's ordered book list, written whole by its PUT.
Parameters
ParameterInTypeDescription
id path string character uuid
Responses
200 array<string> OK
404 Error character not found
PUT /api/characters/{id}/worlds Replace the whole linked-lorebook list (a name with no book is refused with 400)
Parameters
ParameterInTypeDescription
id path string character uuid
Request body application/json
FieldTypeDescription
worlds required array<string>
Responses
200 Ok OK
400 Error worlds is not an array of names, or a name with no book
404 Error character not found
GET /api/global-worlds Lorebooks active in EVERY chat, ordered (every name is a book on the shelf; the list follows a book's rename and loses it on its delete)
CollectionThe whole set: the global ordered book list, written whole by its PUT.
Responses
200 object OK
PUT /api/global-worlds Replace the whole global list, order preserved
Request body application/json
FieldTypeDescription
worlds required array<string>
Responses
200 Ok OK
400 Error bad body
POST /api/global-worlds/apply Atomic add/remove on the global list (the /char-worlds/apply sibling): appends land after the tail, no client read needed, so a failed read can never turn into an empty overwrite
Request body application/json
FieldTypeDescription
add array<string>
remove array<string>
Responses
200 object {ok, added, removed} (actual changes only)
400 Error nothing to do
GET /api/personas/{id}/worlds A persona's bound lorebook names, ordered. They reach whichever chat resolves that persona (its override, else the global active one)
CollectionThe whole set: the persona's ordered book list, written whole by its PUT.
Parameters
ParameterInTypeDescription
id path string persona uuid
Responses
200 array<string> OK
404 Error persona not found
PUT /api/personas/{id}/worlds Replace the whole bound-lorebook list (a name with no book is refused with 400)
Parameters
ParameterInTypeDescription
id path string persona uuid
Request body application/json
FieldTypeDescription
worlds required array<string>
Responses
200 Ok OK
400 Error worlds is not an array of names, or a name with no book
404 Error persona not found
POST /api/personas/{id}/worlds/apply Atomic add/remove on a persona's bound list; same contract as /api/global-worlds/apply
Parameters
ParameterInTypeDescription
id path string persona uuid
Request body application/json
FieldTypeDescription
add array<string>
remove array<string>
Responses
200 object {ok, added, removed} (actual changes only)
400 Error nothing to do
404 Error persona not found
POST /api/char-worlds/apply Add/remove world links on a set of characters, all or nothing (the /tags/apply sibling), at most 10000 charIds a request, so a larger selection is sent as several requests, each landing whole. Appends keep per-char order; unknown charIds skipped; deltas are undo-grade; a name with no book is refused with 400 before anything is written
Request body application/json
FieldTypeDescription
charIds required array<string> at most 10000
add array<string>
remove array<string>
Responses
200 object {ok, touched, affected, skipped, deltas}
400 Error nothing to do, no charIds or more than 10000, or a name with no book
GET /api/worlds A page of the shelf: world summaries in name order, case folded (a reader that needs the whole shelf walks nextCursor); q asks for the names that contain it, in the same order. counts=true carries each book's reach counted per kind, the shelf's chips
CollectionA page: 100 unless limit asks, at most 1000, walked by its cursor (after, nextCursor).
Parameters
ParameterInTypeDescription
limit query integer rows a page: default 100, at most 1000; past it, walk nextCursor with after
after query string the nextCursor of the page before: the books after it, O(page) at any depth
count query 1 | true | yes | 0 | false | no count=false skips the total (null in the answer); a walk reads nextCursor for has-more
q query string the names that contain this text, case folded; a % or _ is a character
counts query 1 | true | yes | 0 | false | no each book also carries chars, chats and personas (how many of each bind it) and global (whether the global list holds it)
placeholders query 1 | true | yes | 0 | false | no a false word leaves out the placeholder books (names something binds with no book yet); default they are listed
Responses
200 object OK
400 Error a limit outside 1 to 1000, an after that is not a cursor, or a flag that is not a boolean word
POST /api/worlds/probe The shelf probe: which of these keys (a provider's external ids or paths) name a book already on the shelf, by the source recorded for it (PUT /api/worlds/{name}/source). The /provider-links/probe sibling for lorebooks; at most 500 keys
Request body application/json
FieldTypeDescription
provider required string
keys required array<string>
Responses
200 object OK
400 Error provider or keys missing, or more than 500 keys
GET /api/worlds/{name}/usage One world's whole reach (linked characters, bound chats, global membership, persona bindings), read by its name alone: what the shelf asks before it fills a placeholder others link
Parameters
ParameterInTypeDescription
name path string world name
Responses
200 object OK
404 Error world not found
POST /api/worlds/sweep Binding-only reference sweep: re-points (rename, the carrier-collision rule applied) or drops (remove) every binding naming the world across character links, chat bindings, the global list and persona bindings, all or nothing. Renaming the world itself is POST /api/worlds/{name}/rename, which runs this leg for you
Request body application/json
FieldTypeDescription
rename object
remove string
Responses
200 object {touched}
400 Error bad sweep
GET /api/world-carriers The books bound to a character, a chat (by its name or its character's) or a persona whose name BEGINS with the prefix, each with the names that matched, at most limit rows per arm. Names compare case-insensitively, in any alphabet. Served beside /api/worlds, never under it: a book name is free, so a path under /api/worlds would be a book no one could open
CollectionThe whole set: at most limit rows per arm and prefix form.
Parameters
ParameterInTypeDescription
prefix query string the start of a carrier name
limit query integer rows per arm: default 200, at most 1000
Responses
200 array<object> OK
400 Error no prefix, or a limit outside 1 to 1000
GET /api/world-entries Every lorebook's entries whose title or content hold each word of q of two letters or more, each matching as a prefix; best match first, a title match weighing above a content match, with <mark> highlighting, paged by offset (a rank order has no key to seek). The hits are ranked among the newest 10000 matching entries: a broader match is ranked there, and the envelope says capped: true. Served beside /api/worlds, never under it, as /api/world-carriers is
CollectionA page: 50 unless limit asks, at most 500, walked by offset.
Parameters
ParameterInTypeDescription
q required query string plain text: every word of two letters or more required, each matching as a prefix (a lone letter is passed over); a text with no such words answers no hits
limit query integer hits a page: default 50, at most 500; past it, walk offset
offset query integer page start
count query 1 | true | yes | 0 | false | no count=false skips the total (null in the envelope), the expensive leg of a broad match
Responses
200 WorldEntrySearchEnvelope OK
400 Error no q, a limit outside 1 to 500, an offset that is not a number, or a count that is not a boolean word
GET /api/worlds/{name} Composed world doc ({entries: {uid: entry}, ...meta})
Parameters
ParameterInTypeDescription
name path string world name
Responses
200 object OK
404 Error not found
PUT /api/worlds/{name} Create/replace whole world. expect=absent only creates (a book of that name in any case answers 409); expect=placeholder only fills a placeholder (409 when the book is not one)
Parameters
ParameterInTypeDescription
name path string world name
expect query absent | placeholder make the write a create or a placeholder fill
Request body application/json
object
Responses
200 Ok OK
400 Error no world name or data object, or an expect that is not 'absent' or 'placeholder'
409 Error the expectation failed: the name is taken, or the book is not a placeholder
DELETE /api/worlds/{name} Delete a world; its entries and every binding go with it
Parameters
ParameterInTypeDescription
name path string world name
Responses
200 object {ok, unbound}
404 Error not found
PUT /api/worlds/{name}/source Record where a book came from (one source per book; it follows a rename and goes with a delete). onlyIfMissing keeps a source the world already has, the "use the existing book" answer of the shelf import
Parameters
ParameterInTypeDescription
name path string world name
Request body application/json
FieldTypeDescription
provider required string
externalId required string
path string | null
url string | null
onlyIfMissing boolean
Responses
200 object OK
400 Error provider or externalId missing
404 Error world not found
POST /api/worlds/{name}/rename Rename a world, all or nothing: its entries and every binding (char, chat, persona, global) follow it, and a saved filter preset's lorebook rule naming it (case-insensitively in ASCII) takes the new name
Parameters
ParameterInTypeDescription
name path string current world name
Request body application/json
FieldTypeDescription
to required string
Responses
200 object {ok, touched}
400 Error new name required
404 Error world not found
409 Error a world with that name already exists
POST /api/worlds/{name}/entries Create one entry (uid allocated server-side)
Parameters
ParameterInTypeDescription
name path string world name
Request body application/json
object
Responses
200 object {ok, uid}
400 Error entry object required
404 Error world not found
PUT /api/worlds/{name}/entries/{uid} Merge onto one entry: absent fields keep their stored value, an explicit null or empty array clears (an entry carries ~40 fields while most editors show a dozen, so a replacing write would silently delete the difference)
Parameters
ParameterInTypeDescription
name path string world name
uid path string entry uid
Request body application/json
object
Responses
200 Ok OK
400 Error a uid that is not a whole number, or no entry object
404 Error world not found
DELETE /api/worlds/{name}/entries/{uid} Delete one entry
Parameters
ParameterInTypeDescription
name path string world name
uid path string entry uid
Responses
200 Ok OK
400 Error a uid that is not a whole number
404 Error entry not found

library

Playlists, versions, personas, settings, KV store, backups, bundles, migration, maintenance and background jobs

POST /api/provider-links/probe Which of these remote keys are linked here (the browse-view badge probe): a key matches a link's externalId, or its fullPath case-insensitively, on one of the named providers; answers the matching input keys in input order
Request body application/json
FieldTypeDescription
providers array<string> provider ids to match against (max 20); or provider: one id
provider string
keys required array<string> remote ids or paths, max 500
owners boolean also answer the links behind the keys (the import duplicate check), each resolved to its character id
loose boolean with owners: links whose path begins with the key or that the key begins with, exact links first; a purely numeric or uuid key, and a purely numeric path, only match exactly
Responses
200 object OK
400 Error providers missing, keys missing, a cap exceeded, owners or loose not boolean, or loose without owners
POST /api/migrate/plan The SillyTavern migration plan: the migration tool's dry-run over a user folder on the server, nothing written. Any signed-in user, into their own library only; the path is read on the server's filesystem
Request body application/json
FieldTypeDescription
path required string the SillyTavern user data folder (holding characters/, chats/, worlds/), a path on the machine running the server
only array<string> a test pool by character name or file
sample integer a random test pool of this size
excludeTags array<string>
Responses
200 object OK
400 Error no characters/ under the path, a targetHandle naming another account, or the tool refused (its lines say why)
409 Error a migration or a plan is already running: the caller's own run with its tail, anything else without details
500 Error the migration tool could not be started
POST /api/migrate/run Run the SillyTavern migration as a child of the server, the log and each step's progress streamed. One run at a time; a dropped stream never stops it (GET /migrate/status keeps the tail and the latest progress of every step). Options: excludeTags, only, sample, warmThumbs, verify (full | fast | off)
Request body application/json
FieldTypeDescription
path required string
only array<string>
sample integer
excludeTags array<string>
warmThumbs boolean
verify full | fast | off
Responses
200 text/event-stream: started {mode, target, source, startedAt, options}, line {line}, progress {step, label, done, total, unit, sources?, sizes?, at} (a step's count; steps read, worlds, characters, chats, rest, check, then thumbs and gallery-thumbs when asked, each from done 0 to its total, the total standing from its first record; sources and sizes on the thumbnail steps say what the total counts), done {mode, target, code, cancelled, report, state} (code 0 done, 1 the tool stopped, 2 some cards could not be read, 3 the check found differences; report as GET /migrate/status answers lastReport), error {message, kind}
400 Error no characters/ under the path, or a targetHandle naming another account
409 Error a migration or a plan is already running: the caller's own run with its tail, anything else without details
POST /api/migrate/finalize Finalize the migration: one last verify, then the SillyTavern-era identity records are purged (one-way; a later run into the same library is refused). Streamed like a run
Request body application/json
FieldTypeDescription
path required string
verify full | fast | off
force boolean
Responses
200 text/event-stream: started, line, progress (steps check, then purge), done (code 3 when the final check found differences and nothing was removed; its report carries ok, purged and the check as GET /migrate/status answers lastFinalize), error
400 Error no characters/ under the path, or a targetHandle naming another account
409 Error a migration or a plan is already running: the caller's own run with its tail, anything else without details
POST /api/migrate/cancel Stop the running migration (the whole process tree); a cancelled run heals on the next run
Responses
200 object OK
404 Error no migration is running
GET /api/migrate/status The run in flight with the tail of its log and the latest progress of each step, the newest run and finalize reports, and what the caller's home already knows (finalized, verified)
Responses
200 object OK
GET /api/backup List existing backups (newest first)
CollectionThe whole set: the backups on disk, pruned to the keep (at most 50).
Responses
200 array<object> OK
POST /api/backup Start a consistent backup of the library database into data/backups/ (the database only; media and avatars are plain files). It is queued and answered at once, and the copy runs beside the server, which keeps answering: the copy holds the library as it was when the copy began, and writes made during it are in the next backup. One backup runs at a time across the server, so another account's may run first. A search index tidy-up of the library pauses while it is queued or runs, and one asked for carries on once it ends. Follow it through GET /api/backup/job
Responses
202 BackupJob the job, queued or running
409 Error this account already has a backup queued or running
GET /api/backup/status Library size and contents, the newest backup, and the schedule, in one round trip. db.bytes counts the database's write-ahead log too, which holds writes not yet folded into the main file
Responses
200 object OK
GET /api/backup/job This account's backup: the one queued or running, else the last that ended (kept in memory until dismissed, another starts, or the server restarts), and the window a scheduled backup missed while none runs. Read it while a backup runs for its progress; every change to it is also a backup record on the change feed
Responses
200 object OK
DELETE /api/backup/job/{id} Cancel a queued or running backup, or with dismiss=true let go of one that ended; neither stands in for the other, so a cancel that arrives after the backup ended leaves its result. A running copy is stopped and its partial file removed; it answers with stopping true and ends cancelled moments later. A scheduled backup that is cancelled or fails is not retried in its window (with no window, for a day)
Parameters
ParameterInTypeDescription
id path string job id
dismiss query boolean true lets go of a backup that ended, so it leaves the notifications
Responses
200 BackupJob OK
400 Error numeric id required
404 Error job not found
409 Error a cancel of a backup that already ended, or a dismiss of one still running
POST /api/backup/missed Answer a missed backup window: tonight waits for the next window and asks again only if that one is missed too; skip counts the missed backup as taken at the end of its window, so the next comes on its usual day. Back Up Now is POST /api/backup
Request body application/json
FieldTypeDescription
answer required tonight | skip
Responses
200 object OK
400 Error answer is 'tonight' or 'skip'
409 Error no missed backup to answer
GET /api/maintenance What this library's background upkeep is doing now. searchIndex names the search index being tidied and when the tidy-up began, null while none is: it runs beside the server once the library sits idle and an index is in pieces, or when asked, and searches may be slower and the disk busy until it ends. memoryHint says the library was found on a slow disk and not in memory, so a search may read it off the disk: offered while the preloadLibrary setting is off and until declined, null otherwise. Every change to either is also a maintenance record on the change feed
Responses
200 object OK
DELETE /api/maintenance/memory-hint No thanks to the memory hint: recorded in the library, so it is not offered again, here or after a restart. Answers the state GET /api/maintenance answers, with a maintenance record on the change feed
Responses
200 object OK
POST /api/maintenance/activity The reader is using this library: a client sends it on its user's own input (a click, a key, a scroll, a touch), at most once every few seconds, never from a background poll. Background upkeep holds off: an automatic search index tidy-up running for this library pauses, its work kept, and the next one waits until the library has had neither this nor a write for two minutes. With the preloadLibrary and keepLibraryWarm settings on, the first one after a minute without any also has the server check that the library is still in the system's file cache, and read it in again in the background when it is not. It is also what counts as the library being in use for the keepLibraryWarmIdleHours pause: the timed cache checks rest once that many hours have passed with none (counted from the library's opening when none was ever sent), so a client of its own sends it on its user's input to keep them going. A script that wants the upkeep to hold off while it works can send it too
Responses
204 noted
GET /api/maintenance/search-index The library's search indexes for a settings panel: for each, how many segments it holds, its size, and its drift, how many times the disk pages a word lookup reads against the same index tidied into one segment, rounded down to hundredths (null where it cannot be read). Also the drift at which an index is tidied on its own (once the library sits idle), the last tidy-up (when it ended, how long it took, the indexes it tidied and whether it was asked for), the last failure since (when, the index, why, whether asked; null once a later tidy-up ends well), the one running as GET /api/maintenance answers it, what this library's asked tidy-up waits for (its backup, or another library's asked tidy-up; null when none waits), whether automatic tidy-ups are on (the autoTidySearchIndex setting), and whether this server lets a library be loaded into memory at all (libraryMemory). A tidy-up that stopped is tried again in full the next time the library sits idle while automatic tidy-ups are on
Responses
200 object OK
POST /api/maintenance/search-index/tidy Tidy every search index holding more than one segment into one, now, while the reader keeps working (it is never paused by activity). Answered at once: 202 with started true and the tidy-up running, named from the first answer (followed through GET /api/maintenance and its maintenance records), or with queued true while this library is backed up or another library's asked tidy-up runs (this one starts when that ends); 200 with started false when every index is already one segment. It takes the lane from an automatic tidy-up of any library, which pauses and resumes later; asked again while it runs, it answers the one running. A backup goes first: one starting while it runs pauses it, and it carries on once the backup ends. It ends with every index in one segment, apart from what writes made while it ran add
Responses
200 object already tidy
202 object the tidy-up running or waiting
GET /api/jobs/{id} A set job of this account (a by-filter write over characters: a tag write or the undo of one, a delete, a favourite, a playlist's membership): its status and progress (done of total characters, or links for an undo), and its answer in result once it ends. The account's jobs run one at a time on one lane, every kind together, so a job may wait queued behind another. Finished jobs are kept a while in memory, not across a restart, where a running job stops with what landed kept
Parameters
ParameterInTypeDescription
id path string job id
Responses
200 SetJob OK
400 Error numeric id required
404 Error no such job for this account
DELETE /api/jobs/{id} Stop a set job: a queued one never starts, a running one halts before its next batch; what landed stays (a tag write's journaled in its run). Answers the job (a finished one as it ended)
Parameters
ParameterInTypeDescription
id path string job id
Responses
200 SetJob OK
400 Error numeric id required
404 Error no such job for this account
PUT /api/personas/{id}/avatar Replace this persona picture (raw image body, converted to PNG server-side). Rewritten in place, so the file is served on ETag revalidation rather than an immutable cache
Parameters
ParameterInTypeDescription
id path string persona uuid
Request body image/*
string (binary)
Responses
200 Persona OK
400 Error empty body
404 Error persona not found
415 Error not a decodable image
DELETE /api/personas/{id}/avatar Remove the picture; the persona keeps its name and description
Parameters
ParameterInTypeDescription
id path string persona uuid
Responses
200 Persona OK
404 Error persona not found
GET /api/personas/resolve Who the user is in one chat: the per-chat override when set, else the global persona. Omit chatId to resolve the global, which is what every preview outside a conversation uses
Parameters
ParameterInTypeDescription
chatId query string chat uuid; omit for the global answer
Responses
200 object OK
GET /api/personas All personas plus the active one (activeId is null when none is selected). Each row carries its bound lorebook names so an editor renders without a per-persona read
CollectionThe whole set: the reader's own personas.
Responses
200 object OK
POST /api/personas Create a persona. The first one created becomes active; later ones do not steal the selection
Request body application/json
FieldTypeDescription
name required string
description string
pronouns object any of the five forms, each a string of at most 64 characters once trimmed; a form left out is left alone (empty on a create), and an empty string clears one back to its they/them word
Responses
200 Persona OK
400 Error name missing or blank, or pronouns not an object of the five forms as strings of at most 64 characters
PUT /api/personas/active Select the active persona, or pass id null to clear it
Request body application/json
FieldTypeDescription
id string | null
Responses
200 object OK
400 Error id must be a string or null
404 Error no such persona
GET /api/personas/{id} One persona
Parameters
ParameterInTypeDescription
id path string persona uuid
Responses
200 Persona OK
404 Error no such persona
PATCH /api/personas/{id} Update a persona; omitted fields are left alone (a one-field patch never blanks the rest)
Parameters
ParameterInTypeDescription
id path string persona uuid
Request body application/json
FieldTypeDescription
name string
description string
pronouns object any of the five forms, each a string of at most 64 characters once trimmed; a form left out is left alone (empty on a create), and an empty string clears one back to its they/them word
Responses
200 Persona OK
400 Error blank name / wrong type, or pronouns not an object of the five forms as strings of at most 64 characters
404 Error no such persona
DELETE /api/personas/{id} Delete a persona. Deleting the active one clears the selection in the same write
Parameters
ParameterInTypeDescription
id path string persona uuid
Responses
200 object OK
404 Error no such persona
POST /api/bundle/export Build and stream a transfer bundle (.zip): card PNGs (chunks embedded fresh), chats as JSONL, gallery media, worlds, plus a manifest carrying each character's flags (favourite, update lock, media localized, lore dismissed) and lorebook lists. v2 layout: zip paths key on the character uuid, card file names are derived cosmetics. X-Bundle-Count holds how many characters the archive carries. A character it cannot carry (its picture or its card gone) is left out and named: X-Bundle-Skipped-Count holds how many, X-Bundle-Skipped their ids (up to 1000, comma-separated); the three are exposed to a detached client
Request body application/json
FieldTypeDescription
ids array<string> character uuids, exported in this order, a repeated one once; omit (with no filter) for the whole library (in creation order; a character renamed mid-export goes out once)
filter string a GET /api/characters query string (read the list's way; sort, order, paging and count ignored): its set, walked in creation order as it stands, so one created mid-walk that matches goes out and one deleted mid-walk is skipped and named. Never with ids
include object all default true
Responses
200 application/zip attachment
400 Error nothing to export (the library is empty, or the filter names no character), ids and a filter both, a filter parameter refused in the list's words, or one the list does not take
404 Error unknown id
POST /api/bundle/import Import a v2 transfer bundle (raw zip body, streamed to disk: the body is as large as the disk holds, while what it unpacks is capped per member and by the archive budget). Imports NEVER overwrite: each entry triages to new (adopting its free uuid), identical-skip (content hash match; its new chats/media still attach additively), or diverged-skip (uuid taken or provider link matched; reported, nothing written). Each entry (its card, chats, gallery and links) lands whole or not at all: an entry refused part way through, by an extension's store guard included, is named in errors with nothing of it kept, and the restore goes on with the next. A client that hangs up mid-upload leaves nothing (the half-received pack is discarded); one that hangs up during the restore stops it before its next entry, the entries already restored staying. v1/extension packs are rejected with a pointer at the migration tool
Parameters
ParameterInTypeDescription
worlds query 1 | true | yes | 0 | false | no false (or 0, no) skips the bundled lorebooks AND each character's and chat's lorebook list past its first book (the first rides the card and the chat header); a value outside the boolean words is 400
only query string restrict to these manifest uids, and the bundled lorebooks to the ones those entries name (a pack from before the per-entry lists brings all of its lorebooks)
copy query string manifest uids to import as forced NEW copies (the per-entry override for diverged duplicates)
Request body application/zip
string (binary)
Responses
200 object {imported, identical, diverged[], chats, chatLinesDropped (chat file lines left out: torn, or not a JSON object), media, worlds, worldsRenamed, errors}
400 Error not a zip / no manifest / pre-v2 pack; or refused by the archive reader: a member past the import cap, members unpacking past the archive budget, or a corrupt member (its local header, its checksum, or inflating past its declared size)
415 Error a Content-Type other than application/zip, application/x-zip-compressed or application/octet-stream
GET /api/playlists Every playlist with how many characters it holds: { version, playlists: { <id>: entry }, order: [<id>] }, each entry { name, description, icon, color, created, modified, count }. Who is in a playlist is read off the character list (each row carries the ids of its playlists, and a playlist rule filters by one) or asked of a selection (POST /api/playlists/tally), never mirrored whole
CollectionThe whole set: the reader's own playlists, without their members.
Responses
200 object OK
POST /api/playlists Create a playlist at the end of the order; the id is minted by the server
Request body application/json
FieldTypeDescription
name required string
description string
icon string
color string
Responses
200 Playlist OK
400 Error name missing, blank or over 100 characters, or a field not a string
409 Error another playlist has this name (regardless of case)
POST /api/playlists/tally How many of a selection of characters each playlist holds, for a picker over the selection: { <playlist id>: n }, the playlists none of them is in absent. The selection is charIds or filter (a GET /api/characters query string, read the list's way), never both
Request body application/json
FieldTypeDescription
charIds array<string> at most 10000
filter string a GET /api/characters query string
Responses
200 object OK
400 Error neither charIds nor a filter, both, charIds not character ids or more than 10000, or a filter parameter the list refuses or does not take
PATCH /api/playlists/{id} Update a playlist; omitted fields keep their value
Parameters
ParameterInTypeDescription
id path string playlist id
Request body application/json
FieldTypeDescription
name string
description string
icon string
color string
Responses
200 Playlist OK
400 Error a blank name or a field not a string
404 Error no such playlist
409 Error another playlist has this name (regardless of case)
DELETE /api/playlists/{id} Delete a playlist and its memberships (the characters stay)
Parameters
ParameterInTypeDescription
id path string playlist id
Responses
200 Ok OK
404 Error no such playlist
GET /api/playlists/{id}/members A playlist's members in its order, a page at a time: walk nextCursor (after) until it is null
CollectionA page: 1000 unless limit asks, at most 10000, walked by its cursor (after, nextCursor); the list is ids.
Parameters
ParameterInTypeDescription
id path string playlist id
after query string the nextCursor of the page before
limit query integer ids a page: default 1000, at most 10000
Responses
200 object OK
400 Error a limit outside 1 to 10000, or an after that is not a cursor
404 Error no such playlist
POST /api/playlists/{id}/members/apply Add and remove members, by ids or by filter. By add and remove (at most 10000 ids between them a request; a larger selection goes in several requests, or by its filter), in one write: added characters join at the end in the order given; an id the library does not hold joins nothing and comes back in skipped. The answer carries the playlist with its new count, and the characters added or removed are reported changed (their rows carry their playlists). By filter and op (a GET /api/characters query string, read the list's way; op add or remove): the set is fixed, then a job adds or removes it in batches of a thousand characters, each landing whole; answered at once (202) with the job, whose answer {changed, playlist} (GET /api/jobs/{id}) counts the memberships that moved (the rest of its total already were members, or were not) and carries the playlist with its new count. A playlist deleted while the job runs fails it
Parameters
ParameterInTypeDescription
id path string playlist id
Request body application/json
FieldTypeDescription
add array<string>
remove array<string>
filter string a GET /api/characters query string
op add | remove with filter
Responses
200 object OK
202 object by filter: the job
400 Error nothing to add or remove, a list that is not character ids, more than 10000 ids between add and remove, a filter beside add or remove, an op other than add or remove, or a filter parameter the list refuses or does not take
404 Error no such playlist
GET /api/versions/char/{charId} A character's snapshot history
Parameters
ParameterInTypeDescription
charId path string character uuid
Responses
200 object OK
404 Error no versions for this character
DELETE /api/versions/char/{charId} Delete all snapshots for a character
Parameters
ParameterInTypeDescription
charId path string character uuid
Responses
200 Ok OK
POST /api/versions/char/{charId}/snapshots Add one snapshot under the next id, never one a deleted snapshot of the character held. An automatic snapshot (auto_backup, or assistant: the Chat Assistant's own before it writes a card) identical to the newest of its source is not stored again (its id answers), and past its source's cap (maxAutoBackups for auto_backup, maxAssistantBackups for assistant; 0 keeps all) that source's oldest go in the same write
Parameters
ParameterInTypeDescription
charId path string character uuid
Request body application/json
FieldTypeDescription
label string
source string 'local' (default), 'auto_backup', 'assistant', 'remote' or another source name
charName string
data required object the composed card's data
Responses
200 object OK
400 Error no data object, or a source that is not a string
404 Error character not found
PATCH /api/versions/char/{charId}/snapshots/{snapId} Rename one snapshot
Parameters
ParameterInTypeDescription
charId path string character uuid
snapId path string snapshot id
Request body application/json
FieldTypeDescription
label required string
Responses
200 Ok OK
400 Error a snapshot id that is not a whole number, or no label
404 Error no such snapshot
DELETE /api/versions/char/{charId}/snapshots/{snapId} Delete one snapshot
Parameters
ParameterInTypeDescription
charId path string character uuid
snapId path string snapshot id
Responses
200 Ok OK
400 Error a snapshot id that is not a whole number
404 Error no such snapshot
PUT /api/versions/char/{charId}/backup Write the one pre-restore backup slot
Parameters
ParameterInTypeDescription
charId path string character uuid
Request body application/json
FieldTypeDescription
timestamp integer
data required object
Responses
200 Ok OK
400 Error no data object
404 Error character not found
DELETE /api/versions/char/{charId}/backup Clear the backup slot
Parameters
ParameterInTypeDescription
charId path string character uuid
Responses
200 Ok OK
GET /api/settings All settings as one object
Responses
200 object OK
PUT /api/settings Replace all settings
Request body application/json
object
Responses
200 Ok OK
400 Error settings body must be an object
PATCH /api/settings Upsert a subset of keys
Request body application/json
object
Responses
200 Ok OK
400 Error settings body must be an object
GET /api/store/{key} Generic KV read (module state documents)
Parameters
ParameterInTypeDescription
key path string store key
Responses
200 object OK
400 Error bad key: must match ^[a-z0-9][a-z0-9_-]{0,63}$
404 Error no such key
PUT /api/store/{key} KV write
Parameters
ParameterInTypeDescription
key path string store key
Request body application/json
object
Responses
200 Ok OK
400 Error bad key (as on the read), or no JSON body
DELETE /api/store/{key} KV delete
Parameters
ParameterInTypeDescription
key path string store key
Responses
200 Ok OK
400 Error bad key (as on the read)

tags

Library-wide tag edits and the undo journal of their runs

GET /api/tags A page of the library's tags, each with how many characters carry it, in name order (case folded) or most used first; q asks for the names that contain it, in the same order
CollectionA page: 100 unless limit asks, at most 1000, walked by its cursor (after, nextCursor).
Parameters
ParameterInTypeDescription
limit query integer rows a page: default 100, at most 1000; past it, walk nextCursor with after
after query string the nextCursor of the page before: the tags after it, O(page) at any depth
count query 1 | true | yes | 0 | false | no count=false skips the total (null in the answer); a walk reads nextCursor for has-more
q query string the names that contain this text, case folded; a % or _ is a character
sort query name | count default name (case folded, ASCII); count is most carried first, then by name. A cursor walks only the sort that answered it; an unknown value is refused 400 naming the set
Responses
200 object OK
400 Error a limit outside 1 to 1000, an after that is not a cursor of this sort, an unknown sort, or a count that is not a boolean word
POST /api/tags/rename Rename a tag everywhere; if the target name exists (compared case-insensitively in ASCII) this merges carriers onto it. With run, the undo is journaled with the rename, landing together, as a links run (each carrier's source link with the place it held, the target link it gained): { label } opens a run, { id } joins the newest run so a bulk run's ops are one undo (POST /api/tag-runs/{id}/undo). A saved filter preset (the filter-presets store document) naming the tag, as the filter engine matches it (case-insensitively in ASCII), takes the new name (on a merge, the surviving tag's) in the same write, the document's change record naming no tab; with run, each rule rewritten is journaled in the run, so the undo puts it back, and so is the rename or merge itself, so the undo reports the name moving back. Answers counts, never carrier ids
Request body application/json
FieldTypeDescription
from required string
to required string
run object { label } opens a run, { id } joins the newest
Responses
200 object OK
400 Error {from, to} required, or a run with no label
404 Error no such tag
409 Error the run named is not the newest
POST /api/tags/remove Remove a tag from every carrier and delete the tag. With run (as rename), each carrier's link is journaled with the place it held, so the undo puts the tag back there. A saved filter preset's rule naming the tag (case-insensitively in ASCII) goes in the same write and the preset lists it under removed, for the client to say once; with run, each rule taken is journaled in the run with its place, so the undo puts it back there, and so is the remove itself. Answers counts, never carrier ids
Request body application/json
FieldTypeDescription
name required string
run object { label } opens a run, { id } joins the newest
Responses
200 object OK
400 Error {name} required, or a run with no label
404 Error no such tag
409 Error the run named is not the newest
POST /api/tags/apply Add/remove tag names on a set of characters (batch tagging), named by charIds or by filter, never both. Appends keep per-char order; zero-use tags are pruned; no character's updatedAt moves. By charIds, all or nothing: unknown ids are skipped and reported, deltas lists per-char ACTUAL changes (undo-grade), and only a character with one is listed in affected, answered {ok, touched, affected, skipped, deltas}; at most 10000 ids a request, so a larger selection is sent as several requests, each landing whole, or as its filter. By filter (a GET /api/characters query string: every filter parameter it takes, read the list's way; sort, order, paging and count ignored): the set is fixed, then a job writes it in batches of a thousand characters, each landing whole, journaling every link it moves as a links run (Undo: POST /api/tag-runs/{id}/undo) and reporting the characters it changed; answered at once (202) with the job, whose progress and answer GET /api/jobs/{id} reads (the answer counts per name, never a list of characters, since a filter can be the whole library)
Request body application/json
FieldTypeDescription
charIds array<string> at most 10000
filter string a GET /api/characters query string
add array<string>
remove array<string>
Responses
200 object by charIds {ok, touched, affected, skipped, deltas: [{charId, added, removed}]}
202 object by filter: the job
400 Error nothing to do, add or remove not an array, a name both added and removed, more than 10000 charIds, charIds and a filter both, a filter parameter refused in the list's words, or a filter parameter the list does not take (a misspelled one would name the whole library)
POST /api/tags/tally The tags a set of characters carries and how many of the set carry each, most carried first, with the size of the set: what the batch tag editor shows as the tags on every character and on some. The set is charIds (an unknown id is not counted; at most 10000 a request, so a larger selection is counted in parts, which add up, or by its filter) or filter (a GET /api/characters query string, read the list's way; sort, order, paging and count ignored), never both. An empty filter is the whole library and answers from the tag list itself
Request body application/json
FieldTypeDescription
charIds array<string> at most 10000
filter string a GET /api/characters query string
Responses
200 object OK
400 Error neither charIds nor a filter, both, more than 10000 charIds, a filter parameter refused in the list's words, or a filter parameter the list does not take
POST /api/tags/resolve Names snapped to the spellings the library already uses: each matched by name case-insensitively in ASCII, then by loose key (case, spacing and punctuation folded, so post-apocalyptic finds Post Apocalyptic), answered with the stored spelling and the carrier count of that tag; an unknown name comes back as given with known false. Input order, deduped by resolved key, blanks dropped, at most 200 names. A read for anything that offers tags (the tag wand of the creator), never a mint
Request body application/json
FieldTypeDescription
names required array<string> at most 200 are read
each boolean true: one answer per name in its place, duplicates and blanks included (a blank tag for what is no name), so many names map back; default: deduped by resolved key, blanks dropped
Responses
200 object OK
400 Error names array required
GET /api/tag-runs The bulk tag-run undo journal, newest first: {id, ts, label, kind, opCount, linkCount} per run (kind links: the links a tag op or job moved, and its opCount the saved filter preset rules its renames and removes rewrote; the server keeps the newest run alone, the one an undo reaches)
CollectionThe whole set: the newest run.
Responses
200 array<object> OK
POST /api/tag-runs/{id}/undo Undo the newest run when it is a tag job's (kind links): a job of its own takes off the links the run added and puts back the ones it removed (a tag the removal pruned is minted again; a character deleted since is passed over), then, as its last step, puts back each saved filter preset rule the run rewrote, newest first, only where the preset still holds what the run left (a preset deleted or a rule changed since is left as it stands, and a rule coming back never doubles one the preset holds), and says each rename, merge or remove the run journaled the other way, newest first: a rename back is reported as a tag rename (a tag change record, the name and its to), so every client's filters naming the tag follow it, while a merge's or a remove's undo brings the name back and reports no rename; all of it journaled as a links run of its own so the undo can be undone, and undoing that undo reports a rename, merge or remove as the op did. Answered at once (202) with the job (GET /api/jobs/{id}). A tag job queued or running holds it; a job of another kind does not, and the undo waits behind it on the lane
Parameters
ParameterInTypeDescription
id path string run id
Responses
202 object OK
400 Error numeric id required
404 Error run not found
409 Error not the newest run, or a tag job queued or running
GET /api/tag-runs/{id} One run's summary, as the journal lists it (its links are the server's to undo, never listed)
Parameters
ParameterInTypeDescription
id path string run id
Responses
200 object OK
400 Error numeric id required
404 Error run not found
DELETE /api/tag-runs/{id} Drop a run, and the undo it held with it
Parameters
ParameterInTypeDescription
id path string run id
Responses
200 Ok OK
400 Error numeric id required
404 Error run not found

llm

LLM profiles + server-side chat calls (keys stay server-side), prompt presets and regex scripts

GET /api/llm/kinds The connection kinds this account can use, with capabilities + base-url requirements (drives the settings UI): the app's own, then the ones this account's switched-on extensions add (ctx.llm.registerAdapter), each naming its extension. A kind whose extension is off for the account is absent, and the profile routes refuse it as a kind
CollectionThe whole set: the app's kinds and the ones the account's extensions add.
Responses
200 array<object> OK
GET /api/presets Every prompt preset by name, plus the active one. A row carries no blocks: one preset is read whole by its id, or beside the resolve that names it. activeId null means assembly uses the built-in default block list, which is returned as defaultBlocks so a client can show it instead of rendering a blank panel
CollectionThe whole set: the reader's own presets.
Responses
200 object OK
POST /api/presets Create a preset. Omitting blocks seeds the default block list, never an empty one (an empty preset assembles no character at all). regexScripts, a preset file's own, are stored as the preset's scripts, which run once the preset is allowed
Request body application/json
FieldTypeDescription
name required string
blocks array<PresetBlock>
regexScripts array<RegexScript>
settings PresetSettings the settings it starts with (a copy sends the original's); one left out reads its default
Responses
200 Preset OK
400 Error name missing / unknown marker / bad role or position / a setting not listed, of another type, or a text past 20000 characters / a regex script out of shape (refused as /api/regex/scripts refuses it, nothing made) / more than 1000 scripts
POST /api/presets/import Import a SillyTavern chat-completion preset. Connection identity (chat_completion_source, *_model, custom_url, reverse_proxy, proxy_password) is DROPPED because the LLM profile holds it, and everything dropped is named in the report. The settings that shape its prompt (its formats, its new-chat and example lines, its impersonation and continue instructions, squash) become the preset's own settings, and a block after Chat History in its order goes after the history
Request body application/json
FieldTypeDescription
preset required object
name string
Responses
200 object OK
400 Error not an object / nothing expressible in it
PUT /api/presets/active Select the active preset, or pass id null to fall back to the built-in default
Request body application/json
FieldTypeDescription
id string | null
Responses
200 object OK
400 Error id must be a string or null
404 Error no such preset
GET /api/presets/resolve Which preset builds one chat's prompt: the chat's own when set, else the active preset, else none (the built-in blocks). Omit chatId to resolve the default. with=preset answers that preset whole beside its id
Parameters
ParameterInTypeDescription
chatId query string chat uuid; omit for the default answer
with query preset preset: the answer also carries the preset in force, with its blocks
Responses
200 object OK
400 Error with is not preset
GET /api/presets/{id}/export The preset as a SillyTavern chat-completion preset file: its blocks as prompts in their order, its settings under the file's keys, its regex scripts in the file's extensions. What the file has no place for (the character picture block, the directed-reply instruction) is named in the report
Parameters
ParameterInTypeDescription
id path string preset uuid
format query sillytavern the file format; sillytavern is the one there is
Responses
200 object OK
400 Error an unknown format
404 Error no such preset
GET /api/presets/{id} One preset with its blocks
Parameters
ParameterInTypeDescription
id path string preset uuid
Responses
200 Preset OK
404 Error no such preset
PATCH /api/presets/{id} Update a preset. Supplying blocks REPLACES the list wholesale, because order is part of the data; supplying settings replaces them whole too, a setting left out reading its default again
Parameters
ParameterInTypeDescription
id path string preset uuid
Request body application/json
FieldTypeDescription
name string
blocks array<PresetBlock>
settings PresetSettings
Responses
200 Preset OK
400 Error blank name / invalid block / a setting not listed, of another type, or a text past 20000 characters
404 Error no such preset
DELETE /api/presets/{id} Delete a preset; deleting the active one clears the selection so assembly falls back to the default
Parameters
ParameterInTypeDescription
id path string preset uuid
Responses
200 object OK
404 Error no such preset
GET /regex/engine.js The regex engine the server runs, as a JavaScript module served without signing in, so a client's screen pass gives the same results
Responses
200 string the module
GET /api/regex/chat/{chatId} The regex scripts a chat runs: the reader's own, then its preset's, then its character's, each source whole with its answer (allowed, declined, or null while unanswered); active is the run order, a preset's or a character's scripts only while allowed; names fills {{user}} and {{char}} for the screen's pass. The read first tries the scripts that change what is shown on the chat's newest 50 shown texts under the same time budget, so a pattern that runs out of time there is stopped (flagged stopped here, and skipped by every pass until saved again)
Parameters
ParameterInTypeDescription
chatId path string chat uuid
Responses
200 object OK
404 Error no such chat
GET /api/regex/scripts One list of regex scripts in run order: the reader's own, or a preset's when presetId names one
CollectionThe whole set: one list of regex scripts.
Parameters
ParameterInTypeDescription
presetId query string preset uuid; omit for the reader's own
Responses
200 object OK
404 Error no such preset
POST /api/regex/scripts Add regex scripts to the reader's list or a preset's: one as script, or several as scripts (an import); each gets a new id. after places them right below that script. A single script is first run over sample when sent, and one that runs out of time there is refused
Request body application/json
FieldTypeDescription
presetId string | null
script RegexScript
scripts array<RegexScript>
after string
sample string
Responses
200 object OK
400 Error no script / a script not an object / a list past its limit
404 Error no such preset
422 Error the pattern ran out of time on the sample (kind timeout)
PATCH /api/regex/scripts/{id} Replace one regex script's fields; run over sample first when sent, and refused when it runs out of time there. Saving clears a stop for running out of time
Parameters
ParameterInTypeDescription
id path string script uuid
Request body application/json
FieldTypeDescription
script required RegexScript
sample string
Responses
200 object OK
400 Error not an object / bad field
404 Error no such script
422 Error the pattern ran out of time on the sample (kind timeout)
DELETE /api/regex/scripts/{id} Remove one regex script from its list
Parameters
ParameterInTypeDescription
id path string script uuid
Responses
200 object OK
404 Error no such script
PUT /api/regex/order Put the reader's list or a preset's in a new order; ids names every script in it, each once
Request body application/json
FieldTypeDescription
presetId string | null
ids required array<string>
Responses
200 object OK
400 Error ids not exactly the list
404 Error no such preset
GET /api/regex/characters/{charId} A character's regex scripts, as its card carries them
Parameters
ParameterInTypeDescription
charId path string character uuid
Responses
200 object OK
404 Error no such character
PUT /api/regex/characters/{charId} Replace a character's regex scripts on its card (an empty list removes them); it reaches open tabs as the character's update. With sample, each script is tried on it first and a list holding one that runs out of time is refused (422, kind timeout), nothing written
Parameters
ParameterInTypeDescription
charId path string character uuid
Request body application/json
FieldTypeDescription
scripts required array<RegexScript>
sample string
Responses
200 object OK
400 Error scripts not a list / a script not an object
404 Error no such character
422 Error a script ran out of time on the sample
POST /api/regex/test Run one regex script alone over a sample, under the same time limit a chat has: what the screen shows, what the model is sent, what a save would keep, and how many places it matches. error is timeout when it ran out of time, invalid when the find does not compile (matches is then 0). chatId fills macros from that chat
Request body application/json
FieldTypeDescription
script required RegexScript
text string
where 1 | 2 | 3 | 5 | 6
depth integer
chatId string
Responses
200 object OK
400 Error not an object / bad field
GET /api/regex/export A list of regex scripts as a SillyTavern script file holds them: the reader's own, a preset's (presetId) or a character's (charId)
CollectionThe whole set: one list of regex scripts.
Parameters
ParameterInTypeDescription
presetId query string preset uuid
charId query string character uuid
Responses
200 array<RegexScript> OK
404 Error no such preset or character
GET /api/llm/profiles LLM profiles (api keys never returned; hasKey and keyHint only)
CollectionThe whole set: the reader's own connection profiles.
Responses
200 array<LlmProfile> OK
POST /api/llm/profiles Create a profile (kind must be a registered adapter; params = neutral default generation params)
Request body application/json
FieldTypeDescription
name required string
kind string
baseUrl string
apiKey string
model string
params object
contextSize integer | null token window this connection declares; overrides the global chat budget, null uses it
vision boolean | null whether the model sees pictures: true, false, or null when not checked; a call carrying pictures to a connection set false is refused
maxImages integer | null the most pictures the host takes in one request; a chat prompt over it sends the oldest as text, null is no limit
Responses
200 LlmProfile OK
400 Error a bad kind, a blank or missing name, a contextSize that is not a positive number, a vision that is not true, false or null, a maxImages that is not a whole number above zero or null, or params that are not an object or that the neutral vocabulary refuses (an unknown key, a sampler that is not a number, a bad stop, json or reasoning.effort)
GET /api/llm/profiles/resolve Which connection answers one chat: the chat's own when set, else the default for chats, else the first. Omit chatId to resolve the default
Parameters
ParameterInTypeDescription
chatId query string chat uuid; omit for the default answer
Responses
200 object OK
PATCH /api/llm/profiles/{id} Update a profile; apiKey is write-only (absent = keep, empty = clear)
Parameters
ParameterInTypeDescription
id path string profile uuid
Request body application/json
FieldTypeDescription
name string
kind string
baseUrl string
apiKey string
model string
params object
contextSize integer | null token window this connection declares; overrides the global chat budget, null uses it
vision boolean | null whether the model sees pictures: true, false, or null when not checked; a call carrying pictures to a connection set false is refused
maxImages integer | null the most pictures the host takes in one request; a chat prompt over it sends the oldest as text, null is no limit
Responses
200 LlmProfile OK
400 Error a bad kind, a blank name, a contextSize that is not a positive number, a vision that is not true, false or null, a maxImages that is not a whole number above zero or null, or params that are not an object or that the neutral vocabulary refuses (an unknown key, a sampler that is not a number, a bad stop, json or reasoning.effort)
404 Error not found
DELETE /api/llm/profiles/{id} Delete a profile
Parameters
ParameterInTypeDescription
id path string profile uuid
Responses
200 Ok OK
404 Error not found
POST /api/llm/profiles/{id}/duplicate Copy a profile at the end of the order, the stored API key included (the client can never read a key back, so the copy is made here); name defaults to "<name> copy"
Parameters
ParameterInTypeDescription
id path string profile uuid
Request body application/json
FieldTypeDescription
name string
Responses
200 LlmProfile OK
404 Error not found
GET /api/llm/models Model list from the profile's upstream (contextLength only when upstream reports it; no hardcoded tables)
CollectionThe whole set: the upstream's model list.
Parameters
ParameterInTypeDescription
profileId query string omit = first profile
Responses
200 array<object> OK
502 Error upstream/list failure with kind
POST /api/llm/models Same list, probing an editor DRAFT: overrides (kind, baseUrl, apiKey, model and params, the params checked as a save checks them) overlay the stored profile for this call only, nothing is saved, and the stored key stands in when the draft key is blank. Overrides ride the body so a key never lands in a query string
Request body application/json
FieldTypeDescription
profileId string omit = first profile
overrides object
Responses
200 array<object> OK
400 Error unknown kind / draft without a base URL / a draft param a save refuses
502 Error upstream/list failure with kind
POST /api/llm/test Connection probe: a 1-token real chat under a 15s ceiling. Always 200; the body carries the verdict. overrides (kind, baseUrl, apiKey, model and params) overlay the stored profile for this call only, the way the model probe takes a draft, so what is on screen is what gets tested and a key is checked before it is saved; the stored key stands in when the draft key is blank
Request body application/json
FieldTypeDescription
profileId string
overrides object
Responses
200 object {ok} | {ok: false, kind, error, timedOut}
POST /api/llm/test-vision Sight probe: shows the model two small pictures of one colour each and asks it to name both, under a 60s ceiling, through the draft as the connection probe takes one. Always 200; the body carries the verdict: sees true when it names both in order; false with a reason when the kind cannot carry pictures, the endpoint refused them (its words) or the answer missed them (what it said); null when the call could not be made or came back empty. Nothing is stored: a saved answer is the profile's vision
Request body application/json
FieldTypeDescription
profileId string
overrides object
Responses
200 object {sees: true} | {sees: false, reason: kind|refused|answer, error?, said?} | {sees: null, kind, error}
POST /api/llm/chat Server-side LLM call via a profile (keys never reach clients). Neutral params (temperature, topP, topK, maxTokens, stop, presencePenalty, frequencyPenalty, seed, reasoning{effort}, json) are translated per adapter, reasoning.effort being one word of 1 to 32 lowercase letters, digits, _ or - that the host receives as-is (none, minimal, low, medium, high, xhigh and max are the common ones, and a model that does not take a level refuses it); profile defaults merge under request params; flat temperature/maxTokens stay accepted. stream=false: normalized {content, reasoning?, finishReason, usage?, profileId}. stream=true: SSE with events chunk({text}|{reasoning}) / done({finishReason, usage?}) / error({kind, message}) - typed even mid-stream. Retries are bounded and pre-first-token only; streams are reaped on token INACTIVITY, not request age; aborting the request observably disconnects the upstream
Request body application/json
FieldTypeDescription
profileId string omit = first profile
messages required array<object>
model string
params object
stream boolean
temperature number
maxTokens integer
Responses
200 object normalized result, or text/event-stream when stream=true
400 Error no profile / bad body / unknown param / an image the call cannot carry
502 Error upstream error with kind
504 Error timeout

extensions

Installed extensions: list, switch on or off, install, update and remove; their background jobs and their own routes

GET /api/extensions Installed-extension inventory ({enabled, extensions[], namespaces[]}), as the asking account sees it: each row carries enabled (whether it runs for this account); a broken install reports an error row instead of vanishing, and namespaces lists every card extensions namespace the server reads as a provider link rather than card content, in this order: the built-in providers', then every one an extension has registered, kept after that extension is removed. Extensions are trusted code: installing one grants it full client and server privileges
CollectionThe whole set: every installed extension.
Responses
200 object OK
PUT /api/extensions/{id}/enabled Switch an extension on or off for your own account. The server keeps the rule: a bundled extension runs until an account switches it off (unless it ships defaultOff), any other runs once switched on, and switching on one that names an exclusive group switches off the group's others that ran for the account. Answers the row as it now stands, with switchedOff, the rows switched off to make room (empty for most); a server half answers, guards and listens for the accounts it is on for
Parameters
ParameterInTypeDescription
id path string
Request body application/json
FieldTypeDescription
enabled required boolean
Responses
200 ExtensionRow + object OK
400 Error enabled is not a boolean
404 Error no such extension
GET /api/extensions/jobs This account's extension jobs (an extension's ctx.jobs work), every extension's: the running, then the queued by their place in their extension's lane, then the last finished, newest first. Held in memory, so a restart forgets them. A job's start and end reach the account's feed as an extensionJob record with a null origin; its progress is read here
CollectionThe whole set: the account's jobs running and queued, and its 20 newest finished.
Responses
200 array<ExtensionJob> OK
DELETE /api/extensions/jobs Dismiss every finished job of this account
Responses
200 object {cleared}
DELETE /api/extensions/jobs/{id} Cancel a queued or running job of this account (a running one settles at once as cancelled, its signal aborted, and its lane moves on), or dismiss a finished one
Parameters
ParameterInTypeDescription
id path integer
Responses
200 object {ok}
400 Error numeric id required
404 Error this account holds no such job
POST /api/extensions/install Install an extension into extensions/installed/<id> (admin), from one of two sources: an https git repo (a JSON body; cloned) or the extension's folder as a zip archive (an application/zip body, streamed to disk; the manifest at its root or inside its one wrapping folder, as a repository's Download ZIP makes it; a .git folder inside is left out). Either lands in a temp dir first and its manifest is validated before it occupies the tree. An archive is refused whole, nothing written, when an entry names a path outside the folder or one the server cannot hold (absolute, dotted, a drive, a device name), when a name repeats, or past its limits (100 MB uploaded, 10000 entries, 50 MB an entry, 200 MB unpacked); each entry's bytes must match the archive's directory (size and crc)
Request body application/json
FieldTypeDescription
git required string plain https git url
Request body application/zip
string (binary)
Responses
200 object {id}
400 Error bad url / clone, archive or manifest failure / a manifest needing a newer extension api than the server speaks (the error names both versions) / extensions disabled
403 Error admin required
409 Error already installed
413 Error the archive is larger than the upload limit
GET /api/extensions/updates The last update check (admin): for each git-installed extension, whether its repository holds a newer commit, the version that commit's manifest names, or why the repository could not be asked. Held in memory, so checkedAt is null until a check runs after a restart
Responses
200 object {checkedAt, checking, extensions}
403 Error admin required
POST /api/extensions/updates/check Ask every git-installed extension's repository for its latest commit now (admin), or answer a check younger than maxAge milliseconds as it is; a second ask joins the one running. It never updates anything. What changed since the last check is announced as extension records
Request body application/json
FieldTypeDescription
maxAge number answer the last check as it is when it is younger than this many milliseconds; 0 or absent always asks
Responses
200 object {checkedAt, checking, extensions}
400 Error maxAge not a number of 0 or more / extensions disabled
403 Error admin required
POST /api/extensions/{id}/update Bring a git-installed extension to its repository's latest commit (admin): the install is reset to that commit, so a rewritten history or an edit inside its folder never blocks an update. A new version that would not load is refused and the install stays as it was. updated is false when it was on that commit already. A server half keeps running the code it booted with, so restart is true when an update reached an extension that has one (its inventory serverState reads restart until the server restarts)
Parameters
ParameterInTypeDescription
id path string
Responses
200 object {id, updated, from, to, restart}
400 Error not a git install / the repository could not be reached / the new version would not load / extensions disabled
403 Error admin required
404 Error no such extension
DELETE /api/extensions/{id} Remove an installed extension from disk, its extensions/installed/.data/<id> scratch and its ext/<id> folder in every account's home included (admin). A mounted server half stops answering at once (its routes 404), without a restart, and every account forgets its switch (the id leaves enabledExtensions and disabledExtensions in every library, a closed one included), so an install under the same id later starts off. A folder shadowing a bundled id goes alone: the bundled extension keeps its scratch, every account's folder of it, its running half and every account's switch, and the answer says shadowed
Parameters
ParameterInTypeDescription
id path string
Responses
200 object {id}, or {id, shadowed: true} for a folder that shadowed a bundled id; {id, leftover: [handle]} names the accounts whose ext/<id> folder could not be deleted, the removal standing
400 Error invalid extension id
403 Error admin required
404 Error no such extension
GET /ext/{id}/{path} An extension's published client files: only paths under the folders holding its manifest client and style entries resolve (the server entry, manifest.json, package.json and the .data scratch never do); a broken or unknown extension, a dotfile, or a traversal segment answers 404. Nothing is served with CL_EXTENSIONS=off
Parameters
ParameterInTypeDescription
id path string the extension id, or <id>@<digits>: a generation, which serves exactly what the id does (a page reloading an extension asks a new one, so the relative imports of its entry resolve inside it and the module graph is fetched fresh); any other suffix answers 404
path path string path below the extension root
Responses
200 file
404 Error not published by this extension

auth

Sessions + accounts (multi-user mode)

POST /api/auth/login Exchange handle + password for a session cookie
Request body application/json
FieldTypeDescription
handle required string
password required string
Responses
200 object {handle, displayName, admin, mustChangePassword}; sets the cl_session cookie
400 Error multi-user disabled
401 Error invalid credentials (one generic error, no account enumeration)
429 Error too many failed attempts on this handle or from this address (Retry-After: the seconds until the lock lifts)
POST /api/auth/logout Clear the session cookie
Responses
200 Ok OK
GET /api/auth/me Who am I ({multiUser, handle, displayName, admin, mustChangePassword}); in single-user mode always the default user
Responses
200 object OK
401 Error signed out (multi-user mode)
POST /api/auth/password Self-service password change; clears mustChangePassword and re-issues the session (the version bump kills all older cookies)
Request body application/json
FieldTypeDescription
currentPassword required string
newPassword required string
Responses
200 Ok OK
400 Error multi-user disabled, or a new password under 4 characters
401 Error wrong current password
429 Error too many failed attempts on this account (the login's lock) (Retry-After: the seconds until the lock lifts)

admin

User management (admin accounts only)

GET /api/admin/users List accounts (no secret material)
CollectionThe whole set: every account on the server.
Responses
200 array<object> OK
400 Error multi-user is disabled on this server
403 Error admin required
POST /api/admin/users Create an account (lands on mustChangePassword)
Request body application/json
FieldTypeDescription
handle required string lowercase [a-z0-9-], 2-32 chars; becomes the data/<handle>/ folder
displayName string
password required string
admin boolean true makes an admin; anything else a plain account
Responses
201 object OK
400 Error bad handle/password, or multi-user is disabled on this server
403 Error admin required
409 Error handle taken
PATCH /api/admin/users/{handle} Update display name / admin / enabled, or reset the password (forces a change on next login). Self-demotion, self-disable, and last-admin removal are refused
Parameters
ParameterInTypeDescription
handle path string
Request body application/json
FieldTypeDescription
displayName string
admin boolean
enabled boolean
password string
Responses
200 object OK
400 Error a field not of its type (admin and enabled are booleans, displayName a string, password at least 4 characters), refused before anything is written; a guard-rail refusal (yourself, the last admin); or multi-user is disabled on this server
403 Error admin required
404 Error no such user
DELETE /api/admin/users/{handle} Delete the account; the data/<handle>/ folder is deliberately KEPT and its path returned
Parameters
ParameterInTypeDescription
handle path string
Responses
200 object {ok, keptData}
400 Error self-delete or last admin, or multi-user is disabled on this server
403 Error admin required
404 Error no such user

infra

Health, the app's own updates, thumbnails, proxy, provider services

GET /api/health Liveness + the package version + apiVersion (the HTTP contract's own, info.version here) + multiUser flag + spec pointer
Responses
200 object OK
GET /api/app/update The app's own update state (admin): the install type, the running version, what the last check found and whether this install can update itself. Held in memory, so checkedAt is null until a check runs after a restart
Responses
200 object OK
403 Error admin required
POST /api/app/update Update a git clone to the newest commit of its branch (admin). Refused with the reason when an update is already starting or running, or waits for a restart, or the install has local edits, a history that cannot move forward, nothing newer, or work a restart would cut (a backup, a job over many characters, an extension job, a write still running). Otherwise it answers 202 at once and goes on: every library is backed up (unless backup is false), the branch moves forward, and a server started by the launcher restarts on the new version; one started another way waits for a restart (restartNeeded). Each phase is announced as appUpdate records
Request body application/json
FieldTypeDescription
backup boolean back up every library first; true when absent
Responses
202 object the state, updating
400 Error a docker or zip install, which updates by hand, or a backup that is not true or false
403 Error admin required
409 Error refused: the reason names what blocks it
502 Error the repository could not be reached
POST /api/app/update/check Ask what is newer now (admin): a clone fetches its branch and reads the version it names, a container or a download asks GitHub's newest release; the notes of every release between come along; a check younger than maxAge milliseconds answers as it is, and a second ask joins the one running. It never changes the install
Request body application/json
FieldTypeDescription
maxAge number answer the last check as it is when it is younger than this many milliseconds; 0 or absent always asks
Responses
200 object OK
400 Error maxAge not a number of 0 or more
403 Error admin required
PUT /api/app/update/skip Remember a version not to be told about again, for the whole server (admin); null forgets it
Request body application/json
FieldTypeDescription
version required string | null
Responses
200 object OK
400 Error no version, or one that is not a version
403 Error admin required
DELETE /api/app/update/failure Let go of a failed update for the whole server (admin), so no tab shows it again; a running update is untouched. Answers the state
Responses
200 object OK
403 Error admin required
GET /api/openapi.json This document
Responses
200 object OK
GET /api/feed The change feed: a WebSocket (a plain GET answers 426)

Upgrade to a WebSocket and every committed write to your library arrives as it lands, whichever client or server code made it. The server speaks JSON messages and ignores anything sent to it: {type: "hello", clientId, handle} once; {type: "changes", records} per batch, each record {entity, op, ids?, all?, fields?, origin, ...} naming what changed by id (entity and op are one of appUpdate updated, assistantSession created/updated/deleted, attachment created/deleted, background created/updated/deleted, backgroundBinding updated/deleted, backup updated, character created/updated/deleted, chat created/updated/deleted, document updated/deleted, extension updated, extensionJob updated/deleted, library changed, llmProfile created/updated/deleted, maintenance updated, media created/updated/deleted, mediaJob updated/deleted, message created/updated/deleted, persona created/updated/deleted, playlist created/updated/deleted, preset created/updated/deleted, regexConsent updated, regexScript created/updated/deleted, setting updated, studioSession created/updated/deleted, tag updated/deleted, tagRun created/deleted, user created/updated/deleted, version updated/deleted, world created/updated/deleted, worldEntry created/updated/deleted, worldLink updated; all: true, with no ids, when the write spanned more rows than a record names (a whole set, or characters past a thousand); origin is the client id the writing request sent as X-CL-Client, so a tab can skip its own, and null for what an extension wrote through its own routes or listeners; extension, on a record an extension reported for a write to its own tables, is that extension's id, its fields named <id>.<name>: the entity's own data did not change; to, on a tag or lorebook rename, is the name it has now, the old one in ids: a tag merge is the merged tag's deleted record with to the surviving tag's spelling, a tag delete carries no to, and a binding sweep that re-pointed a lorebook is a worldLink record naming the old name as world beside to); and {type: "resync"} when a slow connection fell behind, after which a client re-reads what it shows. The feed carries no history: after a reconnect, re-read. user records reach admins only. The connection closes with 4001 when the session ends (a password change, a disabled account).

Parameters
ParameterInTypeDescription
client query string the id of this tab: the value its API requests send as X-CL-Client (8 to 64 of [A-Za-z0-9-])
Responses
101 switching protocols
401 Error signed out
403 Error an Origin the API would not answer (same origin, or one CL_CORS names)
426 Error not a WebSocket upgrade
GET /persona-avatars/{file} Persona picture ({persona-uuid}.png, ETag revalidation)
Parameters
ParameterInTypeDescription
file path string persona uuid plus .png
Responses
200 image/png
400 Error bad path
404 Error not found
GET /thumbs/persona/{id} Persona picture thumbnail (same size ladder)
Parameters
ParameterInTypeDescription
id path string persona uuid
s query integer target size, px
Responses
200 image/webp
400 Error bad id
404 Error persona avatar not found
GET /thumbs/warm Progress of the thumbnail pre-warm: total counts every thumbnail (two widths per portrait, one per gallery picture) before the first is made, and done counts the ones already there as they are found
Responses
200 object OK
POST /thumbs/warm Start a background pre-warm of the avatar thumbnail tiers the client renders (192/512), so a freshly migrated library does not pay every resize on first scroll. One run per user; 409 while one is running
Responses
200 object {ok, started}
409 Error already running
GET /thumbs/avatar/{id} Avatar thumbnail (webp, on-demand, disk-cached; s clamps to the nearest of 96/192/384/512/768/1280/1920)
Parameters
ParameterInTypeDescription
id path string character uuid
s query integer target size, px
Responses
200 image/webp
400 Error bad id
404 Error avatar not found
GET /thumbs/media/{mediaId} Media thumbnail (same ladder)
Parameters
ParameterInTypeDescription
mediaId path string media row id
s query integer target size, px
Responses
200 image/webp
404 Error media or its file not found
415 Error thumbnails are image-only
GET /thumbs/attachment/{id} A chat's or a studio session's picture as a thumbnail (same ladder)
Parameters
ParameterInTypeDescription
id path string attachment id
s query integer target size, px
Responses
200 image/webp
404 Error attachment or its file not found
415 Error thumbnails are image-only
GET /thumbs/background/{id} Background thumbnail (same ladder; the 1280/1920 rungs exist because a wallpaper covers the whole conversation pane, not a card)
Parameters
ParameterInTypeDescription
id path string background row id
s query integer target size, px
Responses
200 image/webp
404 Error background or its file not found
GET /avatars/{id}.png Full avatar image (pure image, no card chunks; ETag revalidation)
Parameters
ParameterInTypeDescription
id path string character uuid
Responses
200 image/png
400 Error bad path
404 Error not found
GET /attachments/{ownerId}/{file} A chat's or a studio session's picture or video (uid-named, immutable cache), under its owner's id
Parameters
ParameterInTypeDescription
ownerId path string the chat's or the studio session's id
file path string physical attachment filename
Responses
200 file
400 Error bad path
404 Error not found
GET /backgrounds/{file} Background image at its original resolution (uid-named, immutable cache)
Parameters
ParameterInTypeDescription
file path string physical background filename
Responses
200 image
400 Error bad path
404 Error not found
GET /docs/{file} A public doc: the user guide (guide.html), the API reference (api-docs.html) or the extension types (extensions.d.ts, as text/plain). Open without signing in, like the app's own files; only an .html or .d.ts name at the top of the docs folder resolves
Parameters
ParameterInTypeDescription
file path string a file name in the docs folder, such as guide.html or extensions.d.ts
Responses
200 the file
400 Error a name with a path, a dotfile, or another kind of file
404 Error not found
GET /docs/assets/screenshots/{file} A screenshot the user guide shows (image/webp). Open without signing in, like the guide; only a lowercase name of letters, digits and hyphens ending .webp resolves
Parameters
ParameterInTypeDescription
file path string a screenshot's file name, such as details-window.webp
Responses
200 the image
400 Error a name with a path, capitals or another kind of file
404 Error not found
GET /api/proxy/{url} Proxy a GET

Byte-verbatim CORS pass-through: body untouched, headers forwarded, accept-encoding pinned to gzip/deflate/br. The request body is passed on unparsed. GET, HEAD, POST, PUT, PATCH and DELETE are proxied; any other method is 405 with an Allow header. The upstream call is aborted when the client disconnects.

Parameters
ParameterInTypeDescription
url path string encoded absolute URL
Responses
200 upstream response
400 Error a target that is not a url, or not http(s)
403 Error the net guard refuses the url: an empty host, or one resolving to a private or local address
502 Error the upstream failed, timed out, or answered past the size cap
HEAD /api/proxy/{url} Proxy a HEAD

Byte-verbatim CORS pass-through: body untouched, headers forwarded, accept-encoding pinned to gzip/deflate/br. The request body is passed on unparsed. GET, HEAD, POST, PUT, PATCH and DELETE are proxied; any other method is 405 with an Allow header. The upstream call is aborted when the client disconnects.

Parameters
ParameterInTypeDescription
url path string encoded absolute URL
Responses
200 upstream headers
400 Error a target that is not a url, or not http(s)
403 Error the net guard refuses the url: an empty host, or one resolving to a private or local address
502 Error the upstream failed, timed out, or answered past the size cap
POST /api/proxy/{url} Proxy a POST (any content type, verbatim)

Byte-verbatim CORS pass-through: body untouched, headers forwarded, accept-encoding pinned to gzip/deflate/br. The request body is passed on unparsed. GET, HEAD, POST, PUT, PATCH and DELETE are proxied; any other method is 405 with an Allow header. The upstream call is aborted when the client disconnects.

Parameters
ParameterInTypeDescription
url path string encoded absolute URL
Responses
200 upstream response
400 Error a target that is not a url, or not http(s)
403 Error the net guard refuses the url: an empty host, or one resolving to a private or local address
502 Error the upstream failed, timed out, or answered past the size cap
PUT /api/proxy/{url} Proxy a PUT (verbatim body)

Byte-verbatim CORS pass-through: body untouched, headers forwarded, accept-encoding pinned to gzip/deflate/br. The request body is passed on unparsed. GET, HEAD, POST, PUT, PATCH and DELETE are proxied; any other method is 405 with an Allow header. The upstream call is aborted when the client disconnects.

Parameters
ParameterInTypeDescription
url path string encoded absolute URL
Responses
200 upstream response
400 Error a target that is not a url, or not http(s)
403 Error the net guard refuses the url: an empty host, or one resolving to a private or local address
502 Error the upstream failed, timed out, or answered past the size cap
PATCH /api/proxy/{url} Proxy a PATCH (verbatim body)

Byte-verbatim CORS pass-through: body untouched, headers forwarded, accept-encoding pinned to gzip/deflate/br. The request body is passed on unparsed. GET, HEAD, POST, PUT, PATCH and DELETE are proxied; any other method is 405 with an Allow header. The upstream call is aborted when the client disconnects.

Parameters
ParameterInTypeDescription
url path string encoded absolute URL
Responses
200 upstream response
400 Error a target that is not a url, or not http(s)
403 Error the net guard refuses the url: an empty host, or one resolving to a private or local address
502 Error the upstream failed, timed out, or answered past the size cap
DELETE /api/proxy/{url} Proxy a DELETE

Byte-verbatim CORS pass-through: body untouched, headers forwarded, accept-encoding pinned to gzip/deflate/br. The request body is passed on unparsed. GET, HEAD, POST, PUT, PATCH and DELETE are proxied; any other method is 405 with an Allow header. The upstream call is aborted when the client disconnects.

Parameters
ParameterInTypeDescription
url path string encoded absolute URL
Responses
200 upstream response
400 Error a target that is not a url, or not http(s)
403 Error the net guard refuses the url: an empty host, or one resolving to a private or local address
502 Error the upstream failed, timed out, or answered past the size cap
GET /api/provider-services/{route} Provider services namespace (see description)

Provider session + proxy namespace: per-provider login handshakes, RAM sessions, GET proxies, the JanitorAI managed-browser family. Each provider service registers its own routes under this namespace; they are not part of this contract. /health under this namespace reports {ok, basicAuth}.

Parameters
ParameterInTypeDescription
route path string service route
Responses
200 route-specific

Schemas

SCHEMAError
FieldTypeDescription
error required string
kind auth | rate_limit | quota | context | upstream | network | timeout | bad_request a model's failure: its kind, which decides the status (bad_request 400, timeout 504, the rest 502)
SCHEMAOk
FieldTypeDescription
ok boolean
SCHEMACharacterEnvelope
FieldTypeDescription
items array<CharacterListItem>
total integer | null rows matching the filters, ignoring the window; null when count=false
limit integer | null
offset integer
sort string
order string
nextCursor string | null pass as after= to continue past the last item; null when the page was not full or sort=relevance
SCHEMACharacterListItem Projection row: never carries heavy card text
FieldTypeDescription
id string
name string
creator string
nickname string
characterVersion string
creatorNotesExcerpt string only with fields=creatorNotesExcerpt: the first 200 characters of the creator notes as plain text (the grid tooltip)
creatorNotes string only with fields=creatorNotes
fav boolean
updateLocked boolean
mediaLocalized boolean
loreDismissed boolean
tokenEstimate integer
tags array<string>
playlists array<string> the ids of the playlists that hold it
links array<object>
providers array<string>
createdAt integer | null
importedAt integer
updatedAt integer when the content of the card itself last changed. Its tags, its provider link, its lorebooks and the per-character flags never move it, by any route
avatarUrl string
ext object present when an extension the account has on declares projection fields: { <extension id>: { <key>: value } }, a character with no value reading null
SCHEMACharacter Full V2/V3 card ({spec, spec_version, data}) plus library fields; tags, provider links and the per-character flags are composed in
FieldTypeDescription
id string
card object
lastChatAt integer | null newest chat recency across the character's chats (epoch ms): the newest dated message, else a chat's creation; kept current by the server on every chat and message write; null when it has no chats
chatCount integer number of chats for this character
mediaCount integer number of gallery items for this character
playlists array<string> the ids of the playlists that hold it
SCHEMAChat
FieldTypeDescription
id string
charId string
name string
userName string
characterName string the ST header's frozen name at chat time
charName string the LIVE card name (a chat always has its character, and goes with it)
draft string | null the composer text not yet sent; never in the JSONL export
chatMetadata object world_info is composed from the head of worlds, never stored; scenario, mes_example and system_prompt, when present, are the chat's own card texts
worlds array<string> the chat lore list, ordered
createDate integer | null
messageCount integer
lastMesAt integer | null the newest dated message, unix ms, a date without a zone read in the server's zone: it orders the list, so it is the same for every reader
personaName string | null the persona this chat is played as when it overrides the active one; null while it follows the active persona
personaPronouns object | null the pronoun forms of the persona this chat overrides to, beside personaName; null while it follows the active persona
lastMes string | null last non-system message. Stored cut to 300 chars; the LIST projection cuts to a 200-char preview, the detail route returns messages whole
updatedAt integer
charChatCount integer the character's chat count; present only on grouped=true list answers
SCHEMAChatSearchEnvelope
FieldTypeDescription
items array<object>
total integer | null null when count=false
limit integer
offset integer
capped boolean true when the match holds more messages than the newest 10000 the hits are ranked among
SCHEMAWorldEntrySearchEnvelope
FieldTypeDescription
items array<object>
total integer | null null when count=false
limit integer
offset integer
capped boolean true when the match holds more entries than the newest 10000 the hits are ranked among
SCHEMAChatEnvelope
FieldTypeDescription
items array<Chat>
total integer | null null when count=false
limit integer
offset integer
nextCursor string | null pass as after= to continue past the last item; null when the page was not full
SCHEMAAttachment A picture or video a chat (or a studio session) holds of its own
FieldTypeDescription
id integer
chatId string | null
studioId string | null
file string the uid name it is stored under
name string its display name
kind image | video
size integer
width integer | null
height integer | null
addedAt integer
url string /attachments/{ownerId}/{file}
uses integer how many messages show it (the gallery's list only)
SCHEMAChatMessage A message as every chat route answers it. The stored message is the interchange shape (the JSONL export writes it verbatim) and rides as raw; the fields beside it are read off it
FieldTypeDescription
id integer the message's own id: never reused, kept through a renumber. A whole-transcript replace or an import makes new messages with new ids
seq integer its place in the chat, 0 to n-1; every later message moves down one when an earlier one is deleted
createdAt integer | null when it was written, unix ms: the stored send_date (a number, an ISO string, SillyTavern's "June 19, 2023 4:13pm" and "2023-6-19 @14h 33m 07s 123ms"), a date without a zone read on the reader's clock (X-Time-Zone, else X-UTC-Offset, else the server's zone); null when unreadable
role user | assistant | system system when the message is a system note, else user when it is the reader's, else assistant
name string | null the stored speaker name
content string the text: the stored mes, which every write keeps equal to the active alternate
attachments array<Attachment> the pictures the message shows, in order, from its chat's gallery
raw object the stored SillyTavern row, verbatim (mes, swipes, swipe_id, swipe_info, extra, send_date, ...), with extra.attachments naming its pictures' ids when it shows any. A write sends row fields, never this object; a row written back with extra.attachments keeps its pictures, and a patch's extra.attachments sets them (null clears)
SCHEMAChatDetail

extends Chat

FieldTypeDescription
messages array<ChatMessage> the window's messages, in seq order. No header line
msgOffset integer
msgLimit integer | null
msgTail integer | null
embeddedLorebook object | null the card's own character_book, when it has entries. Not a lore source by design: a book goes live once promoted to a world and linked, so this reports that one exists and whether that has happened. null when the card has none
SCHEMAAssistantSession An assistant session with its transcript, which only the session's message routes write, a message at a time (there is no whole-transcript write). The list view omits messages and reports messageCount instead
FieldTypeDescription
id string
chatId string
name string
profileId string | null which LLM profile answers; null follows the app default
createdAt integer
updatedAt integer
messageCount integer list view only
messages array<object> detail view only. extra.context on an assistant turn is the snapshot of what the model was shown, and is what every apply is validated against
damaged boolean the stored transcript would not parse; reads refuse rather than reporting it empty, because an empty read invites the next append to overwrite it
SCHEMAStudioSession The creator studio's session: one conversation over ONE draft, its transcript written as an AssistantSession's is (by the server, a message at a time), with the draft the conversation is about stored beside the transcript so picking a session can restore the form. charId null is the drafts bucket for forms not filled from a library character; a session goes with its character, as chats do
FieldTypeDescription
id string
charId string | null
name string
profileId string | null which LLM profile answers; null follows the surface default
createdAt integer
updatedAt integer
messageCount integer list view only
draft object detail view only: the draft as the last generate or apply saw it, or as the panel PATCHed it on close
messages array<object> detail view only. extra.context on an assistant turn is the snapshot of the draft the model was shown (anchors per field, tags, greetings; the scope), and is what every judge and apply reads
damaged boolean the stored transcript would not parse; reads refuse rather than reporting it empty
SCHEMAChatLoreState
FieldTypeDescription
chatId string
charId string
persona object | null whose books the 'persona' source means: the persona resolved for THIS chat (its override, else the global active one); null when none
settings object the scan settings in force, so the panel can explain a miss instead of just showing one
scannedMessages integer how many messages the scan window actually covered
notes array<string> anything matched that is not sent, and why: for example an entry at the author's note while the note is not due, an outlet nothing writes
worlds array<object>
extensionBooks array<object> the books an extension added to this scan through lore.candidates, in the prompt like the chat's own: the panel lists them read-only. Each is named ext:<extension id>:<label>, which the runner holds to the extension that added it
SCHEMAChatLoreEntry
FieldTypeDescription
uid object the entry's key in its book: a whole number in the library's books; an extension's book may use text
comment string
keys array<string>
secondaryKeys array<string>
content string
disable boolean
constant boolean
position integer
order integer
depth integer | null
selective boolean
selectiveLogic integer
role integer
scanDepth integer | null the entry's own scan depth; null inherits the global
caseSensitive boolean | null null inherits the global
matchWholeWords boolean | null null inherits the global
fired boolean true when this entry is IN THE PROMPT as of the current history: it both matched the scan AND the preset this chat uses (its own, else the active one) has the marker block that places its group (worldInfoBefore / worldInfoAfter / chatHistory for at-depth; for an outlet entry, the prompt writes {{outlet::name}}, which a dry build of the prompt answers). A match with no slot to render into reports false and is explained in notes
firedVia object | null why it fired: { kind: 'chat', messageSeq }, { kind: 'recursion', feederWorld, feederUid, feederComment }, { kind: 'source', source }, or constant / sticky / decorator
probabilityPending integer | null a fired entry that still rolls its probability at send, in percent
groupPending number | null a fired member of a weighted inclusion group: the dry run names no winner, so each member that can win is kept with its odds of winning at send, in percent (one decimal)
timed object the turns left of an active sticky and cooldown, each null when not running
suppressedReason string | null why a matching entry was held back, for example 'trigger', 'probability', 'characterFilter', 'cooldown', 'budget' (every matched entry the lore budget left out says budget)
advanced object the engine fields under ST's own names (probability, sticky, cooldown, delay, the group cluster, the recursion flags, ignoreBudget, outletName, triggers, characterFilter, and matchFlags: the six match-source booleans). The bundled panel edits these, so values are raw config, never display labels
outlet string | null for a fired entry placed at an outlet: the outlet name, which the prompt writes as {{outlet::name}}
notHonoured object stored and preserved but not acted on: vectorized, automationId
SCHEMAWorldSummary
FieldTypeDescription
name string
entryCount integer
importedAt integer | null
createdAt integer ms epoch of the first write (an import, a manager create or a placeholder mint); never moves after
updatedAt integer
placeholder boolean minted by an import path for a name with no book yet; filled in place when one arrives
source WorldSource
SCHEMAWorldSource where a book came from: one source per book, following a rename and going with a delete; null for an authored book
FieldTypeDescription
provider string
externalId string the provider id or lowercased path the listing keys on
path string | null
url string | null
linkedAt integer ms epoch of the link
SCHEMAPresetBlock One piece of the prompt. kind=text carries its own content; kind=marker names something the engine expands from the character, chat, persona or lore. Each block goes as its own message, save at_depth blocks sharing a depth, injectionOrder and role, which go as one with any lore or note placed there; PresetSettings.joinSystem joins system neighbours
FieldTypeDescription
id string
key string
name string | null the label the block is listed under, stored trimmed and null when empty; an import brings the SillyTavern prompt's name and an export writes it back
kind text | marker
marker charDescription | charPersonality | scenario | personaDescription | worldInfoBefore | worldInfoAfter | dialogueExamples | chatHistory | characterPicture | what a marker block is filled with; characterPicture shows the model the character's portrait in a user turn, before or after the history, never at a depth
content string
role system | user | assistant
position pre_history | post_history | at_depth at_depth anchors the block INSIDE the chat history, `depth` turns back from the newest, which is SillyTavern's absolute injection position
depth integer turns back from the newest message, at_depth only. 0 sits after the last turn
injectionOrder integer at_depth only: of several blocks at one depth, a higher order sits nearer the reply. Default 100
forbidOverrides boolean main and jailbreak only: the card's system_prompt / post_history_instructions normally replaces the block, and this refuses that
triggers array<string> the generation types the block is sent on, SillyTavern's injection_trigger: normal (a sent turn), continue, impersonate, swipe, regenerate, quiet. Empty or absent: every type. A type the app does not make (quiet, or one it does not know) is kept, so the block is never sent for it
enabled boolean
pos integer
SCHEMAPreset An ordered block list: PROMPT STRUCTURE only. Neither connection nor samplers are here, both belong to the LLM profile, which is what keeps a preset portable across endpoints and stops opening one from retuning an endpoint
FieldTypeDescription
id string
name string
source string | null 'sillytavern' for imports
settings PresetSettings the settings this preset sets; one absent reads its default (defaultSettings)
createdAt integer
updatedAt integer
blocks array<PresetBlock>
SCHEMAPresetRow A preset as the list answers it: its name and how many blocks it holds, never the blocks
FieldTypeDescription
id string
name string
source string | null 'sillytavern' for imports
createdAt integer
updatedAt integer
blockCount integer how many blocks the preset holds
SCHEMAPresetSettings How a preset builds its prompt around its blocks. Every prompt is built one way: each block its own message, the persona as written, the card's examples as system turns that keep each speaker's name in their text, an empty block sending nothing; these settings are what a preset changes within that. A write naming a setting not listed here, a value of another type or a text past 20000 characters is refused 400 by name, never dropped; null puts a setting back to its default
FieldTypeDescription
personalityFormat string sent for the personality, which goes where {{personality}} is; empty sends the personality as it is
scenarioFormat string sent for the scenario, which goes where {{scenario}} is; empty sends it as it is
loreFormat string sent for each lore group placed before or after the character, its entries where {{lore}} is; empty sends them as they are
chatStart string a system message right before the history; empty sends none
exampleSeparator string a system message before each example block; empty sends none
joinSystem boolean adjacent system messages join on a newline, save the chat start line, the example separators and the example turns; an empty text block, or a card or lore marker with nothing to place, in another role ends the run where it stands when it is on for the generation type (Main even when off) and not at a depth
impersonateInstruction string the last message of a Write My Next Message; empty sends none
continueInstruction string the last message of a continue; empty sends none
guidedInstruction string the last message of a directed reply; empty sends none
continueJoiner string joins a continuation onto the message it continues, unless that ends on a space
continueAsOpening boolean a continue ends the prompt on the message as the reply's opening, with no instruction after it; a continue with no message to open on (its target is not in the prompt) is sent the continue instruction
SCHEMAPresetImportReport What the importer did NOT carry over, so a preset never silently changes meaning
FieldTypeDescription
droppedConnection array<string> connection keys, dropped on purpose
droppedSamplers array<string> sampler settings, dropped on purpose: they belong to the connection
droppedUnknown array<string> keys with no equivalent here
unknownBlocks array<string> prompt identifiers with no expressible equivalent
regexScripts object the regex scripts the preset carries, stored as its own and off until the reader allows them
notes array<string>
SCHEMARegexScript A regex script in SillyTavern's file format. Fields it does not name are kept as sent
FieldTypeDescription
id string
scriptName string
findRegex string a pattern written /pattern/flags, or bare
replaceString string {{match}} is the whole match, $1 a numbered group, $<name> a named one; macros expand after
trimStrings array<string> cut from every group before it fills the replacement
placement array<integer> 1 the reader's messages, 2 the character's, 3 narrator rows, 5 lore, 6 reasoning
disabled boolean
markdownOnly boolean changes only what the screen shows
promptOnly boolean changes only what the model is sent
runOnEdit boolean for a script changing the text itself: it still applies to a message edited by hand (extra.edited), and with alterSaved it rewrites the edit as it is saved
substituteRegex 0 | 1 | 2 macros in the find: 0 none, 1 expanded, 2 expanded with each value escaped
minDepth integer | null
maxDepth integer | null
alterSaved boolean for a script changing the text itself: rewrite the message when it is written instead of each time it is read
stopped boolean answers only: skipped since it ran out of time, until it is saved again
SCHEMAPlaylist A named, ordered group of characters by uuid, with how many it holds; the entry shape of the playlists document plus its id
FieldTypeDescription
id string
name string
description string
icon string
color string
created integer | null
modified integer | null
count integer how many characters it holds
SCHEMAExtensionRow One installed extension as the asking account sees it: the server's reading of its manifest, whether it runs for this account, and its server half's state. error replaces the manifest fields on a broken install
FieldTypeDescription
id string
name string
version string | null
author string | null
description string | null
requires object | null
client string | null
style string | null
server string | null
provider boolean
extNamespace string | null
bundled boolean ships with the app and cannot be removed
defaultOff boolean a bundled extension that is off until an account switches it on
exclusive string | null the group it shares one seat with, such as theme: switching a member on switches off the others that ran for the account
git boolean a git install, which update can pull
settings object the manifest-declared setting defaults
contributes array<string>
lazy object | null the entry points a lazy extension declares ({ actions: [{ slot, id, label, icon }], windows: [{ id, label, icon, size?, min? }], views: [{ id, label, icon }] }): the page registers these and imports the code at their first use. A declaration outside the grammar the page's registrars hold, one not named in a declared contributes, or a lazy block with no entry point or no client makes the row broken
enabled boolean whether it runs for this account
error string
serverState loaded | failed | restart | removed present when it has a server half
serverError string
serverHooks array<object> what the server half registered: its store guards, pipeline filters, macros, prompt blocks, job schedules and change listener, each group in the order the half registered it
browserConsumers array<object> the hosted-browser consumers the server half registered, each id <extension>:<name>, served by /api/provider-services/browser/* only for accounts that switched the extension on
serverQuery object the query doors the server half declared over its own tables
serverCalls array<object> what the server half's hooks, model calls (llm.chat, llm.stream) and jobs (jobs.run) cost this account since the server started, costliest first
SCHEMAExtensionJob One extension job of the asking account. status: queued (position is its place in its extension's lane, 1 next), running, then done, failed (error says why), or cancelled
FieldTypeDescription
id integer
extension string
extensionName string its manifest name, for display
key string | null
label string
status queued | running | done | failed | cancelled
progress object | null
queuedAt integer
startedAt integer | null
endedAt integer | null
error string | null
position integer
SCHEMAPersona The user side of a chat: uuid identity, never keyed by display name. The active persona supplies {{user}}, {{persona}} and the pronoun macros during prompt assembly
FieldTypeDescription
id string
name string
description string
avatar string | null
pronouns object the persona's pronoun forms, answered by {{sub}}, {{obj}}, {{poss}}, {{poss_p}} and {{ref}}. An empty form answers its they/them word (they, them, their, theirs, themselves). The case follows how the macro is written: {{sub}} as stored, {{Sub}} with its first letter capitalised, {{SUB}} in upper case, any other mix as stored
createdAt integer
updatedAt integer
SCHEMALlmProfile
FieldTypeDescription
id string
name string
kind string a registered adapter kind (see /api/llm/kinds)
baseUrl string
model string
hasKey boolean
keyHint string | null the last four characters of the stored key when it is twelve or longer, so two keys can be told apart on screen; null otherwise
contextSize integer | null token window this connection declares; overrides the global chat budget, null uses it
vision boolean | null whether the model sees pictures: true, false, or null when not checked; a call carrying pictures to a connection set false is refused
maxImages integer | null the most pictures the host takes in one request; a chat prompt over it sends the oldest as text, null is no limit
params object neutral default generation params; request params override per call. reasoning.effort is one word the host receives as-is
pos integer
SCHEMASetJob A set job: a write over a set of characters, fixed when the job starts and written in batches, each landing whole
FieldTypeDescription
id integer
kind apply | undo | delete | favorite | flags | playlist
label string
status queued | running | done | stopped | failed
done integer
total integer
queuedAt integer
startedAt integer | null
endedAt integer | null
error string | null a failed job's words (an extension's store guard refusing a batch); the batches before it landed
result object | null once the job ends, per kind: an apply {changed, added: [{name, count}], removed: [{name, count}], runId}; an undo {changed, restored, removed, presets, renamed, runId} (presets: the saved filter preset rules put back; renamed: [{from, to}] the tag names it reported moving, to null for a name that went, which the asking client's own filters follow); a delete {changed, missing} (characters deleted, and characters of the set gone before their batch); a favorite {changed} (characters whose favourite moved; the rest already were); a flags {changed} (characters whose flags moved); a playlist {changed, playlist} (memberships added or removed, and the playlist with its new count)
SCHEMABackupJob A library backup: queued behind any other account's, then running (the copy, then its integrity check), then done, failed or cancelled
FieldTypeDescription
id integer
status queued | running | done | failed | cancelled
phase copy | verify | while running: copy, then verify (the integrity check of the copy)
done integer | null while copying: bytes of the copy written so far
total integer | null about what the copy writes: the library's pages in use when the copy began
stopping boolean a cancel was asked and the copy is being stopped
scheduled boolean
queuedAt integer
startedAt integer | null
endedAt integer | null
error string | null
file string | null once done: the backup file
bytes integer | null once done: its size
SCHEMABackupMissed A backup window that opened once a scheduled backup was due and ended without it (the server was not running, or the backup failed or was cancelled), not yet answered
FieldTypeDescription
windowEnd number the end of the window it missed
SCHEMAMedia
FieldTypeDescription
id integer
file string physical uid-named file
displayName string
kind string
sourceUrl string | null
size integer
addedAt integer
url string
SCHEMABackground
FieldTypeDescription
id integer
file string physical uid-named file
displayName string
sourceUrl string | null
width integer | null source pixels; the picker quotes the memory cost from these
height integer | null
size integer
addedAt integer
url string the original, immutably cached
thumb string 192px picker tile
usedBy integer bindings pointing here (list endpoint only)
SCHEMABackgroundBinding
FieldTypeDescription
scope global | character | chat
id string | null character or chat uuid; null for global
background Background null means explicitly none, which STOPS inheritance
fit cover | contain | stretch | center | tile
opacity number
blur integer
brightness number
saturate number
renderWidth integer | null null is auto, 0 is the original
updatedAt integer
SCHEMAResolvedBackground
FieldTypeDescription
source chat | character | global | none which scope answered
binding BackgroundBinding
Generated from server/openapi.js. Single file, no external assets; safe to share as an attachment.