# Mail Letter — DocuPost

> Sends a physical letter via USPS first class mail. See the documentation

- Key: `docupost-mail-letter`
- 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-letter
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/docupost/actions/mail-letter/mail-letter.mjs

## Description

Sends a physical letter via USPS first class mail. [See the documentation](https://help.docupost.com/help/send-letter-api)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `pdf` | `string` | Yes | A valid PDF URL for the letter content. 10mb max. 8.5x11 recommended. |
| `color` | `boolean` | No | Whether the document should be in color. true or false. Defaults to false. |
| `doublesided` | `string` | No | Whether the document should be printed double-sided. true or false. Defaults to true. |
| `mailingClass` | `string` | No | Must be usps_first_class or usps_standard. Defaults to usps_first_class. |
| `servicelevel` | `string` | No | Only available for usps_first_class mailings. Should be blank for non-certified, or certified or certified_return_receipt. |
| `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-letter",
  arguments: {
    pdf: "PDF URL",
    color: true,
  },
})
```

**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-letter",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    docupost: { authProvisionId: "apn_xxxxxxx" },
    pdf: "PDF URL",
    color: true,
  },
})

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-letter",
    "configured_props": {
      "docupost": { "authProvisionId": "apn_xxxxxxx" },
      "pdf": "PDF URL",
      "color": true
    }
  }'
```

---

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