b2_list_buckets
    • Dark
      Light

    b2_list_buckets

    • Dark
      Light

    Article Summary

    Get
    /b2api/v2/b2_list_buckets

    PLEASE NOTE:

    This API request is now being described as a GET request and not a POST request, as was the case in previous versions of our documentation.

    We made this update because we believe that an API call that retrieves data and does not alter state is more accurately represented as a GET request.

    You may still make a POST request to this endpoint by simply submitting a JSON-formatted request body containing the parameters, with Content-Type set to application/json.


    Lists buckets alphabetically by name

    When using an authorization token that is restricted to a bucket, you must include the bucketId or bucketName of that bucket in the request, or the request will be denied.

    API Versions

    v2: Remove application key workaround (Sept 13, 2018)

    Listing buckets will always return all buckets, unless you ask for just one by specifying bucketName or bucketId. If you ask for all buckets and your application key is restricted to one bucket, the call is unauthorized.

    v1: Workaround for existing applications and application keys (August 9, 2018)

    When using an application key that is restricted to a bucket, a request to list all buckets will return just that one bucket instead of returning "unauthorized".

    v1: Application keys (July 26, 2018)

    New optional bucketName and bucketId parameters to b2_list_buckets provide a way to get information about just one bucket. This is useful when using an application key that allows access to only one bucket.

    v1: Original release (September 22, 2015)

    B2 Cloud Storage was released.

    Header parameters
    Authorization
    stringRequired

    An account authorization token, obtained from b2_authorize_account.
    The token must have the listBuckets capability.

    Query parameters
    accountId
    stringRequired

    The ID of your account.

    bucketId
    string

    When bucketId is specified, the result will be a list containing just this bucket, if it's present in the account, or no buckets if the account does not have a bucket with this ID.

    bucketName
    string

    When bucketName is specified, the result will be a list containing just this bucket, if it's present in the account, or no buckets if the account does not have a bucket with this name.

    bucketTypes
    string

    If present, B2 will use it as a filter for bucket types returned in the list buckets response. If not present, only buckets with bucket types "allPublic", "allPrivate" and "snapshot" will be returned. A special filter value of ["all"] will return all bucket types.


    If present, it must be in the form of a json array of strings containing valid bucket types in quotes and separated by a comma. Valid bucket types include "allPrivate", "allPublic", "restricted", "snapshot", "shared", and other values added in the future.


    A bad request error will be returned if "all" is used with other bucketTypes, bucketTypes is empty, or invalid bucketTypes are requested.

    Responses
    200

    The request succeeded.


    The response headers include the Content-Type that was specified when the file was uploaded. They also include the X-Bz-FileName and X-Bz-Content-Sha1 headers, plus X-Bz-Info-* headers for any custom file info that was provided with the upload. The X-Bz-FileName uses percent-encoding, as if it were a URL parameter.

    Array of object
    object
    buckets
    Array of object

    An array of bucket objects.

    object
    accountId
    string

    The account that the bucket is in.

    bucketId
    string

    The unique ID of the bucket.

    bucketName
    string

    The unique name of the bucket

    bucketType
    string

    One of: allPublic, allPrivate, restricted, snapshot, shared, or other values added in the future. allPublic means that anybody can download the files is the bucket; allPrivate means that you need an authorization token to download them; snapshot means that it's a private bucket containing snapshots created on the B2 web site.

    bucketInfo
    string

    The user data stored with this bucket.

    corsRules
    Array

    The CORS rules for this bucket. See CORS Rules for an overview and the rule structure.

    fileLockConfiguration
    object

    The Object Lock configuration for this bucket. This field is filtered based on application key capabilities; readBucketRetentions capability is required to access the value. See Object Lock for more details on response structure.

    isClientAuthorizedToRead
    boolean
    value
    object
    defaultRetention
    object
    mode
    string
    period
    string
    isFileLockEnabled
    boolean
    defaultServerSideEncryption
    object

    The default bucket Server-Side Encryption settings for new files uploaded to this bucket. This field is filtered based on application key capabilities; readBucketEncryption capability is required to access the value. See Server-Side Encryption for more details on response structure.

    isClientAuthorizedToRead
    boolean
    ExampleTrue
    value
    object
    algorithm
    string
    ExampleAES256
    mode
    string
    ExampleSSE-B2
    lifecycleRules
    Array

    The list of lifecycle rules for this bucket. See Lifecycle Rules for an overview and the rule structure.

    replicationConfiguration
    Array

    The list of replication rules for this bucket. See Cloud Replication Rules for an overview and the rule structure.

    revision
    integer

    A counter that is updated every time the bucket is modified, and can be used with the ifRevisionIs parameter to b2_update_bucket to prevent colliding, simultaneous updates.

    options
    Array

    When present and set to s3, the bucket can be accessed through the S3 Compatible API.

    400
    statuscodedescription
    400bad_bucket_idThe requested bucket ID does not match an existing bucket.
    400bad_requestThe request had the wrong fields or illegal values. The message returned with the error will describe the problem.
    400cannot_delete_non_empty_bucketA bucket must be empty before it can be deleted. To delete this bucket, first remove all of the files in the bucket, then try the delete operation again.
    object
    status
    integer

    The numeric HTTP status code. Always matches the status in the HTTP response.

    Example400
    code
    string

    A single-identifier code that identifies the error.

    Exampleinvalid_bucket_name
    message
    string

    A human-readable message, in English, saying what went wrong.

    Examplebucket name is too long
    401
    statuscodedescription
    401bad_auth_tokenThe auth token used is not valid. Call b2_authorize_account again to either get a new one, or an error message describing the problem.
    401expired_auth_tokenThe auth token used has expired. Call b2_authorize_account again to get a new one.
    401unauthorizedThe auth token used is valid, but does not authorize this call with these parameters. The capabilities of an auth token are determined by the application key used with b2_authorize_account.
    403
    statuscodedescription
    403transaction_cap_exceededTransaction cap exceeded. To increase your cap, sign in to your B2 Cloud Storage account online. Then select the Caps & Alerts link in the B2 Cloud Storage section of the sidebar.