Skip to main content
Copy-ready configurations for common setups. Each one is a complete openapi(...) call — combine pieces as needed for your project.
For option-by-option reference, see Configuration.

Basic setup

Minimal

The smallest working config: metadata.title and metadata.version are required, everything else has a default.
payload.config.ts

Scalar and Swagger UI side by side

Each renderer is its own plugin — mount both on different paths against the same spec endpoint.
payload.config.ts
See Docs UI.

Shaping the spec

Public API only

Document only the public-* collections, and drop one of them by exact slug. include is an allowlist: once it’s non-empty, only matching entities survive.
payload.config.ts
See Filters for all matcher forms (slug, RegExp, { kind, slug }).

Read-only spec

Keep every entity but drop all write operations with excludeOperations.
payload.config.ts
Rules combine: add { slug: 'posts', method: 'get' } style entries to target one entity, or { path: /\/preview$/ } to match by route path.

Auth and security

Interactive auth for a private docs site

Add a token endpoint and a matching security scheme, so the docs UI shows an Authorize dialog where users log in with their Payload credentials instead of pasting a token.
payload.config.ts
See Interactive auth.

Security overrides with securityWhen

The plugin marks each operation public or secured by probing your access functions. securityWhen runs last and overrides the detected marking: return true for public, false for secured, undefined to keep the detection.
payload.config.ts
See Security marking.

Environments

Development

Turn the cache off so config edits show up without a restart, and surface hidden and Payload-internal collections while debugging.
payload.config.ts
See Caching.

Generate only, for CI

No runtime endpoint at all — the plugin registers just the openapi:generate CLI, and the file is generated at build time.
payload.config.ts
See Serve a pre-generated spec.

Multi-language docs site

One runtime endpoint, resolved per request via ?lang=; Scalar gets a language switcher through sources. Swagger UI has no switcher — mount one instance per language instead.
payload.config.ts
See Internationalization.

Extensions

Add a webhook path and an API-key security scheme the generator can’t know about, plus a post-build transform.
payload.config.ts
See Extensions.