# Create Expense — Expensify

> Creates a new expense. See docs here

- Key: `expensify-create-expense`
- Type: Action (Write)
- Version: 0.0.7
- App: Expensify (`expensify`) — https://pipedream.com/apps/expensify.md
- This page (HTML): https://pipedream.com/apps/expensify/actions/create-expense
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/expensify/actions/create-expense/create-expense.ts

## Description

Creates a new expense. [See docs here](https://integrations.expensify.com/Integration-Server/doc/#expense-creator)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `employeeEmail` | `string` | Yes | The expenses will be created in this account |
| `currency` | `string` | Yes | The three-letter currency code of the expense. E.g. USD |
| `amount` | `integer` | Yes | The amount of the expense, in cents. E.g. 2215 will be $22.15 |
| `merchant` | `string` | Yes | The name of the expense's merchant |
| `created` | `string` | Yes | The date of the expense (format yyyy-mm-dd). E.g. 2022-07-12 |
| `comment` | `string` | No | An expense comment |

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

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: "expensify-create-expense",
  arguments: {
    employeeEmail: "Employee Email",
    currency: "Currency",
  },
})
```

**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: "expensify-create-expense",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    expensify: { authProvisionId: "apn_xxxxxxx" },
    employeeEmail: "Employee Email",
    currency: "Currency",
  },
})

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": "expensify-create-expense",
    "configured_props": {
      "expensify": { "authProvisionId": "apn_xxxxxxx" },
      "employeeEmail": "Employee Email",
      "currency": "Currency"
    }
  }'
```

---

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