Payload CMS access control: how roles (RBAC), query rules and field access work

Idea Labz · Dec 2, 2026 · 12 min read

You’re building on Payload, or deciding whether it can hold your team’s roles and permissions. Payload’s access control is code you write, so it fits most permission models, and it ships with defaults you need to change.

As of 2 December 2026, Payload’s latest stable release is 3.94.2. In that release, a collection without rules of its own lets any signed-in user create, edit and delete its documents, whichever collection they signed in through. Every Payload behaviour on this page was read from the 3.94.2 code and, for what’s coming, the 4.0.0-beta.12 package.

This guide follows a private university in Dubai with a public website, staff in the admin panel and a portal where students sign in.

  • How does access control work in Payload CMS?
  • Where access rules live, and what each defaults to
  • Role-based access control (RBAC) with a roles field
  • Rules that return a query: row-level access
  • Field-level access: hide or lock one field
  • Making content public on a website
  • Access control and the Local API (overrideAccess)
  • How access shows in the admin panel
  • Access control with multi-tenancy
  • How to test access rules
  • What changes in Payload 4.0
  • Common access-control mistakes, from the code
  • How we set up roles and permissions on client projects
  • Frequently asked questions
  • What to do next

How does access control work in Payload CMS?

In Payload, an access rule is a function you attach to an operation on a collection, a global or a field. It receives the request, with the signed-in user on req.user, and returns true to allow, false to refuse, or a query that limits which documents the user can reach (Payload’s access control docs).

Payload runs your rules on every REST and GraphQL request. A refused REST request usually gets a Forbidden (403) error, and GraphQL returns it in its errors list with a 200. The admin panel reads the same rules to decide what to show, and the Local API, which your server code calls directly, skips them unless you ask.

Who sent the request is authentication, and our guide to Payload authentication covers sign-in, tokens, API keys, SSO and two-factor.

For example, the university has three kinds of reader. Visitors read news and events, staff sign in to the admin panel as an admin, an admissions officer, a professor or campus clinic staff, and students sign in to a portal through their own students collection to read their grades.

Where access rules live, and what each defaults to

The table shows where rules sit, what each may return and what Payload does when you leave it out, as of 3.94.2.

WhereOperationCan returnWhen you leave it out
Collectioncreate, read, update, deletetrue, false or a queryAny signed-in user, from any auth collection
Collection (auth)admintrue or falseAny signed-in user of the admin’s user collection
Collection (auth)unlocktrue, false or a queryUsers of the admin’s user collection, and only when login lockout is on
Collection (versions)readVersionstrue, false or a queryAny signed-in user
Globalread, update, readVersionstrue, false or a queryAny signed-in user
Fieldcreate, read, updatetrue or false onlyAllowed, within the collection’s own rules
Jobsqueue, run, canceltrue or falseUsers of the admin’s user collection

The collection defaults come from one function, defaultAccess, which returns Boolean(user) (Payload’s defaultAccess). It checks that someone is signed in, and never which collection they signed in through, though since 3.94.2 Payload’s own internal collections limit writes to the admin’s user collection (GHSA-8j2x-hjh9-3ff8).

That matters the day you add a second auth collection. For example, once the university’s students can sign in, a student can create, edit and delete news over the REST or GraphQL API, because the news collection has no rules of its own. Payload keeps students out of the admin panel, because only users of the collection named in admin.user can open it, and that doesn’t stop the API.

The fix is to write every rule on every collection, or to start each collection from a shared rule that checks the user’s collection and role.

Role-based access control (RBAC) with a roles field

Payload has no built-in roles. You add a roles field to your users collection and check it in your rules, which is role-based access control (RBAC) built from the same functions as everything else.

For example, the university’s staff collection carries a roles select with the four staff roles:

import type { CollectionConfig, PayloadRequest } from 'payload'

const isAdmin = ({ req: { user } }: { req: PayloadRequest }) =>
  Boolean(user?.collection === 'users' && user.roles?.includes('admin'))

