Skip to content
3 Death Saves

API and Hooks

Wiki updated as of 1.2.3 (Nov 2026)

Default Detach attaches its API to its module entry once Foundry is ready.

const api = game.modules.get('default-detach').api;

add and remove each take a kind of either 'app' or 'type'. 'app' targets the Individual Windows list and takes an application id. 'type' targets the Document Types list and takes a document-type key. When kind is omitted, the method acts on 'app'.

A document-type key is the document name on its own, such as Actor, or the document name and subtype joined by a slash, such as Actor/npc. A document with no subtype data uses the bare document name, as does a document whose subtype is the base document type.

Both lists are user settings saved to the logged-in user. add and remove change the lists for that user only, not the world.

await api.add(id, kind);

Adds an application id or a document-type key to its auto-detach list. Adding an entry already on the list changes nothing.

An application id is stored with the window title the module has discovered this session, either from a rendered window or from a module that declared its detachable windows to 3DS:ATLAS. An undiscovered id is stored with the id as its display name.

A list entry is applied when a window first renders. Adding an id does not detach a window that is already open, and a window that cannot be detached is left alone.

await api.remove(id, kind);

Removes an application id or a document-type key from its auto-detach list. Removing an entry that is not on the list changes nothing.

const { apps, types } = api.list();

Returns the current selections. apps is an array of objects with an id and a displayName. types is an array of document-type keys.

Both hooks receive the application being detached and its type. The type is an object with a key and a label, or null when the application has no document.

Hooks.on('default-detach.preDetach', (application, type) => {
if (type?.key === 'Actor/npc') return false;
});

Fires before a window detaches. Returning false cancels the detachment.

Hooks.on('default-detach.detached', (application, type) => {
console.log(`${application.id} detached`);
});

Fires after a window has detached.

Both hooks fire for manual detachment and for automatic detachment from the saved lists.