R2
Buckets
Buckets endpoint reference.
List
Returns a list of buckets for an account.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
params | array | No | [] | Query Parameters. |
jurisdiction | string|null | No | Jurisdiction where objects in this bucket are guaranteed to be stored. |
php
$response = $client->r2()->buckets()->list('ACCOUNT_ID', [], 'JURISDICTION');
Create
Creates a new bucket for an account.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
values | array | Yes | Values to set on the bucket, e.g. `name`, `locationHint`, `storageClass`. | |
jurisdiction | string|null | No | Jurisdiction where objects in this bucket are guaranteed to be stored. |
php
$response = $client->r2()->buckets()->create('ACCOUNT_ID', [], 'JURISDICTION');
Get
Get a bucket's details.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
bucketName | string | Yes | Bucket Name. | |
jurisdiction | string|null | No | Jurisdiction where objects in this bucket are guaranteed to be stored. |
php
$response = $client->r2()->buckets()->get('ACCOUNT_ID', 'BUCKET_NAME', 'JURISDICTION');
Edit
Apply changes to the storage class of an existing bucket.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
bucketName | string | Yes | Bucket Name. | |
storageClass | string | Yes | Storage class to set on the bucket, e.g. `Standard` or `InfrequentAccess`. | |
jurisdiction | string|null | No | Jurisdiction where objects in this bucket are guaranteed to be stored. |
php
$response = $client->r2()->buckets()->edit('ACCOUNT_ID', 'BUCKET_NAME', 'STORAGE_CLASS', 'JURISDICTION');
Delete
Deletes an existing bucket.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
bucketName | string | Yes | Bucket Name. | |
jurisdiction | string|null | No | Jurisdiction where objects in this bucket are guaranteed to be stored. |
php
$response = $client->r2()->buckets()->delete('ACCOUNT_ID', 'BUCKET_NAME', 'JURISDICTION');
Create Temporary Credentials
Creates temporary access credentials scoped to a specific bucket.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
values | array | Yes | Values to set, e.g. `bucket`, `permission`, `ttlSeconds`, `parentAccessKeyId`. |
php
$response = $client->r2()->buckets()->createTemporaryCredentials('ACCOUNT_ID', []);

