Method: projects.topics.create

Creates the given topic with the given name. See the resource name rules.

HTTP request

Path parameters



Required. Name of the topic. Format is projects/{project}/topics/{topic}.

Request body

The request body contains data with the following structure:

JSON representation
  "labels": {
    string: string,
  "messageStoragePolicy": {
    object (MessageStoragePolicy)
  "kmsKeyName": string,
  "schemaSettings": {
    object (SchemaSettings)
  "satisfiesPzs": boolean,
  "messageRetentionDuration": string,
  "state": enum (State),
  "ingestionDataSourceSettings": {
    object (IngestionDataSourceSettings)

map (key: string, value: string)

Optional. See Creating and managing labels.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.


object (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.



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/*.


object (SchemaSettings)

Optional. Settings for validating messages published against a schema.



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.


string (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 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".


enum (State)

Output only. An output-only field indicating the state of the topic.


object (IngestionDataSourceSettings)

Optional. Settings for ingestion from a data source into this topic.

Response body

If successful, the response body contains a newly created instance of Topic.

Authorization scopes

Requires one of the following OAuth scopes:


For more information, see the Authentication Overview.