# Create Lead — Teamgate

> Create a new lead. See the docs here

- Key: `teamgate-create-lead`
- Type: Action (Write)
- Version: 0.0.3
- App: Teamgate (`teamgate`) — https://pipedream.com/apps/teamgate.md
- This page (HTML): https://pipedream.com/apps/teamgate/actions/create-lead
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/teamgate/actions/create-lead/create-lead.mjs

## Description

Create a new lead. [See the docs here](https://developers.teamgate.com/#8921df2b-3158-4b16-b81c-c37c6414c20f)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | No | Required only if a lead is an person and companyName and companyId is empty. |
| `companyName` | `string` | No | Required only if a lead is an company and name is empty. The field will be set only if companyId is empty. |
| `companies` | `integer[]` | No | Required only if a lead is an company and name is empty. The field will be set only if companyName is empty. Options are loaded from the connected account. |
| `jobTitle` | `string` | No | The field will be set only if is set companyName or companyId. |
| `statusId` | `integer` | No | The lead Status Id Options are loaded from the connected account. |
| `status` | `string` | No | If the stauts does not exist it will be created. |
| `statusDescription` | `string` | No | Will be set only if will be created new status. |
| `starred` | `boolean` | No | Indicator the lead is starred or not. |
| `ownerId` | `integer` | No | The User`s id Options are loaded from the connected account. |
| `ownerUsername` | `string` | No | The username to which the lead belongs. |
| `ownerRandom` | `string` | No | A list of users/user groups to select the random owner. Example 1: "ownerRandom": ["5", "6"], Example 2: "ownerRandom": {"groups":["1"]}, Example 3: "ownerRandom": {"0":"5","1":"6","groups":["1"]} |
| `sourceId` | `integer` | No | The source`s id Options are loaded from the connected account. |
| `source` | `string` | No | If the source does not exist it will be created. |
| `sourceDescription` | `string` | No | Will be set only if will be created new source. |
| `industryId` | `integer` | No | The industry`s id Options are loaded from the connected account. |
| `industry` | `string` | No | If the industry does not exist it will be created. |
| `industryDescription` | `string` | No | Will be set only if will be created new industry. |
| `tags` | `string[]` | No | A list of tags |
| `emails` | `string[]` | No | A list of the company's emails. Example for string value: {"value":"john@example.net","type":"work"} Object format |
| `phones` | `string[]` | No | A list of the company's phones. Example for string value: {"value":"+44 123 456 7890","type":"mobile"} Object format |
| `urls` | `string[]` | No | A list of the company's urls. Example for string value: {"value":"https://facebook.com/example","type":"facebook"} Object format |
| `address` | `string[]` | No | A list of address objects. Example for string value: {"value":{"city":"Chicago","countryIso":"USA"}} Object format |
| `customFields` | `string[]` | No | A list of custom fields. Each row must be an object which the key is the custom field id. Example for string value: {"1":"Test value for field with Id 1"} |

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

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: "teamgate-create-lead",
  arguments: {
    name: "Name",
    companyName: "Company 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: "teamgate-create-lead",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    teamgate: { authProvisionId: "apn_xxxxxxx" },
    name: "Name",
    companyName: "Company 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": "teamgate-create-lead",
    "configured_props": {
      "teamgate": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Name",
      "companyName": "Company Name"
    }
  }'
```

---

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