Skip to content

Upload to Cloudflare R2

Cloudflare R2 is S3-compatible, so ScreenshotOne uploads screenshots, rendered HTML, PDFs, and videos to it the same way it does to Amazon S3. You need four values:

ScreenshotOne fieldWhere to find it in Cloudflare
Endpoint URLhttps://<ACCOUNT_ID>.r2.cloudflarestorage.com
Access key IDShown once after you create an R2 API token, as “Access Key ID”
Secret keyShown once after you create an R2 API token, as “Secret Access Key”
Default bucketThe name of your R2 bucket

Cloudflare’s dashboard changes from time to time, so the names of menus might be a bit different from what you see, but the steps stay the same.

If you don’t have a bucket yet, open R2 object storage in the Cloudflare dashboard and create one. Remember its name. You will need it as the default bucket.

R2 uses its own API tokens. A regular Cloudflare API token from your profile doesn’t work for uploads.

  1. In the Cloudflare dashboard, go to R2 object storage, then Overview.
  2. Under Account Details, select Manage next to API Tokens.
  3. Choose Create Account API token (or Create User API token if you prefer a token tied to your user).
  4. Under Permissions, choose Object Read & Write.
  5. Optionally, limit the token to the bucket you use for screenshots. We recommend it.
  6. Create the token.

The next screen shows several values. Copy these two:

  • Access Key ID. It goes to the “Access key ID” field in ScreenshotOne.
  • Secret Access Key. It goes to the “Secret key” field in ScreenshotOne.

ScreenshotOne needs Object Read & Write, not only write: testing the configuration uploads a small test file and then deletes it.

The endpoint is https://<ACCOUNT_ID>.r2.cloudflarestorage.com, where <ACCOUNT_ID> is your Cloudflare account ID. You can find the account ID in Account Details on the R2 overview page.

You can also copy the endpoint from your bucket’s settings, where Cloudflare shows it as the “S3 API” URL. That URL ends with the bucket name, like https://<ACCOUNT_ID>.r2.cloudflarestorage.com/my-bucket. Remove /my-bucket from the end and put the bucket name in the “Default bucket” field instead.

If you created the bucket with a jurisdiction, use the jurisdiction’s endpoint:

  • European Union: https://<ACCOUNT_ID>.eu.r2.cloudflarestorage.com
  • FedRAMP: https://<ACCOUNT_ID>.fedramp.r2.cloudflarestorage.com

You don’t need to specify a region.

Open the S3 integration page in the dashboard and fill in the form:

  • Endpoint URL: https://<ACCOUNT_ID>.r2.cloudflarestorage.com.
  • Access key ID: the Access Key ID from the token.
  • Secret key: the Secret Access Key from the token.
  • Default bucket: your bucket name.

Click Test configuration. If the test passes, click Save configuration.

You can also skip the dashboard and pass the credentials in every API request with storage_endpoint, storage_access_key_id, storage_secret_access_key, and storage_bucket.

Add store=true and storage_path to your request. The file extension is added automatically based on the format:

https://api.screenshotone.com/take?access_key=<access key>&url=https://example.com&store=true&storage_path=screenshots/example

The screenshot is uploaded to screenshots/example.jpg in your default bucket. Add response_type=empty if you don’t need the screenshot in the response.

All storage options, including asynchronous uploads with webhooks, work the same as for Amazon S3. Read the S3 guide for more examples.

  • ACLs: R2 doesn’t support object ACLs, so don’t set storage_acl. Files in an R2 bucket are private by default. To serve them publicly, enable public access for the bucket in its Cloudflare settings, with a custom domain or the r2.dev URL.
  • Storage class: R2 supports only standard (the default) and standard_ia for storage_class.
  • File location: storage_return_location returns the location on the R2 S3 API endpoint, which isn’t publicly accessible. If you serve files from a public domain, build the public URL from your domain and the storage path.
  • “Access was denied”: check that you used the Access Key ID and the Secret Access Key, not the token value, and that the token has Object Read & Write permission for this bucket.
  • “Failed to resolve the endpoint hostname”: check the account ID in the endpoint. If you just created the bucket, wait a few minutes and try again.

If something still doesn’t work, write to us at support@screenshotone.com with the error message you see.