# Create Postcard — PostGrid Print & Mail

> Creates a new postcard in PostGrid. See the documentation

- Key: `postgrid-create-postcard`
- Type: Action (Write)
- Version: 0.0.3
- App: PostGrid Print & Mail (`postgrid`) — https://pipedream.com/apps/postgrid.md
- This page (HTML): https://pipedream.com/apps/postgrid/actions/create-postcard
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/postgrid/actions/create-postcard/create-postcard.mjs

## Description

Creates a new postcard in PostGrid. [See the documentation](https://docs.postgrid.com/#fe8c4cd6-7617-4023-9437-669fa847ccc1)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `to` | `string` | Yes | The id or contact object of the receiver. Options are loaded from the connected account. |
| `from` | `string` | Yes | The id or contact object of the sender. Options are loaded from the connected account. |
| `frontHTML` | `string` | Yes | The HTML content for the front of the postcard. |
| `backHTML` | `string` | Yes | The HTML content for the back of the postcard. |
| `size` | `string` | Yes | The size of the postcard. Must be one of either 6x4, 9x6 or 11x6. |
| `sendDate` | `string` | No | The desired date for the letter to be sent out. Example: 2023-02-16T15:40:35.873Z |
| `express` | `boolean` | No | Express shipping. |
| `description` | `string` | No | A description for the postcard. |
| `mailingClass` | `string` | No | Mailing class. Defaults to first_class. |

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

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: "postgrid-create-postcard",
  arguments: {
    to: "To",
    from: "From",
  },
})
```

**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: "postgrid-create-postcard",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    postgrid: { authProvisionId: "apn_xxxxxxx" },
    to: "To",
    from: "From",
  },
})

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": "postgrid-create-postcard",
    "configured_props": {
      "postgrid": { "authProvisionId": "apn_xxxxxxx" },
      "to": "To",
      "from": "From"
    }
  }'
```

---

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