Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/docs/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5513,6 +5513,18 @@ export function AsanaIcon(props: SVGProps<SVGSVGElement>) {
)
}

export function PlaidIcon(props: SVGProps<SVGSVGElement>) {
return (
<svg {...props} viewBox='0 0 48 48' fill='none' xmlns='http://www.w3.org/2000/svg'>
<path
fill='currentColor'
fillRule='evenodd'
d='M18.637 0L4.09 3.81.081 18.439l5.014 5.148L0 28.65l3.773 14.693 14.484 4.047 5.096-5.064 5.014 5.147 14.547-3.81 4.008-14.63-5.013-5.146 5.095-5.063L43.231 4.13 28.745.083l-5.094 5.063L18.637 0zM9.71 6.624l7.663-2.008 3.351 3.44-4.887 4.856L9.71 6.624zm16.822 1.478l3.405-3.383 7.63 2.132-6.227 6.187-4.808-4.936zM4.672 17.238l2.111-7.705 6.125 6.288-4.886 4.856-3.35-3.44zm29.547-1.243l6.227-6.189 1.986 7.74-3.404 3.384-4.809-4.935zm-15.502-.127l4.887-4.856 4.807 4.936-4.886 4.856-4.808-4.936zm-7.814 7.765l4.886-4.856 4.81 4.936-4.888 4.856-4.808-4.936zm15.503.127l4.886-4.856L36.1 23.84l-4.887 4.856-4.807-4.936zM4.57 29.927l3.406-3.385 4.807 4.937-6.225 6.186-1.988-7.738zm14.021 1.598l4.887-4.856 4.808 4.936-4.886 4.856-4.809-4.936zm15.502.128l4.887-4.856 3.351 3.439-2.11 7.705-6.128-6.288zm-24.656 8.97l6.226-6.189 4.81 4.936-3.406 3.385-7.63-2.133zm16.843-1.206l4.886-4.856 6.126 6.289-7.662 2.007-3.35-3.44z'
/>
</svg>
)
}

