{"openapi":"3.1.0","info":{"title":"GET /api/v1/advisory-firms/{firm_id}/businesses","version":"1.0.0","description":"List firm businesses"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/advisory-firms/{firm_id}/businesses":{"get":{"tags":["advisory-firms"],"summary":"List firm businesses","description":"List all businesses assigned to an advisory firm.","operationId":"list_firm_businesses","parameters":[{"name":"firm_id","in":"path","required":true,"schema":{"type":"string","title":"Firm Id"}},{"name":"cursor","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Cursor for pagination","title":"Cursor"},"description":"Cursor for pagination"},{"name":"limit","in":"query","required":false,"schema":{"anyOf":[{"type":"integer","maximum":1000,"minimum":1},{"type":"null"}],"description":"Pagination limit","title":"Limit"},"description":"Pagination limit"},{"name":"direction","in":"query","required":false,"schema":{"type":"string","description":"Pagination direction: 'next' or 'prev'","default":"next","title":"Direction"},"description":"Pagination direction: 'next' or 'prev'"},{"name":"include_total_count","in":"query","required":false,"schema":{"type":"boolean","description":"Whether to include total count (expensive - avoid if possible)","default":false,"title":"Include Total Count"},"description":"Whether to include total count (expensive - avoid if possible)"},{"name":"sort_by","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None.","title":"Sort By"},"description":"Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None."},{"name":"descending","in":"query","required":false,"schema":{"type":"boolean","description":"Sort direction: true for descending (newest/largest first), false for ascending","default":true,"title":"Descending"},"description":"Sort direction: true for descending (newest/largest first), false for ascending"},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_FirmBusinessesCursorResponse_"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"list_firm_businesses_api_v1_advisory_firms__firm_id__businesses_get"}}},"components":{"schemas":{"AccountSchema":{"properties":{"plaid_account_id":{"type":"string","title":"Plaid Account Id","description":"Plaid's unique account ID."},"ledger_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ledger Id","description":"Linked ledger UUID in chart of accounts."},"teal_source_account_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Teal Source Account Id","description":"Teal accounting system source account ID."},"balance":{"$ref":"#/components/schemas/BalanceSchema","description":"Current account balances."},"mask":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Mask","description":"Last 4 digits of account number (e.g., '1234')."},"name":{"type":"string","title":"Name","description":"Account name from the bank."},"official_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Official Name","description":"Official account name from the bank."},"subtype":{"type":"string","title":"Subtype","description":"Account subtype (e.g., 'checking', 'savings', 'credit card')."},"type":{"type":"string","title":"Type","description":"Account type: depository, credit, loan, investment."},"last_synced":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Synced","description":"When transactions were last synced."},"business_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Business Id","description":"Business UUID."},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At","description":"When account was linked."},"error_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Code","description":"Plaid error code if sync failed."},"error":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Error","description":"Error details if sync failed."},"is_linked":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Linked","description":"Whether account is saved in our database."},"is_synced_to_teal":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Synced To Teal","description":"Whether account is synced to Teal accounting."},"superseded_by_item_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Superseded By Item Id","description":"Set when this account sits on a Plaid connection that is no longer active and the same real account (institution, mask and subtype) is linked on another live connection of the business; the value is that connection's id. Shown as Replaced rather than Unlinked."},"linked_via_item_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Linked Via Item Id","description":"Set when this connection reports an account that is linked to a ledger through another live connection of the business; the value is that connection's id. The account is not stored under this connection. POST /plaid/account/move moves the link here."},"linked_via_institution_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Linked Via Institution Name","description":"Institution name of the connection in linked_via_item_id."}},"additionalProperties":true,"type":"object","required":["plaid_account_id","balance","name","subtype","type"],"title":"AccountSchema","description":"Schema for a bank account connected via Plaid.\n\nRepresents a single bank account (checking, savings, credit card, etc.)\nthat is linked to the business through a Plaid connection.\n\n**Account Types:**\n- `depository`: Checking, savings accounts\n- `credit`: Credit cards\n- `loan`: Loans, mortgages\n- `investment`: Brokerage, retirement accounts","example":{"balance":{"available":1523450,"current":1548200,"iso_currency_code":"USD"},"business_id":"019ab37c-b051-7000-8000-000000000001","is_linked":true,"is_synced_to_teal":true,"last_synced":"2024-01-15T14:00:00Z","ledger_id":"019ab37c-1ed1-7000-8000-000000000001","mask":"1234","name":"Chase Business Checking","official_name":"CHASE BUSINESS COMPLETE CHECKING","plaid_account_id":"plaid_acc_abc123","subtype":"checking","teal_source_account_id":"teal_src_xyz789","type":"depository"},"examples":[{"balance":{"available":1523450,"current":1548200,"iso_currency_code":"USD"},"business_id":"019ab37c-b051-7000-8000-000000000001","is_linked":true,"is_synced_to_teal":true,"last_synced":"2024-01-15T14:00:00Z","ledger_id":"019ab37c-1ed1-7000-8000-000000000001","mask":"1234","name":"Chase Business Checking","official_name":"CHASE BUSINESS COMPLETE CHECKING","plaid_account_id":"plaid_acc_abc123","subtype":"checking","teal_source_account_id":"teal_src_xyz789","type":"depository"}]},"BalanceSchema":{"properties":{"available":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Available","description":"Available balance in cents (what can be spent now)."},"current":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Current","description":"Current balance in cents (includes pending transactions)."},"iso_currency_code":{"type":"string","title":"Iso Currency Code","description":"ISO 4217 currency code (e.g., 'USD')."},"limit":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Limit","description":"Credit limit in cents (for credit cards)."},"unofficial_currency_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Unofficial Currency Code","description":"Unofficial currency code if ISO code unavailable."},"is_available":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Is Available","description":"Whether available balance is reported (0 or 1)."}},"additionalProperties":true,"type":"object","required":["iso_currency_code"],"title":"BalanceSchema","description":"Schema for a bank account balance from Plaid.\n\nAmounts are in cents (e.g., 150000 = $1,500.00).","example":{"available":1523450,"current":1548200,"is_available":1,"iso_currency_code":"USD"},"examples":[{"available":1523450,"current":1548200,"is_available":1,"iso_currency_code":"USD"}]},"BusinessResponse":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id","description":"Business UUID."},"firm_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Firm Id","description":"Advisory firm UUID this business belongs to."},"mailbox":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Mailbox","description":"Email prefix for bill forwarding."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Business name."},"name_aliases":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Name Aliases","description":"Other names the business goes by."},"logo_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Logo Url","description":"URL to business logo/avatar image."},"default_currency":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Currency","description":"Default currency for the business (USD, CAD, AUD, EUR, or GBP)."},"tax_year_end_month":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Tax Year End Month","description":"Month when the tax/fiscal year ends (1-12). 12 = calendar year."},"accounting_basis":{"anyOf":[{"type":"string","enum":["cash","accrual"]},{"type":"null"}],"title":"Accounting Basis","description":"Default accounting basis financial reports open on: 'accrual' or 'cash'. Null means accrual."},"start_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Start Date","description":"Date the business started operating (founding date). Distinct from entries_start, which anchors bookkeeping imports."},"tax_year_display":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tax Year Display","description":"Human-readable tax year description (e.g., 'Calendar Year (Jan-Dec)')."},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At","description":"Creation timestamp."},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Updated At","description":"Last update timestamp."},"teal_instance_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Teal Instance Id","description":"Teal instance ID (API format)."},"teal_instance":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Teal Instance","description":"Teal database ID."},"entries_start":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Entries Start","description":"Start date for transaction imports."},"stripe_account_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stripe Account Id","description":"Connected Stripe account ID."},"stripe_subscription_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stripe Subscription Id","description":"Stripe subscription ID."},"stripe_customer_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stripe Customer Id","description":"Stripe customer ID."},"subscription_items":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Subscription Items","description":"Stripe subscription items/products linked to this business."},"shopify_shop_domain":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Shopify Shop Domain","description":"Connected Shopify domain."},"shopify_access_token_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Shopify Access Token Id","description":"Shopify token UUID."},"ramp_connection_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ramp Connection Id","description":"Ramp connection UUID."},"square_connection_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Square Connection Id","description":"Square connection UUID."},"finch_connection_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Finch Connection Id","description":"Finch payroll connection UUID."},"hubspot_connection_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Hubspot Connection Id","description":"HubSpot connection UUID."},"plaid_connections":{"anyOf":[{"items":{"$ref":"#/components/schemas/PlaidConnectionSchema"},"type":"array"},{"type":"null"}],"title":"Plaid Connections","description":"Connected bank accounts via Plaid."},"slack_connected":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Slack Connected","description":"Whether a Slack webhook URL is configured."},"sync":{"anyOf":[{"$ref":"#/components/schemas/SyncStatus"},{"type":"null"}],"description":"Teal sync status."},"inventory_mode":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Inventory Mode","description":"Inventory module flavor: 'cpg' or 'finished_goods'."},"ap_approval_enabled":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Ap Approval Enabled","description":"Whether the AP bill approval workflow is enabled for this business. When off (default), bills post directly to 'received'."},"ap_due_date_basis":{"anyOf":[{"type":"string","enum":["invoice_date","received_date"]},{"type":"null"}],"title":"Ap Due Date Basis","description":"Which date vendor-bill payment terms count from on ingest: 'invoice_date' (default, trust the invoice) or 'received_date' (terms run from the day the business received the bill)."},"ar_subledger_mode":{"anyOf":[{"type":"string","enum":["off","per_customer"]},{"type":"null"}],"title":"Ar Subledger Mode","description":"Where invoice and payment journal entries post the receivable: 'off' (one Accounts Receivable) or 'per_customer' (an 'AR - <Customer Name>' child ledger of Accounts Receivable)."},"auto_rename_counterparties":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Auto Rename Counterparties","description":"Whether automated counterparty re-resolution is enabled for transactions that already have a counterparty assigned. On by default. Manually-set counterparties are always protected regardless of this setting."},"stripe_payout_sibling_matching":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Stripe Payout Sibling Matching","description":"Whether an unmatched Stripe payout may be matched to a deposit in a sibling business with no Stripe account. null = only when the firm has exactly one such sibling."}},"additionalProperties":true,"type":"object","title":"BusinessResponse","description":"Response schema for a business.\n\nContains all business details including connected integrations\nand sync status with the accounting system.","example":{"created_at":"2024-01-10T10:30:00Z","entries_start":"2024-01-01T00:00:00Z","firm_id":"019ab37c-f123-7000-8000-000000000001","id":"019ab37c-b051-7000-8000-000000000001","mailbox":"acme","name":"Acme Corporation","plaid_connections":[],"shopify_shop_domain":"acme-store.myshopify.com","stripe_account_id":"acct_abc123","sync":{"last_synced":"2024-01-15T14:00:00Z","status":"completed"},"teal_instance_id":"teal_inst_abc123","updated_at":"2024-01-15T14:00:00Z"},"examples":[{"created_at":"2024-01-10T10:30:00Z","entries_start":"2024-01-01T00:00:00Z","firm_id":"019ab37c-f123-7000-8000-000000000001","id":"019ab37c-b051-7000-8000-000000000001","mailbox":"acme","name":"Acme Corporation","plaid_connections":[],"shopify_shop_domain":"acme-store.myshopify.com","stripe_account_id":"acct_abc123","sync":{"last_synced":"2024-01-15T14:00:00Z","status":"completed"},"teal_instance_id":"teal_inst_abc123","updated_at":"2024-01-15T14:00:00Z"}]},"FirmBusinessesCursorResponse":{"properties":{"items":{"items":{"$ref":"#/components/schemas/BusinessResponse"},"type":"array","title":"Items","description":"List of items"},"total":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total","description":"Total number of items (null when not calculated for performance)"},"limit":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Limit","description":"Pagination limit"},"next_cursor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Next Cursor","description":"Cursor for next page"},"prev_cursor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Prev Cursor","description":"Cursor for previous page"},"has_next":{"type":"boolean","title":"Has Next","description":"Whether there are more items"},"has_prev":{"type":"boolean","title":"Has Prev","description":"Whether there are previous items"}},"type":"object","required":["items","has_next","has_prev"],"title":"FirmBusinessesCursorResponse"},"PlaidConnectionSchema":{"properties":{"id":{"type":"string","title":"Id","description":"Plaid Item UUID."},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"When connection was established."},"updated_at":{"type":"string","format":"date-time","title":"Updated At","description":"Last update timestamp."},"item_id":{"type":"string","title":"Item Id","description":"Plaid Item ID."},"institution_id":{"type":"string","title":"Institution Id","description":"Plaid institution ID (e.g., 'ins_3')."},"institution_name":{"type":"string","title":"Institution Name","description":"Bank/institution name."},"accounts":{"anyOf":[{"items":{"$ref":"#/components/schemas/AccountSchema"},"type":"array"},{"type":"null"}],"title":"Accounts","description":"Bank accounts associated with this connection.","default":[]},"business_id":{"type":"string","title":"Business Id","description":"Business UUID."},"sync_status":{"type":"string","title":"Sync Status","description":"Current sync status."},"error_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Code","description":"Plaid error code if sync failed."}},"additionalProperties":true,"type":"object","required":["id","created_at","updated_at","item_id","institution_id","institution_name","business_id","sync_status"],"title":"PlaidConnectionSchema","description":"Response schema for a Plaid bank connection.\n\nRepresents a linked bank institution with its associated accounts.\nCreated when a user connects a bank via the Plaid Link flow.\n\n**Sync Status Values:**\n- `syncing`: Initial sync in progress\n- `synced`: Fully synced and up to date\n- `error`: Sync failed (check error_code)\n- `disconnected`: Connection needs re-authentication","example":{"accounts":[{"id":"019ab37c-acc1-7000-8000-000000000001","mask":"1234","name":"Chase Business Checking","subtype":"checking","type":"depository"}],"business_id":"019ab37c-b051-7000-8000-000000000001","created_at":"2024-01-10T10:30:00Z","id":"019ab37c-plaid-7000-8000-000000000001","institution_id":"ins_3","institution_name":"Chase","item_id":"plaid_item_abc123","sync_status":"synced","updated_at":"2024-01-15T14:00:00Z"},"examples":[{"accounts":[{"id":"019ab37c-acc1-7000-8000-000000000001","mask":"1234","name":"Chase Business Checking","subtype":"checking","type":"depository"}],"business_id":"019ab37c-b051-7000-8000-000000000001","created_at":"2024-01-10T10:30:00Z","id":"019ab37c-plaid-7000-8000-000000000001","institution_id":"ins_3","institution_name":"Chase","item_id":"plaid_item_abc123","sync_status":"synced","updated_at":"2024-01-15T14:00:00Z"}]},"SuccessEnvelope_FirmBusinessesCursorResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/FirmBusinessesCursorResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[FirmBusinessesCursorResponse]"},"SyncStatus":{"properties":{"status":{"type":"string","enum":["syncing","completed","nothing_to_sync"],"title":"Status","description":"Sync status: 'syncing', 'completed', or 'nothing_to_sync'"},"last_synced":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Synced","description":"ISO timestamp of last successful sync"},"sync_in_progress":{"type":"boolean","title":"Sync In Progress","description":"Whether a teal-sync task is currently running (from tasks table)","default":false}},"type":"object","required":["status"],"title":"SyncStatus","description":"Sync status for a business."},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}