APIYard
Back to APIs
StorageBearer TokenFree tier

Cloudflare R2

Cloudflare R2 is S3-compatible object storage with zero egress costs — store and serve files globally without bandwidth charges.

Base URL

https://{accountId}.r2.cloudflarestorage.com
S3-compatibleegress-freeCDNobject storageglobal

Endpoints

PUT/{bucket}/{key}

Upload an object to an R2 bucket.

const response = await fetch("https://account-id.r2.cloudflarestorage.com/my-bucket/hello.txt", {
  method: "PUT",
  headers: {
  "Content-Type": "application/json",
  "Authorization": "Bearer YOUR_ACCESS_TOKEN"
  },
  body: JSON.stringify({
  "data": "Hello, R2!"
})
});

const data = await response.json();
console.log(data);

Response Preview

// HTTP 200 OK on success
// ETag: "d3b07384..."
// Content-Length: 0