Method: projects.registrations.topicSubscriptions.create

Creates a TopicSubscription. Subscribes an app installation instance (by registration_id, either FID or FCM Token) to a topicSubscription. Returns a TopicSubscription if it is created successfully. If the subscription already exists, returns error of ALREADY_EXISTS.

HTTP request

POST https://fcm.googleapis.com/v1/{parent=projects/*/registrations/*}/topicSubscriptions

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
parent

string

Required. The parent resource where this subscription will be created. Format: projects/{project}/registrations/{registration} The {registration} part can be an FID or an FCM Token.

Query parameters

Parameters
topicName

string

Required. The ID to use for the subscription, which is the topic name. This will become the last segment of the TopicSubscription's resource name. Topic names match the pattern of "[a-zA-Z0-9-_.~%]{1,900}".

Request body

The request body contains an instance of TopicSubscription.

Response body

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

Authorization scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/firebase.messaging
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the OAuth 2.0 Overview.

IAM Permissions

Requires the following IAM permission on the parent resource:

  • cloudmessaging.topicSubscriptions.create

For more information, see the IAM documentation.