export const Users: CollectionConfig = {
  slug: 'users',
  auth: true,
  access: {
    admin: ({ req: { user } }) => Boolean(user?.collection === 'users' && user.roles?.length),
    create: isAdmin,
    delete: isAdmin,
  },
  fields: [
    {
      name: 'roles',
      type: 'select',
      hasMany: true,
      options: ['admin', 'admissions', 'professor', 'clinic'],
      saveToJWT: true,
      access: {
        create: isAdmin,
        update: isAdmin,
      },
    },
  ],
}

Your rules read the roles from req.user, which Payload loads from the database on every request. saveToJWT also puts them in the token, for code outside Payload such as middleware (Payload’s token data docs). The field rules mean only an admin can set roles, so a professor can’t promote themselves. The first user, created from the admin panel’s welcome screen, is saved with access off, which is where your first admin comes from.

A small helper keeps every collection’s rules short and checks the collection too, so a student never passes a staff check:

import type { PayloadRequest } from 'payload'

export const hasRole =
  (...roles: string[]) =>
  ({ req: { user } }: { req: PayloadRequest }) =>
    Boolean(user?.collection === 'users' && user.roles?.some((role) => roles.includes(role)))

// on the news collection
access: {
  create: hasRole('admin', 'admissions'),
  update: hasRole('admin', 'admissions'),
  delete: hasRole('admin'),
}

Rules that return a query: row-level access

A rule that returns a query lets a user reach some documents and not others. Payload adds the query to every request with an AND, on top of any filter the user sends.

For example, the university’s grades collection lets an admin read everything, a professor read grades for their own courses, and a student read their own grades:

import type { AccessResult } from 'payload'

read: ({ req: { user } }): AccessResult => {
  if (!user) return false
  if (user.collection === 'students') return { student: { equals: user.id } }
  if (user.roles?.includes('admin')) return true
  if (user.roles?.includes('professor')) return { 'course.professors': { equals: user.id } }
  return false
},

A document outside the query never reaches the user. A list leaves it out, and a request for it by ID returns 404, as if it didn’t exist (findByID in Payload 3.x). An update or delete by ID outside that operation’s own query returns 403 instead, so give grades update and delete rules too, and expect both codes.

An update rule that returns a query on the _status field decides who can publish a draft (Payload’s drafts docs), and our guide to drafts and versions covers the rest of the publishing flow.

Field-level access: hide or lock one field

A field rule protects one field inside a document the user can otherwise reach. Each field takes create, read and update rules, and each returns true or false, never a query.

For example, a student’s file holds medical notes that only clinic staff and admins may read or change, and a tuition balance that professors never see:

{
  name: 'medicalNotes',
  type: 'textarea',
  access: {
    read: hasRole('clinic', 'admin'),
    update: hasRole('clinic', 'admin'),
  },
},

When a read is refused, Payload removes the value from the response and doesn’t fill in the field’s default (Payload’s field read code). When a create or update is refused, Payload drops the incoming value without an error and saves the rest of the document (Payload’s field write code). On an update the stored value stays. A professor who sends a new tuition balance gets a successful save with the old balance, so test the saved document as well as the response code.

hidden: true on a field removes its value from what the REST API returns, and server code sees it only when it passes showHiddenFields: true. admin.hidden on a collection removes it from the admin’s navigation and routes, and leaves its API to your rules (Payload’s collection config docs). Our guide to Payload fields lists access beside the other field options.

Payload has fixed several field-level access bugs since September 2026. Version 3.88.0 fixed a sort that could reveal protected fields (GHSA-9g87-32v6-3c2r), 3.93.0 fixed queries on fields inside blocks (GHSA-j4q6-g29w-5cmg), and 3.94.2 fixed a field write bypass on MongoDB (GHSA-8899-x9g3-4xgr). Staying on the latest stable release keeps those fixes.

Making content public on a website

A public website needs a read rule that lets visitors in. read: () => true opens every document, drafts included, so most sites return a query for published documents and let staff read the rest. On 3.94.2 a collection’s versions go to any signed-in user unless you set readVersions, so students could read news drafts there.

