Method: projects.topics.create Stay organized with collections Save and categorize content based on your preferences.
Creates the given topic with the given name. See theresource name rules.
HTTP request
Path parameters
| Parameters | |
|---|---|
name |
Required. Name of the topic. Format is |
Request body
The request body contains data with the following structure:
| JSON representation |
|---|
{"labels":{string:string,...},"messageStoragePolicy":{object ( |
| Fields | |
|---|---|
labels |
Optional. SeeCreating and managing labels. An object containing a list of |
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. |
kmsKeyName |
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 |
schemaSettings |
Optional. Settings for validating messages published against a schema. |
satisfiesPzs |
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. |
messageRetentionDuration |
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 A duration in seconds with up to nine fractional digits, ending with ' |
state |
Output only. An output-only field indicating the state of the topic. |
ingestionDataSourceSettings |
Optional. Settings for ingestion from a data source into this topic. |
messageTransforms[] |
Optional. Transforms to be applied to messages published to the topic. Transforms are applied in the order specified. |
Response body
If successful, the response body contains a newly created instance ofTopic.
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/pubsubhttps://www.googleapis.com/auth/cloud-platform
For more information, see theAuthentication Overview.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-22 UTC.