Creates a new B2Client. Call authorize before making API requests.
Configuration including credentials, realm, and transport settings.
ReadonlyaccountAuthorization state storage (tokens, URLs, capabilities).
ReadonlyrawLow-level client for direct B2 API calls.
ReadonlyurlSSRF allow-list applied by the default FetchTransport. null when
a custom transport was supplied — in that case the SDK does not own the
guard. Locked down by B2Client.authorize.
Authenticates with B2 and stores the authorization state. Must be called before other methods.
Optionaloptions: B2ClientAuthorizeOptions
Optional request controls.
The authorization response containing tokens, URLs, and capabilities.
Creates a new B2 bucket.
Bucket configuration including name, type, and optional settings.
OptionalbucketInfo?: Record<string, string>Custom key-value metadata stored with the bucket. Keys must be 1-50
UTF-8 bytes, must not start with b2-, and all values together must be
at most 10,000 UTF-8 bytes. Keys must match
BUCKET_INFO_KEY_PATTERN. There is no bucketInfo pair-count cap.
Globally unique bucket name (6-63 chars; letters, digits, hyphens, periods).
Access level: "allPrivate" or "allPublic".
OptionalcorsRules?: CorsRule[]CORS rules for browser-based access. A bucket may have at most 100
rules; rule names must be unique, 6-63 characters, match
[A-Za-z0-9-], and not start with b2-. Each rule must be less than
1,000 UTF-8 bytes across its name, origins, operations, allowed headers,
and exposed headers. maxAgeSeconds must be at most 86,400.
OptionaldefaultRetention?: BucketRetentionPolicyDefault retention policy for new files (requires file lock).
OptionaldefaultServerSideEncryption?: BucketDefaultServerSideEncryptionSettingDefault server-side encryption for new files.
OptionalfileLockEnabled?: booleanEnable file lock (Object Lock) on the bucket. Cannot be disabled once set.
OptionallifecycleRules?: LifecycleRule[]Lifecycle rules for automatic file deletion or hiding.
OptionalreplicationConfiguration?: ReplicationConfigurationCross-region replication configuration.
A Bucket handle for the newly created bucket.
Creates a new application key with the specified capabilities.
Key configuration including capabilities, name, and optional restrictions.
The full key including the secret (only returned at creation time).
Permanently deletes a bucket. The bucket must be empty.
The unique identifier of the bucket to delete.
The deleted bucket metadata.
Permanently deletes an application key.
The unique identifier of the key to delete.
The deleted application key metadata.
Checks whether the authorized application key carries every capability in
needed. Returns the missing capabilities so callers can fail fast with a
clear error instead of a generic 401/403 from the server.
The capabilities required by the planned operation.
An object with ok: true when every needed capability is
present, otherwise { ok: false, missing: [...] }.
If authorize has not been called yet.
Lists buckets in the account, optionally filtered by ID, name, or type.
Optionaloptions: { bucketId?: BucketId; bucketName?: string; bucketTypes?: BucketTypesFilter }
Optional filters for bucket ID, name, or type.
OptionalbucketId?: BucketIdFilter to a specific bucket by ID.
OptionalbucketName?: stringFilter to a specific bucket by name.
OptionalbucketTypes?: BucketTypesFilterFilter by bucket types (e.g., ["allPrivate"], ["shared"], or ["all"]).
An array of Bucket handles.
Lists application keys in the account.
Optionaloptions: { pageSize?: number; startApplicationKeyId?: ApplicationKeyId }
Optional pagination settings.
OptionalpageSize?: numberMaximum number of keys to return per request. Forwarded to the
raw API's maxKeyCount parameter.
OptionalstartApplicationKeyId?: ApplicationKeyIdStart listing at this key ID, usually from nextApplicationKeyId.
A page of application keys with an optional continuation token.
Async iterator that yields every application key on the account,
automatically handling pagination via listKeys.
Optionaloptions: PaginatorOptions
Pagination + abort options. pageSize is forwarded
to maxKeyCount; the default is 1000.
An async iterable of ApplicationKey entries.
High-level B2 client providing ergonomic access to buckets, files, and keys.
Example