# Create Document — Docupilot

> Create a document See docs here

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

## Description

Create a document [See docs here](https://help.docupilot.app/create-document/api-and-webhook-integration#api-integration)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `templateUrl` | `string` | Yes | Choose a template in the Docupilot dashboard, and go to the Create tab, then to API integrations. Copy the POST Merge URL here. Example: https://api.docupilot.app/documents/create/46ac75c3/5e7d03ec |
| `tokens` | `object` | Yes | The tokens used in this template (as object keys) and their values. Objects and arrays should be in JSON-stringified format. If you need to include characters such as {}[] in a value, and it should not be parsed as an object or array, prefix the key with $. |

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

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: "docupilot-create-document",
  arguments: {
    templateUrl: "Template URL",
    tokens: "Template Tokens",
  },
})
```

**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: "docupilot-create-document",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    docupilot: { authProvisionId: "apn_xxxxxxx" },
    templateUrl: "Template URL",
    tokens: "Template Tokens",
  },
})

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": "docupilot-create-document",
    "configured_props": {
      "docupilot": { "authProvisionId": "apn_xxxxxxx" },
      "templateUrl": "Template URL",
      "tokens": "Template Tokens"
    }
  }'
```

---

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