# Mail Postcard — DocuPost

> Dispatches a glossy, color 4x6 postcard via the US Postal Service. See the documentation

- Key: `docupost-mail-postcard`
- Type: Action (Write)
- Version: 0.0.3
- App: DocuPost (`docupost`) — https://pipedream.com/apps/docupost.md
- This page (HTML): https://pipedream.com/apps/docupost/actions/mail-postcard
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/docupost/actions/mail-postcard/mail-postcard.mjs

## Description

Dispatches a glossy, color 4x6 postcard via the US Postal Service. [See the documentation](https://help.docupost.com/help/send-postcard-api)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `frontImage` | `string` | Yes | A valid image URL for the front of your postcard. Image should be 1875 x 1275. PNG recommended. Your API request will succeed but your mailing will later fail if the image is the incorrect size. |
| `backImage` | `string` | Yes | A valid image URL for the back of your postcard. Image should be 1875 x 1275. PNG recommended. Your API request will succeed but your mailing will later fail if the image is the incorrect size. Important: Your recipient/sender and postage information will be automatically overlaid onto your image. See this template as an example. |
| `toName` | `string` | Yes | The name of the recipient (who the letter/postcard is being sent to). Must be less than 40 characters. |
| `toAddress1` | `string` | Yes | The first line of the recipient's address. |
| `toAddress2` | `string` | No | The second line of the recipient's address. |
| `toCity` | `string` | Yes | The city of the recipient. |
| `toState` | `string` | Yes | The 2-letter abbreviation code for the recipient's U.S. state. |
| `toZip` | `string` | Yes | The 5-digit postal code for the recipient. |
| `fromName` | `string` | Yes | Your sender/return address name. Must be less than 40 characters. |
| `fromAddress1` | `string` | Yes | The first line of your sender/return address. |
| `fromAddress2` | `string` | No | The second line of your sender/return address. |
| `fromCity` | `string` | Yes | The city of your sender/return address. |
| `fromState` | `string` | Yes | The 2-letter abbreviation code for your sender's U.S. state. |
| `fromZip` | `string` | Yes | The 5-digit postal code for your sender/return address. |

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

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: "docupost-mail-postcard",
  arguments: {
    frontImage: "Front Image URL",
    backImage: "Back Image URL",
  },
})
```

**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: "docupost-mail-postcard",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    docupost: { authProvisionId: "apn_xxxxxxx" },
    frontImage: "Front Image URL",
    backImage: "Back Image URL",
  },
})

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": "docupost-mail-postcard",
    "configured_props": {
      "docupost": { "authProvisionId": "apn_xxxxxxx" },
      "frontImage": "Front Image URL",
      "backImage": "Back Image URL"
    }
  }'
```

---

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