# Create Postcard — Lob

> Creates a new postcard given information. See docs here.

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

## Description

Creates a new postcard given information. [See docs here](https://docs.lob.com/#tag/Postcards/operation/postcard_create).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `description` | `string` | Yes | An internal description that identifies this resource |
| `to` | `string` | Yes | Must either be an addressId or an inline object with correct address parameters Options are loaded from the connected account. |
| `front` | `string` | Yes | The artwork to use as the front of your postcard. May be a templateId or a HTML string. HTML Examples |
| `back` | `string` | Yes | The artwork to use as the back of your postcard. May be a templateId or a HTML string. Be sure to leave room for address and postage information as in this example template. |
| `size` | `string` | Yes | Specifies the size of the postcard. Only 4x6 postcards can be sent to international destinations |
| `mailType` | `string` | Yes | The mail postage type: usps_first_class (default) or usps_standard - a cheaper option which is less predictable and takes longer to deliver |
| `mergeVariables` | `object` | No | An object for substituting variables to render dynamic content in your template. Merge Variables Guide |
| `sendDate` | `string` | No | A timestamp in ISO 8601 format which specifies a date after the current time and up to 180 days in the future to send the letter off for production. Until the send_date has passed, the mailpiece can be canceled |
| `from` | `string` | No | 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. |

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

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

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

---

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