PHP Client for Cloudflare API
R2

Buckets

Buckets endpoint reference.

List

Returns a list of buckets for an account.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
paramsarrayNo[]Query Parameters.
jurisdictionstring|nullNoJurisdiction where objects in this bucket are guaranteed to be stored.
php
$response = $client->r2()->buckets()->list('ACCOUNT_ID', [], 'JURISDICTION');
View this operation on the Cloudflare API Reference

Create

Creates a new bucket for an account.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
valuesarrayYesValues to set on the bucket, e.g. `name`, `locationHint`, `storageClass`.
jurisdictionstring|nullNoJurisdiction where objects in this bucket are guaranteed to be stored.
php
$response = $client->r2()->buckets()->create('ACCOUNT_ID', [], 'JURISDICTION');
View this operation on the Cloudflare API Reference

Get

Get a bucket's details.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
bucketNamestringYesBucket Name.
jurisdictionstring|nullNoJurisdiction where objects in this bucket are guaranteed to be stored.
php
$response = $client->r2()->buckets()->get('ACCOUNT_ID', 'BUCKET_NAME', 'JURISDICTION');
View this operation on the Cloudflare API Reference

Edit

Apply changes to the storage class of an existing bucket.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
bucketNamestringYesBucket Name.
storageClassstringYesStorage class to set on the bucket, e.g. `Standard` or `InfrequentAccess`.
jurisdictionstring|nullNoJurisdiction where objects in this bucket are guaranteed to be stored.
php
$response = $client->r2()->buckets()->edit('ACCOUNT_ID', 'BUCKET_NAME', 'STORAGE_CLASS', 'JURISDICTION');
View this operation on the Cloudflare API Reference

Delete

Deletes an existing bucket.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
bucketNamestringYesBucket Name.
jurisdictionstring|nullNoJurisdiction where objects in this bucket are guaranteed to be stored.
php
$response = $client->r2()->buckets()->delete('ACCOUNT_ID', 'BUCKET_NAME', 'JURISDICTION');
View this operation on the Cloudflare API Reference

Create Temporary Credentials

Creates temporary access credentials scoped to a specific bucket.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
valuesarrayYesValues to set, e.g. `bucket`, `permission`, `ttlSeconds`, `parentAccessKeyId`.
php
$response = $client->r2()->buckets()->createTemporaryCredentials('ACCOUNT_ID', []);
View this operation on the Cloudflare API Reference
Copyright © 2026