# Create Link — Dub

> Creates a link. See the documentation

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

## Description

Creates a link. [See the documentation](https://dub.co/docs/api-reference/endpoint/create-a-new-link)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `projectSlug` | `string` | Yes | The slug for the project to create links for Options are loaded from the connected account. |
| `domain` | `string` | Yes | The domain of the short link Options are loaded from the connected account. |
| `url` | `string` | Yes | The destination URL of the short link |
| `password` | `string` | No | The password required to access the destination URL of the short link |
| `publicStats` | `boolean` | Yes | Whether the short link's stats are publicly accessible |
| `comments` | `string` | No | The comments for the short link |

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

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: "dub-create-link",
  arguments: {
    projectSlug: "Project slug",
    domain: "Domain",
  },
})
```

**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: "dub-create-link",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    dub: { authProvisionId: "apn_xxxxxxx" },
    projectSlug: "Project slug",
    domain: "Domain",
  },
})

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": "dub-create-link",
    "configured_props": {
      "dub": { "authProvisionId": "apn_xxxxxxx" },
      "projectSlug": "Project slug",
      "domain": "Domain"
    }
  }'
```

---

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