Bank Connections

List Connections

GET /api/banking/connections

Input:
{
  teamId: string
}

Output: Array<{
  id: string
  teamId: string
  provider: string
  providerId: string
  status: "ACTIVE" | "DISCONNECTED"
  consents: Array<{
    id: string
    status: "AUTHORIZED" | "REVOKED"
    scopes: string[]
    expiresAt: Date
    revokedAt: Date | null
  }>
}>

Connect Bank

POST /api/banking/connect

Input:
{
  teamId: string
  provider: string
  providerId: string
  consentId: string
  metadata?: Record<string, any>
}

Output: {
  id: string
  teamId: string
  provider: string
  providerId: string
  status: "ACTIVE"
  consents: Array<{
    id: string
    status: "AUTHORIZED"
    scopes: string[]
    expiresAt: Date
    revokedAt: null
  }>
}

Disconnect Bank

POST /api/banking/disconnect

Input:
{
  teamId: string
  connectionId: string
}

Output: {
  id: string
  status: "DISCONNECTED"
  consents: Array<{
    id: string
    status: "REVOKED"
    revokedAt: Date
  }>
}
POST /api/banking/consent

Input:
{
  teamId: string
  connectionId: string
  scopes: string[]
  expiresAt: Date
}

Output: {
  id: string
  status: "AUTHORIZED"
  scopes: string[]
  expiresAt: Date
  revokedAt: null
}

Sync Bank Data

POST /api/banking/sync

Input:
{
  teamId: string
  connectionId: string
}

Output: {
  id: string
  status: string
  updatedAt: Date
  consents: Array<{
    id: string
    status: string
    scopes: string[]
    expiresAt: Date
  }>
}

Bank Accounts

List Accounts

GET /api/banking/accounts

Input:
{
  teamId: string
  connectionId?: string
}

Output: Array<{
  id: string
  connectionId: string
  accountName: string
  accountNumber: string | null
  sortCode: string | null
  currency: string
  type: "CHECKING" | "SAVINGS" | "CREDIT" | "INVESTMENT"
  balance: number
  availableBalance: number | null
  connection: {
    id: string
    provider: string
    status: string
  }
}>

Get Account Details

GET /api/banking/accounts/:id

Input:
{
  teamId: string
  accountId: string
}

Output: {
  id: string
  connectionId: string
  accountName: string
  accountNumber: string | null
  sortCode: string | null
  currency: string
  type: "CHECKING" | "SAVINGS" | "CREDIT" | "INVESTMENT"
  balance: number
  availableBalance: number | null
  connection: {
    id: string
    provider: string
    status: string
  }
  transactionCount: number
  recentTransactions: Array<{
    id: string
    amount: number
    currency: string
    description: string
    transactionDate: Date
    type: "CREDIT" | "DEBIT"
    category: string | null
  }>
}

Bank Transactions

List Transactions

GET /api/banking/transactions

Input:
{
  teamId: string
  accountId?: string
  connectionId?: string
  from?: Date
  to?: Date
  type?: "CREDIT" | "DEBIT"
  category?: string
}

Output: Array<{
  id: string
  accountId: string
  amount: number
  currency: string
  description: string
  transactionDate: Date
  type: "CREDIT" | "DEBIT"
  category: string | null
  account: {
    id: string
    accountName: string
    accountNumber: string | null
    connection: {
      id: string
      provider: string
    }
  }
}>