Skip to main content

Macro

GET /macros​

Get all macros

Retrieves a list of all macros available in the Foundry world.

Required scope: macro:list

Parameters​

NameTypeRequiredSourceDescription
clientIdstringqueryClient ID for the Foundry world
userIdstringquery, bodyFoundry user ID or username to scope permissions (omit for GM-level access)

Returns​

array - An array of macros with details

Try It Out​

Code Examples​

const baseUrl = 'http://localhost:3011';
const path = '/macros';
const params = {
clientId: 'qsl-integration-test'
};
const queryString = new URLSearchParams(params).toString();
const url = `${baseUrl}${path}?${queryString}`;

const response = await fetch(url, {
method: 'GET',
headers: {
'x-api-key': 'your-api-key-here'
}
});
const data = await response.json();
console.log(data);

Response​

Status: 200

{
"type": "macros-result",
"requestId": "macros_1782956928928",
"macros": [
0: {
"uuid": "Macro.7zDXWfoXIJPrJ7uh",
"id": "7zDXWfoXIJPrJ7uh",
"name": "test-macro",
"type": "script",
"author": "Gamemaster",
"command": "// Example macro that uses parameters function myMacro(args) { const targetName = args.targetName || "Target"; const damage = args.damage || 0; const effect = args.effect || "none"; // Use the parameters console.log(`Attacking ${targetName} for ${damage} ${effect} damage`); // Return a value (can be any data type) return { success: true, damageDealt: damage, target: targetName }; } // Don't forget to return the result of your function return myMacro(args);",
"img": "icons/svg/dice-target.svg",
"scope": "global",
"canExecute": true
}
]
}

POST /macro/:uuid/execute​

Execute a macro by UUID

Executes a specific macro in the Foundry world by its UUID.

Required scope: macro:execute

Parameters​

NameTypeRequiredSourceDescription
uuidstring✓paramsUUID of the macro to execute
clientIdstringqueryClient ID for the Foundry world
argsobjectbodyOptional arguments to pass to the macro execution
userIdstringquery, bodyFoundry user ID or username to scope permissions (omit for GM-level access)

Returns​

object - Result of the macro execution

Try It Out​

Code Examples​

const baseUrl = 'http://localhost:3011';
const path = '/macro/Macro.7zDXWfoXIJPrJ7uh/execute';
const params = {
clientId: 'qsl-integration-test'
};
const queryString = new URLSearchParams(params).toString();
const url = `${baseUrl}${path}?${queryString}`;

const response = await fetch(url, {
method: 'POST',
headers: {
'x-api-key': 'your-api-key-here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"args": {
"targetName": "Goblin",
"damage": 100000,
"effect": "poison"
}
})
});
const data = await response.json();
console.log(data);

Response​

Status: 200

{
"type": "macro-execute-result",
"requestId": "macro-execute_1782956928931",
"uuid": "Macro.7zDXWfoXIJPrJ7uh",
"success": true,
"result": {
"success": true,
"damageDealt": 100000,
"target": "Goblin"
}
}