> For the complete documentation index, see [llms.txt](https://docs.langstack.com/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.langstack.com/welcome/get-started/learn-langstack/introduction-to-rest-api/exercise-2-delete-a-published-api.md).

# Exercise 2: Delete a published API

## Requirements

1. API is enabled and published.
2. API gateway is selected and enabled.

## Solution

To delete a published API, proceed as follows.\
Step 1: Delete the API gateway(s) using the API.\
Step 2: Delete the API.

### Step 1: Delete the API gateway(s) that is using the API

The API gateway using the API must be deleted first.

{% hint style="info" %}
Note: When an API is set with more than one API gateway, all API gateways must be disabled first, and then the API is deleted.
{% endhint %}

To go to the API gateway, follow any of the options:

* Select “API gateway” under “APIs and integration” on the left side panel and open the required API.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4apigatewaymenu.png>" %}

* OR Open the API gateway by clicking the \[Go to API gateway] button in the API under the Details tab. It displays the API gateway.

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4delapigotoapigateway.png" alt=""><figcaption></figcaption></figure>

3\. OR go to the Usage tab on the API page and click on the API gateway. It displays the API gateway in Used by.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4delapiusage.png>" %}

* To begin deleting the API gateway, click the Delete API gateway icon on the API gateway page.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4delapigatewayicon.png>" %}

* To confirm the deletion for the API gateway, a dialog box will pop up asking for confirmation by entering the API gateway name.\
  Enter the name of the API gateway. The \[Delete] button gets activated.
* To delete the API gateway, click the \[Delete] button. The message for successful deletion displays.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4apigtwydelconfirm.png>" %}

### Step 2: Delete the API

When the API gateway using the API is deleted, delete the API as follows.

* Disable the API. An enabled API cannot be deleted.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4nocalcdisableapi.png>" %}

* Click the Delete API icon to delete the API.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4nocalcdelapi1.png>" %}

* To confirm the deletion for the API, a dialog box will pop up asking for confirmation.\
  Enter the name of the API. The \[Delete] button gets activated.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4nocalcdelapiconfirm.png>" %}

* To delete the API, click the \[Delete] button. The message for successful deletion displays.
