---
schema_version: "1"
id: c73ee5b30b4dcda1c9363c36b4ee61b4df400ba1064f9e4ec5e0676f84c7ebe0
title: How Does an Uninstall Script Work?
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform-pkg-exchange/managed_packaging/guides/first-generation/apex-uninstall-script-intro.md
canonical_url: https://developer.salesforce.com/docs/platform/pkg1-dev/guide/apex-uninstall-script-intro.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 025e5928bc5d30c48f25c083092d7fadc39d4303ccafd93708f0306e07309bc7
products:
  - First-Generation Managed Packaging Developer Guide
  - merged-docs
---

# How Does an Uninstall Script Work?

An uninstall script is an Apex class that implements the `UninstallHandler` interface. This interface has a single method called `onUninstall` that specifies the actions to be performed on uninstall.

```apex
global interface UninstallHandler {
  void onUninstall(UninstallContext context)
}

```

The `onUninstall` method takes a context object as its argument, which provides the following information.

- The org ID of the organization in which the uninstall takes place.
- The user ID of the user who initiated the uninstall.

The context argument is an object whose type is the `UninstallContext` interface. This interface is automatically implemented by the system. The following definition of the `UninstallContext` interface shows the methods you can call on the context argument.

```apex
global interface UninstallContext { 
  ID organizationId();
  ID uninstallerId();
}
```
