# Remove an API Gateway connection from API hub

This page describes how to remove an API Gateway connection from API hub.

## Overview

To remove an API Gateway connection from API hub, do one of the following:

- [Remove API Gateway assets from API hub without detaching the runtime project](https://docs.cloud.google.com/api-gateway/docs/api-hub-remove-connection#remove-assets)
- [Detach the runtime project from API hub](https://docs.cloud.google.com/api-gateway/docs/api-hub-remove-connection#detach-project)

**Important**: When you remove an API Gateway connection from API hub, the API Gateway plugin instance and all ingested data will be deleted from API hub.

## Remove API Gateway assets from API hub without detaching the runtime project

Remove API Gateway assets from API hub without detaching the runtime project as described below.

### Google Cloud console

To remove API Gateway assets from the runtime project association settings, do the following:

1. In the Google Cloud console, select your host project.
2. Go to the **API hub** page.

   [Go to API hub](https://console.cloud.google.com/apigee/api-hub)
3. Click **Settings** from the left navigation menu to open the **Settings** page.
4. Go to the **Project associations** tab.
5. Click **Edit settings** associated with the API Gateway project.
6. In the **Project association settings** pane, deselect **API Gateway Plugin** and any other API assets you want to automatically import.
7. Click **Save**.

### REST

To remove API Gateway assets from the runtime project, use the [delete plugin instance](https://docs.cloud.google.com/apigee/docs/reference/apis/apihub/rest/v1/projects.locations.plugins.instances/delete) API.

For example:

```
curl "https://apihub.googleapis.com/v1/projects/HUB_PROJECT_ID/locations/HUB_LOCATION/plugins/PLUGIN_TYPE/instances/PLUGIN_INSTANCE_ID" \
  -X DELETE \
  -H "Authorization: Bearer $(gcloud auth print-access-token)"
```

Replace the following:

- <var translate="no">HUB_PROJECT_ID</var>: The name of your API hub host project. The host project was selected when API hub was provisioned.
- <var translate="no">HUB_LOCATION</var>: The location of the host project. The location was chosen when API hub was provisioned.
- <var translate="no">PLUGIN_TYPE</var>: Type of plugin. Set to **system-api-gateway**.
- <var translate="no">PLUGIN_INSTANCE_ID</var>: ID of the API Gateway plugin instance. Use the [list plugin instances](https://docs.cloud.google.com/apigee/docs/reference/apis/apihub/rest/v1/projects.locations.plugins.instances/list) API to get the plugin instance ID.

If successful, an [Operation](https://docs.cloud.google.com/apigee/docs/reference/apis/apihub/rest/v1/projects.locations.operations) JSON object is returned.

## Detach the API Gateway project from API hub

Detach the runtime project from API hub as described below.

### Google Cloud console

To detach the API Gateway project from API hub, do the following:

1. In the Google Cloud console, select your host project.
2. Go to the **API hub** page.

   [Go to API hub](https://console.cloud.google.com/apigee/api-hub)
3. Click **Settings** from the left navigation menu to open the **Settings** page.
4. Go to the **Project associations** tab.
5. Click **Detach runtime project** associated with the API Gateway project.
6. Click **Confirm**.

### REST

To detach the runtime project from API hub, use the [delete runtime project attachments](https://docs.cloud.google.com/apigee/docs/reference/apis/apihub/rest/v1/projects.locations.runtimeProjectAttachments/delete) API.

For example:

```
curl 'https://apihub.googleapis.com/v1/projects/HUB_PROJECT_ID/locations/HUB_LOCATION/runtimeProjectAttachments/RUNTIME_PROJECT_ID' \
  -X DELETE \
  -H "Authorization: Bearer $(gcloud auth print-access-token)"
```

Replace the following:

- <var translate="no">HUB_PROJECT</var>: The name of your API hub host project. The host project was selected when API hub was provisioned.
- <var translate="no">HUB_LOCATION</var>: The location of the host project. The location was chosen when API hub was provisioned.
- <var translate="no">RUNTIME_PROJECT_ID</var>: ID of the runtime project. Use the [list runtime project attachments](https://docs.cloud.google.com/apigee/docs/reference/apis/apihub/rest/v1/projects.locations.runtimeProjectAttachments/list) API to get the runtime project ID.

If successful, an empty JSON object is returned.