This document describes how to perform these tasks involving labels:

- Disable a label
- Enable a label
- Delete a label

## Disable a label

Disabling a label results in a new disabled published revision based on the
current published revision. If there's a draft revision, a new disabled draft
revision is created based on the latest draft revision. Older draft revisions
are deleted. For more information, see [Label
lifecycle](https://developers.google.com/workspace/drive/labels/guides/label-lifecycle).

Once disabled, users can still apply this label through the Google Drive Labels API. The
label still appears where it's already been applied and in your search results.
A disabled label can be [deleted](https://developers.google.com/workspace/drive/labels/guides/disable-delete-label#delete).

To disable a published label, use the
[`disable`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels/disable) method on
the [`labels`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels) resource.

You also must specify:

- A `labels` resource that represents the label. It contains a [`name`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#Label.FIELDS.name)
  and an
  [`id`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#Label.FIELDS.id),
  which is a globally unique identifier for the label.

- The [`useAdminAccess`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels/disable#body.request_body.FIELDS.use_admin_access)
  query parameter is set to `true` to use the user's administrator
  credentials. Before allowing access, the server verifies that the user has
  the required [Manage Classification
  Labels](https://knowledge.workspace.google.com/admin/users/administrator-privilege-definitions#data_classification)
  administrator privileges.

The following code sample shows how to use the label's `id` to disable the
correct label:

### Python

    service.labels().disable(
        name='labels/ID',
        body={
            'useAdminAccess': True
        }
    ).execute()

### Node.js

    service.labels.disable({
      name: 'labels/ID',
      requestBody: {
        useAdminAccess: true
      }
    }, (err, res) => {
      if (err) return console.error('The API returned an error: ' + err);
      console.log(res);
    });

Replace <var translate="no">ID</var> with the ID of the label to disable.

The label has the
[`State`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#state) of `DISABLED`
and the label's revision ID is incremented. Users can apply the label through
the Drive Labels API. However, a disabled label isn't shown in a UI unless
the
[`showInApply`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#DisabledPolicy.FIELDS.show_in_apply)
field of the
[`DisabledPolicy`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#disabledpolicy)
object is configured.

## Enable a label

Enabling a disabled label restores it to its published state. It results in a
new published revision based on the current disabled published revision. If
there's an existing disabled draft revision, a new revision is created based on
that draft and is enabled. For more information, see [Label
lifecycle](https://developers.google.com/workspace/drive/labels/guides/label-lifecycle).

To enable a disabled label, use the
[`enable`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels/enable) method on
the `labels` resource.

You also must specify:

- A `labels` resource that represents the label. It contains a [`name`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#Label.FIELDS.name)
  and an
  [`id`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#Label.FIELDS.id),
  which is a globally unique identifier for the label.

- The [`useAdminAccess`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels/disable#body.request_body.FIELDS.use_admin_access)
  query parameter is set to `true` to use the user's administrator
  credentials. Before allowing access, the server verifies that the user has
  the required [Manage Classification
  Labels](https://knowledge.workspace.google.com/admin/users/administrator-privilege-definitions#data_classification)
  administrator privileges.

The following code sample shows how to use the label's `id` to enable the
correct label:

### Python

    service.labels().enable(
        name='labels/ID',
        body={
            'useAdminAccess': True
        }
    ).execute()

### Node.js

    service.labels.enable({
      name: 'labels/ID',
      requestBody: {
        useAdminAccess: true
      }
    }, (err, res) => {
      if (err) return console.error('The API returned an error: ' + err);
      console.log(res);
    });

Replace <var translate="no">ID</var> with the ID of the label to enable.

The label has the
[`State`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#state) of `PUBLISHED`
and the label's revision ID is incremented. Users can view and apply the label
to files through the Drive Labels API.

## Delete a label

Only draft and disabled labels can be deleted. When a label is deleted, all
instances where the label was previously applied, including any corresponding
field values entered by users, are permanently deleted and removed from those
Drive files.

To delete a label, you must first disable it and then use the
[`delete`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels/delete) method on
the `labels` resource.

You also must specify:

- A `labels` resource that represents the label. It contains a [`name`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#Label.FIELDS.name)
  and an
  [`id`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#Label.FIELDS.id),
  which is a globally unique identifier for the label.

- The [`useAdminAccess`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels/disable#body.request_body.FIELDS.use_admin_access)
  query parameter is set to `true` to use the user's administrator
  credentials. Before allowing access, the server verifies that the user has
  the required [Manage Classification
  Labels](https://knowledge.workspace.google.com/admin/users/administrator-privilege-definitions#data_classification)
  administrator privileges.

The following code sample shows how to use the label's `id` to delete the
correct label:

### Python

    response = service.labels().delete(
        name='labels/ID',
        useAdminAccess=True
    ).execute()

### Node.js

    service.labels.delete({
      name: 'labels/ID',
      useAdminAccess: true
    }, (err, res) => {
      if (err) return console.error('The API returned an error: ' + err);
      console.log(res);
    });

Replace <var translate="no">ID</var> with the ID of the label to delete.

The label has the
[`State`](https://developers.google.com/workspace/drive/labels/reference/rest/v2/labels#state) of `DELETED`
and the label's revision ID is incremented. The label cannot be applied and
deleted labels are eventually purged. For more information, see [Label
lifecycle](https://developers.google.com/workspace/drive/labels/guides/label-lifecycle).