Characters¶
Permission required: characters
Full CRUD access to the user's character cards. Use this for extensions that manage, analyze, or batch-edit characters.
Reading gallery image bytes with spindle.images.readBinary() also requires the images permission.
Usage¶
Hosts advertising character-system-filter-v1 change the default list result: internal
container cards are excluded from both results and totals, including searches. Extensions
that previously relied on these cards should pass includeSystem: true (types 0.6.81+).
Ordinary cards named "Multiplayer Rooms" remain visible; legacy containers are identified
by their joined-room chats. The host library and direct characters.get(id) keep their
existing behavior.
// List characters (paginated)
const { data, total } = await spindle.characters.list({ limit: 20, offset: 0 })
// Host-internal container cards (e.g. "Multiplayer Rooms") are omitted by default.
// Pass includeSystem: true only when an extension intentionally needs them.
if (spindle.host.capabilities['character-system-filter-v1'] >= 1) {
const { data: withSystem } = await spindle.characters.list({ limit: 20, includeSystem: true })
}
// Search the full library on supporting hosts, with the same limit/offset pagination.
if (spindle.host.capabilities['character-search-v1'] >= 1) {
const matches = await spindle.characters.list({ limit: 50, offset: 0, search: 'Alice' })
}
// Get a single character
const char = await spindle.characters.get('character-id')
if (char) {
spindle.log.info(`Found: ${char.name}`)
}
// Check support on older hosts before listing gallery images (read-only).
if (spindle.characters.getGallery) {
const gallery = await spindle.characters.getGallery('character-id')
for (const item of gallery) {
const bytes = await spindle.images.readBinary(item.image_id)
}
}
// Create a character (name is required)
const newChar = await spindle.characters.create({
name: 'Alice',
description: 'A curious adventurer.',
personality: 'Brave, curious, kind.',
first_mes: 'Hello! Ready for an adventure?',
tags: ['adventure', 'fantasy'],
})
// Update a character (all fields optional)
const updated = await spindle.characters.update(newChar.id, {
personality: 'Brave, curious, kind, and a bit reckless.',
tags: ['adventure', 'fantasy', 'action'],
})
// Attach world books to a character (replaces the current set)
await spindle.characters.update(newChar.id, {
world_book_ids: ['lore-book-id', 'glossary-book-id'],
})
// Detach all world books
await spindle.characters.update(newChar.id, { world_book_ids: [] })
// Store extension-specific data (shallow-merged into existing extensions)
await spindle.characters.update(newChar.id, {
extensions: {
'my-extension': { questStage: 3, affinity: 72 },
},
})
// Read extension data back
const char = await spindle.characters.get(newChar.id)
const myData = char?.extensions['my-extension']
// Delete a character
const deleted = await spindle.characters.delete(newChar.id)
Methods¶
| Method | Returns | Description |
|---|---|---|
list(options?) |
Promise<{ data: CharacterDTO[], total: number }> |
List characters. Options: { limit?, offset?, search?, userId?, includeSystem? }. Search is capped at 200 characters and requires character-search-v1. Defaults: limit 50, max 200. On hosts advertising character-system-filter-v1, host-internal system/container cards are omitted unless includeSystem: true; this also applies to search results and totals. Older hosts include them and ignore this option. |
get(characterId) |
Promise<CharacterDTO \| null> |
Get a character by ID. Returns null if not found. Direct ID lookup still returns system/container cards. |
getGallery(characterId) |
Promise<CharacterGalleryItemDTO[]> |
List the character's gallery images in gallery order without changing saved character data. Returns [] if the character has no gallery or is not found. Optional on older hosts; check support before calling. |
create(input) |
Promise<CharacterDTO> |
Create a new character. name is required. |
update(characterId, input) |
Promise<CharacterDTO> |
Update a character. All fields are optional. |
delete(characterId) |
Promise<boolean> |
Delete a character. Returns true if deleted. |
CharacterDTO¶
{
id: string
name: string
description: string
personality: string
scenario: string
first_mes: string
mes_example: string
creator_notes: string
system_prompt: string
post_history_instructions: string
tags: string[]
alternate_greetings: string[]
creator: string
image_id: string | null
avatar_url?: string | null // Host-resolved thumbnail; Characters permission is sufficient.
/** IDs of world books attached directly to this character. */
world_book_ids: string[]
/** Raw extensions object. Extensions should namespace their keys. */
extensions: Record<string, any>
created_at: number // unix epoch seconds
updated_at: number
}
CharacterGalleryItemDTO¶
{
id: string // gallery item ID
image_id: string // Lumiverse image ID; read bytes with spindle.images.readBinary()
reference: string // portable gallery:// source for Markdown image embeds
caption: string
sort_order: number
created_at: number // unix epoch seconds
width: number | null
height: number | null
mime_type: string
}
CharacterCreateDTO¶
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Character name |
description |
string |
No | Character description |
personality |
string |
No | Personality summary |
scenario |
string |
No | Scenario/setting |
first_mes |
string |
No | First message (greeting) |
mes_example |
string |
No | Example dialogue |
creator_notes |
string |
No | Creator notes |
system_prompt |
string |
No | System prompt override |
post_history_instructions |
string |
No | Post-history instructions |
tags |
string[] |
No | Tags for organization |
alternate_greetings |
string[] |
No | Alternative first messages |
creator |
string |
No | Creator name |
world_book_ids |
string[] |
No | World books to attach to the character on creation |
extensions |
Record<string, any> |
No | Initial extension data to store on the character |
CharacterUpdateDTO¶
Same fields as CharacterCreateDTO, but all are optional (including name).
- Passing
world_book_idsreplaces the entire attached-book set; pass[]to detach all books, or omit the field to leave the existing attachments unchanged. - Passing
extensionsshallow-merges the provided object into the character's existing extensions. Extension-provided keys overwrite existing ones; omitting a key leaves it untouched. Pass an empty object to make no changes, or omit the field entirely.
Extension Data¶
The full extensions blob is exposed on CharacterDTO so extensions can read and write their own namespaced keys. This is the same object that stores Lumiverse-internal extension state (world books, alternate fields, expressions, etc.).
Best practices:
- Namespace your keys. Use your extension's identifier or a unique prefix to avoid collisions with other extensions or future Lumiverse features.
- Keep values JSON-serializable. The object is stored as JSON in the database.
- Shallow-merge on update. When you pass
extensionstoupdate(), only the top-level keys you provide are overwritten. Deeply nested objects are replaced wholesale at the top level, not recursively merged.
// Good: namespaced key
await spindle.characters.update(char.id, {
extensions: { 'com.example.quest-mod': { stage: 2 } },
})
// Risky: generic key might collide
await spindle.characters.update(char.id, {
extensions: { metadata: { stage: 2 } },
})
World Book Attachments¶
world_book_ids exposes the array of world books attached directly to a character — the same list the built-in world book selector edits inside Lumiverse. The legacy single-id form is auto-migrated, so consumers can rely on the array form unconditionally.
Non-string and duplicate IDs in world_book_ids are silently filtered server-side.
Reading the attached world book contents still goes through the regular spindle.world_books.* API — world_book_ids is just the linkage layer.
Note
For user-scoped extensions, the user context is inferred automatically. For operator-scoped extensions, the user ID is resolved from the extension context. Characters are always scoped to a single user.
Use avatar_url directly in a shared select's { type: 'image', src, fallback: { text } } leading cell. It is resolved by the host for the character owner's image; a missing thumbnail returns null. Older hosts may omit the field. Reading arbitrary image bytes still requires images permission.