Cloudflare Docs
Cloudflare Image Optimization
Edit this page on GitHub
Set theme to dark (⇧+D)

Upload via batch API

The Images batch API lets you make several requests in sequence while bypassing Cloudflare’s global API rate limits.

To use the Images batch API, you will need to obtain a batch token and use the token to make several requests. The requests authorized by this batch token are made to a separate endpoint and do not count toward the global API rate limits. Each token is subject to a rate limit of 200 requests per second. You can use multiple tokens if you require higher throughput to the Cloudflare Images API.

To obtain a token, you can use the new images/v1/batch_token endpoint as shown in the example below.

$ curl -H "Authorization: Bearer <CLOUDFLARE_API_TOKEN>" \
"https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/images/v1/batch_token"
{
"result": {
"token": "<BATCH_TOKEN>",
"expiresAt": "2023-08-09T15:33:56.273411222Z"
},
"success": true,
"errors": [],
"messages": []
}

After getting your token, you can use it to make requests for:

These options use a different host and a different path with the same method, request, and response bodies.

Request for list images V2 against api.cloudflare.com
$ curl -H "Authorization: Bearer <CLOUDFLARE_API_TOKEN>" \
"https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/images/v2"
Example request using a batch token
$ curl -H "Authorization: Bearer <BATCH_TOKEN>" \
"https://batch.imagedelivery.net/images/v2"