Skip to content

CreateKey

Craig edited this page Jan 1, 2024 · 2 revisions

How To Use

<?php

use TechKat\BackBlazeB2\Client;

$keyID = '...';
$applicationKey = '...';

$client = new Client($keyID, $applicationKey);

$response = $client->createKey([
  'keyName' => 'A-Leash-A-Keys',
  'capabilities' => [
    'listKeys',
    'listAllBucketNames',
    'listBuckets',
    'readBuckets',
    'writeBuckets',
    // ...
  ],
  'validDurationInSeconds' => 86400,
  'bucketId' => 'BUCKET_ID',
  // ...
]);

return $response;

Expected Result

{
  "keyName": "A-Leash-A-Keys",
  "applicationKeyId": "NEW_KEY_ID",
  "capabilities": [
    "listKeys",
    "listAllBucketNames",
    "listBuckets",
    "readBuckets",
    "writeBuckets",
    // ...
  ],
  // ...
}

Backblaze B2 API Documentation

https://www.backblaze.com/apidocs/b2-create-key