{"record":{"id":"713d67aae1bad862","repo":"n8n-io/n8n","slug":"you-must-set-up-your-own-account-before-inviting-o","errorCode":null,"errorMessage":"You must set up your own account before inviting others","messagePattern":"You must set up your own account before inviting others","errorType":"exception","errorClass":"BadRequestError","httpStatus":400,"severity":"warning","filePath":"packages/cli/src/controllers/invitation.controller.ts","lineNumber":73,"sourceCode":"\t\t\t\t'SSO is enabled, so users are managed by the Identity Provider and cannot be added through invites',\n\t\t\t);\n\t\t\tthrow new BadRequestError(\n\t\t\t\t'SSO is enabled, so users are managed by the Identity Provider and cannot be added through invites',\n\t\t\t);\n\t\t}\n\n\t\tif (!isWithinUsersLimit) {\n\t\t\tthis.logger.debug(\n\t\t\t\t'Request to send email invite(s) to user(s) failed because the user limit quota has been reached',\n\t\t\t);\n\t\t\tthrow new ForbiddenError(RESPONSE_ERROR_MESSAGES.USERS_QUOTA_REACHED);\n\t\t}\n\n\t\tif (!(await this.ownershipService.hasInstanceOwner())) {\n\t\t\tthis.logger.debug(\n\t\t\t\t'Request to send email invite(s) to user(s) failed because the owner account is not set up',\n\t\t\t);\n\t\t\tthrow new BadRequestError('You must set up your own account before inviting others');\n\t\t}\n\n\t\tconst attributes = invitations.map(({ email, role }) => {\n\t\t\tif (role === 'global:admin' && !this.license.isAdvancedPermissionsLicensed()) {\n\t\t\t\tthrow new ForbiddenError(\n\t\t\t\t\t'Cannot invite admin user without advanced permissions. Please upgrade to a license that includes this feature.',\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { email, role };\n\t\t});\n\n\t\tconst { usersInvited, usersCreated } = await this.userService.inviteUsers(req.user, attributes);\n\n\t\tawait this.externalHooks.run('user.invited', [usersCreated]);\n\n\t\treturn usersInvited;\n\t}\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/controllers/invitation.controller.ts#L55-L91","documentation":"A BadRequestError (HTTP 400) thrown when ownershipService.hasInstanceOwner() resolves false. The instance has no fully set-up owner account (the initial setup was never completed), so it cannot send invites because there is no owner to attribute them to. Logged at debug level before throwing.","triggerScenarios":"POST /invite on a freshly deployed instance where the owner account setup page was skipped or never completed, or where the owner user row was deleted manually from the DB. The check runs after the SSO and quota checks.","commonSituations":"Instance deployed via Docker/compose but the first-run owner setup was bypassed; an operator deleted the owner user directly in the database; restored DB backup that lost the owner row; automated setup script that created users before completing owner setup.","solutions":["Complete the initial owner account setup by visiting the instance URL in a browser and finishing the setup wizard.","If the owner row was deleted from the DB, restore it or re-run the setup flow.","Verify ownershipService.hasInstanceOwner() returns true via the Admin UI before retrying invites.","Check that the user table has at least one user with the global:owner role."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure an owner exists before inviting.\nconst users = await api.get('/users');\nconst hasOwner = users.some((u) => u.role === 'global:owner');\nif (!hasOwner) throw new Error('Complete owner setup first');","typeGuard":"function instanceHasOwner(users: Array<{ role: string }>): boolean {\n  return users.some((u) => u.role === 'global:owner');\n}","tryCatchPattern":"try {\n  await api.post('/invite', invites);\n} catch (e) {\n  if (e.response?.status === 400 && /set up your own account/i.test(e.response.data.message)) {\n    redirect('/setup');\n    return;\n  }\n  throw e;\n}","preventionTips":["Complete the first-run owner setup before scripting invites.","Never delete the owner user row directly from the DB.","Verify ownershipService.hasInstanceOwner() after DB restores."],"tags":["invitations","setup","owner","rest-api","config"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}