Deleting API Gateways and API Deployments

Having created an API gateway, and deployed an API on the API gateway by creating an API deployment, you might decide that either or both are no longer required.

You can delete an API gateway from the API Gateway service, provided there are no API deployments on it.

You can delete individual API deployments on an API gateway, one at a time. Note that when you delete an API deployment, its API deployment specification is permanently removed.

Note that deleted API gateways and API deployments continue to be shown in the Console for 90 days, with a status of Deleted. After 90 days, deleted API gateways and API deployments are no longer shown.

Using the Console

To delete an API gateway or an API deployment using the Console:

  1. In the Console, open the navigation menu and click Developer Services. Under API Management, click Gateways.
  2. Choose a Compartment you have permission to work in.
  3. On the Gateways page, click the name of the API gateway that you want to delete (or that contains the API deployment you want to delete) to show the Gateway Details page.
  4. On the Gateway Details page:

    • To delete the API gateway, click Delete below the API gateway's name. The API gateway is permanently removed. Note that you cannot delete an API gateway if it still has API deployments on it. You must delete the API deployments first.
    • To delete an API deployment, select Deployments from the Resources list, click the Actions icon (three dots) beside the API deployment you want to delete, and select Delete. The API deployment and its API deployment specification are permanently removed.

Using the CLI

To delete API gateways and API deployments using the CLI:

  1. Configure your client environment to use the CLI (Configuring Your Client Environment to use the CLI for API Gateway Development).
  2. To delete an existing API gateway:

    1. Open a command prompt and run oci api-gateway gateway delete to delete the API gateway:

      oci api-gateway gateway delete --gateway-id <gateway-ocid>

      where:

      For example:

      oci api-gateway gateway delete --gateway-id ocid1.apigateway.oc1..aaaaaaaab______hga

      Note that you cannot delete an API gateway if it still has API deployments on it (including API deployments that are in different compartments to the API gateway itself). You must delete the API deployments first.

      The response to the command includes:

      • The lifecycle state (for example, DELETED, FAILED).
      • The id of the work request to delete the API gateway (details of work requests are available for seven days after completion, cancellation, or failure).

      If you want the command to wait to return control until the API gateway has been deleted (or the request has failed), include either or both the following parameters:

      • --wait-for-state DELETED
      • --wait-for-state FAILED

      For example:

      oci api-gateway gateway delete --gateway-id ocid1.apigateway.oc1..aaaaaaaab______hga --wait-for-state DELETED
    2. (Optional) To see the status of the work request that is deleting the API gateway, enter:

      oci api-gateway work-request get --work-request-id <work-request-ocid>
    3. (Optional) To view the logs of the work request that is deleting the API gateway, enter:

      oci api-gateway work-request-log list --work-request-id <work-request-ocid>
    4. (Optional) If the work request that is deleting the API gateway fails and you want to review the error logs, enter:

      oci api-gateway work-request-error --work-request-id <work-request-ocid>
    5. (Optional)  To verify that the API gateway has been deleted, enter the following command and confirm that the API gateway's lifecycle state is DELETED:

      oci api-gateway gateway get --gateway-id <gateway-ocid>
  3. To delete an existing API deployment:

    1. Open a command prompt and run oci api-gateway deployment delete to delete the API deployment:

      oci api-gateway deployment delete --deployment-id <deployment-ocid>

      where:

      For example:

      oci api-gateway deployment delete --deployment-id ocid1.apideployment.oc1..aaaaaaaaab______pwa

      The response to the command includes:

      • The lifecycle state (for example, ACTIVE, DELETED).
      • The id of the work request to delete the API deployment (details of work requests are available for seven days after completion, cancellation, or failure).

      If you want the command to wait to return control until the API deployment is active (or the request has failed), include either or both the following parameters:

      • --wait-for-state DELETED
      • --wait-for-state FAILED

      For example:

      oci api-gateway deployment delete --deployment-id ocid1.apideployment.oc1..aaaaaaaaab______pwa --wait-for-state DELETED
    2. (Optional) To see the status of the work request that is deleting the API deployment, enter:

      oci api-gateway work-request get --work-request-id <work-request-ocid>
    3. (Optional) To view the logs of the work request that is deleting the API deployment, enter:

      oci api-gateway work-request-log list --work-request-id <work-request-ocid>
    4. (Optional) If the work request that is deleting the API deployment fails and you want to review the error logs, enter:

      oci api-gateway work-request-error --work-request-id <work-request-ocid>
    5. (Optional)  To verify that the API deployment has been deleted, enter the following command and confirm that the API deployment 's lifecycle state is DELETED:

      oci api-gateway deployment get --deployment-id <deployment-ocid>

For more information about using the CLI, see Command Line Interface (CLI). For a complete list of flags and options available for CLI commands, see CLI Help.