For example, the university’s news and events show published posts to visitors and every post to staff:

read: ({ req: { user } }) => {
  if (user?.collection === 'users') return true
  return { _status: { equals: 'published' } }
},

When a file is served through Payload’s file route, Payload runs the media collection’s read rule too, with isReadingStaticFile set. Our guide to Payload uploads covers where files are stored and how they’re served.

Access control and the Local API (overrideAccess)

The Local API skips every access rule by default in Payload 3.x. Each Local API operation defaults overrideAccess to true, which skips collection rules and field rules alike (Payload’s Local API find). Passing user on its own doesn’t change that, because the operation checks access only when overrideAccess is false.

Keep the default for system work, such as a seed script, a migration or a scheduled job, and pass both for anything that answers a person. For example, the student portal’s grades page reads as the signed-in student:

const grades = await payload.find({
  collection: 'grades',
  overrideAccess: false,
  user, // the signed-in student
})

The same default applies inside custom endpoints and plugins. A community alt-text plugin’s endpoints called the Local API without overrideAccess: false, so any signed-in user could read and overwrite the alt text and keywords of protected uploads, until the plugin’s 0.8.0 fixed it (CVE-2026-59965, published September 2026). Our guide to Payload’s APIs covers how REST, GraphQL and the Local API each run your rules.

How access shows in the admin panel

The admin panel builds itself from your rules. Each time the admin renders a page, Payload runs each rule without a document, and the navigation leaves out every collection the user can’t read.

Your own front end can ask the same question. GET /api/access returns the signed-in user’s permissions for every collection and global, and /api/{collection}/access/:id returns them for one document (Payload’s auth operations docs).

Because that check runs without a document, id and data are undefined inside your rules, so check them before you read them. A rule that returns a query is shown as allowed, and the list then applies the query, so the professor sees grades for their own courses only (Payload’s permissions code).

access.admin decides who can open the admin panel at all. Custom views don’t check the user for you, and our guide to the Payload admin panel shows how to guard them.

Access control with multi-tenancy

Multi-tenancy decides whose data it is, when one Payload serves several brands, sites or customers. Payload’s multi-tenant plugin adds its tenant filter to your rules on every operation, for users of the admin’s user collection only.

For example, if the university ran three campuses, each campus’s staff would see only that campus’s records, and roles would still decide what they may change. Students, who sign in through their own collection, get your rules alone, so scope them in those rules. Our guide to multi-tenancy in Payload covers the plugin and how tenancy and roles combine.

How to test access rules

Test each rule as the people it’s written for. The Local API with overrideAccess: false and a user from each role runs your rules as the REST API does, without a server. For example, the university’s tests load a user per role:

it('a professor cannot open a grade from another course', async () => {
  await expect(
    payload.findByID({
      collection: 'grades',
      id: otherCourseGrade.id,
      overrideAccess: false,
      user: professor,
    }),
  ).rejects.toThrow() // 404, outside the query
})

Write the same shape for a refused update (403), a filtered list, and a field that kept its old value after a refused write. GET /api/access, called as each role, gives a quick table of what every role can do.

A table of what a refused request gets back in Payload 3.94.2. A collection rule that returns false gives 403 on lists, reads and writes, or an empty list when server code sets disableErrors. A query rule with the document outside it leaves it out of lists with 200, gives 404 on a read by ID, and an update or delete outside that rule’s own query gives 403. A refused field read returns 200 without the value or its default. A refused field create returns 200 and the field gets its default; a refused field update returns 200 and keeps the stored value. Errors are dark chips, successful responses outlined.

Filtered lists and refused fields answer 200, so check the data as well as the status code.

What changes in Payload 4.0

Payload 4.0 is in beta. As of 4.0.0-beta.12, published on 24 November 2026, it changes access control in five ways, and details can change before the release (Payload’s 4.0 migration guide).

  1. The Local API enforces your rules by default, with overrideAccess defaulting to false. Payload’s codemod (npx @payloadcms/codemod) adds overrideAccess: true to existing calls so you can review each one.
  2. When readVersions isn’t set, versions inherit the read rule. A read that returns true then makes past versions and unpublished drafts public too, unless you set readVersions.
  3. A new validate rule controls on-demand validation, and falls back to update when you leave it out.
  4. Collection and global rules receive the collection’s or global’s slug.
  5. In the beta’s code, the default rule requires a signed-in user from the admin’s collection (defaultAccess in 4.0.0-beta.12).

