# Create Draft — Gmail

> Create an unsent draft in the authenticated Gmail account. Same parameter shape as Send Email — the difference is the message is saved to Drafts instead of being sent. For a reply-draft, pass inReplyToMessageId (from Find Emails / Get…

- Key: `gmail-create-draft`
- Type: Action (Write)
- Version: 0.2.3
- App: Gmail (`gmail`) — https://pipedream.com/apps/gmail.md
- This page (HTML): https://pipedream.com/apps/gmail/actions/create-draft
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/gmail/actions/create-draft/create-draft.mjs

## Description

Create an unsent draft in the authenticated Gmail account. Same parameter shape as **Send Email** — the difference is the message is saved to Drafts instead of being sent. For a reply-draft, pass `inReplyToMessageId` (from **Find Emails** / **Get Thread**); the subject, `References`, `In-Reply-To`, and `threadId` are derived from the referenced message. `bodyType` controls whether `body` is treated as plain text (default) or HTML. To draft to yourself, pass `"me"` in `to` — the action resolves it to the authenticated user's email address. No pre-call to **Get Current User** required. Attachments use `file-ref` inputs and require matching `attachmentFilenames[]` entries. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.drafts/create).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `to` | `string[]` | No | Recipient email addresses. Pass "me" to draft to yourself — the action resolves it to the authenticated user's email address. |
| `cc` | `string[]` | No | Cc recipient email addresses. Pass "me" to include yourself. |
| `bcc` | `string[]` | No | Bcc recipient email addresses. Pass "me" to include yourself. |
| `subject` | `string` | No | Subject line. When inReplyToMessageId is set, the subject is derived from the replied-to message with Re: prefixed and this value is ignored. |
| `body` | `string` | Yes | Include an email body as either plain text or HTML. If HTML, make sure to set the "Body Type" prop to html. |
| `bodyType` | `string` | No | Choose to send as plain text or HTML. Defaults to plaintext. |
| `fromName` | `string` | No | Specify the name that will be displayed in the "From" section of the email. |
| `fromEmail` | `string` | No | Specify the email address that will be displayed in the "From" section of the email. Options are loaded from the connected account. |
| `replyTo` | `string` | No | Specify the email address that will appear on the "Reply-To" field, if different than the sender's email. |
| `inReplyToMessageId` | `string` | No | To send this email as a reply, pass the id of any message in the target thread (from Find Emails or Get Thread). The action will preserve References/In-Reply-To headers, thread correctly, and auto-prefix Re: on the subject. |
| `replyAll` | `boolean` | No | When inReplyToMessageId is set, fan-out recipients to the original From/To/Cc (minus the user's own address). Ignored when inReplyToMessageId is blank. |
| `attachmentFilenames` | `string[]` | No | Filenames for each attached file (include the extension, e.g. report.pdf, dna.txt). Must be the same length as attachments — index i in this list pairs with index i in attachments. |
| `attachments` | `string[]` | No | Files to attach. Each entry is either a public URL or a path under /tmp (e.g. /tmp/dna.txt). Must be the same length as attachmentFilenames — index i here pairs with index i there. |
| `syncDir` | `dir` | No | SyncDir |

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

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: "gmail-create-draft",
  arguments: {
    to: ["To"],
    cc: ["Cc"],
  },
})
```

**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: "gmail-create-draft",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    gmail: { authProvisionId: "apn_xxxxxxx" },
    to: ["To"],
    cc: ["Cc"],
  },
})

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": "gmail-create-draft",
    "configured_props": {
      "gmail": { "authProvisionId": "apn_xxxxxxx" },
      "to": ["To"],
      "cc": ["Cc"]
    }
  }'
```

---

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