# Create Text File — Google Drive

> Create a new Google Doc from text content in Google Drive. The file is created as a Google Docs document, which can be viewed and edited in the browser. Use this when the user asks to create a document, write a file, or save text to Drive…

- Key: `google_drive-create-text-file`
- Type: Action (Write)
- Version: 0.0.4
- App: Google Drive (`google_drive`) — https://pipedream.com/apps/google-drive.md
- This page (HTML): https://pipedream.com/apps/google-drive/actions/create-text-file
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/google_drive/actions/create-text-file/create-text-file.mjs

## Description

Create a new Google Doc from text content in Google Drive. The file is created as a Google Docs document, which can be viewed and edited in the browser. Use this when the user asks to create a document, write a file, or save text to Drive. To place the file in a specific folder, pass the `parentId` — use **Search Files** with `mimeType = 'application/vnd.google-apps.folder'` to find the folder ID first. Supported content formats: plain text, Markdown, HTML, Rich Text, CSV. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/create)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | Yes | The name of the new file (e.g., 'Meeting Notes', 'Project Plan'). |
| `content` | `string` | No | The text content of the file. |
| `mimeType` | `string` | No | The format of the content being provided. Defaults to plain text. |
| `parentId` | `string` | No | The ID of the folder to create the file in. Use Search Files with mimeType = 'application/vnd.google-apps.folder' to find folder IDs. Omit to create in the root of My Drive. |

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

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_drive-create-text-file",
  arguments: {
    name: "File Name",
    content: "Content",
  },
})
```

**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_drive-create-text-file",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    google_drive: { authProvisionId: "apn_xxxxxxx" },
    name: "File Name",
    content: "Content",
  },
})

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_drive-create-text-file",
    "configured_props": {
      "google_drive": { "authProvisionId": "apn_xxxxxxx" },
      "name": "File Name",
      "content": "Content"
    }
  }'
```

---

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