# Method: projects.topics.patch

- [HTTP request](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.request_body.SCHEMA_REPRESENTATION)
    - [JSON representation](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.request_body.SCHEMA_REPRESENTATION.topic.SCHEMA_REPRESENTATION)
    - [JSON representation](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.request_body.SCHEMA_REPRESENTATION.topic.SCHEMA_REPRESENTATION_1)
    - [JSON representation](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.request_body.SCHEMA_REPRESENTATION.topic.SCHEMA_REPRESENTATION_2)
    - [JSON representation](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.request_body.SCHEMA_REPRESENTATION.topic.SCHEMA_REPRESENTATION_3)
- [Response body](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#body.aspect)
- [Try it!](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/patch#try-it)

Updates an existing topic by updating the fields specified in the update mask. Note that certain properties of a topic are not modifiable.

### HTTP request

Choose a location:
<button value="global" default="">global</button>   
`PATCH https://pubsub.googleapis.com/v1/{topic.name}`

<br />

### Path parameters

| Parameters ||
|---|---|
| `topic.name` | `string` Required. Identifier. Name of the topic. Format is `projects/{project}/topics/{topic}`. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "topic": { "name": string, "labels": { string: string, ... }, "messageStoragePolicy": { "allowedPersistenceRegions": [ string ], "enforceInTransit": boolean }, "kmsKeyName": string, "schemaSettings": { "schema": string, "encoding": enum (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#Encoding`), "firstRevisionId": string, "lastRevisionId": string }, "satisfiesPzs": boolean, "messageRetentionDuration": string, "state": enum (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#State`), "ingestionDataSourceSettings": { "platformLogsSettings": { object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#PlatformLogsSettings`) }, // Union field `source` can be only one of the following: "awsKinesis": { object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#AwsKinesis`) }, "cloudStorage": { object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#CloudStorage`) }, "azureEventHubs": { object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#AzureEventHubs`) }, "awsMsk": { object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#AwsMsk`) }, "confluentCloud": { object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#ConfluentCloud`) } // End of list of possible types for union field `source`. }, "messageTransforms": [ { "enabled": boolean, "disabled": boolean, // Union field `transform` can be only one of the following: "javascriptUdf": { object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/MessageTransform#JavaScriptUDF`) }, "aiInference": { object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/MessageTransform#AIInference`) } // End of list of possible types for union field `transform`. } ], "tags": { string: string, ... } }, "updateMask": string } ``` |

| Fields ||
|---|---|
| `topic.labels` | `map (key: string, value: string)` Optional. See [Creating and managing labels](https://cloud.google.com/pubsub/docs/labels). An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |
| `topic.messageStoragePolicy` | ``object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#MessageStoragePolicy`)`` Optional. Policy constraining the set of Google Cloud Platform regions where messages published to the topic may be stored. If not present, then no constraints are in effect. |
| `topic.kmsKeyName` | `string` Optional. The resource name of the Cloud KMS CryptoKey to be used to protect access to messages published on this topic. The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`. |
| `topic.schemaSettings` | ``object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#SchemaSettings`)`` Optional. Settings for validating messages published against a schema. |
| `topic.satisfiesPzs` | `boolean` Optional. Reserved for future use. This field is set only in responses from the server; it is ignored if it is set in any requests. |
| `topic.messageRetentionDuration` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Optional. Indicates the minimum duration to retain a message after it is published to the topic. If this field is set, messages published to the topic in the last `messageRetentionDuration` are always available to subscribers. For instance, it allows any attached subscription to [seek to a timestamp](https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) that is up to `messageRetentionDuration` in the past. If this field is not set, message retention is controlled by settings on individual subscriptions. Cannot be more than 31 days or less than 10 minutes. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |
| `topic.state` | ``enum (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#State`)`` Output only. An output-only field indicating the state of the topic. |
| `topic.ingestionDataSourceSettings` | ``object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#IngestionDataSourceSettings`)`` Optional. Settings for ingestion from a data source into this topic. |
| `topic.messageTransforms[]` | ``object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/MessageTransform`)`` Optional. Transforms to be applied to messages published to the topic. Transforms are applied in the order specified. |
| `topic.tags` | `map (key: string, value: string)` Optional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing" See <https://{$universe.dns_names.final_documentation_domain}/pubsub/docs/tags> for more information on using tags with Pub/Sub resources. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |
| `updateMask` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#field-mask` format)`` Required. Indicates which fields in the provided topic to update. Must be specified and non-empty. Note that if `updateMask` contains "messageStoragePolicy" but the `messageStoragePolicy` is not set in the `topic` provided above, then the updated value is determined by the policy configured at the project or organization level. This is a comma-separated list of fully qualified names of fields. Example: `"user.displayName,photo"`. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#Topic`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/pubsub`
- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).