b2_authorize_account
  • 28 Oct 2024
  • Dark
    Light

b2_authorize_account

  • Dark
    Light

Article summary

Get
/b2api/v3/b2_authorize_account

Returns an authorization token that can be used for account-level operations, and a URL that should be used as the base URL for subsequent API calls.

Header parameters
Authorization
stringRequired

Returns an authorization token

Returns an authorization token and base URL that can be used for subsequent API calls.

You can use either the master application key or a normal application key.

NOTE: the account ID can be used in place of the master application key ID.

You'll find the master application key in the Backblaze web UI. When using the master application key, use your "master application key ID" and the "application key" you got from the site.


Master Application Key: this is the first key you have access to, it is available in the Backblaze web UI. This key has all capabilities, access to all buckets, and has no file prefix restrictions or expiration.

Application Key(s) [non-master]: these are other keys created by you and can be limited to a bucket, with a specific file prefix and can expire.


Normal application keys come from the b2_create_key call. When using one of them, the "application key ID" and "application key" are the ones returned when you created the key.

API Versions

v3 b2_authorize_account (September 23, 2021)

b2_authorize_account now returns a data structure that groups the information you need by API suite. For each suite enabled, it provides the information you need to call those APIs.

Please use v2 with b2_authorize_account for B2 Native API calls if the Partner API is enabled on your account.

v2 Return bucket name (Sept 13, 2018)

When using an application key with a bucket restriction, the name of the bucket is now returned.

Responses
200

The request succeeded.

Authorization token returned
{
  "accountId": "ACCOUNT_ID",
  "apiInfo": {
    "storageApi": {
      "absoluteMinimumPartSize": 5000000,
      "apiUrl": "https://api001.backblazeb2.com",
      "bucketId": null,
      "bucketName": null,
      "capabilities": [
        "deleteFiles",
        "deleteKeys",
        "readBucketEncryption",
        "writeKeys",
        "writeBuckets",
        "writeBucketReplications",
        "readBucketReplications",
        "deleteBuckets",
        "readBuckets",
        "bypassGovernance",
        "readFileLegalHolds",
        "readFiles",
        "listAllBucketNames",
        "readBucketNotifications",
        "readBucketRetentions",
        "writeBucketRetentions",
        "writeFileLegalHolds",
        "shareFiles",
        "writeFiles",
        "listKeys",
        "listBuckets",
        "listFiles",
        "writeFileRetentions",
        "writeBucketEncryption",
        "writeBucketNotifications",
        "readFileRetentions"
      ],
      "downloadUrl": "https://f001.backblazeb2.com",
      "infoType": "storageApi",
      "namePrefix": null,
      "recommendedPartSize": 100000000,
      "s3ApiUrl": "https://s3.us-west-001.backblazeb2.com"
    },
    "groupsApi": {
      "capabilities": [
        "all"
      ],
      "groupsApiUrl": "https://apiNNN.backblazeb2.com",
      "infoType": "groupsApi"
    },
    "backupApi": {
      "capabilities": [
        "all"
      ],
      "backupApiUrl": "https://apiNNN.backblazeb2.com",
      "infoType": "backupApi"
    }
  },
  "applicationKeyExpirationTimestamp": null,
  "authorizationToken": "AUTHORIZATION_TOKEN"
}
Expand All
object
accountId
string

The identifier for the account.

ExampleYOUR_ACCOUNT_ID
apiInfo
object

A data structure that groups the information you need by API suite.

groupsApi
object

A data structure that contains the information you need for the Partner API.

capabilities
Array of string

A list of strings, each one naming a capability the new key should have.

Example[ "all" ]
string
groupsApiUrl
string

The base URL for all Partner API calls.

Examplehttps://apiNNN.backblazeb2.com
infoType
string

The API type that the information in the object corresponds to.

ExamplegroupsApi
storageApi
object

A data structure that contains the information you need for the B2 Native API.

absoluteMinimumPartSize
integer

The smallest possible size of a part of a large file (except the last one). This is smaller than the recommendedPartSize. If you use it, you may find that it takes longer overall to upload a large file.

Example5000000
apiUrl
string

The base URL to use for all API calls except for uploading and downloading files.

Examplehttps://apiNNN.backblazeb2.com
bucketId
string

When present, access is restricted to one bucket.

ExampleBUCKET_ID
bucketName
string

When bucketId is set, and it is a valid bucket that has not been deleted, this field is set to the name of the bucket. It's possible that bucketId is set to a bucket that no longer exists, in which case this field will be null. It's also null when bucketId is null.

ExamplemyBucketName
capabilities
Array of string

A list of strings, each one naming a capability the key has.

Example[ "deleteFiles", "deleteKeys", "readBucketEncryption", "writeKeys", "writeBuckets", "writeBucketReplications", "readBucketReplications", "readBucketNotifications", "deleteBuckets", "readBuckets", "bypassGovernance", "readFileLegalHolds", "readFiles", "listAllBucketNames", "readBucketRetentions", "writeBucketNotifications", "writeBucketRetentions", "writeFileLegalHolds", "shareFiles", "writeFiles", "listKeys", "listBuckets", "listFiles", "writeFileRetentions", "writeBucketEncryption", "readFileRetentions" ]
string
Valid values[ "deleteFiles", "deleteKeys", "readBucketEncryption", "writeKeys", "writeBuckets", "writeBucketNotifications", "writeBucketReplications", "readBucketNotifications", "readBucketReplications", "deleteBuckets", "readBuckets", "bypassGovernance", "readFileLegalHolds", "readFiles", "listAllBucketNames", "readBucketRetentions", "writeBucketRetentions", "writeFileLegalHolds", "shareFiles", "writeFiles", "listKeys", "listBuckets", "listFiles", "writeFileRetentions", "writeBucketEncryption", "readFileRetentions" ]
downloadUrl
string

The base URL to use for downloading files.

Examplehttps://f001.backblazeb2.com
infoType
string

The API type that the information in the object corresponds to.

ExamplestorageApi
namePrefix
string

When present, access is restricted to files whose names start with the prefix

ExamplemyFilePrefix
recommendedPartSize
integer

The recommended file part size.

Example100000000
s3ApiUrl
string

The base URL to use for all API calls using the S3 compatible API.

Examplehttps://s3.us-west-NNN.backblazeb2.com
backupApi
object

A data structure that contains the information you need for the Backup API.

capabilities
Array

A list of capabilities the new key should have.

Example[ "all" ]
backupApiUrl
string

The base URL for all Backup API calls.

Examplehttps://apiNNN.backblazeb2.com
infoType
string

The API type that the information in the object corresponds to.

ExamplegroupsApi
authorizationToken
string

An authorization token to use with all calls, other than b2_authorize_account, that need an Authorization header. This authorization token is valid for at most 24 hours.

ExampleAUTHORIZATION_TOKEN
applicationKeyExpirationTimestamp
integer

Expiration timestamp for the application key.

Examplenull
400
statuscodedescription
400bad_requestThe request had the wrong fields or illegal values. The message returned with the error will describe the problem.
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
401unauthorizedThe applicationKeyId and/or the applicationKey are wrong.
401unsupportedThe applicationKeyId is valid, but cannot be used with this version of the Partner API. The message contains information about what the problem is.

Was this article helpful?