Postman
Learn how to configure Postman to interact with R2.
Postman is an API platform that makes interacting with APIs easier. This guide will explain how to use Postman to make authenticated R2 requests to create a bucket, upload a new object, and then retrieve the object. The R2 Postman collection ↗ includes a complete list of operations supported by the platform.
This guide assumes that you have made a Cloudflare account and purchased R2.
Explore R2’s publicly available Postman collection ↗. The collection is organized into a Buckets
folder for bucket-level operations and an Objects
folder for object-level operations. Operations in the Objects > Upload
folder allow for adding new objects to R2.
In the Postman dashboard ↗, select the Cloudflare R2 collection and navigate to the Variables tab. In Variables, you can set variables within the R2 collection. They will be used to authenticate and interact with the R2 platform. Remember to always select Save after updating a variable.
To execute basic operations, you must set the account-id
, r2-access-key-id
, and r2-secret-access-key
variables in the Postman dashboard > Variables.
To do this:
- Log in to the Cloudflare dashboard ↗.
- In Account Home, select R2.
- In R2, under Manage R2 API Tokens on the right side of the dashboard, copy your Cloudflare account ID.
- Go back to the Postman dashboard ↗.
- Set the CURRENT VALUE of
account-id
to your Cloudflare account ID and select Save.
Next, generate an R2 API token:
- Go to the Cloudflare dashboard > R2.
- On the right hand sidebar, select Manage R2 API Tokens.
- Select Create API token.
- Name your token Postman by selecting the pencil icon next to the API name and grant it the Edit permission.
Guard this token and the Access Key ID and Secret Access Key closely. You will not be able to review these values again after finishing this step. Anyone with this information can fully interact with all of your buckets.
After you have created your API token in the Cloudflare dashboard:
- Go to the Postman dashboard ↗ > Variables.
- Copy
Access Key ID
value from the Cloudflare dashboard and paste it into Postman’sr2-access-key-id
variable value and select Save. - Copy the
Secret Access Key
value from the Cloudflare dashboard and paste it into Postman’sr2-secret-access-key
variable value and select Save.
By now, you should have account-id
, r2-secret-access-key
, and r2-access-key-id
set in Postman.
To verify the token:
- In the Postman dashboard, select the Cloudflare R2 folder dropdown arrow > Buckets folder dropdown arrow >
GET
ListBuckets. - Select Send.
The Postman collection uses AWS SigV4 authentication to complete the handshake.
You should see a 200 OK
response with a list of existing buckets. If you receive an error, ensure your R2 subscription is active and Postman variables are saved correctly.
In the Postman dashboard:
- Go to Variables.
- Set the
r2-bucket
variable value as the name of your R2 bucket and select Save. - Select the Cloudflare R2 folder dropdown arrow > Buckets folder dropdown arrow >
PUT
CreateBucket and select Send.
You should see a 200 OK
response. If you run the ListBuckets
request again, your bucket will appear in the list of results.
You will now add an object to your bucket:
- Go to Variables in the Postman dashboard.
- Set
r2-object
tocat-pic.jpg
and select Save. - Select Cloudflare R2 folder dropdown arrow > Objects folder dropdown arrow > Multipart folder dropdown arrow >
PUT
PutObject and select Send. - Go to Body and choose binary before attaching your cat picture.
- Select Send to add the cat picture to your R2 bucket.
After a few seconds, you should receive a 200 OK
response.
It only takes a few more more clicks to download our cat friend using the GetObject
request.
- Select the Cloudflare R2 folder dropdown arrow > Objects folder dropdown arrow >
GET
GetObject. - Select Send.
The R2 team will keep this collection up to date as we expand R2 features set. You can explore the rest of the R2 Postman collection by experimenting with other operations.