This document explains how to delete Single Message Transforms (SMTs) from
an existing Pub/Sub topic, by updating the topic,

To delete topic SMTs, you can use the Google Cloud console, the Google Cloud CLI,
the client library, or the Pub/Sub API.

## Required roles and permissions


To get the permission that
you need to delete topic SMTs,

ask your administrator to grant you the
[Pub/Sub Editor](https://docs.cloud.google.com/iam/docs/roles-permissions/pubsub.md.txt#pubsub.editor) (`roles/pubsub.editor`) IAM role on your project.


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


This predefined role contains the
`pubsub.topics.update`
permission,
which is required to
delete topic SMTs.


You might also be able to get
this permission
with [custom roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles.md.txt) or
other [predefined roles](https://docs.cloud.google.com/iam/docs/roles-overview.md.txt#predefined).

You can configure access control at the project level and at the individual
resource level.

## Delete topic SMTs

To delete topic SMTs, follow these steps:

### Console

1. In the Google Cloud console, go to the Pub/Sub **Topics** page.

   [Go to Topics](https://console.cloud.google.com/cloudpubsub/topic)
2. Click the topic for which you want to delete an SMT.

3. In the topic details page, click **Edit**.

   The **Transforms** tab lists all the SMTs that are attached to the topic.
4. Click the delete button for the SMT you would like to delete.

5. Click **Update**.

### gcloud

1. In the Google Cloud console, activate Cloud Shell.

   [Activate Cloud Shell](https://console.cloud.google.com/?cloudshell=true)


   At the bottom of the Google Cloud console, a
   [Cloud Shell](https://docs.cloud.google.com/shell/docs/how-cloud-shell-works.md.txt)
   session starts and displays a command-line prompt. Cloud Shell is a shell environment
   with the Google Cloud CLI
   already installed and with values already set for
   your current project. It can take a few seconds for the session to initialize.
2. This command deletes all SMTs associated with the specified topic.

   Run the
   [`gcloud pubsub topics update`](https://docs.cloud.google.com/sdk/gcloud/reference/pubsub/topics/update) command with the `--clear-message-transforms` flag:

   <br />

   ```bash
   gcloud pubsub topics update TOPIC_ID --clear-message-transforms
   ```

   Replace the following:
   - <var translate="no">TOPIC_ID</var>: The ID or name of the topic you want to update.

   To instead remove a single SMT, refer to [Update topic SMTs](https://docs.cloud.google.com/pubsub/docs/smts/update-topic-smt.md.txt) and create a new `message-transforms-file` that excludes the SMT you wish to delete.

   <br />

<br />

## What's next

- [Create a topic with SMTs](https://docs.cloud.google.com/pubsub/docs/smts/create-topic-smt.md.txt)

- [Update topic SMTs](https://docs.cloud.google.com/pubsub/docs/smts/update-topic-smt.md.txt)