This page explains how to reactivate a suspended Google Workspace subscription
by resolving or troubleshooting errors and calling the
Google Workspace subscriptions are suspended whenever an error prevents the subscription from receiving events. For example, a subscription is suspended when its target resource or notification endpoint can't be found. After you resolve any errors with the subscription, you can reactivate the subscription to start receiving events again.
You can learn about a suspended subscription in the following ways:
- Your app receives a lifecycle event about the suspension. If your subscription is suspended due to an error with its endpoint, you might not receive a lifecycle event.
- You use the
subscriptions.list()methods to see whether the subscription's
statefield is set to
- You're notified about a delivery failure to your notification endpoint. To learn about monitoring delivery failures to Google Cloud Pub/Sub topics, see Handle message failures.
Reactivated subscriptions maintain the original expiration date. To extend the expiration time of a subscription, see Update or renew a subscription.
- Python 3.6 or greater
- The pip package management tool
- A Google Workspace subscription. To create one, see Create a subscription.
Requires user authentication with one or more scopes that support all event types for the subscription.
Generate an API key
For Developer Preview, you use a non-public version of the Google Workspace Events API's discovery document. To access this discovery document when you call the API, you must pass an API key in your request to authenticate as your app. You use this key in the code sample later in this guide.
To create an API key, open the Google Cloud project for your app and do the following
- In the Google Cloud console, go to Menu > APIs & Services > Credentials.
- Click Create credentials > API key.
- Your new API key is displayed.
- Click Copy to copy your API key for use in your app's code. The API key can also be found in the "API keys" section of your project's credentials.
- Click Restrict key to update advanced settings and limit use of your API key. For more details, see Applying API key restrictions.
Identify and resolve errors
To identify the error for a subscription, review the subscription's
suspensionReason field. You can find this field when you receive a
lifecycle event about the suspension,
or by using the
subscriptions.get() method to review all fields for the
The following table displays possible errors for a subscription and, when possible, how to resolve the errors. If you can't resolve the error, you can delete the subscription, or wait for it to expire. The Google Workspace Events API deletes expired subscriptions automatically.
|Error||Description||Ways to resolve|
||The authorizing user has revoked the grant of one or more OAuth scopes that are required for the subscription.||Obtain another access token. For details, see Obtain an access token from the Google Authorization Server.|
||The target resource for the subscription is deleted.||If the resource is restored, call the
||The authorizing user no longer has access to the resource for the subscription.||No action required. You can't reactivate the subscription, as the user who authorized it can't access the target resource.|
||The Google Workspace application doesn't have access to deliver events to your notification endpoint.||Grant access to the service account for the Google Workspace
application that delivers events.
For Google Chat events, the service account is
For Pub/Sub topics, grant the role of Pub/Sub Publisher (
||The notification endpoint doesn't exist or can't be found.||Check that the endpoint is still active and working. To troubleshoot Pub/Sub topics, see the Troubleshooting documentation.|
||The notification endpoint failed to receive events due to insufficient quota or reaching rate limiting.||Request a quota increase.|
Reactivate a subscription
After you've resolved the error that suspended your subscription, you can use
reactivate() method to let the subscription receive events again. The
method checks that all errors are resolved and changes your subscription's
state field from
To reactivate a Google Workspace subscription:
In your working directory, create a file named
reactivate_subscription.pyand add the following code:
"""Reactivate subscription.""" from google_auth_oauthlib.flow import InstalledAppFlow from googleapiclient.discovery import build # Specify required scopes. SCOPES = [SCOPES] # Authenticate with Google Workspace and get user authentication. flow = InstalledAppFlow.from_client_secrets_file('client_secrets.json', SCOPES) CREDENTIALS = flow.run_local_server() # Call the Workspace Events API using the service endpoint. DISCOVERY_SERVICE_URL = 'https://workspaceevents.googleapis.com/$discovery/rest?version=v1beta&labels=DEVELOPER_PREVIEW&key=API_KEY' service = build( 'workspaceevents', 'v1beta', credentials=CREDENTIALS, discoveryServiceUrl=DISCOVERY_SERVICE_URL, ) NAME = 'subscriptions/SUBSCRIPTION_ID' response = service.subscriptions().reactivate(name=NAME).execute() print(response)
Replace the following:
SCOPES: One or more OAuth scopes that support each event type for the subscription. Formatted as an array of strings. To list multiple scopes, separate by commas. For example,
API_KEY: The API key that you generated for the Google Workspace Events API.
SUBSCRIPTION_ID: The ID of the subscription. To get the ID, you can use any of the following:
In your working directory, make sure you've stored your OAuth client ID credentials and named the file
client_secrets.json. The code sample uses this JSON file to authenticate with Google Workspace and get user credentials. For instructions, see Create OAuth client ID credentials.
To reactivate the Google Workspace subscription, run the following in your terminal:
If successful, the Google Workspace Events API returns a completed
long-running operation that
contains the instance of the
Subscription resource that you reactivated.
If the request fails, see the following section to troubleshoot additional errors.
Troubleshoot multiple errors
If you have resolved the error that suspended the subscription and the
reactivate() method fails, another error might have occurred after your
subscription was suspended.
To identify additional errors, review the output from the failed request. The output contains any errors that are still present.
When your subscription has multiple errors, the value for the
suspensionReason field always uses the original error that suspended your