Follow these steps:
Step 1: Create a Service Account
- Go to the Google Cloud Console.
- Navigate to IAM & Admin > Service accounts.
- Click Create Service Account.
- Follow the prompts to create a new service account.
Step 2: Enable the Search Console API
- Go to the Google Cloud Console.
- Navigate to APIs & Services > Dashboard.
- Click Enable APIs and Services.
- Search for “Search Console API” and click on the result.
- Click Enable.
Step 3: Create Credentials for the Service Account
- Go to the Google Cloud Console.
- Navigate to IAM & Admin > Service accounts.
- Find the service account you created earlier.
- Click on the three vertical dots next to the service account and select Create key.
- Select JSON as the key type and click Create.
Step 4: Configure the Service Account for Search Console
- Go to the Google Search Console.
- Navigate to Settings > Users & permissions.
- Click Add user.
- Enter the service account email address.
- Select Full permissions.
- Click Add.
Step 5: Create a Cloud Scheduler Job
- Go to the Google Cloud Console.
- Navigate to Cloud Scheduler.
- Click Create job.
- Enter a name and description for the job.
- Set the Frequency to your desired schedule (e.g., daily).
- Set the Target to HTTP.
- Set HTTP Method to PUT
- Enter the URL for submitting the sitemap: https://www.googleapis.com/webmasters/v3/sites/https%3A%2F%2Fexample.com/sitemaps/https%3A%2F%2Fexample.com%2Fsitemap.xml
- Replace
1https%3A%2F%2Fexample.com
and
1https%3A%2F%2Fexample.com%2Fsitemap.xmlwith your site URL and sitemap URL.
- Make sure to encode the site URL and sitemap URL like in the example link above, otherwise it wont work.
- Replace
- Set the HTTP Method to POST.
- Add a Header with key Content-Type and value application/json.
- Add a Body with the following JSON data:
{
“siteUrl”: “https://example.com”,
“sitemapUrl”: “https://example.com/sitemap.xml”
}
Replace (link unavailable) with your actual website URL.
Step 6: Authenticate the Cloud Scheduler Job
- Go to the Google Cloud Console.
- Navigate to Cloud Scheduler.
- Find the job you created earlier.
- Click on the three vertical dots next to the job and select Edit.
- Scroll down to the Authentication section.
- Select Service account.
- Enter the service account email address.
- Click Save.
The Cloud Scheduler job will now submit your sitemap to Google Search Console using the service account.