For example, the university’s news rule returns a query, so on 4.0 visitors would also see past published versions of a post, though not its drafts. Set readVersions to keep old versions private. Our guide to Payload versions covers how to move between releases.

Common access-control mistakes, from the code

These mistakes don’t throw an error in Payload 3.94.2, so look for them in review.

  • A second auth collection with unruled collections. The default lets its users write everywhere you haven’t written a rule.
  • Passing user without overrideAccess: false. The Local API still skips every rule.
  • Expecting an error from a refused field write. The value is dropped and the save succeeds.
  • Reading id or data without a check. The admin’s permission check calls your rule without them.

How we set up roles and permissions on client projects

We start client projects from our own template, so a new project starts with roles and access rules in place. Its write rules check for a role and never accept “signed in” alone, so a user without a staff role can’t write staff content. As of template v2.19.0 on Payload 3.94.2 (2 December 2026), a project won’t start if one of its built-in collections leaves create, update or delete undeclared, and the error names Payload’s any-signed-in-user default.

By default, a new project has staff roles at a few levels, from content work to a full admin, plus a base role for everyone else, who can reach only their own account. Every user has a role, and only an admin can set one. Per project we add roles for the client’s team, use site-scoped admins when one admin runs several sites, and add field rules on prices and internal data and approval steps before something goes live.

We test the rules as well. An automated test tries every collection’s create, update and delete as each role and as a signed-out visitor, and fails if a visitor or the base role can write anywhere that isn’t on a short allow list with a reason for each entry. An entry that stops being allowed fails too, so the list can’t go stale. The tests run on a real Postgres database, and leak tests plant a marker in protected fields and check it never comes back. Server code that works for a signed-in person passes that person and turns access on, and system work such as seeding and scheduled jobs runs with access off on purpose.

Customer or member sign-in is added per project and reviewed case by case, read rules included. If you need roles, portals or per-field rules built on Payload, our Payload development work is where we take that on.

Frequently asked questions

Does Payload CMS have role-based access control (RBAC)?

Yes, as code. Payload has no built-in roles, so you add a roles field to your users collection and check it in your access rules. Your rules read them from req.user, and saveToJWT also puts them in the token for code outside Payload.

Is Payload better suited to RBAC or ABAC?

Both work, because a Payload rule is a function that can read anything on the request and the document. Most projects start with roles and add attribute checks, such as ownership or a course list, inside the same rules.

Does the Local API respect access control?

Not by default in Payload 3.x. Every Local API operation defaults overrideAccess to true, so pass overrideAccess: false and the user whenever a call acts for a person. Payload 4.0’s beta flips the default.

Can a field-level rule return a query?

No. Field rules return true or false, and a query object counts as true, so it allows the action. For per-document limits, return a query from the collection’s rule instead.

What’s the difference between access control and admin.hidden?

admin.hidden removes a collection from the admin panel’s navigation and routes, and leaves its API alone. Access rules decide what every API returns. Use rules for security and admin.hidden for a tidier admin.

Can I manage roles and permissions in the admin panel without code?

Not in Payload itself, where roles and rules live in code. Our template adds an optional module, off by default, where a site’s admin defines roles and their permissions in the admin panel, checked the same way on the API and in server code. Protected areas can’t be granted from there.

What to do next

Write a rule for every operation on every collection, check the user’s collection as well as their role, and return queries where users should see only their own documents. Pass overrideAccess: false with the user in server code that acts for a person, and test each role.

Start with your users collection and its roles field. If people will sign in to your site as well as your admin, read how sign-in works in Payload next.

References

All links checked and active as of 2 December 2026.

</content>

READY TO MAKE A REAL CHANGE?

Let's build it together