# Archive a widget

Didomi API allows you to create as many widgets as you need. At some point, you might want to clean the widgets list by deleting the ones you do not use anymore or those you never used.

{% hint style="warning" %}
In Didomi system, **archiving a widget means actually deleting the widget**.
{% endhint %}

However, depending on the widget status, we operate the deletion differently:

* **Draft**: Your widget will be deleted and all information and assets you added will be deleted too.
* **Unpublished changes**: Your widget will be deleted from Widgets table and a copy will be created in Archived Widgets table. Every change made between the last deployment and the deletion will be lost.
* **Published**: Your widget will be deleted from Widgets table and a copy will be created in Archived Widgets table.

#### Delete a widget

To delete a widget, send a **DELETE** request on `/widgets/{id}`.

```json
DELETE https://api.didomi.io/widgets/{id}?organization_id=YOUR_ORG_ID
```

#### Retrieve archived widgets

**If you have published your widget once** and you archive the widget, this entity will be copied in `ArchivedWidgets` table.

To retrieve archived widgets, send a GET request on `/widgets/archived`.

{% hint style="success" %}
Note that the widget ID and the archived widget ID are equivalent.
{% endhint %}

```json
GET https://api.didomi.io/widgets/archived?organization_id=YOUR_ORG_ID

[
    {
        /**
        * Archived widget ID and widget ID are equivalent.
        */
        "id": "String",
        "created_at": "Date",
        "updated_at": "Date",
        "name": "String",
        "widget_created_at": "Date",
        "organization_id": "String",
        "format": "String",
        "last_domain_used": "String",
        "template_id": "Enum"
    }
]
```

Optional query parameters:

* `widget_id`: ID of a widget
* `$limit`: number of max results to return
* `$skip`: Number of results to skip
* `$sort`: represents sorting options. Accepts date properties to sort (`created_at`, `updated_at`) as keys and -1 or 1 for sort direction as value.
  * `$sort[created_at]=1` or `-1`
  * `$sort[updated_at]=1` or `-1`

#### Retrieve an archived widget

To retrieve archived widgets, send a GET request on `/widgets/archived/{id}`.

```json
GET https://api.didomi.io/widgets/archived/{id}?organization_id=YOUR_ORG_ID

{
    /**
    * Archived widget ID and widget ID are equivalent.
    */
    "id": "String",
    "created_at": "Date",
    "updated_at": "Date,
    "name": "String",
    "widget_created_at": "Date",
    "organization_id": "String",
    "format": "String",
    "last_domain_used": "String",
    "template_id": "Enum"
}
```

{% hint style="info" %}
Widget configurations are kept safe in deployments table. To access the configuration, fetch the deployments and search for the latest with the archived widget ID.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.didomi.io/api-and-platform/widgets/privacy-widgets/archive-a-widget.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
