Cloudflare Docs
Images
Visit Cloudflare Image Optimization on GitHub
Set theme to dark (⇧+D)

Make your first API request

To make your first request to the Images API, you must obtain these pieces of information:

Your Cloudflare Account ID
  1. Log in to the Cloudflare dashboard, and select your account and website.
  2. In Overview, scroll down to find your Account ID.
Your Global API Key or API Token

Refer to API tokens .

Once you have this information, you are ready to upload your first image to Cloudflare Images using the API:

curl -X POST \
  "https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/images/v1" \
  -H "Authorization: Bearer <API_TOKEN>" \
  -F file=@./<YOUR_IMAGE>

A successful response will look similar to this:

{
  "result": {
    "id": "083eb7b2-5392-4565-b69e-aff66acddd00",
    "filename": "triceratops.jpg",
    "uploaded": "2021-09-14T05:52:14.767Z",
    "requireSignedURLs": false,
    "variants": [
      "https://imagedelivery.net/ZWd9g1K7eljCn_KDTu_MWA/083eb7b2-5392-4565-b69e-aff66acddd00/test",
      "https://imagedelivery.net/ZWd9g1K7eljCn_KDTu_MWA/083eb7b2-5392-4565-b69e-aff66acddd00/public"
    ]
  },
  "result_info": null,
  "success": true,
  "errors": [],
  "messages": []
}