> For the complete documentation index, see [llms.txt](https://docs.sprinthub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sprinthub.com/en/topics/api/api-how-to-recover-or-delete-archived-leads.md).

# API - How to Recover or Delete Archived Leads

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2F9xzLuErtk7M9TaqiL2Yw%2FWhatsApp%20Image%202024-09-13%20at%2017.01.33.jpeg?alt=media&amp;token=1b928e66-daeb-4fa6-8171-4dde6c51a0dd" alt=""><figcaption></figcaption></figure>

Recovering archived leads is an important function to maintain flexibility in managing the contact base. Sometimes an archived lead may become engaged again or present new opportunities, and it is essential that the unarchiving process be quick and straightforward. The SprintHub API allows you to easily query and manage your archived leads, using the correct endpoint.

### Endpoint to Query Archived Leads

To retrieve the leads that are archived in a SprintHub instance, you must use the following endpoint:

<mark style="color:green;">`https://sprinthub-api-master.sprinthub.app/lead/archive?i=YOUR_INSTANCE&apitoken=YOUR_INSTANCE_TOKEN`</mark>

In this endpoint, you need to pass two essential parameters:

* **i=YOUR\_INSTANCE**: Identifies which instance is being queried.
* **apitoken=YOUR\_INSTANCE\_TOKEN**: Authentication token, ensuring that the request is being made by an authorized user.

### Requirements for the Request Body

To perform the query and ensure that the archived lead is correctly identified, the request body must contain the following data in JSON format:

```json
jsonCopy code{
  "archived": true,
  "id": 2331
}
```

Explanation:

* **archived**: This field must be set to `true` to confirm that you are looking for archived leads.
* **id**: The specific ID of the lead you want to query or manage. In this case, the ID is **2331**, but it must be replaced with the ID of the lead you are trying to retrieve.

### Step-by-Step to Retrieve Archived Leads

1. **Request Setup**: Use an API tool such as the **Postman** or an HTTP client to make the POST request to the endpoint mentioned.
2. **Sending the Parameters**: Make sure the URL parameters and authentication token are correct, ensuring access to the right instance and proper authorization.
3. **Define the Request Body**: In the request body, as shown above, define the fields `"archived": false` and specify the `id` archived lead ID.
4. **Send the Request**: Click on "Send" to send the request. If the request is correct, you will receive a response with status **200 OK**, indicating that the lead was found.

### Practical Example of a Request in Postman

The image shown illustrates a real example in **Postman**, where the request was successful, returning a status **200 OK**.

* **Method**: <mark style="color:yellow;">POST</mark>
* **URL**: <mark style="color:green;">`https://sprinthub-api-master.sprinthub.app/lead/archive?i=YOUR_INSTANCE&apitoken=YOUR_INSTANCE_TOKEN`</mark>
* **Body**:

```json
{
  "archived": true,
  "id": 2331
}
```

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2FNlbqtOTlKHBJn4K5VZM7%2Fimage.png?alt=media&amp;token=48c2cb00-9117-4f99-824a-d7e2ee49c5f9" alt=""><figcaption></figcaption></figure>

When making this request, the lead with ID **2331** was retrieved as archived.

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2FxFT98C1mYOWrEQFNFTOd%2Fimage.png?alt=media&amp;token=b6ed3c04-e892-48ca-b384-9ef8fdd48c43" alt=""><figcaption></figcaption></figure>

<mark style="color:red;">**Now to Delete:**</mark>

{% hint style="danger" %}
Remember that, when you delete this lead, it is lost forever and cannot be recovered
{% endhint %}

* **Method**: <mark style="color:red;">DELETE</mark>
* **URL**: <mark style="color:green;">`https://sprinthub-api-master.sprinthub.app/leads/LEAD_ID?i=YOUR_INSTANCE&apitoken=YOUR_INSTANCE_TOKEN`</mark>

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2FYh3Jv10gTsiqKBP1Hz1f%2Fimage.png?alt=media&amp;token=a05fc56b-f8ea-400c-8aa8-3660e70e5fef" alt=""><figcaption></figcaption></figure>

When making this request, the lead with ID **2346** was Deleted, even though it was archived.

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2FBFOWny6Um3nZamkcTU6W%2Fimage.png?alt=media&amp;token=6b73a57a-1d6d-4bd8-ae66-f3deb53f7d49" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
If you want to perform a bulk archiving, unarchiving, or deletion of archived leads, it will be necessary to pass an array with all the lead IDs.
{% endhint %}

#### Conclusion

The process of retrieving archived leads via the SprintHub API is simple and effective. Make sure to always use the correct ID and set the field `"archived": true` in the request body to ensure that you are accessing the information of archived leads. This feature is essential to maintain flexibility and ensure that leads can be restored whenever necessary, without loss of important data.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.sprinthub.com/en/topics/api/api-how-to-recover-or-delete-archived-leads.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
