# Create Editor Session — CraftMyPDF

> Create a new PDF editor session. The PDF editor url can be embedded into an IFrame. See the documentation

- Key: `craftmypdf-create-editor-session`
- Type: Action (Write)
- Version: 0.0.3
- App: CraftMyPDF (`craftmypdf`) — https://pipedream.com/apps/craftmypdf.md
- This page (HTML): https://pipedream.com/apps/craftmypdf/actions/create-editor-session
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/craftmypdf/actions/create-editor-session/create-editor-session.mjs

## Description

Create a new PDF editor session. The PDF editor url can be embedded into an IFrame. [See the documentation](https://craftmypdf.com/docs/index.html#tag/Template-Management-API/operation/delete-template)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `templateId` | `string` | Yes | The Id of the template. Options are loaded from the connected account. |
| `expiration` | `integer` | Yes | Expiration of the generated PDF in minutes. Default to 5 minutes. Range between 1 minute and 24 hours. |
| `canSave` | `boolean` | No | Can save the template. Default to true. |
| `canCreatePDF` | `boolean` | No | Can Generate PDF. Default to true. |
| `canViewSettings` | `boolean` | No | Can view settings. Default to true. |
| `canPreview` | `boolean` | No | Can preview. Default to true. |
| `canEditJSON` | `boolean` | No | Can edit JSON. Default to true. |
| `canShowHeader` | `boolean` | No | Show CraftMyPDF header. Default to true. |
| `canShowLayers` | `boolean` | No | Show layer dialogue. Default to true. |
| `canShowPropertyPanel` | `boolean` | No | Show property panel. Default to true. |
| `canShowHelp` | `boolean` | No | Show Help tab. Default to true. |
| `canShowData` | `boolean` | No | Show Data tab. Default to true. |
| `canShowExpressionDoc` | `boolean` | No | Show Expression Doc tab. Default to true. |
| `canShowPropertyBinding` | `boolean` | No | Show Property Bind tab for element. Default to true. |
| `canShowBackURL` | `boolean` | No | Show BackURL button. Default to true. |
| `jsonMode` | `integer` | No | JSON editor - 1, JSON viewer - 2. |
| `backURL` | `string` | No | The URL for the back button |

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

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: "craftmypdf-create-editor-session",
  arguments: {
    templateId: "Template Id",
    expiration: 10,
  },
})
```

**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: "craftmypdf-create-editor-session",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    craftmypdf: { authProvisionId: "apn_xxxxxxx" },
    templateId: "Template Id",
    expiration: 10,
  },
})

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": "craftmypdf-create-editor-session",
    "configured_props": {
      "craftmypdf": { "authProvisionId": "apn_xxxxxxx" },
      "templateId": "Template Id",
      "expiration": 10
    }
  }'
```

---

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