Skip to main content

Security Policy API

SecurityPolicyClient manages n8n instance-wide security policy settings — personal space publishing/sharing flags and execution data redaction enforcement.

This is a singleton client (no list/get(id) style collection). Use get() to read the current policy and update() to write changes.

Access

const securityPolicy = client.securityPolicy();

Methods

Common Tasks

  • audit whether users can publish or share from their personal space
  • enforce redaction of execution data across the instance
  • toggle personal-space sharing/publishing off during lockdown

get()

Read the current security policy.

const policy = await client.securityPolicy().get();
// policy.personalSpacePublishing
// policy.personalSpaceSharing
// policy.redactionEnforcement

The response also reports current counts:

PropertyTypeDescription
personalSpacePublishingbooleanWhether publishing from personal space is allowed
personalSpaceSharingbooleanWhether sharing from personal space is allowed
publishedPersonalWorkflowsCountnumberCount of published personal workflows
sharedPersonalWorkflowsCountnumberCount of shared personal workflows
sharedPersonalCredentialsCountnumberCount of shared personal credentials
redactionEnforcementSecurityPolicyRedactionEnforcementRedaction enforcement settings

update(data)

Replace the security policy.

const updated = await client.securityPolicy().update({
personalSpacePublishing: false,
personalSpaceSharing: false,
redactionEnforcement: {
redaction: 'enabled',
floor: 'all',
},
});

update() accepts a full SecurityPolicyUpdate body (the n8n API uses PUT /settings/security-policy, so partial updates are not supported — pass all fields):

PropertyTypeDescription
personalSpacePublishingbooleanWhether publishing from personal space is allowed
personalSpaceSharingbooleanWhether sharing from personal space is allowed
redactionEnforcementSecurityPolicyRedactionEnforcementRedaction enforcement settings

redactionEnforcement has the shape:

interface SecurityPolicyRedactionEnforcement {
redaction: 'off' | 'enabled';
floor: 'off' | 'production' | 'all';
}

Typical Flow

const securityPolicy = client.securityPolicy();

const current = await securityPolicy.get();

if (current.personalSpacePublishing) {
await securityPolicy.update({
personalSpacePublishing: false,
personalSpaceSharing: current.personalSpaceSharing,
redactionEnforcement: current.redactionEnforcement,
});
}