# Create Document From Template — PandaDoc

> Create a Document from a PandaDoc Template. See the documentation here

- Key: `pandadoc-create-document-from-template`
- Type: Action (Write)
- Version: 0.0.10
- App: PandaDoc (`pandadoc`) — https://pipedream.com/apps/pandadoc.md
- This page (HTML): https://pipedream.com/apps/pandadoc/actions/create-document-from-template
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/pandadoc/actions/create-document-from-template/create-document-from-template.mjs

## Description

Create a Document from a PandaDoc Template. [See the documentation here](https://developers.pandadoc.com/reference/create-document-from-pandadoc-template)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | Yes | Specify the document's name. |
| `templateId` | `string` | Yes | The ID of a template you want to use. Note: if you want to prefill fields in your template, you need to map your template fields to the API fields following the instruction here Options are loaded from the connected account. |
| `documentFolderId` | `string` | No | Specify the document folder ID Options are loaded from the connected account. |
| `tags` | `string[]` | No | Mark your document with one or several tags. |
| `recipients` | `string[]` | Yes | The list of recipients you're sending the document to. Every object must contain the email parameter. The role, first_name and last_name parameters are optional. If the role parameter passed, a person is assigned all fields matching their corresponding role. If not passed, a person will receive a read-only link to view the document. If the first_name and last_name not passed the system: 1. creates a new contact, if none exists with the given email; or 2. gets the existing contact with the given email that already exists. E.g. { "email": "john.doe@pipedream.com", "first_name": "John", "last_name": "Doe", "role": "user" } |
| `tokens` | `string[]` | No | You may pass a list of tokens/values to pre-fill tokens (variables) used in a template. Name is a token (variable) name in a template. Value is a real value you would like to replace a token (variable) with. E.g. { "name": "Favorite.Pet", "value": "Dog Doe" } |

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

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: "pandadoc-create-document-from-template",
  arguments: {
    name: "Document Name",
    templateId: "Template Id",
  },
})
```

**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: "pandadoc-create-document-from-template",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    pandadoc: { authProvisionId: "apn_xxxxxxx" },
    name: "Document Name",
    templateId: "Template Id",
  },
})

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": "pandadoc-create-document-from-template",
    "configured_props": {
      "pandadoc": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Document Name",
      "templateId": "Template Id"
    }
  }'
```

---

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