# Invite User — Brex

> Invites a person to the Brex account as an employee, emailing them to finish onboarding. Returns the new Brex user ID, which Create Card, Set Limit for User, and Get User take. See the documentation

- Key: `brex-invite-user`
- Type: Action (Write)
- Version: 0.1.3
- App: Brex (`brex`) — https://pipedream.com/apps/brex.md
- This page (HTML): https://pipedream.com/apps/brex/actions/invite-user
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/brex/actions/invite-user/invite-user.mjs

## Description

Invites a person to the Brex account as an employee, emailing them to finish onboarding. Returns the new Brex user ID, which **Create Card**, **Set Limit for User**, and **Get User** take. [See the documentation](https://developer.brex.com/openapi/team_api/users/createuser)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `firstName` | `string` | Yes | The user's first name, e.g. Jane. |
| `lastName` | `string` | Yes | The user's last name, e.g. Doe. |
| `email` | `string` | Yes | The work email address the invitation is sent to, e.g. jane@acme.com. Must be unique within the Brex account. |
| `manager` | `string` | No | The person who reviews and approves this user's expenses, as a Brex user ID. Use List Users to find a user ID by email address. |
| `department` | `string` | No | The department to assign the user to, as a department ID, e.g. dep_clu9ah28r000008l3d4b1g5xy. Use List Departments to find a department ID by name. Omit to leave the user unassigned. |
| `location` | `string` | No | The office location to assign the user to, as a location ID, e.g. loc_clu9ah28r000008l3d4b1g5xy. Use List Locations to find a location ID by name. Omit to leave the user unassigned. |

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

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: "brex-invite-user",
  arguments: {
    firstName: "First Name",
    lastName: "Last 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: "brex-invite-user",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    brex: { authProvisionId: "apn_xxxxxxx" },
    firstName: "First Name",
    lastName: "Last 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": "brex-invite-user",
    "configured_props": {
      "brex": { "authProvisionId": "apn_xxxxxxx" },
      "firstName": "First Name",
      "lastName": "Last Name"
    }
  }'
```

---

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