Skip to main content

B2 Bucket

@sntxrr/b2-bucketv2026.08.05.3· 1d agoMODELS
01README

Manage one Backblaze B2 bucket via the B2 Native API v4 — sync, create, update, idempotent delete, and get/set event notification rules — with first-class lifecycle rules so restic-pruned hidden file versions are actually deleted.

02Release Notes

Gates making a bucket public: create and update now refuse bucketType=allPublic unless allowPublicBucket=true acknowledges it, as a method input or a global argument. Corrects the lifecycle check's error message, which claimed no rules were declared when they had been supplied via --input — swamp does not give pre-flight checks the method's inputs, so the check cannot see them. Documents that Event Notifications needs account-level enablement. Write paths verified end to end against live B2.

03Models1
@sntxrr/b2/bucketv2026.08.05.3b2_bucket.ts

Global Arguments

ArgumentTypeDescription
applicationKeyIdstringB2 application key ID (master or scoped). Wire with ${{ vault.get(b2, B2_APPLICATION_KEY_ID) }}.
applicationKeystringB2 application key — supply via vault.get(), never inline.
authHost?stringOverride the B2 authorize host (testing only). Defaults to https://api.backblazeb2.com.
bucketNamestringName of the bucket this model manages. B2 bucket names are globally unique and 6-63 characters.
bucketId?stringB2 bucket ID. Optional: when omitted it is resolved from bucketName via b2_list_buckets, which costs one class-C transaction per run. Set it to avoid that call.
bucketType?enumDesired bucket type. `create` defaults to allPrivate when this is unset — a restic repository must never be allPublic. Deliberately NOT a schema-level default: a default here would make `update` send bucketType on every run, silently flipping an allPublic bucket private for an operator who only meant to set lifecycle rules.
lifecycleRules?arrayDesired lifecycle rules. For a restic bucket use [{ fileNamePrefix: "", daysFromUploadingToHiding: null, daysFromHidingToDeleting: 1 }].
corsRules?arrayDesired CORS rules. Omit to leave the bucket's CORS configuration untouched.
bucketInfo?recordDesired user-defined bucket metadata (also carries Cache-Control policies).
fileLockEnabled?booleanEnable Object Lock on the bucket. Requires the writeBucketRetentions capability. Object Lock cannot be disabled once enabled.
allowPublicBucketbooleanAcknowledge that this bucket may be allPublic. Without it, create and
allowUnprunedHiddenVersionsbooleanSet true to acknowledge that this bucket intentionally retains hidden file versions forever, which disables the lifecycle-hidden-version-retention pre-flight check.

Resources

bucket(infinite)— Snapshot of the managed B2 bucket's configuration and state
notificationRules(infinite)— Snapshot of the bucket's event notification rules, with signing secrets and header values redacted
04Previous Versions2
2026.08.05.2

Live-verification fixes. unprunedPrefixes now reports [""] rather than [] for a bucket with NO lifecycle rules: the old value read as 'nothing is accumulating hidden versions' when in fact every file is, hiding exactly the buckets a consumer queries for. Adds defaultRetentionPeriod so a snapshot can distinguish a 1-day Object Lock window from a 10-year one, aliases a bucket named 'latest' to bucket-latest, and stops bucketInfo/options hard-failing sync on an unexpected value type.

2026.08.05.1

First release. Manages one Backblaze B2 bucket via the Native API v4: sync, create, update, idempotent delete, and event notification rules. Models lifecycle rules precisely and surfaces prunesHiddenVersions, because restic-pruned pack files are billed forever without a daysFromHidingToDeleting rule. Notification-rule signing secrets and custom header values are stripped before any snapshot is written.

05Stats
A
100 / 100
Downloads
0
Archive size
39.2 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License declared1/1earned
  • Verified public repository2/2earned
06Platforms
07Labels