---
description: >-
  Wondering about how do you delete an existing asset from your Cloudinary media
  database? Have a look on this quick guide to find the solution! :)
---

# Delete an asset from Cloudinary

If you have read the previous guide "Upload image to Airtable", you might remember we used the Cloudinary Media Database to host our image temporarily until it's uploaded to Airtable.

Now, it only makes sense if we delete the temporarily-hosted image from Cloudinary, as it's of no use now. The Cloudinary Upload API has a method for this particular purpose, known as the destroy method.

{% hint style="info" %}
Click [**here**](#delete-an-image-from-cloudinary-media-database) to view the API reference of **`destroy`** method.
{% endhint %}

## Quick Look - Delete an image from Cloudinary Media Database

<mark style="color:green;">`POST`</mark> `https://api.cloudinary.com/v1_1/<cloud_name>/image/destroy`

The `destroy` method is used to immediately and permanently delete a single asset from your Cloudinary

#### Request Body

| Name       | Type   | Description                             |
| ---------- | ------ | --------------------------------------- |
| public\_id | String | (required) The public ID of the image   |
| signature  | String | (required) Signature for authentication |
| timestamp  | String | (required) Current time in UNIX format  |
| api\_key   | String | (required) Cloudinary API key           |

{% tabs %}
{% tab title="200: OK Success response - { "result": "ok" }" %}
```javascript
{
  "result": "ok"
}
```
{% endtab %}
{% endtabs %}

## API Parameters

As you can see in the above API module, there are 4 required parameters. Let's have a brief look at their use -&#x20;

* **`public_id`** - The value for the **`public_id`** parameter can be easily extracted from the direct URL of the image. For example, in the URL **https://res.cloudinary.com/demo/..../cat.jpg**, "cat" is the public ID of the image.
* **`timestamp`** - The current [UNIX](https://www.unixtimestamp.com/) time. The value for this parameter can be extracted from the [seconds since 1970 block](https://docs.thunkable.com/device#get-seconds-since-1970) in device category in the Blocks section of your project.
* **`api_key`** - The API key of your Cloudinary account. The API key can be found on the top section in your Cloudinary account dashboard ([cloudinary.com/console](https://cloudinary.com/console/)).
* **`signature`** - The value for the **`signature`** parameter (which is the authentication parameter) is a hash value (SHA1 encryption) of a string, which is a combination of a few parameters. The parameters involved are as follows -&#x20;
  * **`public_id`** - The same public\_id we used in the body parameters above.
  * **`timestamp`** - The same timestamp we used in the body parameters above.
  * **`api_secret`** - The API secret of your Cloudinary account. Also located alongside the API key in the account dashboard.

## Generating the SHA1 Signature

Generating the Signature for authentication is a hefty task. But don't worry, I've made it simpler for you. Let's have a look at the steps to produce an SHA1 signature -&#x20;

### The offline SHA1 encryption module

As I said earlier, we need to combine together a bunch of values and encrypt it with SHA1. There are plenty of online APIs for this, but I do not trust anyone of them with my data. So I did some coding, and I made my own SHA1 encoder using HTML, JS, & PHP, to use along with the WebViewer's postData and receiveMessage in Thunkable. Below attached **sha.html** file&#x20;

{% file src="https://2577577115-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lx1MKV2duu0AXeooMX9%2Fuploads%2FEojuPMKCV4QtdhIyEwqo%2Fsha.html?alt=media&token=8a7aa273-d1d3-421f-acdc-99ab5084314c" %}

Assuming you have the values for `public_id`, `timestamp`, & `api_secret`, we'll now join/combine the values using the `join` text block like this -&#x20;

