# Create Send — Twilio SendGrid

> Create a single send. See the docs here

- Key: `sendgrid-create-send`
- Type: Action (Write)
- Version: 0.0.3
- App: Twilio SendGrid (`sendgrid`) — https://pipedream.com/apps/sendgrid.md
- This page (HTML): https://pipedream.com/apps/sendgrid/actions/create-send
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/sendgrid/actions/create-send/create-send.mjs

## Description

Create a single send. [See the docs here](https://www.twilio.com/docs/sendgrid/api-reference/single-sends/create-single-send)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | Yes | The name of the Single Send. |
| `categoryIds` | `string[]` | No | The categories to associate with this Single Send. Options are loaded from the connected account. |
| `sendAt` | `string` | No | Set this property to an ISO 8601 formatted date-time (YYYY-MM-DDTHH:MM:SSZ) when you would like to send the Single Send. Please note that any send_at property value set with this endpoint will prepopulate the send date in the SendGrid user interface (UI). However, the Single Send will remain an unscheduled draft until it's updated with the Schedule Single Send endpoint or SendGrid application UI. Setting this property to now with this endpoint will cause an error. |
| `listIds` | `string[]` | No | The recipient List IDs that will receive the Single Send. Options are loaded from the connected account. |
| `segmentIds` | `string[]` | No | The recipient Segment IDs that will receive the Single Send. Options are loaded from the connected account. |
| `all` | `boolean` | Yes | Set to true to send to All Contacts. If set to false, at least one List Ids or Segment Ids value must be provided before the Single Send is scheduled to be sent to recipients. |
| `subject` | `string` | No | The subject line of the Single Send. Do not include this field when using a Design Id. |
| `htmlContent` | `string` | No | The HTML content of the Single Send. Do not include this field when using a Design Id. |
| `plainContent` | `string` | No | The plain text content of the Single Send. Do not include this field when using a Design Id. |
| `generatePlainContent` | `boolean` | No | If set to true, Plain Content is always generated from HTML Content. If set to false, Plain Content is not altered. |
| `designId` | `string` | No | A design id can be used in place of HTML Content, Plain Content, and/or Subject. Options are loaded from the connected account. |
| `editor` | `string` | No | The editor is used to modify the Single Send's design in the Marketing Campaigns App. |
| `suppressionGroupId` | `integer` | No | Advanced Suppression Manager Group ID. The unsubscribe group to associate with this email. Will override the value set in the asm param if also set Options are loaded from the connected account. |
| `customUnsubscribeUrl` | `string` | No | The URL allowing recipients to unsubscribe — you must provide this or the Suppression Group Id. |
| `senderId` | `string` | No | The ID of the verified Sender. Options are loaded from the connected account. |
| `ipPool` | `string` | No | The name of the IP Pool from which the Single Send emails are sent. |

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

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: "sendgrid-create-send",
  arguments: {
    name: "Name",
    categoryIds: ["Categories"],
  },
})
```

**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: "sendgrid-create-send",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    sendgrid: { authProvisionId: "apn_xxxxxxx" },
    name: "Name",
    categoryIds: ["Categories"],
  },
})

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": "sendgrid-create-send",
    "configured_props": {
      "sendgrid": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Name",
      "categoryIds": ["Categories"]
    }
  }'
```

---

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