# Create Letter — Lob

> Creates a new letter. See docs here.

- Key: `lob-create-letter`
- Type: Action (Write)
- Version: 0.0.3
- App: Lob (`lob`) — https://pipedream.com/apps/lob.md
- This page (HTML): https://pipedream.com/apps/lob/actions/create-letter
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/lob/actions/create-letter/create-letter.ts

## Description

Creates a new letter. [See docs here](https://docs.lob.com/#tag/Letters/operation/letter_create).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `to` | `string` | Yes | Must either be an addressId or an inline object with correct address parameters Options are loaded from the connected account. |
| `description` | `string` | Yes | An internal description that identifies this resource |
| `from` | `string` | Yes | Required if to address is international. Must either be an addressId or an inline object with correct address parameters Options are loaded from the connected account. |
| `name` | `string` | No | Name of the recipient. |
| `company` | `string` | No | Company name associated with the recipient. |
| `email` | `string` | No | Email address of the recipient. |
| `phone` | `string` | No | Phone number of the recipient. |
| `addressLine1` | `string` | No | First line of the address. |
| `addressLine2` | `string` | No | Second line of the address. |
| `addressCity` | `string` | No | City of the address. |
| `addressState` | `string` | No | State of the address. |
| `addressZip` | `string` | No | ZIP code of the address. |
| `addressCountry` | `string` | No | Country of the address. |
| `file` | `string` | Yes | Letter content in HTML |
| `color` | `boolean` | Yes | Set to true if you want to print in color; set to false for black and white. |
| `useType` | `string` | Yes | The use type of the mail. It can only be null if an account default use_type is selected). |
| `mailType` | `string` | No | Designates the mail postage type. |
| `sendDate` | `string` | No | Specifies the date to send the letter off for production (ISO 8601 format, up to 180 days in the future). |

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

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: "lob-create-letter",
  arguments: {
    to: "To",
    description: "Description",
  },
})
```

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

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": "lob-create-letter",
    "configured_props": {
      "lob": { "authProvisionId": "apn_xxxxxxx" },
      "to": "To",
      "description": "Description"
    }
  }'
```

---

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