# Create Room — Element

> Create a new room, optionally inviting other users to it right away. Returns the new room's ID, which can be passed into Send Message or Invite User. Set Room Alias Name to give the room a memorable local alias (e.g. thepub becomes…

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

## Description

Create a new room, optionally inviting other users to it right away. Returns the new room's ID, which can be passed into **Send Message** or **Invite User**. Set `Room Alias Name` to give the room a memorable local alias (e.g. `thepub` becomes `#thepub:matrix.org` on matrix.org). If you omit `Preset`, `Visibility` also picks join rules — `public` creates an openly-joinable room. [See the documentation](https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3createroom)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | No | The name to display for the room, e.g. Project Discussion. |
| `topic` | `string` | No | A short description of the room's purpose. |
| `roomAliasName` | `string` | No | Local part of the room alias to create on this homeserver, e.g. thepub becomes #thepub:matrix.org if you are on matrix.org. The alias becomes the room's canonical alias. Do not include the leading # or the :homeserver suffix. |
| `visibility` | `string` | No | Whether the room is published (public) to the homeserver's room directory or kept unlisted (private). Defaults to private. If preset is omitted, the server also uses this to pick join rules: public maps to public_chat (anyone can join) and private maps to private_chat (invite required). When preset is set, visibility only affects directory listing. |
| `preset` | `string` | No | Convenience preset that sets sensible defaults for the room's join rules and permissions. private_chat requires an invite to join and gives only the creator elevated permissions; trusted_private_chat also requires an invite but gives every invitee the same power level as the creator; public_chat lets anyone join without an invite. If omitted, the server infers this from visibility. |
| `roomVersion` | `string` | No | The Matrix room version to create, e.g. 12. Omit to use the homeserver's default. The server returns M_UNSUPPORTED_ROOM_VERSION if it does not support the requested version. |
| `invite` | `string[]` | No | Full Matrix IDs of users to invite to the room, e.g. ["@alice:matrix.org", "@bob:matrix.org"]. |
| `isDirect` | `boolean` | No | Mark this room as a direct message between the creator and the invited user(s), rather than a group room. |

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

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: "element-create-room",
  arguments: {
    name: "Name",
    topic: "Topic",
  },
})
```

**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: "element-create-room",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    element: { authProvisionId: "apn_xxxxxxx" },
    name: "Name",
    topic: "Topic",
  },
})

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": "element-create-room",
    "configured_props": {
      "element": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Name",
      "topic": "Topic"
    }
  }'
```

---

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