# Create Scheduled Query — Google Cloud

> Creates a scheduled query in Google Cloud. See the documentation

- Key: `google_cloud-create-scheduled-query`
- Type: Action (Write)
- Version: 0.0.5
- App: Google Cloud (`google_cloud`) — https://pipedream.com/apps/google-cloud.md
- This page (HTML): https://pipedream.com/apps/google-cloud/actions/create-scheduled-query
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/google_cloud/actions/create-scheduled-query/create-scheduled-query.mjs

## Description

Creates a scheduled query in Google Cloud. [See the documentation](https://cloud.google.com/bigquery/docs/scheduling-queries)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `destinationDatasetId` | `string` | Yes | The name of the dataset to create the table in. If the dataset does not exist, it will be created. Options are loaded from the connected account. |
| `datasetRegion` | `string` | No | The geographic location where the dataset should reside. See the documentation here |
| `displayName` | `string` | Yes | The user-friendly display name for the transfer config. |
| `query` | `string` | Yes | The GoogleSQL query to execute. Eg. SELECT @run_time AS time, * FROM `my_dataset.my_table` LIMIT 1000. See the documentation here. |
| `schedule` | `string` | No | Data transfer schedule. If the data source does not support a custom schedule, this should be empty. If it is empty, the default value for the data source will be used. The specified times are in UTC. Examples of valid format: every 24 hours, 1st,3rd monday of month 15:30, every wed,fri of jan,jun 13:15, and first sunday of quarter 00:00. See more explanation about the format here. |
| `writeDisposition` | `string` | No | The write preference you select determines how your query results are written to an existing destination table. See the documentation here. |
| `destinationTableNameTemplate` | `string` | No | The destination table name template can contain template variables such as {run_date} or {run_time}. See the documentation here. |

## 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_cloud",
      },
    },
  },
)

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_cloud-create-scheduled-query",
  arguments: {
    destinationDatasetId: "Destination Dataset",
    datasetRegion: "Dataset Region",
  },
})
```

**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_cloud-create-scheduled-query",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    google_cloud: { authProvisionId: "apn_xxxxxxx" },
    destinationDatasetId: "Destination Dataset",
    datasetRegion: "Dataset Region",
  },
})

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_cloud-create-scheduled-query",
    "configured_props": {
      "google_cloud": { "authProvisionId": "apn_xxxxxxx" },
      "destinationDatasetId": "Destination Dataset",
      "datasetRegion": "Dataset Region"
    }
  }'
```

---

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