export function PipedriveIcon(props: SVGProps<SVGSVGElement>) {
const pathId = useId()
return (
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/components/ui/icon-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ import {
PersonaIcon,
PineconeIcon,
PipedriveIcon,
PlaidIcon,
PolymarketIcon,
PostgresIcon,
PosthogIcon,
Expand Down Expand Up @@ -464,6 +465,7 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
persona: PersonaIcon,
pinecone: PineconeIcon,
pipedrive: PipedriveIcon,
plaid: PlaidIcon,
polymarket: PolymarketIcon,
postgresql: PostgresIcon,
posthog: PosthogIcon,
Expand Down
1 change: 1 addition & 0 deletions apps/docs/content/docs/en/integrations/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"pinecone",
"pipedrive",
"pipedrive-service-account",
"plaid",
"polymarket",
"postgresql",
"posthog",
Expand Down
249 changes: 249 additions & 0 deletions apps/docs/content/docs/en/integrations/plaid.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
---
title: Plaid
description: Read bank accounts, balances, transactions, and identity data via Plaid
---

import { BlockInfoCard } from "@/components/ui/block-info-card"

<BlockInfoCard
type="plaid"
color="#111111"
/>

## Usage Instructions

Integrates Plaid into the workflow. Sync categorized transactions, list linked bank accounts with real-time balances, fetch verified account and routing numbers, retrieve account-holder identity, look up supported institutions, and manage Item tokens across the sandbox and production environments.



## Actions

### Plaid Sync Transactions

Incrementally sync transactions for a linked Item. Omit the cursor on the first call to get full history, then pass the returned cursor to fetch only changes; loop while hasMore is true. If Plaid returns TRANSACTIONS_SYNC_MUTATION_DURING_PAGINATION, discard the pages from the current batch and restart the loop from the cursor the batch started with

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `environment` | string | No | Plaid environment: 'production' \(default\) or 'sandbox' |
| `cursor` | string | No | Cursor from a previous sync \(nextCursor\); omit to start from the beginning |
| `count` | number | No | Number of updates to fetch per page \(1-500, default 100\) |
| `accountId` | string | No | Scope the sync \(and cursor\) to a single account ID |
| `includeOriginalDescription` | boolean | No | Include the unmodified original_description from the institution |
| `daysRequested` | number | No | Days of history to request \(1-730, default 90\). Only applies before Transactions is initialized on the Item |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `added` | array | Transactions added since the cursor |
| `modified` | array | Transactions modified since the cursor |
| `removed` | array | Transactions removed since the cursor |
| ↳ `transaction_id` | string | ID of the removed transaction |
| ↳ `account_id` | string | Account the transaction belonged to |
| `nextCursor` | string | Cursor to pass to the next sync call to fetch only new changes |
| `hasMore` | boolean | Whether more updates are available; if true, call again with nextCursor |
| `updateStatus` | string | Sync readiness: NOT_READY, INITIAL_UPDATE_COMPLETE, or HISTORICAL_UPDATE_COMPLETE |

### Plaid Get Accounts

List the accounts linked to an Item with their names, types, and balances. Balances may be cached; use Get Balances for real-time values

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `environment` | string | No | Plaid environment: 'production' \(default\) or 'sandbox' |
| `accountIds` | string | No | Comma-separated account IDs to filter to \(defaults to all accounts\) |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `accounts` | array | Accounts linked to the Item |
| `count` | number | Number of accounts returned |

### Plaid Get Balances

Get real-time balances for the accounts linked to an Item. Forces a live fetch from the institution, so it can take up to 30 seconds

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `environment` | string | No | Plaid environment: 'production' \(default\) or 'sandbox' |
| `accountIds` | string | No | Comma-separated account IDs to filter to \(defaults to all accounts\) |
| `minLastUpdatedDatetime` | string | No | Oldest acceptable balance timestamp \(ISO 8601\). Only required for Capital One non-depository accounts |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `accounts` | array | Accounts with refreshed real-time balances |
| `count` | number | Number of accounts returned |

### Plaid Get Identity

Get account-holder identity information (names, emails, phone numbers, and addresses) for the accounts linked to an Item

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `environment` | string | No | Plaid environment: 'production' \(default\) or 'sandbox' |
| `accountIds` | string | No | Comma-separated account IDs to filter to \(defaults to all accounts\) |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `accounts` | array | Accounts with their owners identity data |
| ↳ `owners` | json | Account owners, each with names, phone_numbers, emails, and addresses arrays |
| `count` | number | Number of accounts returned |

### Plaid Get Auth

Get account and routing numbers for the depository accounts linked to an Item (ACH for US, EFT for Canada, BACS for UK, IBAN/BIC internationally). Check each account verification_status before relying on micro-deposit-verified accounts; null means the institution authenticated instantly

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `environment` | string | No | Plaid environment: 'production' \(default\) or 'sandbox' |
| `accountIds` | string | No | Comma-separated account IDs to filter to \(defaults to all accounts\) |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `accounts` | array | Depository accounts on the Item |
| `numbers` | json | Account and routing numbers grouped by scheme |
| ↳ `ach` | json | US accounts: account_id, account, routing, wire_routing, and is_tokenized_account_number entries \(tokenized numbers come from institutions like Chase and stop working if the Item is deleted\) |
| ↳ `eft` | json | Canadian accounts: account_id, account, institution, and branch entries |
| ↳ `international` | json | International accounts: account_id, iban, and bic entries |
| ↳ `bacs` | json | UK accounts: account_id, account, and sort_code entries |

### Plaid Get Item

Get metadata and health status for a linked Item, including its institution, enabled products, and any error state

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `environment` | string | No | Plaid environment: 'production' \(default\) or 'sandbox' |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `item` | json | Item metadata |
| ↳ `item_id` | string | Unique ID of the Item |
| ↳ `institution_id` | string | Plaid institution ID the Item is linked to |
| ↳ `institution_name` | string | Name of the linked institution |
| ↳ `webhook` | string | Webhook URL set on the Item |
| ↳ `error` | json | Error state of the Item, null when healthy |
| ↳ `available_products` | json | Products available but not yet billed for the Item |
| ↳ `billed_products` | json | Products the Item has been billed for |
| ↳ `products` | json | All products enabled on the Item |
| ↳ `consent_expiration_time` | string | When access consent expires, if the institution enforces expiration |
| ↳ `update_type` | string | Item update type \(background or user_present_required\) |
| ↳ `created_at` | string | When the Item was created |
| `status` | json | Item health: last successful/failed transaction and investment updates and the last webhook fired |

### Plaid Search Institutions

Search financial institutions supported by Plaid by name

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `environment` | string | No | Plaid environment: 'production' \(default\) or 'sandbox' |
| `query` | string | Yes | Institution name to search for, e.g. 'Chase' |
| `countryCodes` | string | No | Comma-separated ISO country codes to search in \(defaults to 'US'\) |
| `products` | string | No | Comma-separated products the institutions must support, e.g. 'transactions,auth' |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `institutions` | array | Institutions matching the search |
| `count` | number | Number of institutions returned |

### Plaid Get Institution

Get details for a financial institution by its Plaid institution ID

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `environment` | string | No | Plaid environment: 'production' \(default\) or 'sandbox' |
| `institutionId` | string | Yes | Plaid institution ID, e.g. 'ins_109508' |
| `countryCodes` | string | No | Comma-separated ISO country codes \(defaults to 'US'\) |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `institution` | json | Institution details |

### Plaid Exchange Public Token

Exchange a public token from Plaid Link (or the sandbox) for a permanent access token and Item ID

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `environment` | string | No | Plaid environment: 'production' \(default\) or 'sandbox' |
| `publicToken` | string | Yes | Public token returned by Plaid Link onSuccess \(or the sandbox token creator\) |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `accessToken` | string | Access token for the linked Item; store it securely and pass it to the other Plaid operations |
| `itemId` | string | ID of the Item the token belongs to |

### Plaid Create Sandbox Public Token

Create a sandbox public token for a test institution without going through Plaid Link. Sandbox only — exchange the result for an access token to test other operations

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `clientId` | string | Yes | Plaid client ID \(from the Plaid Dashboard under Team Settings → Keys\) |
| `secret` | string | Yes | Plaid API secret for the selected environment |
| `institutionId` | string | Yes | Sandbox institution ID, e.g. 'ins_109508' \(First Platypus Bank\) |
| `initialProducts` | string | Yes | Comma-separated products to enable, e.g. 'transactions' or 'auth,identity' |
| `webhook` | string | No | Webhook URL to associate with the Item |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `publicToken` | string | Sandbox public token to exchange for an access token |


19 changes: 1 addition & 18 deletions apps/sim/blocks/blocks/brex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BrexIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { normalizeFileInput } from '@/blocks/utils'
import { normalizeFileInput, toOptionalBoolean, toOptionalFiniteNumber } from '@/blocks/utils'
import type { BrexResponse } from '@/tools/brex/types'

/** Coerces a required money-amount field to a finite number, throwing on blank/non-numeric input rather than silently sending 0 or NaN to Brex. */
Expand All @@ -16,23 +16,6 @@ function toRequiredAmount(value: unknown, fieldLabel: string): number {
return parsed
}

/** Coerces an optional numeric field to a finite number, throwing on non-numeric input instead of silently forwarding NaN. Preserves explicit 0. */
function toOptionalFiniteNumber(value: unknown, fieldLabel: string): number | undefined {
if (value == null || (typeof value === 'string' && value.trim() === '')) return undefined
const parsed = Number(value)
if (!Number.isFinite(parsed)) {
throw new Error(`${fieldLabel} must be a valid number`)
}
return parsed
}

/** Normalizes a boolean field that may arrive as a string (e.g. from a dynamic <Block.output> reference) instead of an actual boolean. */
function toOptionalBoolean(value: unknown): boolean | undefined {
if (value == null) return undefined
if (typeof value === 'boolean') return value
return String(value).toLowerCase() === 'true'
}

const PAGINATED_OPERATIONS = new Set([
'list_expenses',
'list_card_transactions',
Expand Down
Loading
Loading