storage block passed to bunnyStorage(...). This page also covers browser-direct client uploads, which are configured under storage.clientUploads.
payload.config.ts
Options
The top-level
storage block is optional. If every collection points at its own storage zone, you can omit the global storage entirely — the plugin only requires that each collection resolves to at least one active service.Getting your credentials
1
apiKey
Bunny Storage dashboard → your Storage Zone → FTP & API Access → copy the Password (use the full password, not the read-only one).
2
zoneName
The Username shown in the same panel.
3
hostname
Your Pull Zone hostname (not the Storage API endpoint). Bunny Storage needs a Pull Zone configured in front of it; files aren’t reachable without one. See Bunny’s guide on accessing storage files.
4
region
Read from your Storage Zone’s endpoint hostname. For example,
ny.storage.bunnycdn.com means region ny, and storage.bunnycdn.com means de. Leave it out for de.Regions
These codes autocomplete. Any other string is passed through, so a new Bunny region works without a plugin update. Codes with only the Edge (SSD) column are replication regions without a storage endpoint, so they cannot be the zoneregion.
S3 mode
Settingstorage.s3: true makes the plugin upload and delete files through Bunny’s S3-compatible endpoint (SigV4-signed requests) instead of the HTTP Storage API. It also switches client uploads to presigned S3, where the browser sends a presigned PUT straight to that endpoint (no Edge Script needed).
No extra secrets are needed: the S3 access key is your zoneName and the secret is your apiKey (the Storage Zone password) from the options above.
payload.config.ts
https://{region}-s3.storage.bunnycdn.com, with the same region as above.
See Client uploads for how S3 mode powers browser-direct uploads.
Files, versions and rename
Payload manages stored files by their storage key. Every upload through the Payload server goes to a new folder:<prefix> is the prefix stored on the document. It is the collection prefix, or the document prefix placed under the collection prefix. This is the source file. The processed file and the image variants go to the same folder. Client uploads use the same layout. Documents from earlier versions keep their old keys. Payload starts to manage them the first time their file changes.
Payload stores the keys in fields of each upload collection: the original group, and prefix and _objectKey on each image variant. SQL databases need a migration for these fields. See Create the migrations.
Versions
What happens to a replaced file depends onversions. Payload 4 turns versions on for every collection that does not set versions: false, with maxPerDoc: 100.
- With
versions(the default), a replaced file stays in Bunny Storage while any document or version references it. So restoring a version brings back a working file. Payload deletes the file after its last reference is gone. This happens when you replace the file, delete the document, change a draft, or when Payload removes old versions because ofmaxPerDoc. - With
versions: false, Payload deletes the old file when you replace it, as before. Setversions: falseon the collection to get this behavior back.
purge is on. Stream videos follow the same rule, see Replaced videos and versions.
Rename and restore
payload.renameFile, the rename operation in REST and GraphQL, and restoring a version copy the stored files to new keys. A rename adds Payload’s -original suffix to a file without variants: renaming to x.jpg stores x-original.jpg. A restore keeps the name of a file that the current document still uses, and gives every other file a new name, for example photo-original-<uuid>.jpg. How the plugin copies a file depends on the mode:
- Storage HTTP API (the default): the plugin downloads the file and uploads it again through your server. Bunny then sets the
Content-Typefrom the file extension, so a custom type is not kept. A large file costs server bandwidth. The copy is not atomic. The plugin checks right before the upload that no file exists at the new key. A file that another request writes in the short time between the check and the upload is overwritten. - S3 mode: the plugin uses S3
CopyObject, so the file does not pass through your server. The copy keeps theContent-Type. It sendsIf-None-Match: *, so Bunny rejects the copy when a file already exists at the new key. This check is atomic.
409. A restore fails with a server error instead, because Payload maps only rename collisions to 409. A restore rarely collides, because the new name has a random ID.
Requirements
The plugin validates these on startup and throws a clear error if any fails:hostnamemust be your Pull Zone host. The plugin rejectsstorage.bunnycdn.comand any host that ends in.storage.bunnycdn.com.- If you turn on signed URLs anywhere
storageis active,tokenSecurityKeybecomes required.
serverURL in your Payload config. Cropping, changing the focal point and duplicating a document make Payload download the stored file again. Without serverURL, Payload may call the wrong origin, or call it without the editor’s session, and these operations fail when the collection uses Payload access control.
Collection overrides
A collection’sstorage can be one of three things:
- a partial override (
uploadTimeout,clientUploads) — merged onto the global zone; - full options (with their own
apiKey/hostname/zoneName) — this collection uses its OWN storage zone, ignoring the global zone entirely; false— disable Bunny Storage for this collection.
payload.config.ts
apiKey. Full options inherit nothing from the global zone: omitted optional keys (region, s3, tokenSecurityKey, clientUploads, uploadTimeout) fall back to plugin defaults, never to the global zone’s values. Provide that zone’s own tokenSecurityKey if you enable signed URLs for it.
See Collection overrides for the full-options vs partial-override rules and the complete list of options.