# Create Bank Transaction — Xero Accounting

> Create a new bank transaction See the documentation

- Key: `xero_accounting_api-create-bank-transaction`
- Type: Action (Write)
- Version: 0.1.4
- App: Xero Accounting (`xero_accounting_api`) — https://pipedream.com/apps/xero-accounting-api.md
- This page (HTML): https://pipedream.com/apps/xero-accounting-api/actions/create-bank-transaction
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/xero_accounting_api/actions/create-bank-transaction/create-bank-transaction.mjs

## Description

Create a new bank transaction [See the documentation](https://developer.xero.com/documentation/api/accounting/banktransactions#put-banktransactions)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `tenantId` | `string` | Yes | Select an organization tenant to use, or provide a tenant ID Options are loaded from the connected account. |
| `bankAccountCode` | `string` | No | The Account Code of the Bank Account of the transaction. If Code is not included then AccountID is required. |
| `bankAccountId` | `string` | No | The ID of the Bank Account transaction. If AccountID is not included then Code is required. |
| `contactId` | `string` | No | ID of the contact associated to the bank transaction. Options are loaded from the connected account. |
| `contactName` | `string` | No | Name of the contact associated to the bank transaction. If there is no contact matching this name, a new contact is created. |
| `type` | `string` | Yes | See Bank Transaction Types |
| `lineItems` | `object` | Yes | See LineItems. The LineItems element can contain any number of individual LineItem sub-elements. At least one is required to create a bank transaction. |
| `isReconciled` | `boolean` | No | Boolean to show if transaction is reconciled. Conversion related apps can set the IsReconciled flag in scenarios when a matching bank statement line is not available. Learn more |
| `date` | `string` | No | Date of transaction - YYYY-MM-DD |
| `reference` | `string` | No | Reference for the transaction. Only supported for SPEND and RECEIVE transactions. |
| `currencyCode` | `string` | No | The currency that bank transaction has been raised in (see Currencies). Setting currency is only supported on overpayments. |
| `currencyRate` | `string` | No | Exchange rate to base currency when money is spent or received. e.g. 0.7500 Only used for bank transactions in non base currency. If this isn't specified for non base currency accounts then either the user-defined rate (preference) or the XE.com day rate will be used. Setting currency is only supported on overpayments. |
| `url` | `string` | No | URL link to a source document - shown as "Go to App Name" |
| `status` | `string` | No | See Bank Transaction Status Codes |
| `lineAmountTypes` | `string` | No | Line amounts are exclusive of tax by default if you don't specify this element. See Line Amount Types |

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

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: "xero_accounting_api-create-bank-transaction",
  arguments: {
    tenantId: "Tenant ID",
    bankAccountCode: "Bank Account Code",
  },
})
```

**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: "xero_accounting_api-create-bank-transaction",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    xero_accounting_api: { authProvisionId: "apn_xxxxxxx" },
    tenantId: "Tenant ID",
    bankAccountCode: "Bank Account Code",
  },
})

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": "xero_accounting_api-create-bank-transaction",
    "configured_props": {
      "xero_accounting_api": { "authProvisionId": "apn_xxxxxxx" },
      "tenantId": "Tenant ID",
      "bankAccountCode": "Bank Account Code"
    }
  }'
```

---

- App: https://pipedream.com/apps/xero-accounting-api.md · All apps: https://pipedream.com/apps
