Repository navigation
api create journal entry
Audience: Modules (e.g. Regent) that build area, encounter, or location journals from JSON and must not import Blacksmith scripts/*.
Contract: Same behavior as Blacksmith's internal JSON journal import (implemented in utility-common.js). Call only after Foundry ready (GM creates documents).
const api = game.modules.get('coffee-pub-blacksmith')?.api;
if (!api?.createJournalEntry) return;
await api.createJournalEntry(journalData);Parameters
-
journalData(Object): Structured payload. Required: ajournaltypestring (case-insensitive) that selects the code path:-
AREA— playable scene journal (blocksenvelope; seeprompt-journal-profile-area.txt). Area Narrative copy prompt:prompt-journal-core.txt+ profile (JSON only). Images: Illustration Image (prompt-journal-visual-illustration.txt— proven ink-and-wash contract +[ADD-ILLUSTRATION-*]facets); Portrait Image (prompt-journal-visual-core.txt+prompt-journal-visual-portrait.txt+[ADD-PORTRAIT-*]). -
ENCOUNTER— encounter journal (Blacksmith encounter template / legacy encounter JSON). -
LOCATION— location encyclopedia journal (dedicated location template / folder rules). Location Import JSON copy is JSON-only (prompt-location.txt); generate card art with Illustration Image, then setlocationimageon import.
-
Legacy NARRATIVE import is not supported (use AREA with blocks.*).
Optional / common fields (depending on type; align with Blacksmith JSON import):
-
foldername— Journal folder name; folder is created under JournalEntry if missing. -
Area:
realm,region,site,area,scenetitle,breadcrumb,blocks(preparation,area,encounter,conversations), etc. -
Encounter:
realm,region,site,area,scenetitle,prepencounter,prepencounterdetails,preprewards,prepsetup,sections/cards,linkedEncounters, etc. -
Location:
title,scenetitle,journalname,realm,region,site,area,locationimage/image, and other fields consumed by the location builder (seecreateLocationJournalEntryinutility-common.js).
Returns: Promise<JournalEntry> — the journal entry, so you can act on it directly:
const entry = await api.createJournalEntry(data);
entry.sheet.render(true);All three types (AREA, ENCOUNTER, LOCATION) resolve to a JournalEntry. When an entry with the same name already exists, these builders update it in place rather than creating a duplicate — and return that existing entry, so the return value is a handle to the journal your data now lives in, whether or not this call created it.
Unsupported input throws rather than being handled internally — a NARRATIVE journaltype, any unrecognised type, missing required blocks, and template failures all throw — so wrap the call in try/catch.
Permissions: Creating folders and journal entries requires appropriate GM/world permissions, same as the in-app import.
-
Window / UI: Use
api.registerWindow/api.openWindowfor Application V2 windows; seeapi-window.md.
Implementation: scripts/utility-common.js (createJournalEntry).
- Ai assistance
- Applicationv2 traps
- CSS traps
- dnd5e conditions
- Documentation standard
- Token actor identity
- Campaign
- Canvas
- Chatcards
- Compendiums
- Contextmenu
- Core
- Create journal entry
- Dialog
- Active Effects
- Entity list
- Equiplocations
- Geography
- GM request
- Gmnotes
- Health
- Hookmanager
- Importer
- Inventory
- Menubar
- Notes
- Party
- Pins
- Quantity split
- Requestroll
- Rolls
- Scene config
- Sockets
- Stats
- Tags
- Toast
- Tokens
- Toolbar
- Window
- Worldclock