{"openapi":"3.1.0","info":{"title":"POST /api/v1/credit/bank-feeds","version":"1.0.0","description":"Register a merchant's bank feed"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/bank-feeds":{"post":{"tags":["credit"],"summary":"Register a merchant's bank feed","description":"For a merchant whose bank you already hold through Stripe Financial Connections and copy into BigQuery (`ab_stripe_fc_{app_id}`). Name the merchant (`program_id` and `external_merchant_id` while it applies, or `credit_line_id`) and its `app_id`. DayZero uses the merchant's DayZero business, creating it the first time, gives your token read access to it, and starts syncing: posted transactions and balances land on that business, where underwriting reads them, every six hours. The dataset must grant DayZero's service account `READER`; until it does the feed reads `error` with `last_error: not_shared`. Registering the same `app_id` again returns the feed (`created: false`) and resumes it if it was removed; for another merchant it is `409` `CREDIT_832`.","operationId":"register_credit_bank_feed","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BankFeedRegisterRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_BankFeedResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"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"}}}},"409":{"description":"Conflict - Resource already exists or is in an incompatible state","content":{"application/json":{"example":{"error":"conflict","message":"Resource already exists","code":"CONFLICT_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":"register_credit_bank_feed_api_v1_credit_bank_feeds_post"}}},"components":{"schemas":{"BankFeedAccount":{"properties":{"account_id":{"type":"string","title":"Account Id","description":"The partner's account id (Stripe's fca_…)."},"institution_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Institution Name","description":"The bank."},"display_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Display Name","description":"The account's name."},"last4":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last4","description":"The last four digits."},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status","description":"Stripe's status for the account: active, ..."},"transactions":{"type":"integer","title":"Transactions","description":"Posted transactions DayZero holds for it.","default":0},"first_transaction_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"First Transaction On","description":"The earliest transaction's date."},"last_transaction_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Last Transaction On","description":"The latest transaction's date."},"balance_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Balance Cents","description":"The latest reported current balance, in cents."},"balance_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Balance On","description":"The day that balance is for."},"skipped_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Skipped Reason","description":"Why the account's data is not used: covered_by_plaid (the same account already reaches DayZero through Plaid, so taking it twice would count its money twice) or credit_account (a card, not cash)."}},"type":"object","required":["account_id"],"title":"BankFeedAccount","description":"One account in the feed. No numbers."},"BankFeedRegisterRequest":{"properties":{"app_id":{"type":"string","maxLength":128,"title":"App Id","description":"Your organisation id for the merchant, as it appears in the bank data dataset's name (`ab_stripe_fc_{app_id}`) or your direct-push merchant feed key. Letters, digits and underscores (`400` `CREDIT_831` otherwise). One organisation feeds one merchant (`409` `CREDIT_832`)."},"provider":{"anyOf":[{"type":"string","enum":["stripe_fc_bigquery","direct_push"]},{"type":"null"}],"title":"Provider","description":"Where the merchant's bank data arrives from: `stripe_fc_bigquery` (pulled from your BigQuery dataset) or `direct_push` (pushed directly via `POST /credit/bank-feeds/{id}/ingest`). Defaults to the program's `bank_feed_config.provider`, else `stripe_fc_bigquery`."},"program_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Program Id","description":"Your program the merchant is applying under. Required without `credit_line_id`; with it, must be the line's program if sent."},"external_merchant_id":{"anyOf":[{"type":"string","maxLength":128},{"type":"null"}],"title":"External Merchant Id","description":"Your id for the merchant, as you send it on `POST /credit/lines` and `POST /credit/bank-connections`. Required without `credit_line_id`. The merchant keeps one DayZero business whichever way its bank arrives."},"credit_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Credit Line Id","description":"An open line of yours. Its program and merchant are used; a different `program_id` or `external_merchant_id` is `400` `CREDIT_781`."},"merchant_legal_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Merchant Legal Name","description":"Names the merchant's DayZero business when this call creates it. Ignored when the business exists."},"merchant_business_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Business Id","description":"The merchant's existing DayZero business, when your token can reach it. Leave it out and DayZero uses the business the merchant was linked to before, or creates one (`400` `CREDIT_788` when it names another)."}},"additionalProperties":false,"type":"object","required":["app_id"],"title":"BankFeedRegisterRequest","description":"Register a merchant's bank feed: name the merchant and its organisation."},"BankFeedResponse":{"properties":{"id":{"type":"string","title":"Id","description":"The bank feed's id."},"status":{"type":"string","enum":["pending","active","error","removed"],"title":"Status","description":"pending: registered, first sync not finished. active: synced and kept current. error: the last sync failed (`last_error`); it is tried again. removed: no longer synced."},"created":{"type":"boolean","title":"Created","description":"False when the call returned the feed already registered.","default":false},"provider":{"type":"string","title":"Provider","description":"stripe_fc_bigquery."},"app_id":{"type":"string","title":"App Id","description":"Your organisation id the dataset is named after."},"dataset":{"type":"string","title":"Dataset","description":"The BigQuery dataset read, project.dataset."},"program_id":{"type":"string","title":"Program Id","description":"The program the feed is under."},"credit_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Credit Line Id","description":"The line, if any."},"external_merchant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Merchant Id","description":"Your id for the merchant."},"merchant_business_id":{"type":"string","title":"Merchant Business Id","description":"The merchant's DayZero business the data lands on: the `subject_business_id` for `POST /credit/underwriting/assessments`."},"merchant_business_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Business Name","description":"The merchant business's name."},"merchant_business_created":{"type":"boolean","title":"Merchant Business Created","description":"Whether registering this feed created the merchant's business.","default":false},"first_synced_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"First Synced At","description":"When the history first landed, UTC. Underwriting waits for it."},"last_synced_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Synced At","description":"The last successful sync, UTC."},"last_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Error","description":"While status is error: not_shared (the dataset is not readable by DayZero's service account: grant it READER), not_found (no dataset for this app_id), not_configured, auth_failed, bigquery_error or sync_failed."},"last_error_detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Error Detail","description":"What the failing call said."},"latest_transaction_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Latest Transaction On","description":"The newest transaction's date across accounts."},"latest_balance_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Latest Balance On","description":"The newest reported balance's date."},"accounts":{"items":{"$ref":"#/components/schemas/BankFeedAccount"},"type":"array","title":"Accounts","description":"The accounts seen in the dataset."},"sandbox":{"type":"boolean","title":"Sandbox","description":"True on a sandbox program.","default":false},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At","description":"When the feed was registered, UTC."}},"type":"object","required":["id","status","provider","app_id","dataset","program_id","merchant_business_id"],"title":"BankFeedResponse","description":"A merchant's bank feed and where it stands."},"SuccessEnvelope_BankFeedResponse_":{"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/BankFeedResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[BankFeedResponse]"},"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":[]}]}