# Create Document From File — PandaDoc

> Create a document from a file or public file URL. See the documentation here

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

## Description

Create a document from a file or public file URL. [See the documentation here](https://developers.pandadoc.com/reference/create-document-from-pdf)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | Yes | Specify the document's name. |
| `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" } |
| `file` | `string` | Yes | The file to upload. Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.txt) |
| `documentFolderId` | `string` | No | Specify the document folder ID Options are loaded from the connected account. |
| `fields` | `string` | No | A fields object containing fields to add to the document. See the documentation for more information about fields. E.g. { "name": { "value": "Jane", "role": "user" }, "like": { "value": true, "role": "user" } } |
| `syncDir` | `dir` | No | SyncDir |

## 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-file",
  arguments: {
    name: "Document Name",
    recipients: ["Recipients"],
  },
})
```

**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-file",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    pandadoc: { authProvisionId: "apn_xxxxxxx" },
    name: "Document Name",
    recipients: ["Recipients"],
  },
})

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-file",
    "configured_props": {
      "pandadoc": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Document Name",
      "recipients": ["Recipients"]
    }
  }'
```

---

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