COMING SOON - The application key APIs are under development, and will be available soon.

b2_create_key

Creates a new application key.

There is a limit of 100 million key creations per account.

Request

Request HTTP Headers

Authorization

required

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

Request HTTP Message Body Parameters

accountId

required

Your account ID.

capabilities

required

A list of strings, each one naming a capability the new key should have. Possibilities are: listKeys, writeKeys, deleteKeys, listBuckets, writeBuckets, deleteBuckets, listFiles, readFiles, shareFiles, writeFiles, and deleteFiles.

keyName

required

A name for this key. There is no requirement that the name be unique. The name cannot be used to look up the key. Names can contain letters, numbers, and "-", and are limited to 100 characters.

validDurationInSeconds

optional

When provided, the key will expire after the given number of seconds, and will have expirationTimestamp set. Value must be a positive integer, and must be less than 1000 days (in seconds).

bucketId

optional

When present, the new key can only access this bucket. When set, only these capabilities can be specified: listBuckets, listFiles, readFiles, shareFiles, writeFiles, and deleteFiles.

namePrefix

optional

When present, restricts access to files whose names start with the prefix. You must set bucketId when setting this.

Response

Response HTTP Status 200

Bucket successfully created. The JSON response will contain:

applicationKeyId

required

The ID of the newly created key.

applicationKey

required

The secret part of the key. This is the only time it will be returned, so you need to keep it. This is not returned when you list the keys in your account.

capabilities

required

A list of strings, each one naming a capability the key has. Possibilities are: listKeys, writeKeys, deleteKeys, listBuckets, writeBuckets, deleteBuckets, listFiles, readFiles, shareFiles, writeFiles, and deleteFiles.

accountId

required

The account that this application key is for.

bucketId

optional

When present, restricts access to one bucket.

expirationTimestamp

optional

When present, says when this key will expire, in milliseconds since 1970.

keyName

required

The name assigned when the key was created.

namePrefix

optional

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

Response Errors

Bucket not created. If possible the server will return a JSON error structure. Errors include:

status

code

message

400

bad_request

accountId bad

400

bad_request

Account <accountId> does not exist

400

bad_request

No Authorization header

401

unauthorized

Not authorized