# Create Contract from Template — fynk

> Create a new contract in Fynk based on an existing template. See the documentation.

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

## Description

Create a new contract in Fynk based on an existing template. [See the documentation](https://app.fynk.com/v1/docs#/operations/v1.documents.create-from-template).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `templateUuid` | `string` | Yes | The template to use as a basis for the new document Options are loaded from the connected account. |
| `name` | `string` | No | The new document's name. If omitted, the name of the template will be used as the new document's name |
| `ownerEmails` | `string[]` | No | Email addresses of the user(s) from your account who should be given ownership of the new document |

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

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: "fynk-create-contract-from-template",
  arguments: {
    templateUuid: "Template",
    name: "Name",
  },
})
```

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

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": "fynk-create-contract-from-template",
    "configured_props": {
      "fynk": { "authProvisionId": "apn_xxxxxxx" },
      "templateUuid": "Template",
      "name": "Name"
    }
  }'
```

---

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