> [!CAUTION]
> **Caution:** This documentation covers Edge for Private Cloud 4.52.00, which is no longer supported. Google does not provide security patches, bug fixes, or technical support for this version. The current supported version is 4.54.00. See the [Edge for Private Cloud documentation](https://docs.apigee.com/private-cloud/latest/overview) for the current version, or [All versions](https://docs.apigee.com/private-cloud/versions) to compare releases.

This section shows how to remove organizations, environments, and virtual hosts. The order of
API calls is very important; for example, the step to remove an
organization can only be executed after you remove all associated environments in the
organization.

## Delete a virtual host

Before you can delete a virtual host from an environment, you must update any API proxies that
reference the virtual host to remove the reference. See
[Virtual hosts](https://docs.apigee.com/api-platform/fundamentals/virtual-hosts) for more.

Use the following API to delete a virtual host:

```
curl -u <admin user>:<admin passwd> -X DELETE \
"http://ms_IP:8080/v1/organizations/org_name/environments/env_name/virtualhosts/virtualhost_name"
```

## Delete an environment

You can only delete an environment after you have:

1. Deleted all virtual hosts in the environment as described above.
2. Disassociated the environment from all Message Processors.
3. Cleaned up analytics.

### Disassociate an
environment from Message Processor

Use the following API to remove an association of an environment with a Message Processor. If
you want to delete the environment, you must disassociate it from all Message Processors:

```
curl -H "Content-Type: application/x-www-form-urlencoded" \
-u ADMIN_USERNAME:ADMIN_PASSWORD -X POST \
"http://ms_IP:8080/v1/organizations/org_name/environments/env_name/servers" \
-d "action=remove&uuid=uuid"
```

Where <var translate="no">uuid</var> is the UUID of Message Processor.

> [!NOTE]
> **NOTE:** To retrieve the UUID of the Message Processor, execute the following command:
>
> ```
> curl "http://mp_IP:8082/v1/servers/self"
> ```
>
> Where <var translate="no">mp_IP</var> is the IP address of the Message Processor.

### Clean up analytics

To remove analytics information about the organization:

```
curl -u ADMIN_EMAIL:ADMIN_PASSWORD -X DELETE \
"http://ms_IP:8080/v1/analytics/groups/ax/analytics_group/scopes?org=org_name&env=env_name"
```

Where <var translate="no">analytics_group</var> defaults to "analytics-001".

If you are unsure of the name of the analytics group, use the following command to display
it:

```
apigee-adminapi.sh analytics groups list --admin ADMIN_EMAIL --pwd ADMIN_PASSWORD --host localhost
```

This command returns the analytics group name in the `name` field.

### Drop fact and aggregate tables for specific Organization and Environment

> [!WARNING]
> **Warning:** This step is irrreversible. Create a backup before proceding.

To delete fact and aggregate tables:

```
/opt/apigee/apigee-service/bin/apigee-service apigee-postgresql pg-drop-tables org_name env_name [confirm_drop-N/Y]
```

where `confirm_drop` is an optional parameter with default value `N`
(which prompts for confirmation).

### Delete the environment

To delete an environment:

```
curl -u ADMIN_EMAIL:ADMIN_PASSWORD \
"http://ms_IP:8080/v1/organizations/org_name/environments/env_name" \ -X DELETE
```

## Delete an organization

You can only delete an organization after you have:

1. Deleted all virtual hosts in all environments in the organization as described above.
2. Deleted all environments in the organization as described above.
3. Disassociated the organization from all pods.

### Disassociate an organization from
a pod

Use the following API to disassociate an organization from a pod:

```
curl -H "Content-Type: application/x-www-form-urlencoded" \
-u ADMIN_EMAIL:ADMIN_PASSWORD -X POST "http://ms_IP:8080/v1/organizations/org_name/pods" \
-d "action=remove&region=region_name&pod=pod_name"
```

> [!NOTE]
> **NOTE:** To find out what region and pods an organization is associated with, run the following command:
>
> ```
> curl -u ADMIN_EMAIL:ADMIN_PASSWORD "http://ms_IP:8080/v1/organizations/org_name/pods"
> ```

### Delete the organization

Use the following API to delete an organization:

```
curl -u ADMIN_EMAIL:ADMIN_PASSWORD -X DELETE "http://ms_IP:8080/v1/organizations/org_name"
```