Skip to content

Multi-tenant plugin creates a tenant but can't show it #13366

Closed

Description

@openbayou

Describe the Bug

I'm having problems with the multi-tenant plugin. I want to have a multsite so I can have one site serve multiple websites on one installation. I installed the multi-tenant plugin and have it loaded in my payload.config.ts file and added a tenant collection but when I tried to add a new entry to the tenant collection, it's added but won't show in the collection.

I followed the directions on the mult-tenant plugin page (https://payloadcms.com/docs/plugins/multi-tenant) and I keep getting this error: "The document with ID xxx could not be found. It may have been deleted or never existed, or you may not have access to it."

When I looking at the DB, the entry was created.

Here's a short version of my payload.config.ts file:

import Article from './collections/Post'
import Episodes from './collections/Episode'
import { Tenants } from './collections/Tenant'
import { multiTenantPlugin } from '@payloadcms/plugin-multi-tenant'
import { Config } from './payload-types'

export default buildConfig({
  admin: {
    user: Users.slug,
  },
  collections: [Article, Episodes, Tenants],
  globals: [externalAPI, Settings, Podcast_Settings],
  plugins: [    
    multiTenantPlugin<Config>({
      // Define which collections should be tenant-specific
      collections: {
        post: {}, // Posts are tenant-specific
        episode: {}, // Episodes are tenant-specific
      },
    }),
  ],
})

And my Tenant.ts file:

import type { CollectionConfig } from 'payload'

export const Tenants: CollectionConfig = {
  slug: 'tenants',
  admin: {
    useAsTitle: 'name',
  },
  fields: [
    {
      name: 'name',
      type: 'text',
      required: true,
    },
    {
      name: 'domain',
      type: 'text',
      admin: {
        description: 'Used for domain-based tenant handling',
      },
    },
    {
      name: 'slug',
      type: 'text',
      admin: {
        description: 'Used for url paths, example: /tenant-slug/page-slug',
      },
      index: true,
      required: true,
    },
  ],
}

Link to the code that reproduces this issue

see above

Reproduction Steps

see above

Which area(s) are affected? (Select all that apply)

plugin: multi-tenant

Environment Info

{
  "name": "openbayou",
  "version": "1.0.0",
  "description": "A blank template to get started with Payload 3.0",
  "license": "MIT",
  "type": "module",
  "scripts": {
    "build": "cross-env NODE_OPTIONS=--no-deprecation next build",
    "dev": "cross-env NODE_OPTIONS=--no-deprecation next dev",
    "devsafe": "rm -rf .next && cross-env NODE_OPTIONS=--no-deprecation next dev",
    "generate:importmap": "cross-env NODE_OPTIONS=--no-deprecation payload generate:importmap",
    "generate:types": "cross-env NODE_OPTIONS=--no-deprecation payload generate:types",
    "lint": "cross-env NODE_OPTIONS=--no-deprecation next lint",
    "payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
    "start": "cross-env NODE_OPTIONS=--no-deprecation next start"
  },
  "dependencies": {
    "@payloadcms/db-mongodb": "latest",
    "@payloadcms/next": "latest",
    "@payloadcms/payload-cloud": "latest",
    "@payloadcms/richtext-lexical": "^3.25.0",
    "@payloadcms/plugin-multi-tenant": "^3.49.1",
    "cross-env": "^7.0.3",
    "file-type": "^20.4.0",
    "graphql": "^16.8.1",
    "next": "^15.4.5",
    "node-cron": "^4.0.7",
    "payload": "^3.39.1",
    "react": "^19.1.1",
    "react-dom": "^19.1.1",
    "sharp": "0.32.6"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^3.2.0",
    "@types/node": "^22.5.4",
    "@types/react": "19.0.7",
    "@types/react-dom": "19.0.3",
    "eslint": "^9.16.0",
    "eslint-config-next": "^15.4.5",
    "prettier": "^3.4.2",
    "typescript": "5.7.3"
  },
  "engines": {
    "node": "^18.20.2 || >=20.9.0",
    "pnpm": "^9"
  },
  "pnpm": {
    "onlyBuiltDependencies": [
      "sharp"
    ]
  }
}

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Aug 4, 2025
  2. github-actions commented on Aug 4, 2025

    @github-actions
    Contributor

    Please add a reproduction in order for us to be able to investigate.

    Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided.

    Why was this issue marked with the invalid-reproduction label?

    To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository created with create-payload-app@latest -t blank or a forked/branched version of this repository with tests added (more info in the reproduction-guide).

    To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.

    Please test your reproduction against the latest version of Payload to make sure your issue has not already been fixed.

    I added a link, why was it still marked?

    Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

    Useful Resources

  3. removed
    validate-reproduction
    on Aug 4, 2025
  4. added
    plugin: multi-tenant
    on Aug 5, 2025
  5. Osyed002 commented on Aug 7, 2025

    @Osyed002

    Hi, I'm facing the same issue. Did you find something ?

  6. natergj commented on Aug 14, 2025

    @natergj

    I am also seeing the same issue.

    Here is a reproduction repo created with the blank template. commits show each step of the setup. This repo uses an sqllite db which has been committed with the repo. I have tried postgres and mongo with the same results.

    https://github.com/natergj/payload-multi-tenant-bug
    email: [email protected]
    ps: admin

    reproduction steps:

    1. clone repo
    2. start repo with npm run dev
    3. log in with [email protected]:admin
    4. click Tenants menu item
    5. attempt to add Tenant
    6. note that "success" toast appears at bottom of screen, but error message is show and tenant is not visible in the UI.
  7. harrygantz commented on Aug 19, 2025

    @harrygantz

    I just ran into this issue tonight too.

  8. JarrodMFlesch commented on Aug 19, 2025

    @JarrodMFlesch
    Contributor

    @openbayou @Osyed002 @natergj @harrygantz

    Yeah I think the plugin should just force users to define userHasAccessToAllTenants, but currently it is optional. You should define that function. Then you will be able to see all tenants. Since you do not define it, your user is:

    • not a super admin
    • not assigned to any tenants

    and therefore cannot read the tenant you just created.

  9. removed
    status: needs-triage
    on Aug 19, 2025
  10. harrygantz commented on Aug 20, 2025

    @harrygantz

    Yeah I think the plugin should just force users to define userHasAccessToAllTenants

    @JarrodMFlesch I totally agree. If that’s not possible then the docs should be updated to make this a bit more clear. Anyways, thanks for your comment it was a huge help!

  11. github-actions commented on Sep 4, 2025

    @github-actions
    Contributor

    This issue has been automatically locked.
    Please open a new issue if this issue persists with any additional detail.

  12. locked as resolved and limited conversation to collaborators on Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

plugin: multi-tenant

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions