# R2 # Buckets ## List Buckets `client.r2.buckets.list(BucketListParamsparams, RequestOptionsoptions?): BucketListResponse` **get** `/accounts/{account_id}/r2/buckets` Lists all R2 buckets on your account. ### Parameters - `params: BucketListParams` - `account_id: string` Path param: Account ID. - `cursor?: string` Query param: Pagination cursor received during the last List Buckets call. R2 buckets are paginated using cursors instead of page numbers. - `direction?: "asc" | "desc"` Query param: Direction to order buckets. - `"asc"` - `"desc"` - `name_contains?: string` Query param: Bucket names to filter by. Only buckets with this phrase in their name will be returned. - `order?: "name"` Query param: Field to order buckets by. - `"name"` - `per_page?: number` Query param: Maximum number of buckets to return in a single call. - `start_after?: string` Query param: Bucket name to start searching after. Buckets are ordered lexicographically. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `BucketListResponse` - `buckets?: Array` - `creation_date?: string` Creation timestamp. - `jurisdiction?: "default" | "eu" | "fedramp"` Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` - `location?: "apac" | "eeur" | "enam" | 3 more` Location of the bucket. - `"apac"` - `"eeur"` - `"enam"` - `"weur"` - `"wnam"` - `"oc"` - `name?: string` Name of the bucket. - `storage_class?: "Standard" | "InfrequentAccess"` Storage class for newly uploaded objects, unless specified otherwise. - `"Standard"` - `"InfrequentAccess"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const buckets = await client.r2.buckets.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' }); console.log(buckets.buckets); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "buckets": [ { "creation_date": "creation_date", "jurisdiction": "default", "location": "apac", "name": "example-bucket", "storage_class": "Standard" } ] }, "success": true, "result_info": { "cursor": "1-JTdCJTIydiUyMiUzQTElMkMlMjJzdGFydEFmdGVyJTIyJTNBJTIyZGF2aWRwdWJsaWMlMjIlN0Q=", "per_page": 20 } } ``` ## Get Bucket `client.r2.buckets.get(stringbucketName, BucketGetParamsparams, RequestOptionsoptions?): Bucket` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}` Gets properties of an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: BucketGetParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `Bucket` A single R2 bucket. - `creation_date?: string` Creation timestamp. - `jurisdiction?: "default" | "eu" | "fedramp"` Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` - `location?: "apac" | "eeur" | "enam" | 3 more` Location of the bucket. - `"apac"` - `"eeur"` - `"enam"` - `"weur"` - `"wnam"` - `"oc"` - `name?: string` Name of the bucket. - `storage_class?: "Standard" | "InfrequentAccess"` Storage class for newly uploaded objects, unless specified otherwise. - `"Standard"` - `"InfrequentAccess"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const bucket = await client.r2.buckets.get('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(bucket.creation_date); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "creation_date": "creation_date", "jurisdiction": "default", "location": "apac", "name": "example-bucket", "storage_class": "Standard" }, "success": true } ``` ## Create Bucket `client.r2.buckets.create(BucketCreateParamsparams, RequestOptionsoptions?): Bucket` **post** `/accounts/{account_id}/r2/buckets` Creates a new R2 bucket. ### Parameters - `params: BucketCreateParams` - `account_id: string` Path param: Account ID. - `name: string` Body param: Name of the bucket. - `locationHint?: "apac" | "eeur" | "enam" | 3 more` Body param: Location of the bucket. - `"apac"` - `"eeur"` - `"enam"` - `"weur"` - `"wnam"` - `"oc"` - `storageClass?: "Standard" | "InfrequentAccess"` Body param: Storage class for newly uploaded objects, unless specified otherwise. - `"Standard"` - `"InfrequentAccess"` - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `Bucket` A single R2 bucket. - `creation_date?: string` Creation timestamp. - `jurisdiction?: "default" | "eu" | "fedramp"` Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` - `location?: "apac" | "eeur" | "enam" | 3 more` Location of the bucket. - `"apac"` - `"eeur"` - `"enam"` - `"weur"` - `"wnam"` - `"oc"` - `name?: string` Name of the bucket. - `storage_class?: "Standard" | "InfrequentAccess"` Storage class for newly uploaded objects, unless specified otherwise. - `"Standard"` - `"InfrequentAccess"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const bucket = await client.r2.buckets.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', name: 'example-bucket', }); console.log(bucket.creation_date); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "creation_date": "creation_date", "jurisdiction": "default", "location": "apac", "name": "example-bucket", "storage_class": "Standard" }, "success": true } ``` ## Patch Bucket `client.r2.buckets.edit(stringbucketName, BucketEditParamsparams, RequestOptionsoptions?): Bucket` **patch** `/accounts/{account_id}/r2/buckets/{bucket_name}` Updates properties of an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: BucketEditParams` - `account_id: string` Path param: Account ID. - `storage_class: "Standard" | "InfrequentAccess"` Header param: Storage class for newly uploaded objects, unless specified otherwise. - `"Standard"` - `"InfrequentAccess"` - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `Bucket` A single R2 bucket. - `creation_date?: string` Creation timestamp. - `jurisdiction?: "default" | "eu" | "fedramp"` Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` - `location?: "apac" | "eeur" | "enam" | 3 more` Location of the bucket. - `"apac"` - `"eeur"` - `"enam"` - `"weur"` - `"wnam"` - `"oc"` - `name?: string` Name of the bucket. - `storage_class?: "Standard" | "InfrequentAccess"` Storage class for newly uploaded objects, unless specified otherwise. - `"Standard"` - `"InfrequentAccess"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const bucket = await client.r2.buckets.edit('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', storage_class: 'Standard', }); console.log(bucket.creation_date); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "creation_date": "creation_date", "jurisdiction": "default", "location": "apac", "name": "example-bucket", "storage_class": "Standard" }, "success": true } ``` ## Delete Bucket `client.r2.buckets.delete(stringbucketName, BucketDeleteParamsparams, RequestOptionsoptions?): BucketDeleteResponse` **delete** `/accounts/{account_id}/r2/buckets/{bucket_name}` Deletes an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: BucketDeleteParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `BucketDeleteResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const bucket = await client.r2.buckets.delete('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(bucket); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Domain Types ### Bucket - `Bucket` A single R2 bucket. - `creation_date?: string` Creation timestamp. - `jurisdiction?: "default" | "eu" | "fedramp"` Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` - `location?: "apac" | "eeur" | "enam" | 3 more` Location of the bucket. - `"apac"` - `"eeur"` - `"enam"` - `"weur"` - `"wnam"` - `"oc"` - `name?: string` Name of the bucket. - `storage_class?: "Standard" | "InfrequentAccess"` Storage class for newly uploaded objects, unless specified otherwise. - `"Standard"` - `"InfrequentAccess"` ### Bucket List Response - `BucketListResponse` - `buckets?: Array` - `creation_date?: string` Creation timestamp. - `jurisdiction?: "default" | "eu" | "fedramp"` Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` - `location?: "apac" | "eeur" | "enam" | 3 more` Location of the bucket. - `"apac"` - `"eeur"` - `"enam"` - `"weur"` - `"wnam"` - `"oc"` - `name?: string` Name of the bucket. - `storage_class?: "Standard" | "InfrequentAccess"` Storage class for newly uploaded objects, unless specified otherwise. - `"Standard"` - `"InfrequentAccess"` ### Bucket Delete Response - `BucketDeleteResponse = unknown` # Lifecycle ## Get Object Lifecycle Rules `client.r2.buckets.lifecycle.get(stringbucketName, LifecycleGetParamsparams, RequestOptionsoptions?): LifecycleGetResponse` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle` Get object lifecycle rules for a bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: LifecycleGetParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `LifecycleGetResponse` - `rules?: Array` - `id: string` Unique identifier for this rule. - `conditions: Conditions` Conditions that apply to all transitions of this rule. - `prefix: string` Transitions will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads. - `enabled: boolean` Whether or not this rule is in effect. - `abortMultipartUploadsTransition?: AbortMultipartUploadsTransition` Transition to abort ongoing multipart uploads. - `condition?: Condition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `deleteObjectsTransition?: DeleteObjectsTransition` Transition to delete objects. - `condition?: R2LifecycleAgeCondition | R2LifecycleDateCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `R2LifecycleAgeCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `R2LifecycleDateCondition` Condition for lifecycle transitions to apply on a specific date. - `date: string` - `type: "Date"` - `"Date"` - `storageClassTransitions?: Array` Transitions to change the storage class of objects. - `condition: R2LifecycleAgeCondition | R2LifecycleDateCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `R2LifecycleAgeCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `R2LifecycleDateCondition` Condition for lifecycle transitions to apply on a specific date. - `date: string` - `type: "Date"` - `"Date"` - `storageClass: "InfrequentAccess"` - `"InfrequentAccess"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const lifecycle = await client.r2.buckets.lifecycle.get('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(lifecycle.rules); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "rules": [ { "id": "Expire all objects older than 24 hours", "conditions": { "prefix": "prefix" }, "enabled": true, "abortMultipartUploadsTransition": { "condition": { "maxAge": 0, "type": "Age" } }, "deleteObjectsTransition": { "condition": { "maxAge": 0, "type": "Age" } }, "storageClassTransitions": [ { "condition": { "maxAge": 0, "type": "Age" }, "storageClass": "InfrequentAccess" } ] } ] }, "success": true } ``` ## Put Object Lifecycle Rules `client.r2.buckets.lifecycle.update(stringbucketName, LifecycleUpdateParamsparams, RequestOptionsoptions?): LifecycleUpdateResponse` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle` Set the object lifecycle rules for a bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: LifecycleUpdateParams` - `account_id: string` Path param: Account ID. - `rules?: Array` Body param - `id: string` Unique identifier for this rule. - `conditions: Conditions` Conditions that apply to all transitions of this rule. - `prefix: string` Transitions will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads. - `enabled: boolean` Whether or not this rule is in effect. - `abortMultipartUploadsTransition?: AbortMultipartUploadsTransition` Transition to abort ongoing multipart uploads. - `condition?: Condition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `deleteObjectsTransition?: DeleteObjectsTransition` Transition to delete objects. - `condition?: R2LifecycleAgeCondition | R2LifecycleDateCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `R2LifecycleAgeCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `R2LifecycleDateCondition` Condition for lifecycle transitions to apply on a specific date. - `date: string` - `type: "Date"` - `"Date"` - `storageClassTransitions?: Array` Transitions to change the storage class of objects. - `condition: R2LifecycleAgeCondition | R2LifecycleDateCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `R2LifecycleAgeCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `R2LifecycleDateCondition` Condition for lifecycle transitions to apply on a specific date. - `date: string` - `type: "Date"` - `"Date"` - `storageClass: "InfrequentAccess"` - `"InfrequentAccess"` - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `LifecycleUpdateResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const lifecycle = await client.r2.buckets.lifecycle.update('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(lifecycle); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Domain Types ### Lifecycle Get Response - `LifecycleGetResponse` - `rules?: Array` - `id: string` Unique identifier for this rule. - `conditions: Conditions` Conditions that apply to all transitions of this rule. - `prefix: string` Transitions will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads. - `enabled: boolean` Whether or not this rule is in effect. - `abortMultipartUploadsTransition?: AbortMultipartUploadsTransition` Transition to abort ongoing multipart uploads. - `condition?: Condition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `deleteObjectsTransition?: DeleteObjectsTransition` Transition to delete objects. - `condition?: R2LifecycleAgeCondition | R2LifecycleDateCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `R2LifecycleAgeCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `R2LifecycleDateCondition` Condition for lifecycle transitions to apply on a specific date. - `date: string` - `type: "Date"` - `"Date"` - `storageClassTransitions?: Array` Transitions to change the storage class of objects. - `condition: R2LifecycleAgeCondition | R2LifecycleDateCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `R2LifecycleAgeCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `R2LifecycleDateCondition` Condition for lifecycle transitions to apply on a specific date. - `date: string` - `type: "Date"` - `"Date"` - `storageClass: "InfrequentAccess"` - `"InfrequentAccess"` ### Lifecycle Update Response - `LifecycleUpdateResponse = unknown` # CORS ## Get Bucket CORS Policy `client.r2.buckets.cors.get(stringbucketName, CORSGetParamsparams, RequestOptionsoptions?): CORSGetResponse` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/cors` Get the CORS policy for a bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: CORSGetParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `CORSGetResponse` - `rules?: Array` - `allowed: Allowed` Object specifying allowed origins, methods and headers for this CORS rule. - `methods: Array<"GET" | "PUT" | "POST" | 2 more>` Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser. - `"GET"` - `"PUT"` - `"POST"` - `"DELETE"` - `"HEAD"` - `origins: Array` Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser. - `headers?: Array` Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders. - `id?: string` Identifier for this rule. - `exposeHeaders?: Array` Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here. - `maxAgeSeconds?: number` Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const cors = await client.r2.buckets.cors.get('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(cors.rules); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "rules": [ { "allowed": { "methods": [ "GET" ], "origins": [ "http://localhost:3000" ], "headers": [ "x-requested-by" ] }, "id": "Allow Local Development", "exposeHeaders": [ "Content-Encoding" ], "maxAgeSeconds": 3600 } ] }, "success": true } ``` ## Put Bucket CORS Policy `client.r2.buckets.cors.update(stringbucketName, CORSUpdateParamsparams, RequestOptionsoptions?): CORSUpdateResponse` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/cors` Set the CORS policy for a bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: CORSUpdateParams` - `account_id: string` Path param: Account ID. - `rules?: Array` Body param - `allowed: Allowed` Object specifying allowed origins, methods and headers for this CORS rule. - `methods: Array<"GET" | "PUT" | "POST" | 2 more>` Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser. - `"GET"` - `"PUT"` - `"POST"` - `"DELETE"` - `"HEAD"` - `origins: Array` Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser. - `headers?: Array` Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders. - `id?: string` Identifier for this rule. - `exposeHeaders?: Array` Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here. - `maxAgeSeconds?: number` Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `CORSUpdateResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const cors = await client.r2.buckets.cors.update('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(cors); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Delete Bucket CORS Policy `client.r2.buckets.cors.delete(stringbucketName, CORSDeleteParamsparams, RequestOptionsoptions?): CORSDeleteResponse` **delete** `/accounts/{account_id}/r2/buckets/{bucket_name}/cors` Delete the CORS policy for a bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: CORSDeleteParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `CORSDeleteResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const cors = await client.r2.buckets.cors.delete('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(cors); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Domain Types ### CORS Get Response - `CORSGetResponse` - `rules?: Array` - `allowed: Allowed` Object specifying allowed origins, methods and headers for this CORS rule. - `methods: Array<"GET" | "PUT" | "POST" | 2 more>` Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser. - `"GET"` - `"PUT"` - `"POST"` - `"DELETE"` - `"HEAD"` - `origins: Array` Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser. - `headers?: Array` Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders. - `id?: string` Identifier for this rule. - `exposeHeaders?: Array` Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here. - `maxAgeSeconds?: number` Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified. ### CORS Update Response - `CORSUpdateResponse = unknown` ### CORS Delete Response - `CORSDeleteResponse = unknown` # Domains # Custom ## List Custom Domains of Bucket `client.r2.buckets.domains.custom.list(stringbucketName, CustomListParamsparams, RequestOptionsoptions?): CustomListResponse` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom` Gets a list of all custom domains registered with an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: CustomListParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `CustomListResponse` - `domains: Array` - `domain: string` Domain name of the custom domain to be added. - `enabled: boolean` Whether this bucket is publicly accessible at the specified custom domain. - `status: Status` - `ownership: "pending" | "active" | "deactivated" | 3 more` Ownership status of the domain. - `"pending"` - `"active"` - `"deactivated"` - `"blocked"` - `"error"` - `"unknown"` - `ssl: "initializing" | "pending" | "active" | 3 more` SSL certificate status. - `"initializing"` - `"pending"` - `"active"` - `"deactivated"` - `"error"` - `"unknown"` - `ciphers?: Array` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` - `zoneId?: string` Zone ID of the custom domain resides in. - `zoneName?: string` Zone that the custom domain resides in. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const customs = await client.r2.buckets.domains.custom.list('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(customs.domains); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domains": [ { "domain": "prefix.example-domain.one.com", "enabled": false, "status": { "ownership": "deactivated", "ssl": "pending" }, "ciphers": [ "string" ], "minTLS": "1.0", "zoneId": "36ca64a6d92827b8a6b90be344bb1bfd", "zoneName": "example-domain.one.com" }, { "domain": "prefix.example-domain.two.com", "enabled": true, "status": { "ownership": "active", "ssl": "active" }, "ciphers": [ "string" ], "minTLS": "1.0", "zoneId": "d9d28585d5f8f5b0f857b055bf574f19", "zoneName": "zoneName" } ] }, "success": true } ``` ## Get Custom Domain Settings `client.r2.buckets.domains.custom.get(stringbucketName, stringdomain, CustomGetParamsparams, RequestOptionsoptions?): CustomGetResponse` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}` Get the configuration for a custom domain on an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `domain: string` Name of the custom domain. - `params: CustomGetParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `CustomGetResponse` - `domain: string` Domain name of the custom domain to be added. - `enabled: boolean` Whether this bucket is publicly accessible at the specified custom domain. - `status: Status` - `ownership: "pending" | "active" | "deactivated" | 3 more` Ownership status of the domain. - `"pending"` - `"active"` - `"deactivated"` - `"blocked"` - `"error"` - `"unknown"` - `ssl: "initializing" | "pending" | "active" | 3 more` SSL certificate status. - `"initializing"` - `"pending"` - `"active"` - `"deactivated"` - `"error"` - `"unknown"` - `ciphers?: Array` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` - `zoneId?: string` Zone ID of the custom domain resides in. - `zoneName?: string` Zone that the custom domain resides in. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const custom = await client.r2.buckets.domains.custom.get( 'example-bucket', 'example-domain/custom-domain.com', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(custom.domain); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domain": "prefix.example-domain.one.com", "enabled": false, "status": { "ownership": "deactivated", "ssl": "pending" }, "ciphers": [ "string" ], "minTLS": "1.0", "zoneId": "36ca64a6d92827b8a6b90be344bb1bfd", "zoneName": "example-domain.one.com" }, "success": true } ``` ## Attach Custom Domain To Bucket `client.r2.buckets.domains.custom.create(stringbucketName, CustomCreateParamsparams, RequestOptionsoptions?): CustomCreateResponse` **post** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom` Register a new custom domain for an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: CustomCreateParams` - `account_id: string` Path param: Account ID. - `domain: string` Body param: Name of the custom domain to be added. - `enabled: boolean` Body param: Whether to enable public bucket access at the custom domain. If undefined, the domain will be enabled. - `zoneId: string` Body param: Zone ID of the custom domain. - `ciphers?: Array` Body param: An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Body param: Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `CustomCreateResponse` - `domain: string` Domain name of the affected custom domain. - `enabled: boolean` Whether this bucket is publicly accessible at the specified custom domain. - `ciphers?: Array` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const custom = await client.r2.buckets.domains.custom.create('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', domain: 'prefix.example-domain.com', enabled: true, zoneId: '36ca64a6d92827b8a6b90be344bb1bfd', }); console.log(custom.domain); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domain": "example-domain.com", "enabled": true, "ciphers": [ "string" ], "minTLS": "1.0" }, "success": true } ``` ## Configure Custom Domain Settings `client.r2.buckets.domains.custom.update(stringbucketName, stringdomain, CustomUpdateParamsparams, RequestOptionsoptions?): CustomUpdateResponse` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}` Edit the configuration for a custom domain on an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `domain: string` Name of the custom domain. - `params: CustomUpdateParams` - `account_id: string` Path param: Account ID. - `ciphers?: Array` Body param: An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `enabled?: boolean` Body param: Whether to enable public bucket access at the specified custom domain. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Body param: Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to previous value. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `CustomUpdateResponse` - `domain: string` Domain name of the affected custom domain. - `ciphers?: Array` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `enabled?: boolean` Whether this bucket is publicly accessible at the specified custom domain. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const custom = await client.r2.buckets.domains.custom.update( 'example-bucket', 'example-domain/custom-domain.com', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(custom.domain); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domain": "example-domain.com", "ciphers": [ "string" ], "enabled": true, "minTLS": "1.0" }, "success": true } ``` ## Remove Custom Domain From Bucket `client.r2.buckets.domains.custom.delete(stringbucketName, stringdomain, CustomDeleteParamsparams, RequestOptionsoptions?): CustomDeleteResponse` **delete** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}` Remove custom domain registration from an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `domain: string` Name of the custom domain. - `params: CustomDeleteParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `CustomDeleteResponse` - `domain: string` Name of the removed custom domain. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const custom = await client.r2.buckets.domains.custom.delete( 'example-bucket', 'example-domain/custom-domain.com', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(custom.domain); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domain": "example-domain/custom-domain.com" }, "success": true } ``` ## Domain Types ### Custom List Response - `CustomListResponse` - `domains: Array` - `domain: string` Domain name of the custom domain to be added. - `enabled: boolean` Whether this bucket is publicly accessible at the specified custom domain. - `status: Status` - `ownership: "pending" | "active" | "deactivated" | 3 more` Ownership status of the domain. - `"pending"` - `"active"` - `"deactivated"` - `"blocked"` - `"error"` - `"unknown"` - `ssl: "initializing" | "pending" | "active" | 3 more` SSL certificate status. - `"initializing"` - `"pending"` - `"active"` - `"deactivated"` - `"error"` - `"unknown"` - `ciphers?: Array` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` - `zoneId?: string` Zone ID of the custom domain resides in. - `zoneName?: string` Zone that the custom domain resides in. ### Custom Get Response - `CustomGetResponse` - `domain: string` Domain name of the custom domain to be added. - `enabled: boolean` Whether this bucket is publicly accessible at the specified custom domain. - `status: Status` - `ownership: "pending" | "active" | "deactivated" | 3 more` Ownership status of the domain. - `"pending"` - `"active"` - `"deactivated"` - `"blocked"` - `"error"` - `"unknown"` - `ssl: "initializing" | "pending" | "active" | 3 more` SSL certificate status. - `"initializing"` - `"pending"` - `"active"` - `"deactivated"` - `"error"` - `"unknown"` - `ciphers?: Array` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` - `zoneId?: string` Zone ID of the custom domain resides in. - `zoneName?: string` Zone that the custom domain resides in. ### Custom Create Response - `CustomCreateResponse` - `domain: string` Domain name of the affected custom domain. - `enabled: boolean` Whether this bucket is publicly accessible at the specified custom domain. - `ciphers?: Array` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` ### Custom Update Response - `CustomUpdateResponse` - `domain: string` Domain name of the affected custom domain. - `ciphers?: Array` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `enabled?: boolean` Whether this bucket is publicly accessible at the specified custom domain. - `minTLS?: "1.0" | "1.1" | "1.2" | "1.3"` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `"1.0"` - `"1.1"` - `"1.2"` - `"1.3"` ### Custom Delete Response - `CustomDeleteResponse` - `domain: string` Name of the removed custom domain. # Managed ## Get r2.dev Domain of Bucket `client.r2.buckets.domains.managed.list(stringbucketName, ManagedListParamsparams, RequestOptionsoptions?): ManagedListResponse` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed` Gets state of public access over the bucket's R2-managed (r2.dev) domain. ### Parameters - `bucketName: string` Name of the bucket. - `params: ManagedListParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `ManagedListResponse` - `bucketId: string` Bucket ID. - `domain: string` Domain name of the bucket's r2.dev domain. - `enabled: boolean` Whether this bucket is publicly accessible at the r2.dev domain. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const manageds = await client.r2.buckets.domains.managed.list('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(manageds.bucketId); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "bucketId": "0113a9e4549cf9b1ff1bf56e04da0cef", "domain": "pub-0113a9e4549cf9b1ff1bf56e04da0cef.r2.dev", "enabled": true }, "success": true } ``` ## Update r2.dev Domain of Bucket `client.r2.buckets.domains.managed.update(stringbucketName, ManagedUpdateParamsparams, RequestOptionsoptions?): ManagedUpdateResponse` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed` Updates state of public access over the bucket's R2-managed (r2.dev) domain. ### Parameters - `bucketName: string` Name of the bucket. - `params: ManagedUpdateParams` - `account_id: string` Path param: Account ID. - `enabled: boolean` Body param: Whether to enable public bucket access at the r2.dev domain. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `ManagedUpdateResponse` - `bucketId: string` Bucket ID. - `domain: string` Domain name of the bucket's r2.dev domain. - `enabled: boolean` Whether this bucket is publicly accessible at the r2.dev domain. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const managed = await client.r2.buckets.domains.managed.update('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', enabled: true, }); console.log(managed.bucketId); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "bucketId": "0113a9e4549cf9b1ff1bf56e04da0cef", "domain": "pub-0113a9e4549cf9b1ff1bf56e04da0cef.r2.dev", "enabled": true }, "success": true } ``` ## Domain Types ### Managed List Response - `ManagedListResponse` - `bucketId: string` Bucket ID. - `domain: string` Domain name of the bucket's r2.dev domain. - `enabled: boolean` Whether this bucket is publicly accessible at the r2.dev domain. ### Managed Update Response - `ManagedUpdateResponse` - `bucketId: string` Bucket ID. - `domain: string` Domain name of the bucket's r2.dev domain. - `enabled: boolean` Whether this bucket is publicly accessible at the r2.dev domain. # Event Notifications ## List Event Notification Rules `client.r2.buckets.eventNotifications.list(stringbucketName, EventNotificationListParamsparams, RequestOptionsoptions?): EventNotificationListResponse` **get** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration` List all event notification rules for a bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: EventNotificationListParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `EventNotificationListResponse` - `bucketName?: string` Name of the bucket. - `queues?: Array` List of queues associated with the bucket. - `queueId?: string` Queue ID. - `queueName?: string` Name of the queue. - `rules?: Array` - `actions: Array<"PutObject" | "CopyObject" | "DeleteObject" | 2 more>` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `createdAt?: string` Timestamp when the rule was created. - `description?: string` A description that can be used to identify the event notification rule after creation. - `prefix?: string` Notifications will be sent only for objects with this prefix. - `ruleId?: string` Rule ID. - `suffix?: string` Notifications will be sent only for objects with this suffix. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const eventNotifications = await client.r2.buckets.eventNotifications.list('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(eventNotifications.bucketName); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "bucketName": "bucketName", "queues": [ { "queueId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "queueName": "first-queue", "rules": [ { "actions": [ "PutObject", "CopyObject" ], "createdAt": "2024-09-19T21:54:48.405Z", "description": "Notifications from source bucket to queue", "prefix": "img/", "ruleId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "suffix": ".jpeg" } ] } ] }, "success": true } ``` ## Get Event Notification Rule `client.r2.buckets.eventNotifications.get(stringbucketName, stringqueueId, EventNotificationGetParamsparams, RequestOptionsoptions?): EventNotificationGetResponse` **get** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}` Get a single event notification rule. ### Parameters - `bucketName: string` Name of the bucket. - `queueId: string` Queue ID. - `params: EventNotificationGetParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: The bucket jurisdiction. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `EventNotificationGetResponse` - `queueId?: string` Queue ID. - `queueName?: string` Name of the queue. - `rules?: Array` - `actions: Array<"PutObject" | "CopyObject" | "DeleteObject" | 2 more>` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `createdAt?: string` Timestamp when the rule was created. - `description?: string` A description that can be used to identify the event notification rule after creation. - `prefix?: string` Notifications will be sent only for objects with this prefix. - `ruleId?: string` Rule ID. - `suffix?: string` Notifications will be sent only for objects with this suffix. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const eventNotification = await client.r2.buckets.eventNotifications.get( 'example-bucket', 'queue_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(eventNotification.queueId); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "queueId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "queueName": "first-queue", "rules": [ { "actions": [ "PutObject", "CopyObject" ], "createdAt": "2024-09-19T21:54:48.405Z", "description": "Notifications from source bucket to queue", "prefix": "img/", "ruleId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "suffix": ".jpeg" } ] }, "success": true } ``` ## Create Event Notification Rule `client.r2.buckets.eventNotifications.update(stringbucketName, stringqueueId, EventNotificationUpdateParamsparams, RequestOptionsoptions?): EventNotificationUpdateResponse` **put** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}` Create event notification rule. ### Parameters - `bucketName: string` Name of the bucket. - `queueId: string` Queue ID. - `params: EventNotificationUpdateParams` - `account_id: string` Path param: Account ID. - `rules: Array` Body param: Array of rules to drive notifications. - `actions: Array<"PutObject" | "CopyObject" | "DeleteObject" | 2 more>` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `description?: string` A description that can be used to identify the event notification rule after creation. - `prefix?: string` Notifications will be sent only for objects with this prefix. - `suffix?: string` Notifications will be sent only for objects with this suffix. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `EventNotificationUpdateResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const eventNotification = await client.r2.buckets.eventNotifications.update( 'example-bucket', 'queue_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', rules: [{ actions: ['PutObject', 'CopyObject'] }], }, ); console.log(eventNotification); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Delete Event Notification Rules `client.r2.buckets.eventNotifications.delete(stringbucketName, stringqueueId, EventNotificationDeleteParamsparams, RequestOptionsoptions?): EventNotificationDeleteResponse` **delete** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}` Delete an event notification rule. **If no body is provided, all rules for specified queue will be deleted**. ### Parameters - `bucketName: string` Name of the bucket. - `queueId: string` Queue ID. - `params: EventNotificationDeleteParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `EventNotificationDeleteResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const eventNotification = await client.r2.buckets.eventNotifications.delete( 'example-bucket', 'queue_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(eventNotification); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Domain Types ### Event Notification List Response - `EventNotificationListResponse` - `bucketName?: string` Name of the bucket. - `queues?: Array` List of queues associated with the bucket. - `queueId?: string` Queue ID. - `queueName?: string` Name of the queue. - `rules?: Array` - `actions: Array<"PutObject" | "CopyObject" | "DeleteObject" | 2 more>` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `createdAt?: string` Timestamp when the rule was created. - `description?: string` A description that can be used to identify the event notification rule after creation. - `prefix?: string` Notifications will be sent only for objects with this prefix. - `ruleId?: string` Rule ID. - `suffix?: string` Notifications will be sent only for objects with this suffix. ### Event Notification Get Response - `EventNotificationGetResponse` - `queueId?: string` Queue ID. - `queueName?: string` Name of the queue. - `rules?: Array` - `actions: Array<"PutObject" | "CopyObject" | "DeleteObject" | 2 more>` Array of R2 object actions that will trigger notifications. - `"PutObject"` - `"CopyObject"` - `"DeleteObject"` - `"CompleteMultipartUpload"` - `"LifecycleDeletion"` - `createdAt?: string` Timestamp when the rule was created. - `description?: string` A description that can be used to identify the event notification rule after creation. - `prefix?: string` Notifications will be sent only for objects with this prefix. - `ruleId?: string` Rule ID. - `suffix?: string` Notifications will be sent only for objects with this suffix. ### Event Notification Update Response - `EventNotificationUpdateResponse = unknown` ### Event Notification Delete Response - `EventNotificationDeleteResponse = unknown` # Locks ## Get Bucket Lock Rules `client.r2.buckets.locks.get(stringbucketName, LockGetParamsparams, RequestOptionsoptions?): LockGetResponse` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/lock` Get lock rules for a bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: LockGetParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `LockGetResponse` - `rules?: Array` - `id: string` Unique identifier for this rule. - `condition: R2LockRuleAgeCondition | R2LockRuleDateCondition | R2LockRuleIndefiniteCondition` Condition to apply a lock rule to an object for how long in seconds. - `R2LockRuleAgeCondition` Condition to apply a lock rule to an object for how long in seconds. - `maxAgeSeconds: number` - `type: "Age"` - `"Age"` - `R2LockRuleDateCondition` Condition to apply a lock rule to an object until a specific date. - `date: string` - `type: "Date"` - `"Date"` - `R2LockRuleIndefiniteCondition` Condition to apply a lock rule indefinitely. - `type: "Indefinite"` - `"Indefinite"` - `enabled: boolean` Whether or not this rule is in effect. - `prefix?: string` Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const lock = await client.r2.buckets.locks.get('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(lock.rules); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "rules": [ { "id": "Lock all objects for 24 hours", "condition": { "maxAgeSeconds": 100, "type": "Age" }, "enabled": true, "prefix": "prefix" } ] }, "success": true } ``` ## Put Bucket Lock Rules `client.r2.buckets.locks.update(stringbucketName, LockUpdateParamsparams, RequestOptionsoptions?): LockUpdateResponse` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/lock` Set lock rules for a bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: LockUpdateParams` - `account_id: string` Path param: Account ID. - `rules?: Array` Body param - `id: string` Unique identifier for this rule. - `condition: R2LockRuleAgeCondition | R2LockRuleDateCondition | R2LockRuleIndefiniteCondition` Condition to apply a lock rule to an object for how long in seconds. - `R2LockRuleAgeCondition` Condition to apply a lock rule to an object for how long in seconds. - `maxAgeSeconds: number` - `type: "Age"` - `"Age"` - `R2LockRuleDateCondition` Condition to apply a lock rule to an object until a specific date. - `date: string` - `type: "Date"` - `"Date"` - `R2LockRuleIndefiniteCondition` Condition to apply a lock rule indefinitely. - `type: "Indefinite"` - `"Indefinite"` - `enabled: boolean` Whether or not this rule is in effect. - `prefix?: string` Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `LockUpdateResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const lock = await client.r2.buckets.locks.update('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(lock); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Domain Types ### Lock Get Response - `LockGetResponse` - `rules?: Array` - `id: string` Unique identifier for this rule. - `condition: R2LockRuleAgeCondition | R2LockRuleDateCondition | R2LockRuleIndefiniteCondition` Condition to apply a lock rule to an object for how long in seconds. - `R2LockRuleAgeCondition` Condition to apply a lock rule to an object for how long in seconds. - `maxAgeSeconds: number` - `type: "Age"` - `"Age"` - `R2LockRuleDateCondition` Condition to apply a lock rule to an object until a specific date. - `date: string` - `type: "Date"` - `"Date"` - `R2LockRuleIndefiniteCondition` Condition to apply a lock rule indefinitely. - `type: "Indefinite"` - `"Indefinite"` - `enabled: boolean` Whether or not this rule is in effect. - `prefix?: string` Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads. ### Lock Update Response - `LockUpdateResponse = unknown` # Metrics ## Get Account-Level Metrics `client.r2.buckets.metrics.list(MetricListParamsparams, RequestOptionsoptions?): MetricListResponse` **get** `/accounts/{account_id}/r2/metrics` Get Storage/Object Count Metrics across all buckets in your account. Note that Account-Level Metrics may not immediately reflect the latest data. ### Parameters - `params: MetricListParams` - `account_id: string` Account ID. ### Returns - `MetricListResponse` Metrics based on the class they belong to. - `infrequentAccess?: InfrequentAccess` Metrics based on what state they are in(uploaded or published). - `published?: Published` Metrics on number of objects/amount of storage used. - `metadataSize?: number` Amount of. - `objects?: number` Number of objects stored. - `payloadSize?: number` Amount of storage used by object data. - `uploaded?: Uploaded` Metrics on number of objects/amount of storage used. - `metadataSize?: number` Amount of. - `objects?: number` Number of objects stored. - `payloadSize?: number` Amount of storage used by object data. - `standard?: Standard` Metrics based on what state they are in(uploaded or published). - `published?: Published` Metrics on number of objects/amount of storage used. - `metadataSize?: number` Amount of. - `objects?: number` Number of objects stored. - `payloadSize?: number` Amount of storage used by object data. - `uploaded?: Uploaded` Metrics on number of objects/amount of storage used. - `metadataSize?: number` Amount of. - `objects?: number` Number of objects stored. - `payloadSize?: number` Amount of storage used by object data. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const metrics = await client.r2.buckets.metrics.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(metrics.infrequentAccess); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "infrequentAccess": { "published": { "metadataSize": 0, "objects": 0, "payloadSize": 0 }, "uploaded": { "metadataSize": 0, "objects": 0, "payloadSize": 0 } }, "standard": { "published": { "metadataSize": 0, "objects": 0, "payloadSize": 0 }, "uploaded": { "metadataSize": 0, "objects": 0, "payloadSize": 0 } } }, "success": true } ``` ## Domain Types ### Metric List Response - `MetricListResponse` Metrics based on the class they belong to. - `infrequentAccess?: InfrequentAccess` Metrics based on what state they are in(uploaded or published). - `published?: Published` Metrics on number of objects/amount of storage used. - `metadataSize?: number` Amount of. - `objects?: number` Number of objects stored. - `payloadSize?: number` Amount of storage used by object data. - `uploaded?: Uploaded` Metrics on number of objects/amount of storage used. - `metadataSize?: number` Amount of. - `objects?: number` Number of objects stored. - `payloadSize?: number` Amount of storage used by object data. - `standard?: Standard` Metrics based on what state they are in(uploaded or published). - `published?: Published` Metrics on number of objects/amount of storage used. - `metadataSize?: number` Amount of. - `objects?: number` Number of objects stored. - `payloadSize?: number` Amount of storage used by object data. - `uploaded?: Uploaded` Metrics on number of objects/amount of storage used. - `metadataSize?: number` Amount of. - `objects?: number` Number of objects stored. - `payloadSize?: number` Amount of storage used by object data. # Sippy ## Get Sippy Configuration `client.r2.buckets.sippy.get(stringbucketName, SippyGetParamsparams, RequestOptionsoptions?): Sippy` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/sippy` Gets configuration for Sippy for an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: SippyGetParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `Sippy` - `destination?: Destination` Details about the configured destination bucket. - `accessKeyId?: string` ID of the Cloudflare API token used when writing objects to this bucket. - `account?: string` - `bucket?: string` Name of the bucket on the provider. - `provider?: Provider` - `"r2"` - `enabled?: boolean` State of Sippy for this bucket. - `source?: Source` Details about the configured source bucket. - `bucket?: string | null` Name of the bucket on the provider (AWS, GCS only). - `bucketUrl?: string | null` S3-compatible URL (Generic S3-compatible providers only). - `provider?: "aws" | "gcs" | "s3"` - `"aws"` - `"gcs"` - `"s3"` - `region?: string | null` Region where the bucket resides (AWS only). ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const sippy = await client.r2.buckets.sippy.get('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(sippy.destination); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "destination": { "accessKeyId": "accessKeyId", "account": "account", "bucket": "bucket", "provider": "r2" }, "enabled": true, "source": { "bucket": "bucket", "bucketUrl": "bucketUrl", "provider": "aws", "region": "region" } }, "success": true } ``` ## Enable Sippy `client.r2.buckets.sippy.update(stringbucketName, SippyUpdateParamsparams, RequestOptionsoptions?): Sippy` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/sippy` Sets configuration for Sippy for an existing R2 bucket. ### Parameters - `bucketName: string` Name of the bucket. - `SippyUpdateParams = R2EnableSippyAws | R2EnableSippyGcs | R2EnableSippyS3` - `SippyUpdateParamsBase` - `R2EnableSippyAws extends SippyUpdateParamsBase` - `R2EnableSippyGcs extends SippyUpdateParamsBase` - `R2EnableSippyS3 extends SippyUpdateParamsBase` ### Returns - `Sippy` - `destination?: Destination` Details about the configured destination bucket. - `accessKeyId?: string` ID of the Cloudflare API token used when writing objects to this bucket. - `account?: string` - `bucket?: string` Name of the bucket on the provider. - `provider?: Provider` - `"r2"` - `enabled?: boolean` State of Sippy for this bucket. - `source?: Source` Details about the configured source bucket. - `bucket?: string | null` Name of the bucket on the provider (AWS, GCS only). - `bucketUrl?: string | null` S3-compatible URL (Generic S3-compatible providers only). - `provider?: "aws" | "gcs" | "s3"` - `"aws"` - `"gcs"` - `"s3"` - `region?: string | null` Region where the bucket resides (AWS only). ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const sippy = await client.r2.buckets.sippy.update('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(sippy.destination); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "destination": { "accessKeyId": "accessKeyId", "account": "account", "bucket": "bucket", "provider": "r2" }, "enabled": true, "source": { "bucket": "bucket", "bucketUrl": "bucketUrl", "provider": "aws", "region": "region" } }, "success": true } ``` ## Disable Sippy `client.r2.buckets.sippy.delete(stringbucketName, SippyDeleteParamsparams, RequestOptionsoptions?): SippyDeleteResponse` **delete** `/accounts/{account_id}/r2/buckets/{bucket_name}/sippy` Disables Sippy on this bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: SippyDeleteParams` - `account_id: string` Path param: Account ID. - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `SippyDeleteResponse` - `enabled?: false` - `false` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const sippy = await client.r2.buckets.sippy.delete('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(sippy.enabled); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "enabled": false }, "success": true } ``` ## Domain Types ### Provider - `Provider = "r2"` - `"r2"` ### Sippy - `Sippy` - `destination?: Destination` Details about the configured destination bucket. - `accessKeyId?: string` ID of the Cloudflare API token used when writing objects to this bucket. - `account?: string` - `bucket?: string` Name of the bucket on the provider. - `provider?: Provider` - `"r2"` - `enabled?: boolean` State of Sippy for this bucket. - `source?: Source` Details about the configured source bucket. - `bucket?: string | null` Name of the bucket on the provider (AWS, GCS only). - `bucketUrl?: string | null` S3-compatible URL (Generic S3-compatible providers only). - `provider?: "aws" | "gcs" | "s3"` - `"aws"` - `"gcs"` - `"s3"` - `region?: string | null` Region where the bucket resides (AWS only). ### Sippy Delete Response - `SippyDeleteResponse` - `enabled?: false` - `false` # Temporary Credentials ## Create Temporary Access Credentials `client.r2.temporaryCredentials.create(TemporaryCredentialCreateParamsparams, RequestOptionsoptions?): TemporaryCredentialCreateResponse` **post** `/accounts/{account_id}/r2/temp-access-credentials` Creates temporary access credentials on a bucket that can be optionally scoped to prefixes or objects. ### Parameters - `params: TemporaryCredentialCreateParams` - `account_id: string` Path param: Account ID. - `bucket: string` Body param: Name of the R2 bucket. - `parentAccessKeyId: string` Body param: The parent access key id to use for signing. - `permission: "admin-read-write" | "admin-read-only" | "object-read-write" | "object-read-only"` Body param: Permissions allowed on the credentials. - `"admin-read-write"` - `"admin-read-only"` - `"object-read-write"` - `"object-read-only"` - `ttlSeconds: number` Body param: How long the credentials will live for in seconds. - `objects?: Array` Body param: Optional object paths to scope the credentials to. - `prefixes?: Array` Body param: Optional prefix paths to scope the credentials to. ### Returns - `TemporaryCredentialCreateResponse` - `accessKeyId?: string` ID for new access key. - `secretAccessKey?: string` Secret access key. - `sessionToken?: string` Security token. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const temporaryCredential = await client.r2.temporaryCredentials.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', bucket: 'example-bucket', parentAccessKeyId: 'example-access-key-id', permission: 'object-read-write', ttlSeconds: 3600, }); console.log(temporaryCredential.accessKeyId); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "accessKeyId": "example-access-key-id", "secretAccessKey": "example-secret-key", "sessionToken": "example-session-token" }, "success": true } ``` ## Domain Types ### Temporary Credential - `TemporaryCredential` - `bucket: string` Name of the R2 bucket. - `parentAccessKeyId: string` The parent access key id to use for signing. - `permission: "admin-read-write" | "admin-read-only" | "object-read-write" | "object-read-only"` Permissions allowed on the credentials. - `"admin-read-write"` - `"admin-read-only"` - `"object-read-write"` - `"object-read-only"` - `ttlSeconds: number` How long the credentials will live for in seconds. - `objects?: Array` Optional object paths to scope the credentials to. - `prefixes?: Array` Optional prefix paths to scope the credentials to. ### Temporary Credential Create Response - `TemporaryCredentialCreateResponse` - `accessKeyId?: string` ID for new access key. - `secretAccessKey?: string` Secret access key. - `sessionToken?: string` Security token. # Super Slurper # Jobs ## List jobs `client.r2.superSlurper.jobs.list(JobListParamsparams, RequestOptionsoptions?): SinglePage` **get** `/accounts/{account_id}/slurper/jobs` Lists all R2 Super Slurper migration jobs for the account with their status. ### Parameters - `params: JobListParams` - `account_id: string` Path param - `limit?: number` Query param - `offset?: number` Query param ### Returns - `JobListResponse` - `id?: string` - `createdAt?: string` - `finishedAt?: string | null` - `overwrite?: boolean` - `source?: S3SourceResponseSchema | GcsSourceResponseSchema | R2SourceResponseSchema` - `S3SourceResponseSchema` - `bucket?: string` - `endpoint?: string | null` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: "s3"` - `"s3"` - `GcsSourceResponseSchema` - `bucket?: string` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: "gcs"` - `"gcs"` - `R2SourceResponseSchema` - `bucket?: string` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: Provider` - `"r2"` - `status?: "running" | "paused" | "aborted" | "completed"` - `"running"` - `"paused"` - `"aborted"` - `"completed"` - `target?: Target` - `bucket?: string` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` - `vendor?: Provider` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const jobListResponse of client.r2.superSlurper.jobs.list({ account_id: 'account_id', })) { console.log(jobListResponse.id); } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": [ { "id": "id", "createdAt": "createdAt", "finishedAt": "finishedAt", "overwrite": true, "source": { "bucket": "bucket", "endpoint": "endpoint", "keys": [ "string" ], "pathPrefix": "pathPrefix", "vendor": "s3" }, "status": "running", "target": { "bucket": "bucket", "jurisdiction": "default", "vendor": "r2" } } ], "success": true } ``` ## Get job details `client.r2.superSlurper.jobs.get(stringjobId, JobGetParamsparams, RequestOptionsoptions?): JobGetResponse` **get** `/accounts/{account_id}/slurper/jobs/{job_id}` Retrieves detailed status and configuration for a specific R2 Super Slurper migration job. ### Parameters - `jobId: string` - `params: JobGetParams` - `account_id: string` ### Returns - `JobGetResponse` - `id?: string` - `createdAt?: string` - `finishedAt?: string | null` - `overwrite?: boolean` - `source?: S3SourceResponseSchema | GcsSourceResponseSchema | R2SourceResponseSchema` - `S3SourceResponseSchema` - `bucket?: string` - `endpoint?: string | null` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: "s3"` - `"s3"` - `GcsSourceResponseSchema` - `bucket?: string` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: "gcs"` - `"gcs"` - `R2SourceResponseSchema` - `bucket?: string` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: Provider` - `"r2"` - `status?: "running" | "paused" | "aborted" | "completed"` - `"running"` - `"paused"` - `"aborted"` - `"completed"` - `target?: Target` - `bucket?: string` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` - `vendor?: Provider` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const job = await client.r2.superSlurper.jobs.get('job_id', { account_id: 'account_id' }); console.log(job.id); ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "id": "id", "createdAt": "createdAt", "finishedAt": "finishedAt", "overwrite": true, "source": { "bucket": "bucket", "endpoint": "endpoint", "keys": [ "string" ], "pathPrefix": "pathPrefix", "vendor": "s3" }, "status": "running", "target": { "bucket": "bucket", "jurisdiction": "default", "vendor": "r2" } }, "success": true } ``` ## Create a job `client.r2.superSlurper.jobs.create(JobCreateParamsparams, RequestOptionsoptions?): JobCreateResponse` **post** `/accounts/{account_id}/slurper/jobs` Creates a new R2 Super Slurper migration job to transfer objects from a source bucket (e.g. S3, GCS, R2) to R2. ### Parameters - `params: JobCreateParams` - `account_id: string` Path param - `overwrite?: boolean` Body param - `source?: R2SlurperS3SourceSchema | R2SlurperGcsSourceSchema | R2SlurperR2SourceSchema` Body param - `R2SlurperS3SourceSchema` - `bucket: string` - `secret: Secret` - `accessKeyId: string` - `secretAccessKey: string` - `vendor: "s3"` - `"s3"` - `endpoint?: string | null` - `keys?: Array | null` - `pathPrefix?: string | null` - `region?: string | null` - `R2SlurperGcsSourceSchema` - `bucket: string` - `secret: Secret` - `clientEmail: string` - `privateKey: string` - `vendor: "gcs"` - `"gcs"` - `keys?: Array | null` - `pathPrefix?: string | null` - `R2SlurperR2SourceSchema` - `bucket: string` - `secret: Secret` - `accessKeyId: string` - `secretAccessKey: string` - `vendor: Provider` - `"r2"` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` - `keys?: Array | null` - `pathPrefix?: string | null` - `target?: Target` Body param - `bucket: string` - `secret: Secret` - `accessKeyId: string` - `secretAccessKey: string` - `vendor: Provider` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` ### Returns - `JobCreateResponse` - `id?: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const job = await client.r2.superSlurper.jobs.create({ account_id: 'account_id' }); console.log(job.id); ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "id": "id" }, "success": true } ``` ## Abort all jobs `client.r2.superSlurper.jobs.abortAll(JobAbortAllParamsparams, RequestOptionsoptions?): JobAbortAllResponse` **put** `/accounts/{account_id}/slurper/jobs/abortAll` Cancels all running R2 Super Slurper migration jobs for the account. Any objects in the middle of a transfer will finish, but no new objects will start transferring. ### Parameters - `params: JobAbortAllParams` - `account_id: string` ### Returns - `JobAbortAllResponse = string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.r2.superSlurper.jobs.abortAll({ account_id: 'account_id' }); console.log(response); ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": "result", "success": true } ``` ## Abort a job `client.r2.superSlurper.jobs.abort(stringjobId, JobAbortParamsparams, RequestOptionsoptions?): JobAbortResponse` **put** `/accounts/{account_id}/slurper/jobs/{job_id}/abort` Cancels a specific R2 Super Slurper migration job. Any objects in the middle of a transfer will finish, but no new objects will start transferring. ### Parameters - `jobId: string` - `params: JobAbortParams` - `account_id: string` ### Returns - `JobAbortResponse = string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.r2.superSlurper.jobs.abort('job_id', { account_id: 'account_id' }); console.log(response); ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": "result", "success": true } ``` ## Pause a job `client.r2.superSlurper.jobs.pause(stringjobId, JobPauseParamsparams, RequestOptionsoptions?): JobPauseResponse` **put** `/accounts/{account_id}/slurper/jobs/{job_id}/pause` Pauses a running R2 Super Slurper migration job. The job can be resumed later to continue transferring. ### Parameters - `jobId: string` - `params: JobPauseParams` - `account_id: string` ### Returns - `JobPauseResponse = string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.r2.superSlurper.jobs.pause('job_id', { account_id: 'account_id' }); console.log(response); ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": "result", "success": true } ``` ## Get job progress `client.r2.superSlurper.jobs.progress(stringjobId, JobProgressParamsparams, RequestOptionsoptions?): JobProgressResponse` **get** `/accounts/{account_id}/slurper/jobs/{job_id}/progress` Retrieves current progress metrics for an R2 Super Slurper migration job ### Parameters - `jobId: string` - `params: JobProgressParams` - `account_id: string` ### Returns - `JobProgressResponse` - `id?: string` - `createdAt?: string` - `failedObjects?: number` - `objects?: number` - `skippedObjects?: number` - `status?: "running" | "paused" | "aborted" | "completed"` - `"running"` - `"paused"` - `"aborted"` - `"completed"` - `transferredObjects?: number` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.r2.superSlurper.jobs.progress('job_id', { account_id: 'account_id' }); console.log(response.id); ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "id": "id", "createdAt": "createdAt", "failedObjects": 0, "objects": 0, "skippedObjects": 0, "status": "running", "transferredObjects": 0 }, "success": true } ``` ## Resume a job `client.r2.superSlurper.jobs.resume(stringjobId, JobResumeParamsparams, RequestOptionsoptions?): JobResumeResponse` **put** `/accounts/{account_id}/slurper/jobs/{job_id}/resume` Resumes a paused R2 Super Slurper migration job, continuing the transfer from where it stopped. ### Parameters - `jobId: string` - `params: JobResumeParams` - `account_id: string` ### Returns - `JobResumeResponse = string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.r2.superSlurper.jobs.resume('job_id', { account_id: 'account_id' }); console.log(response); ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": "result", "success": true } ``` ## Domain Types ### Job List Response - `JobListResponse` - `id?: string` - `createdAt?: string` - `finishedAt?: string | null` - `overwrite?: boolean` - `source?: S3SourceResponseSchema | GcsSourceResponseSchema | R2SourceResponseSchema` - `S3SourceResponseSchema` - `bucket?: string` - `endpoint?: string | null` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: "s3"` - `"s3"` - `GcsSourceResponseSchema` - `bucket?: string` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: "gcs"` - `"gcs"` - `R2SourceResponseSchema` - `bucket?: string` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: Provider` - `"r2"` - `status?: "running" | "paused" | "aborted" | "completed"` - `"running"` - `"paused"` - `"aborted"` - `"completed"` - `target?: Target` - `bucket?: string` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` - `vendor?: Provider` ### Job Get Response - `JobGetResponse` - `id?: string` - `createdAt?: string` - `finishedAt?: string | null` - `overwrite?: boolean` - `source?: S3SourceResponseSchema | GcsSourceResponseSchema | R2SourceResponseSchema` - `S3SourceResponseSchema` - `bucket?: string` - `endpoint?: string | null` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: "s3"` - `"s3"` - `GcsSourceResponseSchema` - `bucket?: string` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: "gcs"` - `"gcs"` - `R2SourceResponseSchema` - `bucket?: string` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` - `keys?: Array | null` - `pathPrefix?: string | null` - `vendor?: Provider` - `"r2"` - `status?: "running" | "paused" | "aborted" | "completed"` - `"running"` - `"paused"` - `"aborted"` - `"completed"` - `target?: Target` - `bucket?: string` - `jurisdiction?: "default" | "eu" | "fedramp"` - `"default"` - `"eu"` - `"fedramp"` - `vendor?: Provider` ### Job Create Response - `JobCreateResponse` - `id?: string` ### Job Abort All Response - `JobAbortAllResponse = string` ### Job Abort Response - `JobAbortResponse = string` ### Job Pause Response - `JobPauseResponse = string` ### Job Progress Response - `JobProgressResponse` - `id?: string` - `createdAt?: string` - `failedObjects?: number` - `objects?: number` - `skippedObjects?: number` - `status?: "running" | "paused" | "aborted" | "completed"` - `"running"` - `"paused"` - `"aborted"` - `"completed"` - `transferredObjects?: number` ### Job Resume Response - `JobResumeResponse = string` # Logs ## Get job logs `client.r2.superSlurper.jobs.logs.list(stringjobId, LogListParamsparams, RequestOptionsoptions?): SinglePage` **get** `/accounts/{account_id}/slurper/jobs/{job_id}/logs` Gets log entries for an R2 Super Slurper migration job, showing migration status changes, errors, etc. ### Parameters - `jobId: string` - `params: LogListParams` - `account_id: string` Path param - `limit?: number` Query param - `offset?: number` Query param ### Returns - `LogListResponse` - `createdAt?: string` - `job?: string` - `logType?: "migrationStart" | "migrationComplete" | "migrationAbort" | 12 more` - `"migrationStart"` - `"migrationComplete"` - `"migrationAbort"` - `"migrationError"` - `"migrationPause"` - `"migrationResume"` - `"migrationErrorFailedContinuation"` - `"importErrorRetryExhaustion"` - `"importSkippedStorageClass"` - `"importSkippedOversized"` - `"importSkippedEmptyObject"` - `"importSkippedUnsupportedContentType"` - `"importSkippedExcludedContentType"` - `"importSkippedInvalidMedia"` - `"importSkippedRequiresRetrieval"` - `message?: string | null` - `objectKey?: string | null` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const logListResponse of client.r2.superSlurper.jobs.logs.list('job_id', { account_id: 'account_id', })) { console.log(logListResponse.createdAt); } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": [ { "createdAt": "createdAt", "job": "job", "logType": "migrationStart", "message": "message", "objectKey": "objectKey" } ], "success": true } ``` ## Domain Types ### Log List Response - `LogListResponse` - `createdAt?: string` - `job?: string` - `logType?: "migrationStart" | "migrationComplete" | "migrationAbort" | 12 more` - `"migrationStart"` - `"migrationComplete"` - `"migrationAbort"` - `"migrationError"` - `"migrationPause"` - `"migrationResume"` - `"migrationErrorFailedContinuation"` - `"importErrorRetryExhaustion"` - `"importSkippedStorageClass"` - `"importSkippedOversized"` - `"importSkippedEmptyObject"` - `"importSkippedUnsupportedContentType"` - `"importSkippedExcludedContentType"` - `"importSkippedInvalidMedia"` - `"importSkippedRequiresRetrieval"` - `message?: string | null` - `objectKey?: string | null` # Connectivity Precheck ## Check source connectivity `client.r2.superSlurper.connectivityPrecheck.source(ConnectivityPrecheckSourceParamsparams, RequestOptionsoptions?): ConnectivityPrecheckSourceResponse` **put** `/accounts/{account_id}/slurper/source/connectivity-precheck` Check whether tokens are valid against the source bucket ### Parameters - `ConnectivityPrecheckSourceParams = R2SlurperS3SourceSchema | R2SlurperGcsSourceSchema | R2SlurperR2SourceSchema` - `ConnectivityPrecheckSourceParamsBase` - `R2SlurperS3SourceSchema extends ConnectivityPrecheckSourceParamsBase` - `R2SlurperGcsSourceSchema extends ConnectivityPrecheckSourceParamsBase` - `R2SlurperR2SourceSchema extends ConnectivityPrecheckSourceParamsBase` ### Returns - `ConnectivityPrecheckSourceResponse` - `connectivityStatus?: "success" | "error"` - `"success"` - `"error"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.r2.superSlurper.connectivityPrecheck.source({ account_id: 'account_id', bucket: 'bucket', secret: { accessKeyId: 'accessKeyId', secretAccessKey: 'secretAccessKey' }, vendor: 's3', }); console.log(response.connectivityStatus); ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "connectivityStatus": "success" }, "success": true } ``` ## Check target connectivity `client.r2.superSlurper.connectivityPrecheck.target(ConnectivityPrecheckTargetParamsparams, RequestOptionsoptions?): ConnectivityPrecheckTargetResponse` **put** `/accounts/{account_id}/slurper/target/connectivity-precheck` Check whether tokens are valid against the target bucket ### Parameters - `params: ConnectivityPrecheckTargetParams` - `account_id: string` Path param - `bucket: string` Body param - `secret: Secret` Body param - `accessKeyId: string` - `secretAccessKey: string` - `vendor: Provider` Body param - `"r2"` - `jurisdiction?: "default" | "eu" | "fedramp"` Body param - `"default"` - `"eu"` - `"fedramp"` ### Returns - `ConnectivityPrecheckTargetResponse` - `connectivityStatus?: "success" | "error"` - `"success"` - `"error"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.r2.superSlurper.connectivityPrecheck.target({ account_id: 'account_id', bucket: 'bucket', secret: { accessKeyId: 'accessKeyId', secretAccessKey: 'secretAccessKey' }, vendor: 'r2', }); console.log(response.connectivityStatus); ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "connectivityStatus": "success" }, "success": true } ``` ## Domain Types ### Connectivity Precheck Source Response - `ConnectivityPrecheckSourceResponse` - `connectivityStatus?: "success" | "error"` - `"success"` - `"error"` ### Connectivity Precheck Target Response - `ConnectivityPrecheckTargetResponse` - `connectivityStatus?: "success" | "error"` - `"success"` - `"error"`