# Submit Sitemap — Google Search Console

> Submits a sitemap (or resubmits one already listed) to Google Search Console for a property, then reads the stored record back. Resubmitting is idempotent — it creates no duplicate, it updates lastSubmitted and sets isPending: true.

- Key: `google_search_console-submit-sitemap`
- Type: Action (Write)
- Version: 0.0.1
- App: Google Search Console (`google_search_console`) — https://pipedream.com/apps/google-search-console.md
- This page (HTML): https://pipedream.com/apps/google-search-console/actions/submit-sitemap
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/google_search_console/actions/submit-sitemap/submit-sitemap.mjs

## Description

Submits a sitemap (or resubmits one already listed) to Google Search Console for a property, then reads the stored record back. Resubmitting is idempotent — it creates no duplicate, it updates `lastSubmitted` and sets `isPending: true`.

**Use for** a new sitemap, or when the user wants Google to pick up new or changed pages on a site: resubmitting an existing sitemap is the SUPPORTED way to ask Google to re-read it.

**There is no API to request indexing of a single ordinary page.** The "Request indexing" button in the Search Console UI has no API equivalent, and the Indexing API behind **Submit URL for Indexing** covers only JobPosting and BroadcastEvent pages. So the two legitimate options are this tool (have Google re-read the sitemap containing the page) and **Inspect URLs** (check the page's current index status). Say that plainly rather than implying a page can be force-indexed — and when the user asks to request indexing or force a recrawl, OFFER those two options and wait for them to pick one; do not run either unasked.

**Returns** `{ submitted: true, sitemap, previous_last_submitted }`. The submit call itself returns an empty body, so `sitemap` is the record read back from Google immediately afterwards and is how you confirm it landed. `previous_last_submitted` is the `lastSubmitted` the sitemap had before this call, or `null` for a first submission — use it to tell a fresh submission from a resubmission. Right after a submit `isPending` is normally `true` and `lastDownloaded` still holds the old date (or is absent): Google fetches asynchronously, usually within minutes to days. So do NOT report a sitemap as "processed" or "indexed" on the strength of a successful submit.

**Mistakes.** `sitemapUrl` must be an absolute URL to the sitemap file (`https://www.example.com/sitemap.xml`) that lives under the property — not a page URL, a path (`/sitemap.xml`) or a property identifier. If the user has not given you a sitemap URL, ask for it rather than guessing a conventional path. Submitting is not indexing: Google may still choose not to index the URLs it finds. Do not delete and resubmit to "refresh" a sitemap — just resubmit. Requires `siteOwner` or `siteFullUser` (check with **List Sites**); a `siteRestrictedUser` gets 403.

[See the documentation](https://developers.google.com/webmaster-tools/v1/sitemaps/submit)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `siteUrl` | `string` | Yes | Exact property identifier from List Sites — sc-domain:example.com for a domain property, or a URL-prefix such as https://www.example.com/ (trailing slash; scheme and subdomain must match exactly, or the call 403s). Copy it verbatim, never construct it. For traffic questions prefer the domain property when one exists: it covers all subdomains and protocols. |
| `sitemapUrl` | `string` | Yes | Full URL of the sitemap or sitemap index, e.g. https://www.example.com/sitemap.xml. It must live under the property given in siteUrl (for a domain property, any subdomain or scheme qualifies). Use List Sitemaps for the exact paths Search Console already knows. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "google_search_console",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "google_search_console-submit-sitemap",
  arguments: {
    siteUrl: "Property (siteUrl)",
    sitemapUrl: "Sitemap URL",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "google_search_console-submit-sitemap",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    google_search_console: { authProvisionId: "apn_xxxxxxx" },
    siteUrl: "Property (siteUrl)",
    sitemapUrl: "Sitemap URL",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "google_search_console-submit-sitemap",
    "configured_props": {
      "google_search_console": { "authProvisionId": "apn_xxxxxxx" },
      "siteUrl": "Property (siteUrl)",
      "sitemapUrl": "Sitemap URL"
    }
  }'
```

---

- App: https://pipedream.com/apps/google-search-console.md · All apps: https://pipedream.com/apps
