How to use Cloud Scheduler API to submit your sitemap.xml to Google Search Console using a Service Account

Follow these steps:

Step 1: Create a Service Account

  1. Go to the Google Cloud Console.
  2. Navigate to IAM & Admin > Service accounts.
  3. Click Create Service Account.
  4. Follow the prompts to create a new service account.

Step 2: Enable the Search Console API

  1. Go to the Google Cloud Console.
  2. Navigate to APIs & Services > Dashboard.
  3. Click Enable APIs and Services.
  4. Search for “Search Console API” and click on the result.
  5. Click Enable.

Step 3: Create Credentials for the Service Account

  1. Go to the Google Cloud Console.
  2. Navigate to IAM & Admin > Service accounts.
  3. Find the service account you created earlier.
  4. Click on the three vertical dots next to the service account and select Create key.
  5. Select JSON as the key type and click Create.

Step 4: Configure the Service Account for Search Console

  1. Go to the Google Search Console.
  2. Navigate to Settings > Users & permissions.
  3. Click Add user.
  4. Enter the service account email address.
  5. Select Full permissions.
  6. Click Add.

Step 5: Create a Cloud Scheduler Job

  1. Go to the Google Cloud Console.
  2. Navigate to Cloud Scheduler.
  3. Click Create job.
  4. Enter a name and description for the job.
  5. Set the Frequency to your desired schedule (e.g., daily).
  6. Set the Target to HTTP.
  7. Set HTTP Method to PUT
  8. 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
      1
      https%3A%2F%2Fexample.com

      and

      1
      https%3A%2F%2Fexample.com%2Fsitemap.xml

      with 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.
  9. Set the HTTP Method to POST.
  10. Add a Header with key Content-Type and value application/json.
  11. 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

  1. Go to the Google Cloud Console.
  2. Navigate to Cloud Scheduler.
  3. Find the job you created earlier.
  4. Click on the three vertical dots next to the job and select Edit.
  5. Scroll down to the Authentication section.
  6. Select Service account.
  7. Enter the service account email address.
  8. Click Save.

The Cloud Scheduler job will now submit your sitemap to Google Search Console using the service account.

Post Created 3

Leave a Reply

Related Posts

Begin typing your search above and press enter to search. Press ESC to cancel.

Back To Top