# Invalidation API

The Invalidation API is a REST API that lets you remove cached images from the CDN and Cloudimage resizing servers.

## Step 1. Get your API key <a href="#od_db63d55d" id="od_db63d55d"></a>

Your API key is available in the Cloudimage admin console, under *Invalidation*:

<figure><img src="https://727245914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIDIcmPiz7q6Sr6ZHHQxV%2Fuploads%2FJAUg1qFAcR1l75Mn4D4l%2Fimage.png?alt=media&#x26;token=df5a9f84-89ea-4ca9-9307-3ee3f61d88d4" alt=""><figcaption></figcaption></figure>

## Step 2. Call the Invalidation REST API <a href="#od_0c753286" id="od_0c753286"></a>

```
POST https://api.cloudimage.com/invalidate
```

```
X-Client-Key: your_API_KEY
Content-Type: application/json
```

**Body:**

* For Cloudimage tokens created ***before*** November 2021, the invalidated URL should include "/v7/". Example: **/v7/**[https://img.domain.com/image2.jpg](https://img.domain.com/image2.jpg?w=600)
* For Cloudimage tokens created ***after*** November 2021, the invalidated URL should ***not*** include "/v7/". Example: [https://img.domain.com/image2.jpg](https://img.domain.com/image2.jpg?w=600)
* If you are using the [Origin prefix,](https://docs.cloudimage.io/setup/shortening-urls/origin-url-prefix) its value should not be included. Example:   images/image1.jpg
* If you are using an[ alias](https://docs.cloudimage.io/setup/shortening-urls/aliases), the alias should be invalidated (not the original value behind it). Example: **\_alias\_/**&#x69;mages/image1.jpg
* If you are using Invalidation with scope 'original', please do not append any Cloudimage query string parameters at the end of the invalidated URL. Example:<br>
  * correct URL format: <https://img.domain.com/image2.jpg>&#x20;
  * incorrect URL format: [https://img.domain.com/image2.jp&#x67;**?w=600**](https://img.domain.com/image2.jpg?w=600)&#x20;

### **Invalidate multiple images with all their resizes**

```json
{
  "scope": "original",
  "urls": ["/sample.li/birds.jpg",
            "/sample.li/boat.jpg", ...
  ]
}
```

### **Invalidate all your images**&#x20;

{% hint style="info" %}
Flushing all images will result in Cloudimage downloading all your images from your origin image storage again. This will result in slower image loading times for the first times the images are downloaded.&#x20;

[Contact us](mailto:hello@cloudimage.io) if you have more than 1 TB of monthly CDN traffic or 1 TB of storage.
{% endhint %}

```json
{
  "scope": "all"
}
```

**Try it out with the doc token**

You can use our [sample image](http://sample.li/now.php) showing the time it is resized the first time:

[https://**doc**.cloudimg.io/**sample.li/now.php**?**width=500**](https://doc.cloudimg.io/sample.li/now.php?w=500&)
