# DayZero API — Full Reference > Complete API endpoint documentation generated from the OpenAPI spec. > All amounts are in cents (e.g. $150.00 = 15000). IDs are UUID v7. > Authentication: Bearer token in Authorization header. > Pagination: cursor-based (pass `cursor` param from `next_cursor`). ## Base URL https://api.ondayzero.com/api/v1 ## Authentication Authorization: Bearer dz_your_token x-business-id: YOUR_BUSINESS_ID ## accounting-dimensions ### GET /api/v1/accounting-dimensions List classes/locations List accounting dimensions, optionally filtered by type. Parameters: - dimension_type (query, string, optional): Filter by 'class' or 'location'. - include_inactive (query, boolean, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/accounting-dimensions Create class/location Create a new accounting dimension. Request body (AccountingDimensionCreateRequest): - dimension_type (string, required) - name (string, required) - code (string, optional) - parent_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/accounting-dimensions/pnl Dimensional P&L Profit & loss broken down by class or location for a date range. Parameters: - dimension_type (query, string, required): 'class' or 'location'. - start_date (query, string · date, required): Period start (inclusive). - end_date (query, string · date, required): Period end (inclusive). Responses: 200, 400, 401, 403, 422 ### DELETE /api/v1/accounting-dimensions/{dimension_id} Deactivate class/location Soft-delete (deactivate) an accounting dimension. Parameters: - dimension_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/accounting-dimensions/{dimension_id} Get class/location Get a single accounting dimension. Parameters: - dimension_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/accounting-dimensions/{dimension_id} Update class/location Update an accounting dimension. Parameters: - dimension_id (path, string, required) Request body (AccountingDimensionUpdateRequest): - name (string, optional) - code (string, optional) - parent_id (string, optional) - is_active (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ## accounting-periods — Manage fiscal periods (month/quarter/year) and period locks. ### GET /api/v1/accounting-periods List accounting periods List all accounting periods for the business. Parameters: - status (query, string, optional): Filter by status: open, closed, locked - search (query, string, optional): Search status, dates, or lock/reopen reasons (case-insensitive) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/accounting-periods Create accounting period Create a new accounting period. Idempotent on the exact range: an existing period with the same start and end is returned with 200 and `created` false. A range that overlaps another period any other way is a 400 naming that period. Request body (AccountingPeriodCreateRequest): - period_start (string · date, required) - period_end (string · date, required) Responses: 200, 201, 400, 401, 403, 422 ### POST /api/v1/accounting-periods/bulk-lock Bulk close-and-lock accounting periods Close and lock multiple accounting periods in one call. Designed for historical-data migration: any open period in the list is closed first, then transitioned to locked. Already-locked periods are skipped. Request body (BulkLockPeriodsRequest): - period_ids (array · string, required) - lock_reason (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/accounting-periods/close Close accounting period Close an accounting period to prevent modifications. Refused with the blocker list while the period has high-severity close blockers, unless force=true with an override_reason (audit-logged). Closing does not lock; locking needs sign-offs from different reviewers. Request body (ClosePeriodRequest): - period_end (string · date, required) - lock_reason (string, optional) - force (boolean, optional) - override_reason (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/close-commitment Close commitment: deadline and record The business's close commitment ('each month closed by business day N', close_target_business_day in Settings > Automation): the deadline of the month that just ended with the business days left, its readiness score and top blockers, and the last 12 closed periods with the days each took, the on-time rate, the median and the current on-time streak. Business days are weekdays; no holiday calendar. Responses: 200, 401, 403, 422 ### GET /api/v1/accounting-periods/close-run Close run of a month The close agents' run record of each SOP job for one month being closed: owner, status, due business day, overdue, evidence and blocker, ordered by due day, plus a summary. Defaults to the month being closed now (the previous month, New York date). Parameters: - period_start (query, string, optional): First day of the month being closed (YYYY-MM-01) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/accounting-periods/nightly-close Nightly soft close: status and the last 30 nights Whether the business closes its books every night (nightly_soft_close_enabled in Settings > Automation), the last night's run (readiness score, Trust Scorecard grade, pending changes filed, status) and up to the last 30 nights, oldest first. Responses: 200, 401, 403, 422 ### GET /api/v1/accounting-periods/public/close-binder/{token} Verify and view a sealed public Close Evidence Binder Token-verified board/lender verification endpoint returning a PII-redacted, SHA-256-sealed Close Evidence Binder. Parameters: - token (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/settings Get accounting period settings Whether this business opens its accounting periods automatically. Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/accounting-periods/settings Update accounting period settings Turn automatic period creation on or off. When on, the daily job opens the period of the month that just ended and of the current month if they are missing. auto_close_prep_enabled / auto_close_prep_day opt the business in to automatic close preparation: the daily job dry-runs Regent's close checks and files the close as a pending change; nothing closes without approval. agent_close_business_day (1-23, -1 = last; null or 0 = off) is the business day the Agent window starts the close of the month that just ended. Request body (AccountingPeriodSettings): - auto_create_periods (boolean, required) - auto_close_prep_enabled (boolean, optional) - auto_close_prep_day (integer, optional) - agent_close_business_day (integer, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/{period_id} Get accounting period Get details of a specific accounting period. Parameters: - period_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/{period_id}/blockers List what's blocking close Return only the itemized 'What's between you and 100%' blockers list ordered by severity. Used by the AccountingPeriodsPage side panel and the Daily Brief tile. Parameters: - period_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/{period_id}/checklist-acks List checklist acknowledgements Return all manual checklist step acknowledgements recorded for the period. Used by the close dashboard so Phase 4 'trial balance reviewed', 'P&L variance reviewed', 'controller signed off' etc. persist across page refreshes. Parameters: - period_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/accounting-periods/{period_id}/checklist-acks/{step_id} Remove a checklist acknowledgement Clear a previously-recorded checklist step ack for a period. Parameters: - period_id (path, string, required) - step_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/accounting-periods/{period_id}/checklist-acks/{step_id} Acknowledge a checklist step Record (or update) a manual-step ack so the dashboard treats the step as done. Idempotent — re-calling updates the notes. Parameters: - period_id (path, string, required) - step_id (path, string, required) Request body (AcknowledgeCloseStepRequest): - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/accounting-periods/{period_id}/close-race Run the 8-stage Autonomous Close Race and seal the Evidence Binder Executes all 8 autonomous month-end close stages in one pass, computes the SHA-256 workpaper seal, and mints a signed share link for board members or lenders. Parameters: - period_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/accounting-periods/{period_id}/close-readiness AI close readiness check Check period close readiness with AI-enhanced analysis. Parameters: - period_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/{period_id}/close-run Close run of a period The close agents' run record of each SOP job for this period's month: owner, status, due business day, overdue, evidence and blocker, ordered by due day, plus a summary. Parameters: - period_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/{period_id}/close-score Get unified close readiness score Return the persisted close-as-score gauge value for the period. If no score has been computed yet (or upstream state has changed) the score is recomputed in-line. Components include: txn_review, categorization, reconciliation, checklist, anomalies. Parameters: - period_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/accounting-periods/{period_id}/close-score/recompute Force-recompute close score Re-run scoring for the period and persist the new value. Use this after resolving a blocker (e.g. dismissing the last anomaly) so the gauge updates immediately rather than waiting for the nightly Temporal recompute. Parameters: - period_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/{period_id}/evidence-binder Get period close evidence binder Assemble the audit-ready close evidence binder for the period, including trial balance tie-out, deterministic verification checks, pending change and accrual summary, prepaid amortization candidates, and a downloadable Markdown workpaper report. Parameters: - period_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/accounting-periods/{period_id}/lock Lock accounting period Lock a closed period (stronger protection than close). Parameters: - period_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/accounting-periods/{period_id}/reopen Reopen accounting period Reopen a closed or locked period (requires reason). Parameters: - period_id (path, string, required) Request body (ReopenPeriodRequest): - reopen_reason (string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/{period_id}/score-history Daily close-score trend Return the append-only daily snapshot of close score for this period (oldest first). Powers the 'Day 1 → Day 6' sparkline. Parameters: - period_id (path, string, required) - limit (query, integer, optional) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/accounting-periods/{period_id}/sign-offs Revoke a reviewer sign-off Remove the caller's sign-off for the given role. The close-score is recomputed on success so the gauge reflects the lost sign-off. Parameters: - period_id (path, string, required) - role (query, string, required): Role to revoke (preparer/reviewer/...) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/accounting-periods/{period_id}/sign-offs List multi-reviewer sign-offs Return all sign-off rows for the period (preparer, reviewer, controller, partner). Powers the Multi-reviewer sign-off badge on the AccountingPeriodsPage. Parameters: - period_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/accounting-periods/{period_id}/sign-offs Record a reviewer sign-off Record (or update) a reviewer's sign-off on the period. Idempotent on (user_id, role) — re-signing refreshes the snapshot score + notes. Side-effects: triggers a close-score recompute so the gauge updates immediately, and when sign-offs from enough DIFFERENT reviewers exist on a closed period, locks it (response field locked). Parameters: - period_id (path, string, required) Request body (SignOffRequest): - role (string, required) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ## activation ### GET /api/v1/activation Get activation status Returns the business's post-onboarding activation milestones. Derived milestones (bank connected, first transactions, teammate added, first invoice) are recomputed from live data on each call. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/activation/sample-preview Seed an isolated sample-data preview Seeds a small set of clearly-labeled, isolated sample transactions so a brand-new workspace isn't empty. No-ops if the business already has real transactions or a preview. Auto-purged when the first real bank sync lands. Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/activation/{milestone} Record a client-reported activation milestone Records an explicit, client-only activation milestone (e.g. first_report, coa_reviewed, first_value_moment). Idempotent: recording an already-completed milestone is a no-op. Derived milestones cannot be set here. Parameters: - milestone (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## advisory-firm-entity-groups ### GET /api/v1/advisory-firms/{firm_id}/entity-groups List entity groups List all entity groups for a firm with their member businesses. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 422 ### POST /api/v1/advisory-firms/{firm_id}/entity-groups Create entity group Create a named group of related client businesses. Requires owner or admin role. Initial members may be provided via business_ids. Parameters: - firm_id (path, string, required) Request body (CreateEntityGroupRequest): - name (string, required) - description (string, optional) - group_type (string, optional) - primary_business_id (string, optional) - business_ids (array · string, optional) Responses: 201, 400, 401, 403, 409, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id} Delete entity group Delete an entity group and its memberships. Member businesses themselves are not affected. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id} Get entity group Get an entity group with its member businesses. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id} Update entity group Update a group's name, description, type, or primary entity. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Request body (UpdateEntityGroupRequest): - name (string, optional) - description (string, optional) - group_type (string, optional) - primary_business_id (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id}/businesses Add business to entity group Add an active firm client business to an entity group. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Request body (EntityGroupMemberRequest): - business_id (string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### PUT /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id}/businesses Set entity group businesses Replace the group's membership with the given business set. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Request body (SetEntityGroupMembersRequest): - business_ids (array · string, required) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id}/businesses/{business_id} Remove business from entity group Remove a business from an entity group. Parameters: - firm_id (path, string, required) - group_id (path, string, required) - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## advisory-firm-procedures ### GET /api/v1/advisory-firms/{firm_id}/procedures Every client's procedures (firm roll-up) One row per procedure across the firm's client businesses the caller can see: visibility, install state, the clients that hold a copy of a shared one and the clients that do not. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/procedures/{procedure_id}/install-everywhere Install one client's procedure for every client Copy the procedure into every client business of the firm that does not hold it yet (`source_procedure_id` set, the source's `install_count` grows). Idempotent: clients that already hold a copy are reported as `already_installed`, the owner as `source`. Parameters: - firm_id (path, string, required) - procedure_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## advisory-firm-reports — Cross-client reporting for advisory firms. ### GET /api/v1/advisory-firms/{firm_id}/reports List available firm reports Get list of available reports for this advisory firm. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/reports/client-open-items Get open client items Exact per-business counts of open transaction questions and document requests across the firm's clients (feeds the firm client roster). Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/reports/close-board Get the firm's monthly close board Period-specific stages, owners, waiting-on, overdue work and report packages. Parameters: - firm_id (path, string, required) - period_start (query, string · date, required): First day of the month being closed Responses: 200, 400, 401, 403, 422 ### GET /api/v1/advisory-firms/{firm_id}/reports/portfolio-overview Get portfolio overview Quick access to the client portfolio overview report. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/reports/work-queue Get work queue Get prioritized work queue for the advisory firm. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/reports/{report_name} Generate firm report Generate a specific report for an advisory firm. Parameters: - firm_id (path, string, required) - report_name (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ## advisory-firm-teams — Team management within advisory firms — assign staff to teams and manage client access. ### GET /api/v1/advisory-firms/{firm_id}/teams List firm teams List all teams for a firm with member and business counts. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 422 ### POST /api/v1/advisory-firms/{firm_id}/teams Create team Create a new team within the firm. Requires owner or admin role. Parameters: - firm_id (path, string, required) Request body (CreateTeamRequest): - name (string, required) - description (string, optional) Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/teams/{team_id} Delete team Delete a team and all its member/business associations. Parameters: - firm_id (path, string, required) - team_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/teams/{team_id} Get team details Get a team with full member and business lists. Parameters: - firm_id (path, string, required) - team_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/advisory-firms/{firm_id}/teams/{team_id} Update team Update a team's name or description. Parameters: - firm_id (path, string, required) - team_id (path, string, required) Request body (UpdateTeamRequest): - name (string, optional) - description (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/teams/{team_id}/businesses Add business to team Assign a firm business to a team. Parameters: - firm_id (path, string, required) - team_id (path, string, required) Request body (TeamBusinessRequest): - business_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/teams/{team_id}/businesses/{business_id} Remove business from team Remove a business from a team. Parameters: - firm_id (path, string, required) - team_id (path, string, required) - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/teams/{team_id}/members Add team member Add a firm staff member to a team. Parameters: - firm_id (path, string, required) - team_id (path, string, required) Request body (TeamMemberRequest): - user_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/teams/{team_id}/members/{user_id} Remove team member Remove a member from a team. Parameters: - firm_id (path, string, required) - team_id (path, string, required) - user_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/users/{user_id}/accessible-businesses List accessible businesses Returns the resolved list of businesses a member can see, with source info. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/advisory-firms/{firm_id}/users/{user_id}/assignments List staff assignments List all business assignments for a firm member, with engagement metadata. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Responses: 200, 401, 403, 422 ### POST /api/v1/advisory-firms/{firm_id}/users/{user_id}/assignments Create staff assignment Assign a member to a business with optional engagement metadata. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Request body (CreateStaffAssignmentRequest): - business_id (string, required) - engagement_type (string, optional) - start_date (string, optional) - end_date (string, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 409, 422 ### PUT /api/v1/advisory-firms/{firm_id}/users/{user_id}/assignments Bulk set assignments Replace all business assignments for a member with the given set. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Request body (BulkSetAssignmentsRequest): - business_ids (array · string, required) Responses: 200, 400, 401, 403, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/users/{user_id}/assignments/{assignment_id} Delete assignment Remove a business assignment from a member. Parameters: - firm_id (path, string, required) - user_id (path, string, required) - assignment_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/advisory-firms/{firm_id}/users/{user_id}/assignments/{assignment_id} Update assignment Update engagement metadata on an assignment. Parameters: - firm_id (path, string, required) - user_id (path, string, required) - assignment_id (path, string, required) Request body (UpdateStaffAssignmentRequest): - engagement_type (string, optional) - start_date (string, optional) - end_date (string, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ## advisory-firm-templates ### GET /api/v1/advisory-firms/{firm_id}/templates List firm templates List firm-level COA / Bank Rules / Review Checklist templates. Optionally filter by ``kind``. Parameters: - firm_id (path, string, required) - kind (query, string, optional): Filter by template kind Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/templates Create a firm template Parameters: - firm_id (path, string, required) Request body (FirmTemplateCreate): - kind (string, required) - name (string, required) - description (string, optional) - payload (JsonValue, required) → JsonValue Responses: 201, 401, 403, 404, 409, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/templates/{template_id} Delete a firm template Parameters: - firm_id (path, string, required) - template_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/templates/{template_id} Get a firm template Parameters: - firm_id (path, string, required) - template_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/advisory-firms/{firm_id}/templates/{template_id} Update a firm template Parameters: - firm_id (path, string, required) - template_id (path, string, required) Request body (FirmTemplateUpdate): - name (string, optional) - description (string, optional) - payload (JsonValue, optional) Responses: 200, 401, 403, 404, 409, 422 ### POST /api/v1/advisory-firms/{firm_id}/templates/{template_id}/deploy Deploy a firm template to selected client businesses Bulk-applies the template to each business in ``business_ids``. COA templates use ``LedgerService.apply_coa``; bank-rule templates create new ``BankRule`` rows (duplicates by name are treated as skips so re-deploying is idempotent); review-checklist templates are recorded informationally. Parameters: - firm_id (path, string, required) - template_id (path, string, required) Request body (FirmTemplateDeployRequest): - business_ids (array · string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/templates/{template_id}/deployments List deployment history for a template Parameters: - firm_id (path, string, required) - template_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## advisory-firms — Advisory firm management for multi-tenant accounting. ### GET /api/v1/advisory-firms List advisory firms List advisory firms for a user. Defaults to the authenticated user; pass `user_id` to filter by a different user. Parameters: - user_id (query, string, optional): Filter firms by this user's memberships - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/advisory-firms Create advisory firm Create a new advisory firm. Operators only: sign-up links and checkout are how firms come to exist otherwise. Request body (AdvisoryFirmCreateRequest): - name (string, required) - address (string, optional) - ein (string, optional) - logo_url (string, optional) - stripe_customer_id (string, optional) - client_messaging_enabled (boolean, optional) - ap_automation_enabled (boolean, optional) - client_visible_integrations (array · string, optional) - client_ai_assistant_enabled (boolean, optional) - client_digest_email_enabled (boolean, optional) - client_digest_frequency (string, optional) - mfa_enforced (boolean, optional) Responses: 201, 400, 401, 403, 409, 422 ### DELETE /api/v1/advisory-firms/{firm_id} Delete advisory firm Delete an advisory firm and all associations. Requires a JSON body with 'confirm_password' — the caller's own account password. Parameters: - firm_id (path, string, required) Request body (AdvisoryFirmDeleteRequest): - confirm_password (string · password, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id} Get advisory firm Get details of a specific advisory firm. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id} Update advisory firm Update advisory firm details. Parameters: - firm_id (path, string, required) Request body (AdvisoryFirmUpdateRequest): - name (string, optional) - address (string, optional) - ein (string, optional) - logo_url (string, optional) - client_messaging_enabled (boolean, optional) - ap_automation_enabled (boolean, optional) - client_ai_assistant_enabled (boolean, optional) - client_digest_email_enabled (boolean, optional) - client_digest_frequency (string, optional) - slack_webhook_url (string, optional) - client_visible_integrations (array · string, optional) - mfa_enforced (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/ai-insights AI cross-client insights Get AI-powered cross-client insights for an advisory firm. Parameters: - firm_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/businesses List firm businesses List all businesses assigned to an advisory firm. Parameters: - firm_id (path, string, required) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/businesses Assign business to firm Assign a business to an advisory firm. Parameters: - firm_id (path, string, required) Request body (BusinessFirmAssociationCreateRequest): - business_id (string, required) - notes (string, optional) Responses: 201, 422 ### PATCH /api/v1/advisory-firms/{firm_id}/businesses/accounting-basis Bulk-set client accounting basis Set the default accounting basis (cash or accrual) that financial reports open on for several of the firm's client businesses at once. Every id must be an active client of the firm; otherwise the whole batch is rejected and nothing is changed. Firm owners/admins only. Parameters: - firm_id (path, string, required) Request body (FirmBusinessAccountingBasisRequest): - business_ids (array · string, required) - accounting_basis (string, required) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/businesses/{business_id} Unassign business from firm Unassign a business from an advisory firm. Parameters: - firm_id (path, string, required) - business_id (path, string, required) Responses: 200, 422 ### POST /api/v1/advisory-firms/{firm_id}/businesses/{business_id}/invite-client Invite a client user to a business Invite a user by email to access a client business. If the user already exists they are added immediately; otherwise an invitation email is sent and they are added on signup. Parameters: - firm_id (path, string, required) - business_id (path, string, required) Request body (InviteClientRequest): - email (string, required) - first_name (string, optional) - last_name (string, optional) - message (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/advisory-firms/{firm_id}/businesses/{business_id}/preferences/notifications/topics Get a business notification topic policy Per-topic channel toggles applied to a client business's users. Parameters: - firm_id (path, string, required) - business_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id}/businesses/{business_id}/preferences/notifications/topics Update a business notification topic policy Replace the per-topic channel policy for a client business. Parameters: - firm_id (path, string, required) - business_id (path, string, required) Request body (TopicChannelOverridesUpdate): - overrides (object, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/clients List firm clients List all users with the 'client' role in this firm, with their assigned businesses. Parameters: - firm_id (path, string, required) - search (query, string, optional): Search by client name or email Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/clients/{user_id}/businesses List client business access List which businesses a specific client can access. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/clients/{user_id}/businesses Grant client business access Grant a client user access to a specific business within the firm. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Request body (ClientBusinessAccessRequest): - business_id (string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/clients/{user_id}/businesses/{business_id} Revoke client business access Revoke a client's access to a specific business. Parameters: - firm_id (path, string, required) - user_id (path, string, required) - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/invitations List pending invitations List all invitations for a firm, optionally filtered by type (client, staff, or all) and status. Parameters: - firm_id (path, string, required) - type (query, string, optional): Filter by invitation type - status (query, string, optional): Filter by status (e.g. pending) Responses: 200, 401, 403, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/invitations/{invitation_id} Cancel an invitation Cancel a pending invitation. Cannot undo. Parameters: - firm_id (path, string, required) - invitation_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/invitations/{invitation_id}/resend Resend an invitation Resend the invitation email and reset the expiry to 7 days from now. Only works on pending invitations. Parameters: - firm_id (path, string, required) - invitation_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/logo Get firm logo download URL Generate a short-lived presigned download URL for the firm logo. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/preferences/notifications/topics Get firm notification topic policy Per-topic channel toggles applied firm-wide to firm staff. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id}/preferences/notifications/topics Update firm notification topic policy Replace the firm-wide per-topic channel policy. Parameters: - firm_id (path, string, required) Request body (TopicChannelOverridesUpdate): - overrides (object, optional) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id}/slack Save firm Slack webhook Configure a Slack Incoming Webhook URL for the advisory firm. Parameters: - firm_id (path, string, required) Request body (SlackWebhookSaveRequest): - slack_webhook_url (string, optional) - channel_name (string, optional) - preferences (object, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/slack/status Get firm Slack status Check whether a Slack webhook is configured and get notification preferences. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/slack/test Test Slack webhook Send a test message to the firm's first configured Slack webhook (legacy). Parameters: - firm_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/slack/{webhook_id} Disconnect Slack Remove the firm's Slack webhook URL and notification preferences. Parameters: - firm_id (path, string, required) - webhook_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id}/slack/{webhook_id}/preferences Update firm Slack notification preferences Toggle which notification categories are sent to the firm's Slack. Parameters: - firm_id (path, string, required) - webhook_id (path, string, required) Request body (SlackPreferencesUpdateRequest): - preferences (object, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/slack/{webhook_id}/test Test Slack webhook Send a test message to the firm's configured Slack webhook. Parameters: - firm_id (path, string, required) - webhook_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id}/stripe-customer Link Stripe customer Link an advisory firm to a Stripe customer for billing. Parameters: - firm_id (path, string, required) Request body (UpdateStripeCustomerRequest): - stripe_customer_id (string, required) Responses: 200, 422 ### GET /api/v1/advisory-firms/{firm_id}/users List firm users List all users in an advisory firm. Parameters: - firm_id (path, string, required) Responses: 200, 422 ### POST /api/v1/advisory-firms/{firm_id}/users Add user to firm (DayZero operators) Attach an existing account to a firm directly. DayZero operators only: firm owners and admins invite with POST /{firm_id}/users/invite and the person joins when they accept. Parameters: - firm_id (path, string, required) Request body (UserFirmAssociationCreateRequest): - user_id (string, optional) - email (string, optional) - role (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/users/invite Invite a staff member to the firm Invite a user by email to join the firm as staff (admin or member). If the user already exists they are added immediately; otherwise an invitation email is sent and they are added on signup. Owner role cannot be assigned via invitation. Parameters: - firm_id (path, string, required) Request body (InviteStaffRequest): - email (string, required) - role (string, optional) - first_name (string, optional) - last_name (string, optional) - message (string, optional) - business_ids (array · string, optional) - team_id (string, optional) - assign_all_firm_businesses (boolean, optional) Responses: 201, 400, 401, 403, 409, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/users/{user_id} Remove user from firm Remove a user from an advisory firm. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Responses: 200, 422 ### PATCH /api/v1/advisory-firms/{firm_id}/users/{user_id}/api-access Set firm user API access Allow or block DayZero API access for a firm staff member. The firm-side switch is on by default and can only restrict: a member still needs DayZero to approve their API access request before they can create or use API tokens. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Request body (FirmUserApiAccessRequest): - api_access_enabled (boolean, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/users/{user_id}/menu Get a firm staff member's sidebar menu The stored sidebar menus for a firm staff member: their firm-wide default plus any per-client overrides. Firm owners/admins can read any member's menu; a member can read their own. The menu that applies on a client resolves business-level first (a direct membership's menu, else the per-client override), then firm-wide, then all sections. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id}/users/{user_id}/menu Set a firm staff member's sidebar menu Restrict which app sections a firm staff member can reach, either firm-wide or for one client business. Firm staff reach clients *through the firm* and have no membership row there, so the per-membership menu could not be stored for them at all — this is where their menu lives instead. Unlike the per-membership menu, this one is enforced server-side: a request for a section outside the menu is rejected with 403, not merely hidden from the sidebar. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Request body (FirmStaffMenuRequest): - business_id (string, optional) - visible_sections (array · string, optional) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id}/users/{user_id}/role Update user role in firm Update a user's role in an advisory firm. Parameters: - firm_id (path, string, required) - user_id (path, string, required) Request body (UserRoleUpdateRequest): - role (string, required) Responses: 200, 422 ## advisory-packs ### GET /api/v1/advisory-packs List advisory packs Newest month first, with each pack's approval state. Responses: 200, 401, 403, 422 ### POST /api/v1/advisory-packs/generate Generate an advisory pack Queue the advisory pack for a month (default: last month) and build it in the background. The pack is a draft until firm staff approve it. Refused while a pack for the month is still being built. Request body (AdvisoryPackRequest): - period (string, optional) Responses: 201, 400, 401, 403, 409, 422 ### PATCH /api/v1/advisory-packs/goals Update advisory goals Set the target close business day, the cash floor (cents) and the gross margin target (percent). Send only the goals to change; an explicit null clears one. Request body (AdvisoryGoals): - target_close_business_day (integer, optional) - cash_floor_cents (integer, optional) - gross_margin_target_pct (number, optional) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/advisory-packs/settings Advisory goals and the monthly-draft switch Goals and whether the monthly draft is on (Settings > Automation). Responses: 200, 401, 403, 422 ### GET /api/v1/advisory-packs/{pack_id} Get an advisory pack Get one pack with its sections and figures. Parameters: - pack_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-packs/{pack_id}/approve Approve an advisory pack Firm staff of the business's firm (or the admin of a business with no firm) approve a ready draft. Approval is what allows sharing. Parameters: - pack_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/advisory-packs/{pack_id}/share Revoke the pack's public link The public page 404s immediately. Idempotent. Parameters: - pack_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-packs/{pack_id}/share Create the pack's public link Mint a token-protected, read-only public URL for an approved pack. The raw token is returned here **exactly once**; a new link replaces the previous one. Refused for a draft. Parameters: - pack_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/firm/advisory-packs The firm's advisory pack states One row per client the caller can see: the newest pack's month and whether it is a draft or approved, or `none`. Parameters: - firm_id (query, string, optional): The firm to read; defaults to the caller's staff firm. Responses: 200, 401, 403, 422 ## advisory-packs-public ### GET /api/v1/public/advisory-packs/{token} Public advisory pack viewer (unauthenticated) Resolve a share token to an approved pack's sections and figures. 404 for unknown, revoked or unapproved packs alike; rate-limited per IP. Parameters: - token (path, string, required) Responses: 200, 404, 422, 429 ## agents ### GET /api/v1/agents/cards List agent cards What runs are waiting on a person for. Default: pending cards. Parameters: - status (query, string, optional): pending, answered, denied, expired, cancelled or all - run_id (query, string, optional): One run's cards Responses: 200, 400, 401, 403, 422 ### POST /api/v1/agents/cards/{card_id}/answer Answer an agent card Allow or deny a permission, answer a question, confirm a sign-in or hand over a secret. The run continues. `409` when already answered. Parameters: - card_id (path, string, required) Request body (AgentCardAnswerRequest): - decision (string, required) - answer (object | string, optional) - note (string, optional) - scope (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/agents/channel/posts Read the Team chat The business's shared room, oldest to newest: people's messages, one post per job (its runs inline) and Regent's routing lines. Without a cursor the newest page; `before` pages older (`next_cursor`), `after` returns up to 100 newer posts. `role_id` keeps one teammate's work. Parameters: - before (query, string, optional): Post id: the page older than it - after (query, string, optional): Post id: only posts newer than it - role_id (query, string, optional): One teammate's work - limit (query, integer, optional): Page size (max 50) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/agents/channel/posts Post to the Team chat Post a message. Each mentioned teammate (up to 3) gets a job with the message as its brief, run as you. With no mention Regent picks a teammate, says it can't, or stays out of a conversation between people. Refused for a disabled or paused teammate (AGENT_004). Request body (ChannelPostCreate): - text (string, required) - mention_role_ids (array · string, optional) Responses: 201, 400, 401, 403, 404, 409, 422, 503 ### DELETE /api/v1/agents/channel/posts/{post_id} Delete your Team chat message Withdraw a message you wrote: its text is cleared and `deleted_at` set; the post stays so replies keep their place. Needs write permission, not delete. Someone else's message is `403`. Parameters: - post_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/agents/channel/posts/{post_id} Get one Team chat post One post with its runs, e.g. after a live hint. `404` (AGENT_027) when it is not on this business. Parameters: - post_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/agents/channel/posts/{post_id} Edit your Team chat message Replace the text of a message you wrote (1 to 4000 characters); the post shows `edited_at`. Someone else's message is `403`, a job or Regent post or a deleted message `400`. Parameters: - post_id (path, string, required) Request body (ChannelPostUpdate): - text (string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/agents/channel/posts/{post_id}/reactions React to a Team chat post Put one of the six reactions (👍 ✅ 👀 🎉 ❤️ 😂) on a post. A repeat is a no-op. Returns the post with its reactions; `mine` marks yours. Parameters: - post_id (path, string, required) Request body (ChannelReactionRequest): - emoji (string, required) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/agents/channel/posts/{post_id}/reactions/{emoji} Remove your reaction from a Team chat post Take your `emoji` off the post (missing is a no-op). Needs write permission. Parameters: - post_id (path, string, required) - emoji (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/agents/channel/read Mark the Team chat read Remember the newest post you have seen. The pointer only moves forward; `GET /channel/posts` returns it as `last_read_post_id` and `GET /channel/unread` counts what came after it. Any business reader. Request body (ChannelReadRequest): - post_id (string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/agents/channel/stream Stream Team chat hints (SSE) Server-Sent Events: `data: {"type": "post", "post_id"}` when a post is added and `data: {"type": "run", "run_id", "post_id", "event"}` when a job's run moves on, with a `: heartbeat` comment every 15 s. Re-read the posts the hint names; the stream carries no content. Responses: 200, 401, 403, 422 ### GET /api/v1/agents/channel/unread Count unread Team chat posts Posts after the caller's last read, not counting their own messages or deleted ones. Capped at 999. Responses: 200, 401, 403, 422 ### GET /api/v1/agents/controls Agent Controls: every subject that can act on this business Agent roles, connected MCP clients and partner API clients with their scopes, mandates, spend this period against the ceiling, and their last actions from the usage ledger. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/engines Engine status (superuser) Which engines the agents worker can run, whether each is signed in, and whether a worker is online. Superusers only. Parameters: - refresh (query, boolean, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/engines/activity Agent runs across every business (superuser) What agents are doing on every business, newest first: open runs (queued, running, waiting) by default, or every run with `status=all`. Each run carries its business name and live `activity` line. Superusers only. Parameters: - status (query, string, optional): open (default) or all - business_id (query, string, optional): One business's runs - cursor (query, string, optional): next_cursor from the last page - limit (query, integer, optional): Page size (max 200) Responses: 200, 400, 401, 403, 422 ### DELETE /api/v1/agents/engines/dropbox Disconnect the team Dropbox (superuser) Revoke DayZero's token at Dropbox and forget it. Folder mappings and the app key stay. Superusers only. Responses: 200, 401, 403, 422 ### GET /api/v1/agents/engines/dropbox Team Dropbox status (superuser) Whether the staff team Dropbox is set up and connected, the account and team, and the OAuth redirect URI to register in the Dropbox App Console. Superusers only. Responses: 200, 401, 403, 422 ### PUT /api/v1/agents/engines/dropbox/app Set the Dropbox app key and secret (superuser) Store the Dropbox app's key and secret (encrypted). A different app key forgets the current sign-in. Superusers only. Request body (TeamDropboxAppCredentialsRequest): - app_key (string, required) - app_secret (string, required) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/agents/engines/dropbox/browse Browse the team Dropbox (superuser) One folder's children, folders first; `path` empty is the root of the team space. `400 DROPBOX_002` when Dropbox is not connected. Superusers only. Parameters: - path (query, string, optional): Folder path; empty = root Responses: 200, 400, 401, 403, 422 ### POST /api/v1/agents/engines/dropbox/connect Start connecting the team Dropbox (superuser) Returns the Dropbox consent URL to open in this browser and sets the browser-binding cookie the callback checks. `400 DROPBOX_001` until an app key and secret are set. Superusers only. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/agents/engines/dropbox/folders Team Dropbox folder mappings (superuser) Every Dropbox folder staff runs may use: shared folders first, then each business's. Superusers only. Responses: 200, 401, 403, 422 ### POST /api/v1/agents/engines/dropbox/folders Map a Dropbox folder (superuser) Map a Dropbox folder to a business, or share it with every staff run (no `business_id`). The folder must exist. `409` when it is already mapped there. Superusers only. Request body (TeamDropboxFolderCreate): - business_id (string, optional) - path (string, required) - label (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### DELETE /api/v1/agents/engines/dropbox/folders/{folder_id} Remove a Dropbox folder mapping (superuser) Stop staff runs using this folder. Nothing in Dropbox changes. Parameters: - folder_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/engines/dropbox/oauth/callback Team Dropbox OAuth callback Handle the redirect from Dropbox's consent page. Parameters: - code (query, string, optional): Authorization code - state (query, string, optional): Single-use OAuth state nonce - error (query, string, optional): Set when the person declines Responses: 200, 422 ### GET /api/v1/agents/engines/mcp-usage External MCP servers and agents' use of them (superuser) Every external MCP server connected on any business: health, whether agents may use it, its tool count and agents' calls in the last 30 days. Superusers only. Responses: 200, 401, 403, 422 ### GET /api/v1/agents/engines/runs/{run_id}/events Read any business's run transcript (superuser) Transcript events of a run on any business after `after_seq`, in order. Pass `last_seq` back as `after_seq`. Superusers only. Parameters: - run_id (path, string, required) - after_seq (query, integer, optional): Return events with seq above this - limit (query, integer, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/engines/spend Agent spend across every business (superuser) Runs, tokens and cost per business and role for one month (default: this month), over every business that ran an agent. Superusers only. Parameters: - month (query, string, optional): YYYY-MM; default this month Responses: 200, 400, 401, 403, 422 ### DELETE /api/v1/agents/engines/{engine}/credential Disconnect an engine account (superuser) Forget the stored credential; the row becomes `revoked` and every role on the engine stops until someone reconnects it (the worker's environment token is only used when there is no row at all). Parameters: - engine (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/agents/engines/{engine}/credential Paste an engine credential (superuser) Store a token made on a laptop: the `sk-ant-oat01-…` token from `claude setup-token`, or the text of `~/.codex/auth.json`; or with `kind = api_key` an Anthropic / OpenAI API key. The row is `connected` at once; its first use (or `POST /engines/{engine}/test`) proves it. `400 AGENT_012` when the shape is wrong. Parameters: - engine (path, string, required) Request body (EngineCredentialRequest): - credential (string, required) - label (string, optional) - kind (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/agents/engines/{engine}/sign-in Sign an engine in from the worker (superuser) Start `claude setup-token` or `codex login --device-auth` on the agents worker. Poll `/engines` for the URL and code to show. `503 AGENT_008` when no worker is online, `409 AGENT_011` while a sign-in is already running, `404 AGENT_013` for an engine without a firm account. Parameters: - engine (path, string, required) Responses: 201, 401, 403, 404, 409, 422, 503 ### POST /api/v1/agents/engines/{engine}/sign-in/cancel Cancel an engine sign-in (superuser) Stop the sign-in running on the worker. The row goes back to `connected` when an older credential is still stored, else `revoked`. `409 AGENT_011` when nothing is pending. Parameters: - engine (path, string, required) Responses: 200, 401, 403, 404, 409, 422 ### POST /api/v1/agents/engines/{engine}/sign-in/code Paste the code the browser showed (superuser) Claude Code: hand the one-time code from the browser to the sign-in running on the worker. `409 AGENT_011` unless a sign-in is pending and waiting for a code. Parameters: - engine (path, string, required) Request body (EngineSignInCodeRequest): - code (string, required) Responses: 200, 400, 401, 403, 404, 409, 422, 503 ### POST /api/v1/agents/engines/{engine}/test Test an engine's credential (superuser) An API key is checked against the provider's API (no tokens spent); a rejected key marks the account `error`. A subscription token gets a local check (format, expiry, last successful run on the worker) and says so in `method`. Parameters: - engine (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/firm/overview Every client's team (firm roll-up) One row per business and role across every business the caller can see: status, open runs, what needs a person, cost this month, the last and the next scheduled job; plus a total per business. Members of an advisory firm (and DayZero staff) only. Responses: 200, 401, 403, 422 ### GET /api/v1/agents/library List the agent role library and shared procedures The firm's role templates (Data Ops, Bookkeeper, Controller, AP Desk, Cash Analyst) in `items`, plus shared procedures in three groups: `mine` (this business's), `firm` (shared by the firm's other clients) and `public` (everyone's, newest first, with install counts and the publishing business's name only). Responses: 200, 401, 403, 422 ### GET /api/v1/agents/library/{procedure_id} Read a shared procedure One firm-shared or public procedure with its SOP text and draft. Parameters: - procedure_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/agents/library/{procedure_id}/install Install a shared procedure Copy a firm-shared or public procedure into this business: SOP text, description and draft, with `source_procedure_id` set; the source's `install_count` grows. Installing twice returns the existing copy. Parameters: - procedure_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/agents/mail Agents Mail Settings Responses: 200, 401, 403, 422 ### PUT /api/v1/agents/mail Agents Mail Configure Request body (MailboxUpdate): - enabled (boolean, required) - display_name (string, required) - reminder_days (integer, optional) - max_reminders (integer, optional) - acknowledge_receipts (boolean, optional) - remove_promotions (boolean, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mail/client/threads Agents Mail Client Threads Parameters: - cursor (query, string, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mail/client/threads/{thread_id} Agents Mail Client Thread Parameters: - thread_id (path, string, required) - before (query, string, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mail/client/threads/{thread_id}/messages/{message_id}/attachments/{index} Agents Mail Client Attachment Parameters: - thread_id (path, string, required) - message_id (path, string, required) - index (path, integer, required) Responses: 200, 401, 403, 422 ### POST /api/v1/agents/mail/client/threads/{thread_id}/reply Agents Mail Client Reply Clients may answer only conversations addressed to their own signed-in email. Parameters: - thread_id (path, string, required) Request body (MailDraftUpdate): - body (string, required) - message_id (string, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/agents/mail/drafts Agents Mail Compose Request body (MailCompose): - to (string · email, required) - subject (string, required) - body (string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/agents/mail/emails/{email_id}/conversation Agents Mail Open Email Parameters: - email_id (path, string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/agents/mail/emails/{email_id}/restore Agents Mail Restore Email Parameters: - email_id (path, string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/agents/mail/grants Agents Mail Grant Request body (MailGrantCreate): - email (string · email, required) - procedure_id (string, required) - job_id (string, required) - response_mode (string, optional) - confirm_start (boolean, optional) - allowed_tools (array · string, required) - browser_hosts (array · string, optional) Responses: 201, 401, 403, 422 ### DELETE /api/v1/agents/mail/grants/{grant_id} Agents Mail Revoke Parameters: - grant_id (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mail/inbox Agents Mail Inbox Parameters: - cursor (query, string, optional) - folder (query, string, optional) - search (query, string, optional) - category (query, string, optional) - sort (query, string, optional) Responses: 200, 401, 403, 422 ### PUT /api/v1/agents/mail/inbox/{kind}/{item_id}/category Agents Mail Category Parameters: - kind (path, string, required) - item_id (path, string, required) Request body (MailCategoryUpdate): - category (string, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mail/messages/{message_id}/attachments/{index} Agents Mail Attachment Parameters: - message_id (path, string, required) - index (path, integer, required) Responses: 200, 401, 403, 422 ### POST /api/v1/agents/mail/messages/{message_id}/send Agents Mail Send Parameters: - message_id (path, string, required) Request body (MailDecision): - content_hash (string, required) Responses: 201, 401, 403, 422 ### GET /api/v1/agents/mail/senders Agents Mail Senders Everyone who has emailed the business, waiting decisions first. Parameters: - status (query, string, optional) - search (query, string, optional) - contact_type (query, string, optional) - offset (query, integer, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mail/senders/{sender_id} Agents Mail Sender One sender: who they are, what they sent, and what Regent sent them. Parameters: - sender_id (path, string, required) Responses: 200, 401, 403, 422 ### PATCH /api/v1/agents/mail/senders/{sender_id} Agents Mail Sender Update Parameters: - sender_id (path, string, required) Request body (MailSenderUpdate): - display_name (string, optional) - company (string, optional) - notes (string, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/agents/mail/senders/{sender_id}/link Agents Mail Sender Link Make the sender a vendor, contractor, employee or customer (and allow them). Parameters: - sender_id (path, string, required) Request body (MailSenderLink): - contact_type (string, required) - record_id (string, optional) - name (string, optional) Responses: 201, 401, 403, 422 ### PUT /api/v1/agents/mail/senders/{sender_id}/status Agents Mail Sender Status Allow (and read their held mail), block, or reset a sender. Parameters: - sender_id (path, string, required) Request body (MailSenderDecision): - status (string, required) - whole_domain (boolean, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mail/sent Agents Mail Sent Email Regent sent for the business, with delivery and open status. Parameters: - recipient (query, string, optional) - kind (query, string, optional) - ref_id (query, string, optional) - offset (query, integer, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mail/threads Agents Mail Threads Parameters: - cursor (query, string, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mail/threads/{thread_id} Agents Mail Thread Parameters: - thread_id (path, string, required) - before (query, string, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/agents/mail/threads/{thread_id}/drafts Agents Mail Draft Parameters: - thread_id (path, string, required) Request body (MailDraftUpdate): - body (string, required) - message_id (string, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/agents/mail/threads/{thread_id}/start Agents Mail Start Parameters: - thread_id (path, string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/agents/mail/threads/{thread_id}/suggested-reply Agents Mail Suggest Reply Parameters: - thread_id (path, string, required) Responses: 201, 401, 403, 422 ### PUT /api/v1/agents/mail/threads/{thread_id}/takeover Agents Mail Takeover Parameters: - thread_id (path, string, required) Request body (MailTakeover): - enabled (boolean, required) Responses: 200, 401, 403, 422 ### GET /api/v1/agents/mandates List payment mandates List mandates, newest first. Parameters: - subject_type (query, string, optional) - subject_id (query, string, optional) - include_revoked (query, boolean, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/agents/mandates Propose a payment mandate Propose a mandate for an agent subject. A different owner or admin counter-signs it before it takes effect. The business's only admin may pass `self_sign=true`; the row and the audit log record that. Request body (AgentMandateCreate): - subject_type (string, required) - subject_id (string, required) - purpose (string, required) - allowed_vendor_ids (array · string, optional) - per_payment_ceiling_cents (integer, required) - period_ceiling_cents (integer, required) - period (string, optional) - valid_from (string · date-time, optional) - valid_to (string · date-time, optional) - self_sign (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/agents/mandates/{mandate_id} Get a payment mandate One mandate with its spend this period. Parameters: - mandate_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/mandates/{mandate_id}/ap2 Export a mandate as an AP2 v0.2-shaped payment mandate A JSON document shaped after the AP2 PaymentMandate (shape only; nothing is sent to any network). The user authorization field is DayZero's HMAC signature. Refused for an unsigned mandate (AGENT_040). Parameters: - mandate_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/agents/mandates/{mandate_id}/countersign Counter-sign a proposed mandate A different owner or admin signs the proposal. Computes the HMAC signature over the canonical mandate; the mandate is active from `valid_from`. Parameters: - mandate_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/agents/mandates/{mandate_id}/revoke Revoke a payment mandate Agent payments under it stop at once; idempotent. Parameters: - mandate_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/agents/mandates/{mandate_id}/uses List a mandate's uses Every payment the mandate covered, newest first (up to 200). Parameters: - mandate_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/needs-you What agents need from you Pending proposed changes, open cards, parked questions and recent failed runs for this business, or every business you can see with `all=true`. Parameters: - all (query, boolean, optional): Every business the caller can see - limit (query, integer, optional) - counts_only (query, boolean, optional): Only the counts; every item list comes back empty Responses: 200, 401, 403, 422 ### GET /api/v1/agents/procedures List procedures Every SOP this business has turned into a procedure draft, newest first. Responses: 200, 401, 403, 422 ### POST /api/v1/agents/procedures Generate a procedure draft from SOP text Reads the SOP with the planner model and returns a draft of jobs, roles, schedules and params for review. Nothing is installed. Request body (ProcedureGenerateRequest): - source_text (string, required) - source_name (string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/agents/procedures/{procedure_id} Get a procedure One procedure with its current draft and what its last install created. Parameters: - procedure_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/agents/procedures/{procedure_id} Replace a procedure's draft Save the reviewed draft (edited jobs, roles, schedules) and, when sent, the description others read in the library; bumps the version. Parameters: - procedure_id (path, string, required) Request body (ProcedureUpdateRequest): - draft (ProcedureDraft, required) → ProcedureDraft - description (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/agents/procedures/{procedure_id}/install Install a procedure Create or update the agent roles the draft names (library template plus the draft's additions) and one scheduled workflow per scheduled job, each a single agent_run node. Refused with AGENT_009 when the draft is invalid. Parameters: - procedure_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/agents/procedures/{procedure_id}/publish Share a procedure `firm`: every business the firm manages sees it (the business must belong to a firm). `public`: every DayZero business sees it; needs the business admin permission and a description, and the SOP text is scrubbed of secrets, emails, tokens in URLs and account numbers first. Refused with AGENT_031 (naming the line) when a credential still shows. Parameters: - procedure_id (path, string, required) Request body (ProcedurePublishRequest): - visibility (string, required) - description (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/agents/procedures/{procedure_id}/refresh Update a team from its SOP Start regenerating the team's draft from the linked SOP's current text (poll GET /sops/generations/{id}). The team stays behind until the new draft is installed. AGENT_014 when the procedure is unlinked, 409 AGENT_017 when a person edited the draft (send discard_edits). Parameters: - procedure_id (path, string, required) Responses: 202, 400, 401, 403, 404, 409, 422 ### GET /api/v1/agents/procedures/{procedure_id}/source-diff Compare a copy with its source The SOP text of the shared procedure this copy was installed from, next to the copy's own text, so a person can see what a sync would change. Parameters: - procedure_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/agents/procedures/{procedure_id}/sync-from-source Update a copy from its source Re-copy the source's SOP text, description, jobs, schedules and notes; the copy keeps its own role configuration and params. Bumps the version; re-install the team to apply it. Parameters: - procedure_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/agents/procedures/{procedure_id}/unpublish Stop sharing a procedure Back to this business only. Copies other businesses installed keep working. Parameters: - procedure_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/roles List agent roles The business's team of agents with open runs and cost this month. Parameters: - include_disabled (query, boolean, optional): Include disabled roles Responses: 200, 401, 403, 422 ### POST /api/v1/agents/roles Create an agent role Add an agent to the team. The claude_code and codex engines run on the firm's own subscriptions and are for DayZero staff only (AGENT_003). Business admins only. Request body (AgentRoleCreate): - name (string, required) - title (string, optional) - instructions (string, optional) - skills (array · AgentSkill, optional) → AgentSkill - engine (string, optional) - model (string, optional) - scope (string, optional) - allowed_tools (array · string, optional) - params (object, optional) - spend_cap_usd_month (string, optional) - max_cost_usd_run (string, optional) - browser (boolean, optional) - library_key (string, optional) - persona (AgentPersonaUpdate, optional) Responses: 201, 400, 401, 403, 409, 422 ### DELETE /api/v1/agents/roles/{role_id} Delete an agent role Remove the role; its runs, transcripts and cards go with it. Business admins only. Parameters: - role_id (path, string, required) Responses: 204, 401, 403, 404, 422 ### GET /api/v1/agents/roles/{role_id} Get an agent role One role with its roll-ups. Parameters: - role_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/agents/roles/{role_id} Update an agent role Change what was sent; a null title, model or allowed_tools clears it. Business admins only. Parameters: - role_id (path, string, required) Request body (AgentRoleUpdate): - name (string, optional) - title (string, optional) - instructions (string, optional) - skills (array · AgentSkill, optional) - engine (string, optional) - model (string, optional) - scope (string, optional) - allowed_tools (array · string, optional) - params (object, optional) - spend_cap_usd_month (string, optional) - max_cost_usd_run (string, optional) - enabled (boolean, optional) - paused (boolean, optional) - browser (boolean, optional) - persona (AgentPersonaUpdate, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/agents/roles/{role_id}/permission-grants List a role's always-allowed tools The role-wide "allow always" answers DayZero staff gave on permission cards: every run of the role uses the tool (a shell tool: that exact command) without asking. Business admins only. Parameters: - role_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/agents/roles/{role_id}/permission-grants/{grant_id} Revoke a role's always-allowed tool Forget one role-wide grant; the next run that wants the tool opens a permission card again. Answers the grants that are left. Business admins only. Parameters: - role_id (path, string, required) - grant_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/agents/roles/{role_id}/run Hand a job to a role Start a run of this role. Refused when the role is disabled or paused (AGENT_004) or over its monthly spend cap (AGENT_006). Parameters: - role_id (path, string, required) Request body (AgentRoleRunRequest): - brief (string, required) - title (string, optional) - done_when (string, optional) - conversation_id (string, optional) - origin (string, optional) - period_id (string, optional) - checklist_item_key (string, optional) - workflow_run_id (string, optional) - max_cost_usd (string, optional) - parent_run_id (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422, 503 ### POST /api/v1/agents/routines/dismiss Agents Routine Dismiss Request body (DismissPattern): - role_id (string, required) - key (string, required) Responses: 201, 401, 403, 422 ### GET /api/v1/agents/routines/opportunities Agents Routine Opportunities Responses: 200, 401, 403, 422 ### GET /api/v1/agents/routines/today Agents Routine Today Responses: 200, 401, 403, 422 ### GET /api/v1/agents/runs List agent runs Runs on this business, newest first, with cursor paging. Parameters: - role_id (query, string, optional): One role's runs - status (query, string, optional): queued, running, needs_input, completed, failed, cancelled or a comma-separated list - conversation_id (query, string, optional): Runs started from one Regent thread - cursor (query, string, optional): next_cursor from the last page - limit (query, integer, optional): Page size (max 200) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/agents/runs Start an agent run Hand a job to a role. Refused when the role is disabled or paused (AGENT_004) or over its monthly spend cap (AGENT_006). Request body (AgentRunCreate): - role_id (string, required) - brief (string, required) - title (string, optional) - done_when (string, optional) - result_checks (array · AgentResultCheck, optional) → AgentResultCheck - conversation_id (string, optional) - origin (string, optional) - period_id (string, optional) - checklist_item_key (string, optional) - workflow_run_id (string, optional) - max_cost_usd (string, optional) - parent_run_id (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422, 503 ### GET /api/v1/agents/runs/{run_id} Get an agent run One run with its status, result and open-card count. Parameters: - run_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/agents/runs/{run_id}/answer Answer a run's question Answer the question a run parked on (`needs_input` with no card) and let it continue. `409` when the run is not waiting. Parameters: - run_id (path, string, required) Request body (AgentRunAnswer): - text (string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/agents/runs/{run_id}/dismiss Take a job off Needs you without answering it A failed job leaves Needs you (it stays failed in Runs). A job waiting on a question closes as not needed: it ends `cancelled` with outcome `dismissed` and does no more work. `409` for any other run. Parameters: - run_id (path, string, required) Responses: 200, 401, 403, 404, 409, 422 ### GET /api/v1/agents/runs/{run_id}/events Read a run's transcript Transcript events after `after`, in order. Pass `last_seq` back as `after`. Parameters: - run_id (path, string, required) - after (query, integer, optional): Return events with seq above this - limit (query, integer, optional) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/agents/runs/{run_id}/reopen Reopen a job that expired waiting for an answer A job nobody answered for seven days closes as `Expired: no answer` with its question kept. Reopen parks it on the same question for another seven days; answering resumes it. `409` (AGENT_042) for any other run. Parameters: - run_id (path, string, required) Responses: 200, 401, 403, 404, 409, 422 ### POST /api/v1/agents/runs/{run_id}/routine Agents Routine From Run Parameters: - run_id (path, string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/agents/runs/{run_id}/steer Adjust a running agent run Give a run new instructions mid-task. The turn in flight is interrupted and the next one starts with the note; work already done stays done, and a gated write the note asks for is still filed as a proposed change. A run waiting on a question takes the note as its answer; a queued run reads it on its first turn. Appends a `steer` event. `409` (AGENT_005) when the run is not queued, running or waiting. Parameters: - run_id (path, string, required) Request body (AgentRunSteer): - text (string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/agents/runs/{run_id}/stop Stop an agent run Ask the run to stop; it ends `cancelled`. `409` when it is not open. Parameters: - run_id (path, string, required) Responses: 200, 401, 403, 404, 409, 422 ### GET /api/v1/agents/runs/{run_id}/stream Stream a run's transcript (SSE) Server-Sent Events: replays events after `after`, then relays new ones as `event: ` frames with a `: heartbeat` comment every 15 s. Closes after run.completed, run.failed or run.cancelled. Parameters: - run_id (path, string, required) - after (query, integer, optional): Resume after this seq Responses: 200, 401, 403, 404, 422 ### POST /api/v1/agents/runs/{run_id}/trial Agents Routine Trial Parameters: - run_id (path, string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/agents/runs/{run_id}/verify Agents Routine Verify Parameters: - run_id (path, string, required) Responses: 201, 401, 403, 422 ### GET /api/v1/agents/sops List SOPs The business's own SOPs and, when it belongs to an advisory firm, the firm's shared library (scope=firm; written by firm owners and admins). Parameters: - scope (query, string, optional): business, firm or all - include_archived (query, boolean, optional): Include archived SOPs - archived_only (query, boolean, optional): Only archived SOPs Responses: 200, 401, 403, 422 ### POST /api/v1/agents/sops Create an SOP Write an SOP in the app; an empty body starts from the template. Request body (SopCreateRequest): - title (string, required) - slug (string, optional) - body_md (string, optional) - status (string, optional) - scope (string, optional) Responses: 201, 400, 401, 403, 409, 422 ### POST /api/v1/agents/sops/format Auto-structure notes as an SOP Turn plain-English checklist notes or extracted Word text into structured SOP markdown with YAML front matter and `## J-NN` job sections. A rule-based pass (headings and bullets become jobs), not a model. Request body (SopFormatRequest): - title (string, optional) - body_md (string, required) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/agents/sops/generations/{generation_id} Get a team generation Poll a team generation started by generate or refresh until its status is succeeded (the team's procedure is included) or failed (with the reason). Parameters: - generation_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/sops/suggestions Suggested SOPs SOPs worth writing for this business, ranked, from what it has connected (bank and card feeds, Shopify, Stripe, QuickBooks, payroll), its bill and invoice volume, open periods, and the SOPs and roles it already has. Each names a starter template and an owner role; already_have marks one a draft or live SOP covers. Parameters: - include_existing (query, boolean, optional): Also return suggestions an SOP already covers Responses: 200, 401, 403, 422 ### POST /api/v1/agents/sops/upload Upload an SOP A .md, .txt or .docx file (up to 10 MB; at most 400,000 characters of text) becomes a draft SOP (``source = upload``). Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/agents/sops/{sop_id} Archive an SOP Hide the SOP from the library; procedures built from it keep working. Parameters: - sop_id (path, string, required) Responses: 204, 401, 403, 404, 422 ### GET /api/v1/agents/sops/{sop_id} Get an SOP The document, its parsed jobs and the format problems to fix. Parameters: - sop_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/agents/sops/{sop_id} Update an SOP Edit the document or its header; the front matter always follows the header. A save that changes nothing makes no new version. Send expected_updated_at to be refused with 409 AGENT_015 when the SOP changed since it was loaded. Retiring pauses its teams' schedules. Parameters: - sop_id (path, string, required) Request body (SopUpdateRequest): - title (string, optional) - body_md (string, optional) - status (string, optional) - version (string, optional) - owner (string, optional) - effective (string · date, optional) - change_note (string, optional) - version_bump (string, optional) - expected_updated_at (string · date-time, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/agents/sops/{sop_id}/duplicate Duplicate an SOP Create an editable business copy of any accessible SOP (including Firm library templates). Parameters: - sop_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/agents/sops/{sop_id}/generate Build or update the team for an SOP Start reading a live SOP with the planner model; poll GET /sops/generations/{id} for the procedure draft (jobs, roles, schedules) to review. A business has one team per SOP: when it exists its draft is replaced (409 AGENT_017 if a person edited it, unless discard_edits). 400 AGENT_016 for a draft, retired or archived SOP, AGENT_019 when the SOP has format problems. For a firm SOP the caller must be a firm owner or admin. Parameters: - sop_id (path, string, required) Responses: 202, 400, 401, 403, 404, 409, 422 ### POST /api/v1/agents/sops/{sop_id}/improvements Agents Routine Improvement Parameters: - sop_id (path, string, required) Request body (LearnFromRun): - run_id (string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/agents/sops/{sop_id}/restore Restore a previous SOP revision Make a saved revision's text current again as a new version; the SOP keeps its status. 409 AGENT_015 when expected_updated_at is stale. Parameters: - sop_id (path, string, required) Request body (SopRestoreRequest): - revision_id (string, required) - expected_updated_at (string · date-time, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/agents/sops/{sop_id}/revisions List an SOP's revisions Every saved version, newest first (the first is the current text). No document text. Parameters: - sop_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/sops/{sop_id}/revisions/{revision_id} Get an SOP revision One saved version with its full text (for compare and restore). Parameters: - sop_id (path, string, required) - revision_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/agents/sops/{sop_id}/teams/resume Resume the teams of an SOP Turn back on the schedules that retiring the SOP paused. Parameters: - sop_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/agents/sops/{sop_id}/unarchive Unarchive an SOP Put an archived SOP back in the library. Parameters: - sop_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/spend Agent spend by role Runs and cost per role for one month (default: this month). Parameters: - month (query, string, optional): YYYY-MM; default this month - all (query, boolean, optional): Every business the caller can see Responses: 200, 400, 401, 403, 422 ### GET /api/v1/agents/staff/browser-sessions List a business's roles' browser sign-ins (superuser) The roles on the business that keep a browser sign-in between runs, and the sites (cookie domains) they are signed in to. Superusers only. Parameters: - business_id (query, string, required): The business Responses: 200, 401, 403, 422 ### DELETE /api/v1/agents/staff/browser-sessions/{role_id} Sign a role out of every site (superuser) Forget the role's saved cookies and storage; its next run starts signed out. Superusers only. Parameters: - role_id (path, string, required) - business_id (query, string, required): The business Responses: 204, 401, 403, 404, 422 ### GET /api/v1/agents/staff/logins List saved logins (superuser) The logins browser roles may fill for one business or one firm, plus read-only rows from its own 1Password connection and from team vaults mapped to it (source=1password). Never a password or two-factor key. Superusers only. Parameters: - business_id (query, string, optional): The business whose logins these are - firm_id (query, string, optional): The advisory firm whose logins these are Responses: 200, 400, 401, 403, 422 ### POST /api/v1/agents/staff/logins Save a login (superuser) Save a username and password (and optionally a two-factor setup key) for one exact host. The same owner, host and username (any case) replaces the saved one. AGENT_022 for an address that is not a website, AGENT_023 for a two-factor key that cannot be read. Superusers only. Parameters: - business_id (query, string, optional): The business whose logins these are - firm_id (query, string, optional): The advisory firm whose logins these are Request body (LoginCreate): - scope (string, optional) - host (string, required) - username (string, optional) - password (string, required) - totp (string, optional) - label (string, optional) - role_ids (array · string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/agents/staff/logins/scope A business's login scope (superuser) The business, the firm whose logins and vaults its runs also use, and its roles for the role picker. Superusers only. Parameters: - business_id (query, string, required): The business Responses: 200, 400, 401, 403, 422 ### DELETE /api/v1/agents/staff/logins/{login_id} Delete a saved login (superuser) Remove a saved login of the named owner. Parameters: - login_id (path, string, required) - business_id (query, string, optional): The business whose logins these are - firm_id (query, string, optional): The advisory firm whose logins these are Responses: 204, 400, 401, 403, 404, 422 ### PATCH /api/v1/agents/staff/logins/{login_id} Update a saved login (superuser) Change what was sent. A new password replaces the old one; an empty totp removes the two-factor key; a null role_ids lets every role use it. 1Password rows are changed in 1Password. Superusers only. Parameters: - login_id (path, string, required) - business_id (query, string, optional): The business whose logins these are - firm_id (query, string, optional): The advisory firm whose logins these are Request body (LoginUpdate): - username (string, optional) - password (string, optional) - totp (string, optional) - label (string, optional) - role_ids (array · string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### DELETE /api/v1/agents/staff/team-vault Disconnect the team 1Password (superuser) Forget the token and the index; vault mappings stay for a reconnect. AGENT_025 when it is not connected. Superusers only. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/agents/staff/team-vault Get the team 1Password (superuser) DayZero's 1Password service account: whether it is connected, each vault it reads with its item count and the business or firm it is mapped to. Superusers only. Responses: 200, 401, 403, 422 ### PUT /api/v1/agents/staff/team-vault Connect the team 1Password (superuser) Store DayZero's 1Password service account token after reading its vaults with it. AGENT_024 when 1Password does not accept the token. Replaces an earlier token; vault mappings are kept. Superusers only. Request body (TeamVaultConnectRequest): - token (string, required) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/agents/staff/team-vault/refresh Refresh the team 1Password index (superuser) Read the vaults again. A failure answers status=error with last_error. AGENT_025 when the team vault is not connected. Superusers only. Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/agents/staff/team-vault/vaults/{vault_id}/mapping Unmap a team vault (superuser) No client uses the vault's logins any more. Superusers only. Parameters: - vault_id (path, string, required) Responses: 200, 401, 403, 422 ### PUT /api/v1/agents/staff/team-vault/vaults/{vault_id}/mapping Map a team vault to a client (superuser) Give one vault to one business or one firm (replacing its client): browser runs for that business, or the firm's businesses, use its logins. Superusers only. Parameters: - vault_id (path, string, required) Request body (TeamVaultMapRequest): - business_id (string, optional) - firm_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/agents/staff/vault Disconnect a business's or firm's 1Password (superuser) Forget the token and the index. AGENT_025 when none is connected. Superusers only. Parameters: - business_id (query, string, optional): The business whose logins these are - firm_id (query, string, optional): The advisory firm whose logins these are Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/agents/staff/vault Get a business's or firm's 1Password (superuser) Whether the owner has its own vault connected, its vaults and item count. Superusers only. Parameters: - business_id (query, string, optional): The business whose logins these are - firm_id (query, string, optional): The advisory firm whose logins these are Responses: 200, 400, 401, 403, 422 ### PUT /api/v1/agents/staff/vault Connect a business's or firm's 1Password (superuser) Store a 1Password service account token for one owner after reading its vaults with it. AGENT_024 when 1Password does not accept the token. Replaces an earlier token. Prefer the team vault. Superusers only. Parameters: - business_id (query, string, optional): The business whose logins these are - firm_id (query, string, optional): The advisory firm whose logins these are Request body (VaultConnectRequest): - scope (string, optional) - token (string, required) - role_ids (array · string, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/agents/staff/vault/refresh Refresh a business's or firm's 1Password index (superuser) Read the vault again. A failure answers status=error with last_error rather than an error response. AGENT_025 when no vault is connected. Superusers only. Parameters: - business_id (query, string, optional): The business whose logins these are - firm_id (query, string, optional): The advisory firm whose logins these are Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/agents/team/pause Pause the team Every role stops taking new runs; runs in flight finish. Business admins only. Responses: 200, 401, 403, 422 ### POST /api/v1/agents/team/resume Resume the team Every role takes new runs again. Business admins only. Responses: 200, 401, 403, 422 ### GET /api/v1/agents/timeline One timeline of every agent, connected app and approver Agent run tool calls, proposed changes, approval decisions, automation runs, mandate uses, writes refused in closed periods and OAuth grants, merged newest first. Parameters: - actor_type (query, string, optional) - actor_id (query, string, optional) - since (query, string · date-time, optional) - cursor (query, string, optional) - limit (query, integer, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/agents/tool-groups List tool groups and connected servers for a role's tool access The groups a role can be given (group:, one per DayZero tool mount) and this business's connected MCP servers (server:), with tool counts and who each server lets in. Responses: 200, 401, 403, 422 ### GET /api/v1/agents/vibes List teammate vibes The personalities a role can talk in, with a sample line each. A vibe changes tone only: documents, ledger text and proposed changes stay plain and numbers stay exact. Responses: 200, 401, 403, 422 ## ai-chat-public ### GET /api/v1/share/{token} Public conversation viewer (unauthenticated) Resolve a share token to a read-only conversation snapshot. Organization-only links answer 401 so the viewer can sign in and retry the member endpoint. Parameters: - token (path, string, required) Responses: 200, 401, 404, 422, 429 ### GET /api/v1/share/{token}/member Shared conversation viewer (authenticated) Resolve a share token for a signed-in viewer. Organization-only links require access to the business the conversation belongs to. Parameters: - token (path, string, required) Responses: 200, 401, 403, 404, 422 ## ai-reporting ### GET /api/v1/ai-reporting/decks List generated decks Cursor-paginated list of AI-generated decks for the business. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/ai-reporting/decks Generate a new AI deck Build a new deck from live data + AI commentary and persist it. Returns the full DeckSpec ready to render. Request body (GenerateDeckRequest): - prompt (string, required) - period_start (string · date, optional) - period_end (string · date, optional) - slide_types (array · string, optional) - title (string, optional) Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/ai-reporting/decks/{deck_id} Delete a deck Soft-delete a deck. Existing share links continue to 404. Parameters: - deck_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/ai-reporting/decks/{deck_id} Get a deck Fetch the full DeckSpec for a single deck. Parameters: - deck_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/ai-reporting/decks/{deck_id}/export Export a deck Export an already-generated deck to PPTX or PDF. The default path assembles the file natively from the stored DeckSpec (python-pptx / WeasyPrint) — searchable text, real tables, server-rendered charts. Clients may still upload rendered slide PNGs as multipart parts to force the legacy screenshot pipeline. Returns the file as a streaming response with a content-disposition header. Parameters: - deck_id (path, string, required) - format (query, string, optional) - commentary (query, string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/ai-reporting/decks/{deck_id}/refresh Refresh a deck with live data Re-pull live CFO-portal data into every data-bound slide of an existing deck. Titles, ordering, hidden flags, and commentary are preserved (pass regenerate_commentary=true to refresh the AI commentary too). The reporting period stays fixed — a refresh means 'same window, current numbers'. Parameters: - deck_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/ai-reporting/decks/{deck_id}/share Create a public share link for a deck Mint a SHA-256 token-protected public share URL. The raw token is returned in this response exactly once — store or display it immediately. Subsequent listings only show metadata (no token). Parameters: - deck_id (path, string, required) Request body (CreateShareRequest): - expires_in_hours (integer, optional) - slug (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/ai-reporting/decks/{deck_id}/shares List share links for a deck All share links (active and revoked) ordered newest first. Parameters: - deck_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/ai-reporting/decks/{deck_id}/slides Add a slide to a deck Insert a new slide. Data-bound types are populated from live CFO portal data (with AI commentary); 'custom' slides use the supplied markdown. Optional 0-based position, defaults to the end. Parameters: - deck_id (path, string, required) Request body (AddSlideRequest): - slide_type (string, required) - title (string, optional) - markdown (string, optional) - position (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/ai-reporting/decks/{deck_id}/slides/reorder Reorder slides Set a new slide order via a list of slide_ids. Parameters: - deck_id (path, string, required) Request body (ReorderSlidesRequest): - slide_ids (array · string, required) Responses: 201, 400, 401, 403, 404, 422 ### PATCH /api/v1/ai-reporting/decks/{deck_id}/slides/{slide_id} Edit a slide Patch the slide title, commentary (headline/claims/recommendation) or hidden flag. Use this for the 'edit commentary' button. Parameters: - deck_id (path, string, required) - slide_id (path, string, required) Request body (UpdateSlideRequest): - title (string, optional) - commentary (SlideCommentary, optional) - hidden (boolean, optional) - markdown (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/ai-reporting/decks/{deck_id}/slides/{slide_id}/duplicate Duplicate a slide Copy a slide (new id, same content, title suffixed with '(copy)') directly after the original. No body required. Parameters: - deck_id (path, string, required) - slide_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/ai-reporting/decks/{deck_id}/slides/{slide_id}/refresh Refresh a single slide with live data Re-pull live data for one data-bound slide. 400s for slide types that carry no live data (cover, asks, custom). Pass regenerate_commentary=true to refresh its AI commentary too. Parameters: - deck_id (path, string, required) - slide_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/ai-reporting/decks/{deck_id}/slides/{slide_id}/toggle-hidden Toggle slide visibility Flip the ``hidden`` flag on a single slide. No body required. Parameters: - deck_id (path, string, required) - slide_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### DELETE /api/v1/ai-reporting/shares/{share_id} Revoke a share link Mark the share as revoked. The public viewer returns 404 after. Parameters: - share_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## anomalies — AI-powered anomaly detection for unusual transactions and patterns. ### GET /api/v1/anomalies List transaction anomalies Return the latest pre-computed anomaly scan for the current business. Results are written by background jobs (daily cron & post-sync). Dismissed anomalies are excluded by default. Parameters: - severity (query, string, optional): Filter by severity: low, medium, high - anomaly_type (query, string, optional): Filter by anomaly type (e.g. duplicate_payment, unusual_amount) - show_dismissed (query, boolean, optional): Include previously dismissed anomalies - start_date (query, string · date, optional): Optional inclusive lower bound for anomaly date window (YYYY-MM-DD). - end_date (query, string · date, optional): Optional inclusive upper bound for anomaly date window (YYYY-MM-DD). Responses: 200, 401, 403, 422 ### POST /api/v1/anomalies/dismiss Dismiss an anomaly Mark a detected anomaly as dismissed with a reason and optional notes. Request body (app__api__v1__schemas__anomaly__DismissRequest): - fingerprint (string, required) - anomaly_type (string, required) - reason (string, required) - description (string, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/anomalies/dismiss-all Bulk dismiss all active anomalies Dismiss every active anomaly in the latest scan for the current business. Used by the notifications inbox when clearing the anomaly topic in bulk. Request body (BulkDismissAllRequest): - reason (string, required) - notes (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/anomalies/dismiss-by-period Bulk dismiss anomalies in a date range Dismiss every active anomaly whose date metadata overlaps the given period. Used by the close checklist's 'Dismiss all anomalies' CTA for historical periods that were reviewed offline. Request body (BulkDismissByPeriodRequest): - start_date (string · date, required) - end_date (string · date, required) - reason (string, required) - notes (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/anomalies/dismiss-type Bulk dismiss all anomalies of a given type Dismiss every active anomaly matching the specified type in one operation. Request body (BulkDismissRequest): - anomaly_type (string, required) - reason (string, required) - notes (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/anomalies/rescan Trigger an on-demand anomaly rescan Start a Temporal workflow that re-runs the anomaly detection engine for the current business and refreshes the cached scan results. Returns immediately; clients should refetch `GET /anomalies` shortly afterwards. Rate-limited to one rescan per business every 5 minutes. Responses: 201, 401, 403, 422, 429 ### POST /api/v1/anomalies/restore Restore a dismissed anomaly Remove a dismissal so the anomaly appears in active results again. Parameters: - fingerprint (query, string, required): Fingerprint of the anomaly to restore Responses: 201, 401, 403, 404, 422 ### GET /api/v1/anomalies/{fingerprint} Get anomaly finding detail Return the hydrated detail for a single anomaly fingerprint, including the recommended_action payload and the evidence rows shown in the side-by-side panel on the AnomaliesPage. Parameters: - fingerprint (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/anomalies/{fingerprint}/resolve Execute a recommended action and dismiss the anomaly Run the `recommended_action` attached to the finding (e.g. void duplicate payments, merge duplicate vendors) and record a `resolved` dismissal in the same call. For void actions the endpoint records the user's intent and stages the dismissal; the actual journal-entry mutation must be confirmed on the transaction itself to keep posting side-effects observable to the audit log. Parameters: - fingerprint (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## ap-approval — Accounts payable approval workflows for bill review and authorization. ### GET /api/v1/ap-approval Get AP approval workflow Get the AP approval workflow for the current business's firm. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/ap-approval/analytics Approval queue analytics Return queue health stats: pending counts by tier, average age, and oldest pending item. Responses: 200, 401, 403, 422 ### GET /api/v1/ap-approval/approvers Get approvers by tier Return the configured approver user IDs grouped by tier. Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/ap-approval/approvers/{tier} Update approvers for a tier Replace the approver list for a tier in the workflow graph. Parameters: - tier (path, string, required) Request body (SetApproversRequest): - user_ids (array · string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/ap-approval/batch-approve Batch approve pending items Approve multiple suspended workflow executions in a single request. Request body (BatchApproveRequest): - execution_ids (array · string, required) - comment (string, optional) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/ap-approval/completed List completed AP approvals List recently approved or rejected bills that have left the pending queue (their workflow run reached a terminal state). Parameters: - limit (query, integer, optional): Maximum number of completed rows to return. Responses: 200, 401, 403, 422 ### GET /api/v1/ap-approval/pending List pending AP approvals List bills currently suspended at an AP approval gate. Parameters: - tier (query, string, optional): Filter to a specific tier: 'ops', 'advisor', or 'owner'. - mine (query, boolean, optional): When true, only show approvals whose gate tier the caller is configured as an approver for. Responses: 200, 401, 403, 422 ### POST /api/v1/ap-approval/provision Provision AP approval workflow for firm Create or retrieve the AP approval workflow for the firm associated with this business. Parameters: - auto_approve_max_cents (query, integer, optional): Max amount in cents for auto-approval (default: $500) - ops_approve_max_cents (query, integer, optional): Max amount in cents for ops approval (default: $5,000) Responses: 201, 401, 403, 422 ### POST /api/v1/ap-approval/risk-score AI approval risk scores Get AI-powered risk scores for pending bill approvals. Responses: 201, 401, 403, 422 ### GET /api/v1/ap-approval/runs/{execution_id} Verify an AP approval run Re-read the bill behind an approval run: its status now, its receipt journal entry and the last continuation error. `state` is received, awaiting_approval, posting or failed. Parameters: - execution_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/ap-approval/thresholds Get approval thresholds and routing warnings Thresholds, tiers with their approvers, the routing branches and warnings: a reachable tier with no approvers (naming the bills waiting in it), an ops ceiling above $1,000,000, and labels that drifted from their conditions. Drifted labels are corrected on read. Responses: 200, 401, 403, 422 ### PATCH /api/v1/ap-approval/thresholds Update approval thresholds Update amount thresholds and/or escalation timeout without re-provisioning. Only provided fields are changed; the rest retain their current values. Request body (UpdateThresholdsRequest): - auto_approve_max_cents (integer, optional) - ops_approve_max_cents (integer, optional) - escalation_hours (integer, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/ap-approval/vendor-routes List vendor approval routes Approvers named per vendor (and optionally per expense ledger). A bill whose vendor has a matching route waits on those approvers instead of the amount tiers. Parameters: - vendor_id (query, string, optional): Only this vendor's routes - cursor (query, string, optional): next_cursor from the last page - limit (query, integer, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/ap-approval/vendor-routes Create a vendor approval route Name who approves a vendor's bills. Approvers must be owners, admins or members of the business, or staff at its managing firm. Request body (VendorApprovalRouteCreate): - vendor_id (string, required) - approver_user_ids (array · string, required) - require_all (boolean, optional) - ledger_id (string, optional) - max_amount_cents (integer, optional) - active (boolean, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### DELETE /api/v1/ap-approval/vendor-routes/{route_id} Delete a vendor approval route Remove a route. The vendor's next bills route by amount again; bills already waiting on the route's approvers keep waiting on them. Parameters: - route_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/ap-approval/vendor-routes/{route_id} Update a vendor approval route Change a route's approvers, ledger, ceiling, require-all or active flag. Bills already waiting keep the approvers they started with. Parameters: - route_id (path, string, required) Request body (VendorApprovalRouteUpdate): - approver_user_ids (array · string, optional) - require_all (boolean, optional) - ledger_id (string, optional) - max_amount_cents (integer, optional) - active (boolean, optional) - clear_ledger (boolean, optional) - clear_max_amount (boolean, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/ap-approval/vendor/{vendor_id}/history Vendor payment history Return recent bill history for a vendor to provide context at approval time. Parameters: - vendor_id (path, string, required) - limit (query, integer, optional): Number of recent bills to return. Responses: 200, 401, 403, 422 ## api-clients ### GET /api/v1/api-clients List API clients The caller's partner API clients, the token endpoint they use, the accepted assertion audiences, and whether mTLS is available. Responses: 200, 401, 403, 422 ### POST /api/v1/api-clients Create API client Register a partner API client with its public keys (JWK set). Requires the two-factor step-up; refused for API tokens. Request body (ApiClientCreate): - name (string, required) - description (string, optional) - scopes (array · string, optional) - allowed_ips (array · string, optional) - rate_limit_per_minute (integer, optional) - token_ttl_seconds (integer, optional) - jwks (object, required) - require_mtls (boolean, optional) - mtls_cert_thumbprints (array · string, optional) - require_signed_requests (boolean, optional) Responses: 201, 400, 401, 403, 422, 429 ### GET /api/v1/api-clients/{client_pk} Get API client One of the caller's API clients (404 `NOT_FOUND_109` otherwise). Parameters: - client_pk (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/api-clients/{client_pk} Update API client Change an API client's settings. Changing anything but the name or description requires the two-factor step-up. Parameters: - client_pk (path, string, required) Request body (ApiClientUpdate): - name (string, optional) - description (string, optional) - scopes (array · string, optional) - allowed_ips (array · string, optional) - rate_limit_per_minute (integer, optional) - token_ttl_seconds (integer, optional) - require_mtls (boolean, optional) - mtls_cert_thumbprints (array · string, optional) - require_signed_requests (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/api-clients/{client_pk}/disable Disable API client Disable the client and revoke every live access token issued to it, effective on the next request. Parameters: - client_pk (path, string, required) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/api-clients/{client_pk}/enable Enable API client Re-enable a disabled API client (step-up). Parameters: - client_pk (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### PUT /api/v1/api-clients/{client_pk}/jwks Replace API client JWK set Replace the public keys assertions are verified with (step-up). Parameters: - client_pk (path, string, required) Request body (ApiClientJwksReplace): - jwks (object, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/api-clients/{client_pk}/signing-keys Add API client signing key Add a request-signing key. For `hmac-sha256` DayZero generates the secret and returns it once; for `ed25519` send the public key. Step-up. Parameters: - client_pk (path, string, required) Request body (ApiClientSigningKeyCreate): - alg (string, required) - kid (string, optional) - public_key (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/api-clients/{client_pk}/signing-keys/{kid}/retire Retire API client signing key Stop a signing key verifying requests, at once or after an overlap. A retirement can be brought forward, never pushed back. Parameters: - client_pk (path, string, required) - kid (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## api-tokens — Create, list, and revoke Bearer API tokens. ### GET /api/v1/tokens List tokens List all API tokens for current user Parameters: - include_revoked (query, boolean, optional): Include revoked tokens - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/tokens Create token Create a new API token. Requires two-factor authentication on the account and a recent verification of both factors in the current session; must be called from the DayZero web app, not with an API token. Request body (APITokenCreate): - name (string, required) - description (string, optional) - expires_in_days (integer, optional) - business_ids (array · string, optional) - program_id (string, optional) - scopes (array · string, optional) - allowed_ips (array · string, optional) - rate_limit_per_minute (integer, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/tokens/access Get API access status Whether the caller may create and use API tokens. API access is off until a request for it is approved: immediately for an owner or admin of a CFO Suite business with two-factor enrolled, otherwise by a DayZero operator. Responses: 200, 401, 422 ### POST /api/v1/tokens/access-request Request API access Ask for API access. An owner or admin of a business with CFO Suite who has two-factor enrolled is approved immediately (the response says `approved`); every other request is reviewed by a DayZero operator. The caller is emailed when it is approved or denied. Request body (ApiAccessRequestCreate): - use_case_kind (string, optional) - use_case (string, optional) - company_name (string, optional) Responses: 201, 400, 401, 409, 422, 429 ### GET /api/v1/tokens/client-ip Get your current IP The public IP address this request came from, as the API sees it. The key form uses it to offer "Use my current IP" for an allowlist. Responses: 200, 401, 422 ### DELETE /api/v1/tokens/{token_id} Delete token Permanently delete an API token Parameters: - token_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/tokens/{token_id}/credit-check Test a credit key What `GET /credit/me` would answer for one of your API keys: the business, program, scopes, `credit_api_enabled` with `disabled_reasons` and `shopify_transport`, or the exact error (`409` `CREDIT_TOKEN_BUSINESS_AMBIGUOUS`, `403` scope, `401` revoked or expired). Worked out from the key's record with the same code; the key's secret is never used or shown. Browser sessions only. Parameters: - token_id (path, string, required): The key's id, from `GET /tokens`. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/tokens/{token_id}/revoke Revoke token Revoke an API token. Parameters: - token_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/tokens/{token_id}/rotate Rotate token Mint a replacement for an API token and keep the old one working for an overlap window, so credentials can be swapped without downtime. Same two-factor step-up as creating a token. Parameters: - token_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## ar-subledgers ### GET /api/v1/ar/customer-cash-receipts Cash received from customers Bank deposits whose offset is an AR ledger, by customer and calendar quarter with QoQ, YoY and YTD comparisons; investor-note, refund and uncategorized inflows listed separately. Parameters: - start_date (query, string · date, optional): First day (YYYY-MM-DD). Default: Jan 1 of the prior year. - end_date (query, string · date, optional): Last day (YYYY-MM-DD). Default: today. Responses: 200, 400, 401, 403, 422 ### POST /api/v1/ar/subledgers/backfill Backfill customer AR sub-ledgers Move historical invoice, payment and credit-memo journal lines from Accounts Receivable onto each customer's 'AR - ' sub-ledger by updating the original line. Dry run by default. Request body (ArSubledgerBackfillRequest): - dry_run (boolean, optional) - include_closed_periods (boolean, optional) - create_missing (boolean, optional) Responses: 200, 400, 401, 403, 422 ## attention ### GET /api/v1/attention List attention items Get the merged list of inbox messages and live alerts. Items are sorted with action-required first, then by priority, then newest first. Inbox messages support cursor pagination; live alerts are always returned in full on the first page. Parameters: - action_required (query, boolean, optional): Only show items requiring user action. - category (query, string, optional): Filter by category. - priority (query, string, optional): Filter by priority. - entity_type (query, string, optional): Filter by entity type. - unread_only (query, boolean, optional): Hide read inbox messages and dismissed live alerts. - include_live (query, boolean, optional): Include live (computed) alerts alongside inbox rows. - client_view (query, boolean, optional): If true, action URLs use the ``/client`` shell prefix instead of ``/books``. - cursor (query, string, optional): Inbox pagination cursor. - limit (query, integer, optional): Max inbox items per page. Responses: 200, 401, 422 ### POST /api/v1/attention/clear-dismissals Restore dismissed live alerts Clears the user's per-user live alert dismissals. Responses: 201, 401, 422 ### POST /api/v1/attention/mark-all-read Mark all read + clear dismissals Mark every inbox message read and clear all live alert dismissals so the bell shows zero. Responses: 201, 401, 422 ### GET /api/v1/attention/summary Attention summary counts Counts used by the bell badge and the Action Items card. Combines unread inbox messages with live alert counts. Parameters: - client_view (query, boolean, optional) Responses: 200, 401, 422 ### GET /api/v1/attention/{item_id} Get single attention item Fetch a single attention item (inbox or live) by its prefixed ID. Optionally marks it read/dismissed. Parameters: - item_id (path, string, required) - auto_mark_read (query, boolean, optional) - client_view (query, boolean, optional) Responses: 200, 401, 404, 422 ### POST /api/v1/attention/{item_id}/read Mark item read or dismiss Mark an attention item read. Inbox items get ``read_at`` set; live alerts are dismissed for this user (until they clear dismissals). Parameters: - item_id (path, string, required) Responses: 201, 401, 404, 422 ## attestations ### GET /api/v1/attestations List attestations Every attestation, active, expired and revoked, newest first; tokens are never re-emitted. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 404, 422 ### POST /api/v1/attestations Create a signed attestation Compute the chosen facts as of the period end, sign the canonical payload and mint a public link. The raw token is returned here **exactly once**. Admins only: a link is a standing anonymous grant to the facts it carries. Request body (CreateAttestationRequest): - fact_keys (array · string, required) - period_start (string · date, required) - period_end (string · date, required) - grantee_label (string, required) - expires_in_days (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/attestations/facts Facts an attestation can carry Every supported fact key with its label, unit and definition. Responses: 200, 401, 403, 422 ### GET /api/v1/attestations/{attestation_id} Get an attestation Get one attestation (without its token). Parameters: - attestation_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/attestations/{attestation_id}/revoke Revoke an attestation The public page and the verify endpoint stop resolving the link at once. Idempotent. Parameters: - attestation_id (path, string, required) Responses: 201, 401, 403, 404, 422 ## attestations-public ### GET /api/v1/public/attestations/verify Verify an attestation payload and signature (unauthenticated) Recompute the HMAC signature of a canonical attestation payload under the key it names (`key_id`) and compare it with the signature presented. `verification` is `valid`, `signature_mismatch` or `unknown_key`. Rate-limited per IP. Parameters: - payload (query, string, required): The attestation payload as a JSON object - signature (query, string, required): Hex HMAC-SHA256 Responses: 200, 400, 422, 429 ### GET /api/v1/public/attestations/{token} Public attestation viewer (unauthenticated) Resolve a share token to the attested facts, the signed payload, its hash and signature, and `verified`, recomputed server-side on every request. Returns 404 for unknown, expired or revoked tokens, indistinguishably. Rate-limited per IP and cached for 60 seconds. Parameters: - token (path, string, required) Responses: 200, 404, 422, 429 ## audit-packs ### POST /api/v1/accounting-periods/{period_id}/audit-pack Request an audit pack for a closed period Queue the Reproducible Audit Pack for a closed or locked period: close replay on a copy of the books, audit-chain verification, approvals, traces, the evidence binder and a signed manifest. Refused for an open period and while a pack for the period is still running. Parameters: - period_id (path, string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/audit-packs List audit packs Newest first; `period` narrows to one accounting period. Parameters: - period (query, string, optional): Accounting period id Responses: 200, 401, 403, 422 ### GET /api/v1/audit-packs/{pack_id} Get an audit pack The pack's status and sections. `verified` is recomputed by the server from the stored manifest, hash and signature. Parameters: - pack_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/audit-packs/{pack_id}/share Revoke the pack's public link The public page 404s immediately. Idempotent. Parameters: - pack_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/audit-packs/{pack_id}/share Create the pack's public link Mint a token-protected, read-only public URL for a ready pack. The raw token is returned here **exactly once**; a new link replaces the previous one. Admins only: a link is a standing anonymous grant. Parameters: - pack_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## audit-packs-public ### GET /api/v1/public/audit-packs/{token} Public audit pack viewer (unauthenticated) Resolve a share token to the pack's manifest, summaries, hash and signature, with a server-recomputed `verified` flag and the binder download URL. 404 for unknown or revoked tokens alike; rate-limited per IP. Parameters: - token (path, string, required) Responses: 200, 404, 422, 429 ## automation-review ### GET /api/v1/counterparty-merge-review Counterparty merges waiting for review Duplicate-counterparty merges the nightly maintenance held back because this business reviews merges first (Automation settings), newest batch first, each with its undecided pairs. Responses: 200, 401, 403, 422 ### POST /api/v1/counterparty-merge-review/{pending_change_id}/decide Approve or decline counterparty merge pairs Decide pairs of one merge batch: approved pairs merge now (recorded as a `counterparty_merge` automation run), declined pairs are remembered so the nightly job never proposes them again. Pairs left out stay pending; when none is left the batch closes. Needs a person signed in to the app. Parameters: - pending_change_id (path, string, required) Request body (MergeReviewDecisionRequest): - approve_pair_ids (array · string, optional) - decline_pair_ids (array · string, optional) - note (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/payment-suggestions/bulk-accept Bulk accept payment suggestions Accept many pending invoice (deposit -> invoice) or bill (payment -> bill) match suggestions at once: the `suggestion_ids` you name, or every pending suggestion at or above `min_confidence` (default 0.85), optionally for one customer / vendor (`party_id`) and a bank-transaction date range. Each accept is isolated, so a bad row never loses the rest (`results` lists every one). The batch is one `payment_match` automation run: undo it with `POST /automation-runs/{run_id}/undo`. `dry_run` lists what would be accepted. Request body (BulkAcceptPaymentSuggestionsRequest): - kind (string, required) - suggestion_ids (array · string, optional) - min_confidence (number, optional) - party_id (string, optional) - start_date (string · date, optional) - end_date (string · date, optional) - limit (integer, optional) - dry_run (boolean, optional) - plan_hash (string, optional) Responses: 200, 400, 401, 403, 422 ## automation-runs ### GET /api/v1/automation-runs List recent automation runs Recent passes of the automations that write without a person: the post-sync auto-categorization, the payment auto-match and the nightly counterparty merge, newest first, with what each changed. Parameters: - kind (query, string, optional): categorization | payment_match | counterparty_merge | inbox_auto_post - limit (query, integer, optional) - offset (query, integer, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/automation-runs/{run_id} Get one automation run Parameters: - run_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/automation-runs/{run_id}/undo Undo an automation run Puts a categorization run back: every row it categorized returns to its previous category and method, and the bank rules the run created are removed. A row a person has changed since, one in a closed period or a split is left alone and counted under ``skipped_reasons``. For a payment-match run the payments it linked are unlinked. Rows that were undone are not auto-categorized again. For a Bill Inbox auto-post run the unpaid bills nobody has acted on are deleted and their drafts go back to the inbox (paid, approved or edited bills are skipped). Parameters: - run_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ## automation-settings ### GET /api/v1/automation-settings Get automation settings Every switch that lets DayZero act without a person, grouped (categorization, payment matching, counterparties, Bill Inbox, month-end close, approvals, and the firm client digest for firm owners and admins), with what each does and whether it is active, plus plain lines for what runs unattended today. Responses: 200, 401, 403, 422 ### PATCH /api/v1/automation-settings Update automation settings Applies a change to the automation switches. Owner or admin only; the firm client digest switches need an owner or admin of the business's advisory firm. Callers should preview with ``/plan`` and confirm the widening changes with the person first. A refused key fails the whole request (400) and nothing is saved. Request body (AutomationSettingsChangeRequest): - settings (object, required) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/automation-settings/plan Preview an automation settings change Validates a change and lists what it would do without saving. ``widening`` names the changes that give the automation more room (turning one on, lowering a confidence line, raising or removing a cap, dropping a review step); ``errors`` maps refused keys to why. Request body (AutomationSettingsChangeRequest): - settings (object, required) Responses: 200, 401, 403, 422 ## bank-deposits ### GET /api/v1/bank-deposits List bank deposits List bank deposits for the business. Parameters: - status (query, string, optional): Filter by status: posted or void. - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/bank-deposits Create bank deposit Group undeposited receipts and ad-hoc lines into a bank deposit. Request body (BankDepositCreateRequest): - deposit_to_ledger_id (string, required) - deposit_date (string · date, optional) - sales_receipt_ids (array · string, optional) - other_lines (array · OtherDepositLine, optional) → OtherDepositLine - number (string, optional) - memo (string, optional) - currency (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/bank-deposits/undeposited List undeposited funds List posted sales receipts in Undeposited Funds awaiting deposit. Responses: 200, 401, 403, 422 ### GET /api/v1/bank-deposits/{deposit_id} Get bank deposit Get details of a specific bank deposit. Parameters: - deposit_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/bank-deposits/{deposit_id}/void Void bank deposit Void a deposit, reversing the entry and releasing its receipts. Parameters: - deposit_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## benchmarks ### GET /api/v1/benchmarks/me Peer benchmarks for a month The business's operating ratios for the month (gross margin, DSO, DPO, inventory turns, ad spend and opex to revenue, business days to close, trust grade, auto-coded share), the cohorts it falls into and, for the first cohort with 20 or more contributors, the cohort quartiles and the business's percentile. Smaller cohorts are null with a reason. Parameters: - month (query, string, optional): YYYY-MM; default the last complete month Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/benchmarks/settings Peer benchmark consent settings Whether the business sees its own peer view and whether it contributes to cohorts. Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/benchmarks/settings Update peer benchmark consent Turn the business's own peer view on or off, and opt in or out of contributing its operating ratios (never amounts, names or transactions) to anonymised cohorts of 20+ businesses. Opting out of contribution removes the business from every cohort at once. Request body (BenchmarkSettingsUpdate): - benchmarks_opt_in (boolean, optional) - benchmarks_contribute (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/firm/benchmarks Every client's peer percentiles (firm table) One row per business the caller can see with its percentile per metric in the first cohort that has 20 or more contributors. Members of an advisory firm (and DayZero staff) only. Parameters: - month (query, string, optional): YYYY-MM; default the last complete month Responses: 200, 400, 401, 403, 422 ## billing — Subscription billing, plan management, and usage tracking. ### POST /api/v1/billing/addon Toggle Addon Add or remove an add-on from the business's Stripe subscription. Request body (AddonToggleRequest): - addon_slug (string, required) - action (string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/billing/addon/preview Preview Addon Change Preview the billing impact of adding or removing an add-on. Request body (AddonPreviewRequest): - addon_slug (string, required) - action (string, required) Responses: 201, 401, 403, 422 ### GET /api/v1/billing/ai-usage Get Ai Usage Return current daily and monthly AI request counts with plan limits. Responses: 200, 401, 403, 422 ### GET /api/v1/billing/ai-usage/details Get Ai Usage Details Return detailed AI usage stats: top users, model breakdown, daily trend. Parameters: - scope (query, string, optional): Set to 'firm' to aggregate across all firm businesses. Responses: 200, 401, 403, 422 ### POST /api/v1/billing/ai/pause Pause Ai Features Pause all AI features for the authenticated business. Responses: 201, 401, 403, 422 ### POST /api/v1/billing/ai/resume Resume Ai Features Resume AI features for the authenticated business. Responses: 201, 401, 403, 422 ### GET /api/v1/billing/catalog Get Billing Catalog Return the Stripe price catalog (slug → price details). Responses: 200 ### POST /api/v1/billing/change-plan Change Plan Switch the base subscription plan to a different price. Request body (PlanChangeRequest): - price_id (string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/billing/checkout Create Checkout Session Create a Stripe Checkout session so the user can subscribe. Request body (CheckoutRequest): - price_id (string, required) - success_url (string, required) - cancel_url (string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/billing/firm/change-tier Change Firm Tier Upgrade or downgrade the firm's plan tier, in-app. Request body (FirmTierChangeRequest): - firm_plan_tier (string, required) Responses: 201, 401, 403, 422 ### GET /api/v1/billing/firm/client-usage Get Firm Client Usage Return the firm's active client count, tier cap, and remaining seats. Responses: 200, 401, 403, 422 ### POST /api/v1/billing/grandfather Grandfather the current business (superuser only) Mark the current business as grandfathered so it keeps access without billing. Responses: 201, 401, 403, 422 ### GET /api/v1/billing/grandfathered-summary Get Grandfathered Summary Return a summary of the grandfathered business's current access and available plans. Responses: 200, 401, 403, 422 ### GET /api/v1/billing/invoices Get Invoice History Return the business's Stripe subscription invoice history. Parameters: - limit (query, integer, optional): Max invoices to return Responses: 200, 401, 403, 422 ### POST /api/v1/billing/migrate-from-grandfathered Migrate grandfathered account to a paid plan Create a Stripe Checkout session to move from a grandfathered plan to a paid plan. Request body (GrandfatheredMigrateRequest): - target_plan (string, required) - success_url (string, required) - cancel_url (string, required) - billing_interval (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/billing/portal Create Portal Session Create a Stripe Billing Portal session for subscription management. Request body (PortalRequest): - return_url (string, required) Responses: 201, 401, 403, 422 ### GET /api/v1/billing/pricing-config Get Pricing Config Return billing pricing configuration derived from the single discount knob. Responses: 200 ### GET /api/v1/billing/status Get Billing Status Return the current billing state for the authenticated business. Responses: 200, 401, 403, 422 ## bills — Accounts payable — create and manage vendor bills. ### GET /api/v1/bills List bills Retrieve all bills for a business with cursor-based pagination. Can filter by vendor name (fuzzy search) or associated journal entry. Parameters: - id (query, array · string, optional): Filter bills by specific bill UUIDs (batch fetch — avoids N+1 single-bill requests) - vendor_search (query, string, optional): Fuzzy search bills by vendor name (uses PostgreSQL trigram matching) - journal_entry_id (query, string, optional): Filter bills by associated journal entry UUID - payment_method (query, string, optional): Filter bills by payment method: 'Wire Transfer', 'ACH', 'Check', 'Credit Card' - vendor_id (query, string, optional): Filter bills by vendor UUID - status (query, string, optional): Filter by bill status (e.g. draft, approved, received, paid, canceled) - search (query, string, optional): Search bills by bill number, description, or vendor name (case-insensitive partial match) - bill_number (query, string, optional): Filter bills by invoice/bill number (case-insensitive partial match) - due_date_from (query, string, optional): Filter bills with due date on or after this date (YYYY-MM-DD) - due_date_to (query, string, optional): Filter bills with due date on or before this date (YYYY-MM-DD) - on_hold (query, boolean, optional): true: only bills with an active payment hold; false: only bills without one - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/bills Create bill Create a new bill in draft status. Optionally include 'recurring' config to also create a recurring template. Request body (BillCreateRequest): - description (string, optional) - currency (string, optional) - vendor_id (string, optional) - bill_number (string, optional) - payment_term_id (string, optional) - type (string, optional) - expected_amount (integer, optional) - expected_paid_on_date (string · date-time | string, optional) - s3_key (string, optional) - recurring (RecurringConfig, optional) - submitted_for_review (boolean, optional) - purpose (string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/bills/aging AP aging summary Returns accounts payable aging data grouped by vendor with Current, 1-30, 31-60, 61-90, and 91+ day buckets. Includes per-bill detail for drill-down. Responses: 200, 401, 403, 422 ### POST /api/v1/bills/ai-create AI-extract draft bills from documents Upload pasted text, PDFs, images, Excel files, or a CSV to extract draft bill entities using AI. Returns draft bills in 'received' status format ready for user review before creation. Request body (BillAICreatePayloadRequest): - pasted_text (string, optional) - pasted_text_s3_key (string, optional) - single_bill_s3_keys (array · string, optional) - multi_bill_s3_key (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/bills/bulk Bulk create bills Create multiple bills from CSV data in a single request. Request body (BillBulkRequest): - s3_key (string, optional) - approve (boolean, optional) - create_as_received (boolean, optional) - attachments (object, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/bills/duplicate-check Check for possible duplicate bills Advisory, read-only check used during bill entry. Returns existing bills that may duplicate the one being entered (same bill number, or same vendor and amount within ~90 days). Never blocks creation — it is purely a heads-up so the user can confirm before saving. Parameters: - bill_number (query, string, optional): In-progress bill/invoice number to match (optional). - vendor_id (query, string, optional): In-progress vendor UUID to match (optional). - amount (query, integer, optional): In-progress amount in cents to match (optional). - received_on (query, string · date, optional): Invoice date (YYYY-MM-DD); bounds the vendor+amount lookback window. Responses: 200, 401, 403, 422 ### GET /api/v1/bills/expense-candidates List expense candidates Return outgoing transactions that may represent bill payments. Filters to posted expense transactions with unallocated balances, useful for the Record Payment modal on the bills page. Parameters: - limit (query, integer, optional): Max results Responses: 200, 401, 403, 422 ### GET /api/v1/bills/metrics Get bill metrics Retrieve aggregated bill metrics for the business: total due and total balance due across all received and partially paid bills, plus the overdue balance across bills past their due date. Responses: 200, 401, 403, 422 ### GET /api/v1/bills/pay-plan Pay plan: which bills to pay first Rank open bills by what to pay first — late bills, then open early-pay discounts, then bills due within a week, then the rest — with a reason for each, cash on hand, and counts of the bills left out (on hold, payment initiated, awaiting approval). Read-only and deterministic. Responses: 200, 401, 403, 422 ### POST /api/v1/bills/payment-run Build the pay list for a run date Split open bills into pay (due by pay_through, approved externally when rows are given, amounts agree, affordable), blocked (with reasons) and deferred. Read-only; nothing is paid. Request body (PaymentRunRequest): - pay_through (string · date, required) - rows (array · ExternalBillRow, optional) - csv_text (string, optional) - cash_available_cents (integer, optional) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/bills/payment-suggestions List bill payment suggestions List auto-detected matches between bank transactions and open bills. Parameters: - bill_id (query, string, optional): Filter by bill UUID - status (query, string, optional): Filter by status - min_confidence (query, number, optional): Minimum confidence threshold - start_date (query, string · date, optional): Only include suggestions whose transaction date is on or after this date (YYYY-MM-DD) - end_date (query, string · date, optional): Only include suggestions whose transaction date is on or before this date (YYYY-MM-DD) - limit (query, integer, optional): Max results Responses: 200, 401, 403, 422 ### POST /api/v1/bills/payment-suggestions/bulk-approve Bulk approve bill payment suggestions Accept all pending suggestions above a confidence threshold. Request body (BulkApproveSuggestionsRequest): - min_confidence (number, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/bills/payment-suggestions/trigger Trigger bill payment matching Run the AP matching engine to find bank transactions that match open bills. Request body (TriggerBillMatchingRequest): - min_confidence (number, optional) - auto_match (boolean, optional) - bill_ids (array · string, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/bills/payment-suggestions/{suggestion_id}/accept Accept a bill payment suggestion Accept a suggestion and create the actual BillPayment. Parameters: - suggestion_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/bills/payment-suggestions/{suggestion_id}/reject Reject a bill payment suggestion Reject a suggestion so it is no longer shown. Parameters: - suggestion_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/bills/payments/batch Split one transaction across multiple bills Apply a single bank transaction to multiple bills and/or direct expense lines in one atomic request. Validates the total allocation against the transaction's remaining unallocated balance before creating any payments. Request body (BillBatchPaymentRequest): - transaction_id (string, required) - allocations (array · BillBatchPaymentAllocation, optional) → BillBatchPaymentAllocation - expense_lines (array · BillBatchExpenseLine, optional) → BillBatchExpenseLine - paid_on (string · date-time, optional) - override_hold (boolean, optional) - override_reason (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/bills/received Create bill in received status Create a new bill directly in 'received' status, ready for payment. Creates both the bill AND journal entry when ledger_id is provided. Request body (BillReceivedCreateRequest): - vendor_id (string, required) - amount (integer, required) - description (string, optional) - bill_number (string, optional) - payment_term_id (string, optional) - currency (string, optional) - type (string, optional) - received_on (string · date-time | string, optional) - due_on (string · date-time | string, optional) - s3_key (string, optional) - ledger_id (string, optional) - line_items (array · JournalEntryLineItem, optional) - journal_entry_date (string · date-time | string · date | string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/bills/suggest-payment-priority Payment priority suggestions The pay plan (see GET /bills/pay-plan): open bills ranked by what to pay first, with reasons and cash on hand. Read-only. Responses: 201, 401, 403, 422 ### POST /api/v1/bills/tie-out Tie bills out against an external bill-pay export Compare an external bill-pay system's bill list (rows or CSV text) with the books in both directions: missing bills, amount deltas, double-payment risk, duplicates, bills paid here but open there and external payments with no cash in the bank feed yet. Read-only. Request body (ExternalBillTieoutRequest): - rows (array · ExternalBillRow, optional) - csv_text (string, optional) - as_of (string · date, optional) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/bills/upcoming List upcoming (expected) bills Forecast rows for bills the business expects — recurring contractor payments, retainers. These are estimates: they carry no journal entries and are excluded from AP totals, aged payables and the balance sheet. Parameters: - status (query, string, optional): Filter by status: expected, converted, dismissed. - vendor_id (query, string, optional): Filter by vendor. - date_from (query, string · date, optional): Only occurrences expected on or after this date. - date_to (query, string · date, optional): Only occurrences expected on or before this date. - limit (query, integer, optional): Maximum rows to return. Responses: 200, 401, 403, 422 ### POST /api/v1/bills/upcoming Create an upcoming bill (optionally recurring) Create one expected bill, or a recurring series. A recurring request materialises every projected occurrence up front (capped by `recurrence.occurrences`), so each one can be edited, deleted or matched independently. Returns every occurrence created. Request body (UpcomingBillCreateRequest): - vendor_id (string, optional) - vendor_name (string, optional) - description (string, optional) - estimated_amount (integer, required) - expected_date (string · date, required) - notes (string, optional) - recurrence (UpcomingBillRecurrence, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/bills/upcoming/{upcoming_bill_id} Delete an upcoming bill Deletes this occurrence. Pass `series=true` to also drop every later still-expected occurrence in the same series; occurrences already converted into real bills are never touched. Parameters: - upcoming_bill_id (path, string, required) - series (query, boolean, optional): Also delete later still-expected occurrences. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/bills/upcoming/{upcoming_bill_id} Get one upcoming bill Parameters: - upcoming_bill_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/bills/upcoming/{upcoming_bill_id} Edit an upcoming bill Edits this occurrence only, not the whole series — so a one-month change to a recurring estimate does not redefine the schedule. Parameters: - upcoming_bill_id (path, string, required) Request body (UpcomingBillUpdateRequest): - vendor_id (string, optional) - vendor_name (string, optional) - description (string, optional) - estimated_amount (integer, optional) - expected_date (string · date, optional) - notes (string, optional) - status (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/bills/upcoming/{upcoming_bill_id}/convert Push an upcoming bill into a real bill Creates a **draft** bill from the estimate and marks the forecast row converted. The bill posts nothing to the ledger until it is approved and marked received, exactly like a hand-entered bill. Parameters: - upcoming_bill_id (path, string, required) Request body (UpcomingBillConvertRequest): - amount (integer, optional) - due_date (string · date, optional) - bill_number (string, optional) - s3_key (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/bills/upcoming/{upcoming_bill_id}/link Match an upcoming bill to a bill that arrived Links the forecast row to an existing bill so the obligation stops being counted twice — once as a projection and once as a payable. Parameters: - upcoming_bill_id (path, string, required) Request body (UpcomingBillLinkRequest): - bill_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/bills/upload Upload bill document Upload a PDF or image file for a bill. Returns s3_key to use when creating/updating bills. Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/bills/{bill_id} Delete bill Delete a bill and its associated records. Parameters: - bill_id (path, string, required) - force (query, boolean, optional): Force delete even if bill has associated records Responses: 200, 401, 403, 404, 409, 422 ### GET /api/v1/bills/{bill_id} Get bill Retrieve a specific bill by ID. Parameters: - bill_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/bills/{bill_id} Update bill Update an existing bill. Optionally include 'recurring' config to create a recurring template. Parameters: - bill_id (path, string, required) Request body (BillUpdateRequest): - status (string, optional) - description (string, optional) - bill_number (string, optional) - vendor_id (string, optional) - payment_term_id (string, optional) - type (string, optional) - expected_amount (integer, optional) - expected_paid_on_date (string · date-time | string · date | string, optional) - amount (integer, optional) - due_on (string · date-time | string · date | string, optional) - received_on (string · date-time | string · date | string, optional) - s3_key (string, optional) - source_inventory_order_id (string, optional) - purpose (string, optional) - payment_method (string, optional) - recurring (RecurringConfig, optional) Responses: 200, 400, 401, 403, 404, 422 ### PATCH /api/v1/bills/{bill_id}/approval Approve bill Approve a bill and change status to 'forecasted' Parameters: - bill_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/bills/{bill_id}/attachment Attach file to existing bill Attach a document file to an existing bill by updating its s3_key. Parameters: - bill_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### PATCH /api/v1/bills/{bill_id}/cancellation Cancel bill Cancel a bill and change status to 'canceled' Parameters: - bill_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/contract-comparison Compare bill against vendor contract Compare a bill's amount against the vendor's active contract/MSA. Parameters: - bill_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/decline Decline bill A business owner declines a draft bill from the client portal: the bill moves to 'canceled', the reason is kept in the audit trail and returned as `rejection_reason`, and the assigned advisor is notified. Parameters: - bill_id (path, string, required) Request body (DeclineBillRequest): - reason (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/duplicate Duplicate bill Copy a bill into a new draft with a fresh bill number and dates starting today. No attachment, payments, journal entries or approval state are carried over. Parameters: - bill_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/hold Put a bill on payment hold Record a 'do not pay' instruction on the bill. While held, recording or initiating a payment is refused (BUSINESS_157) unless override_hold is passed with a reason. Paid or canceled bills cannot be held (BUSINESS_155). Parameters: - bill_id (path, string, required) Request body (BillHoldRequest): - reason (string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/journal-entry Generate bill journal entry Create the outstanding AP journal entry for a received bill that has none linked. Parameters: - bill_id (path, string, required) Request body (BillJournalEntryGenerateRequest): - ledger_id (string, required) - journal_entry_date (string · date-time | string · date | string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/bills/{bill_id}/journal-entry/link Attach journal entry to bill Link an existing journal entry to a bill. Parameters: - bill_id (path, string, required) Request body (JournalEntryLinkRequest): - journal_entry_id (string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/bills/{bill_id}/journal-entry/unlink Detach journal entry from bill Detach a hand-linked journal entry from a bill. The entry stays posted and can then be deleted or reversed. Parameters: - bill_id (path, string, required) Request body (BillJournalEntryUnlinkRequest): - journal_entry_id (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### PATCH /api/v1/bills/{bill_id}/payment-initiation Mark or clear bill payment-initiated Track money in flight: mark that payment was initiated outside DayZero (e.g. a bank with no API) before the bank transaction exists to reconcile against. Parameters: - bill_id (path, string, required) Request body (BillPaymentInitiationRequest): - initiated (boolean, required) - initiated_on (string · date-time, optional) - override_hold (boolean, optional) - override_reason (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/bills/{bill_id}/payments List bill payments Retrieve all payments for a specific bill. Parameters: - bill_id (path, string, required) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/payments Add payment to bill Create a new payment for a specific bill. Parameters: - bill_id (path, string, required) Request body (BillPaymentRequest): - transaction_id (string, required) - amount (integer, required) - paid_on (string · date-time, optional) - override_hold (boolean, optional) - override_reason (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/bills/{bill_id}/payments/{payment_id} Remove payment from bill Un-link a payment record from a bill and recalculate status. Parameters: - bill_id (path, string, required) - payment_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/bills/{bill_id}/receipt Mark bill as received Mark a bill as received and create journal entry Parameters: - bill_id (path, string, required) Request body (BillReceivedRequest): - bill_id (string, optional) - amount (integer, required) - ledger_id (string, required) - s3_key (string, optional) - journal_entry_date (string · date-time | string · date | string, optional) - received_on (string · date-time | string · date | string, optional) - due_on (string · date-time | string · date | string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/release-hold Release a bill's payment hold Release the active payment hold so the bill can be paid again. Refused with BUSINESS_156 when the bill has no active hold. Parameters: - bill_id (path, string, required) Request body (BillReleaseHoldRequest): - note (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/resolve-approval Force-resolve a stuck pending-approval bill Manually drive a bill that is wedged in 'pending_approval' to a terminal state when the normal Approve/Reject card is unavailable (the approval run never started, crashed before suspending, or suspended on a gate with no approvers). Cancels any in-flight approval run for the bill, then either approves it to 'received' (posting the journal entry) or rejects it to 'canceled'. Parameters: - bill_id (path, string, required) Request body (ResolvePendingApprovalRequest): - action (string, required) - ledger_id (string, optional) - reason (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/revert-to-draft Revert bill to draft Move a 'forecasted', 'pending_approval' or 'received' bill back to 'draft' so it can be edited. A received bill's journal entry is reversed on its original date (refused if that period is closed or any payment/credit is applied); a multi-account split is kept on the draft. Any in-flight approval run is cancelled. Bills raised by a purchase order or inventory transfer cannot be reverted. Parameters: - bill_id (path, string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/bills/{bill_id}/submit-for-ap-approval Submit bill for AP approval Manually route a forecasted bill into the firm's AP approval workflow. Use when a bill was approved before the workflow was provisioned or when automatic routing did not run. The bill moves from 'forecasted' to 'pending_approval' and posts to 'received' only once an approver signs off. Parameters: - bill_id (path, string, required) Request body (BillReceivedRequest): - bill_id (string, optional) - amount (integer, required) - ledger_id (string, required) - s3_key (string, optional) - journal_entry_date (string · date-time | string · date | string, optional) - received_on (string · date-time | string · date | string, optional) - due_on (string · date-time | string · date | string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/bills/{bill_id}/submit-for-approval Send bill for approval Submit a cleaned-up draft bill into the AP approval workflow. The bill moves to 'pending_approval' and is NOT posted to the general ledger until an approver signs off, at which point it posts to 'received'. Requires the business to have the approval workflow enabled. Parameters: - bill_id (path, string, required) Request body (BillReceivedRequest): - bill_id (string, optional) - amount (integer, required) - ledger_id (string, required) - s3_key (string, optional) - journal_entry_date (string · date-time | string · date | string, optional) - received_on (string · date-time | string · date | string, optional) - due_on (string · date-time | string · date | string, optional) Responses: 201, 400, 401, 403, 404, 422 ## brex ### GET /api/v1/brex/cards List Brex cards and their credit-line mappings Every Brex card read by sync or named in an export, with its mapping. Responses: 200, 401, 403, 422 ### POST /api/v1/brex/cards/mapping/bulk Preview or apply many Brex card mappings at once Map several cards, or every card of a cardholder, to credit lines. Request body (BrexBulkMapRequest): - items (array · BrexBulkMapItem, required) → BrexBulkMapItem - apply (boolean, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/brex/cards/mapping/csv Preview or apply Brex card mappings from a CSV or XLSX Read card to credit line rows from a file; see the bulk endpoint. Responses: 201, 400, 401, 403, 422 ### PUT /api/v1/brex/cards/{brex_card_id}/mapping Map a Brex card to a borrower's credit line Registers the card on the line so its charges are attributed there. A null credit_line_id removes a mapping that has no charges yet. Parameters: - brex_card_id (path, string, required) Request body (BrexCardMapRequest): - credit_line_id (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/brex/connect Connect Brex with a user token Verify a Brex user token (cards.readonly, transactions.card.readonly) and store it encrypted. Credit ingest stays off. Request body (BrexConnectRequest): - token (string · password, required) - sync_from (string · date, required) Responses: 201, 400, 401, 403, 409, 422, 429 ### PUT /api/v1/brex/credit-ingest Switch Brex credit ingest on or off Switching on requires confirm_mappings and at least one mapped card. Off stops new loans; recorded settlements stay. Request body (BrexCreditIngestRequest): - enabled (boolean, required) - confirm_mappings (boolean, optional) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/brex/credit-ingest/preview Preview what credit ingest would do Dry run over every undecided row. Writes nothing. Responses: 200, 401, 403, 422 ### POST /api/v1/brex/credit-ingest/run Apply staged Brex transactions to credit lines now Apply what the preview shows. Requires credit ingest on. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/brex/credit-line-candidates List or search credit lines to map a Brex card to Search this lender's lines by merchant name or id. Parameters: - search (query, string, optional) Responses: 200, 401, 403, 422 ### DELETE /api/v1/brex/disconnect Disconnect Brex Remove the token; staged transactions and card mappings remain. Responses: 200, 401, 403, 422 ### POST /api/v1/brex/exports/commit Stage a Brex card-transactions export Stages the export's rows by Brex transaction id. With credit ingest on, mapped rows reach their credit lines as a sync would. Responses: 201, 400, 401, 403, 422 ### POST /api/v1/brex/exports/preview Preview a Brex card-transactions export Reads a Brex dashboard export (CSV or XLSX) and shows what each row would do: ingest, link, duplicate or review. Writes nothing. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/brex/status Brex connection status Connection health, mapping progress and transaction counts. No token. Responses: 200, 401, 403, 422 ### POST /api/v1/brex/sync Sync Brex cards and settled card transactions Queue a background sync. Applies to credit lines only when ingest is on. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/brex/transactions List staged Brex card transactions List staged rows, newest first; `status=needs_review` is the review queue. Parameters: - status (query, string, optional) - cursor (query, string, optional) - limit (query, integer, optional) - card_id (query, string, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/brex/transactions/{transaction_id}/review Resolve a Brex review-queue row ignore, reprocess, link_settlement (already recorded), refund_of (name the original purchase) or chargeback (dispute, merchant won). Parameters: - transaction_id (path, string, required) Request body (BrexReviewActionRequest): - action (string, required) - settlement_id (string, optional) - note (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ## budgets — Financial budgets and forecasts with variance tracking. ### GET /api/v1/budgets List budgets List all budgets for the business with optional filtering. Parameters: - status (query, BudgetStatusEnum, optional): Filter by status: draft, active or closed (closed = a budget replaced by activating another; read-only) - fiscal_year (query, integer, optional): Filter by fiscal year - search (query, string, optional): Search by budget name - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 400, 401, 403, 422 ### POST /api/v1/budgets Create budget Create a new budget for the business. Request body (BudgetCreateRequest): - name (string, required) - fiscal_year (integer, required) - start_date (string · date, required) - end_date (string · date, required) - period_type (BudgetPeriodTypeEnum, optional) → BudgetPeriodTypeEnum - description (string, optional) - notes (string, optional) - source_scenario_id (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/budgets/forecast Generate forecast Generate a financial forecast based on historical data. Request body (GenerateForecastRequest): - method (ForecastMethodEnum, optional) → ForecastMethodEnum - lookback_months (integer, optional) - forecast_months (integer, optional) - growth_rate_percent (integer, optional) - use_seasonality (boolean, optional) - include_cash_flow (boolean, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/budgets/forecast/configs List forecast configs List saved forecast configurations. Responses: 200, 401, 403, 422 ### POST /api/v1/budgets/forecast/configs Create forecast config Save a forecast configuration for reuse. Request body (ForecastConfigCreateRequest): - name (string, required) - method (ForecastMethodEnum, optional) → ForecastMethodEnum - lookback_months (integer, optional) - forecast_months (integer, optional) - growth_rate_percent (integer, optional) - use_seasonality (boolean, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/budgets/{budget_id} Delete budget Delete a draft budget. Parameters: - budget_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/budgets/{budget_id} Get budget Get a budget with all its line items. Parameters: - budget_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/budgets/{budget_id} Update budget Update a draft budget's metadata. Parameters: - budget_id (path, string, required) Request body (BudgetUpdateRequest): - name (string, optional) - description (string, optional) - notes (string, optional) - start_date (string · date, optional) - end_date (string · date, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/budgets/{budget_id}/activate Activate budget Set a budget as the active budget (deactivates current active). Parameters: - budget_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/budgets/{budget_id}/copy Copy budget Create a copy of a budget with optional percentage adjustment. Parameters: - budget_id (path, string, required) Request body (BudgetCopyRequest): - name (string, required) - fiscal_year (integer, required) - start_date (string · date, required) - end_date (string · date, required) - adjustment_percent (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/budgets/{budget_id}/lines List budget lines Get all line items for a budget. Parameters: - budget_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/budgets/{budget_id}/lines Add budget line Add a budget line item for a ledger account. Parameters: - budget_id (path, string, required) Request body (BudgetLineCreateRequest): - ledger_id (string, required) - jan_amount (integer, optional) - feb_amount (integer, optional) - mar_amount (integer, optional) - apr_amount (integer, optional) - may_amount (integer, optional) - jun_amount (integer, optional) - jul_amount (integer, optional) - aug_amount (integer, optional) - sep_amount (integer, optional) - oct_amount (integer, optional) - nov_amount (integer, optional) - dec_amount (integer, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/budgets/{budget_id}/lines/{line_id} Delete budget line Remove a budget line. Parameters: - budget_id (path, string, required) - line_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### PATCH /api/v1/budgets/{budget_id}/lines/{line_id} Update budget line Update amounts on a budget line. Parameters: - budget_id (path, string, required) - line_id (path, string, required) Request body (BudgetLineUpdateRequest): - jan_amount (integer, optional) - feb_amount (integer, optional) - mar_amount (integer, optional) - apr_amount (integer, optional) - may_amount (integer, optional) - jun_amount (integer, optional) - jul_amount (integer, optional) - aug_amount (integer, optional) - sep_amount (integer, optional) - oct_amount (integer, optional) - nov_amount (integer, optional) - dec_amount (integer, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/budgets/{budget_id}/vs-actual Budget vs Actual Compare budgeted amounts to actual performance. Parameters: - budget_id (path, string, required) - start_date (query, string · date, required): Comparison period start date - end_date (query, string · date, required): Comparison period end date Responses: 200, 401, 403, 404, 422 ## businesses — Business entities — the core tenant in DayZero. ### GET /api/v1/businesses List businesses Retrieve businesses the authenticated user has access to. Parameters: - id (query, string, optional) - name (query, string, optional) - stripe_account_id (query, string, optional) - shopify_shop_domain (query, string, optional) - user_id (query, string, optional) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/businesses Create business Create a new business entity with optional integrations. Request body (BusinessCreateRequest): - accounting_basis (string, optional) - name (string, required) - default_currency (string, optional) - tax_year_end_month (integer, optional) - mailbox (string, optional) - user_id (string, optional) - coa_template_id (string, optional) - custom_coa_template (CustomCoaTemplate, optional) - entries_start (string, optional) - firm_id (string, optional) - stripe_account_id (string, optional) - stripe_subscription_id (string, optional) - stripe_customer_id (string, optional) - subscription_items (object, optional) - accounting_engine_type (string, optional) - trial_ends_at (string · date-time, optional) - billing_status (string, optional) - plan_tier (string, optional) - active_addons (array · string, optional) Responses: 201, 400, 401, 403, 409, 422 ### GET /api/v1/businesses/auto-numbering Get auto-numbering settings Get the current auto-numbering configuration for bills and invoices. Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/businesses/auto-numbering Update auto-numbering settings Configure automatic bill and invoice number generation. Request body (AutoNumberingSettingsUpdateRequest): - auto_number_bills (boolean, optional) - auto_number_invoices (boolean, optional) - bill_number_prefix (string, optional) - invoice_number_prefix (string, optional) - next_bill_number (integer, optional) - next_invoice_number (integer, optional) - journal_entry_number_prefix (string, optional) - next_journal_entry_number (integer, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/auto-numbering/preview Preview next auto-generated numbers See what the next bill and invoice numbers would be without incrementing. Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/businesses/entries-start Update entries start date Set the date from which accounting entries should begin. Request body (UpdateEntriesStartRequest): - business_id (string, optional) - entries_start (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/generate-coa Generate a COA template using AI Uses AI to generate a complete chart of accounts template based on a business description. Request body (CoaGenerateRequest): - business_description (string, required) - accounting_basis (string, optional) - currency (string, optional) - include_inventory (boolean, optional) Responses: 201, 400, 401, 422 ### GET /api/v1/businesses/invoice-settings Get invoice branding settings Get invoice branding configuration including footer text and logo sync status. Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/businesses/invoice-settings Update invoice branding settings Update the default footer text shown on invoice PDFs. Request body (InvoiceSettingsUpdateRequest): - invoice_footer (string, optional) - payment_details (InvoicePaymentDetails, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/invoice-settings/sync-logo Sync logo to Stripe branding Upload the business logo to Stripe for invoice branding. Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/mailbox Check mailbox uniqueness Check if a mailbox is unique; validation and conflicts are handled by the service. Parameters: - mailbox (query, string, required): Mailbox to check for uniqueness Responses: 200, 400, 409, 422, 429 ### GET /api/v1/businesses/nav-preferences Get sidebar navigation preferences Get the per-business set of hidden nav items. Empty = show everything entitled. Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/businesses/nav-preferences Update sidebar navigation preferences Replace the per-business hidden nav set. Send an empty list to show everything. Request body (NavPreferencesUpdateRequest): - hidden (array · string, optional) - profile (NavPreferencesProfile, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/nav-preferences/suggest AI-suggest which nav items to hide Given a business description and the hideable nav catalog, returns a proposed set of items to hide (with reasons) plus a one-line profile. Proposal only — nothing is saved; apply via PUT /nav-preferences. Request body (NavSuggestRequest): - description (string, required) - items (array · NavCatalogItem, optional) → NavCatalogItem - signals (object, optional) Responses: 201, 400, 401, 403, 422, 500 ### GET /api/v1/businesses/plaid-transaction-settings Get Plaid pending-transaction settings Whether this business ingests & displays Plaid pending (unsettled) transactions as a read-only awareness layer. Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/businesses/plaid-transaction-settings Update Plaid pending-transaction settings Enable or disable ingesting & displaying Plaid pending transactions. Pending rows are financially inert (no journal entries) until they settle. Local accounting engine only. Request body (PlaidTransactionSettingsUpdateRequest): - show_pending_transactions (boolean, required) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/businesses/slack Save Slack webhook URL Configure a Slack Incoming Webhook URL for this business. Request body (SlackWebhookSaveRequest): - slack_webhook_url (string, optional) - channel_name (string, optional) - preferences (object, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/slack/status Get Slack integration status Check whether a Slack webhook is configured for this business. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/slack/test Test Slack webhook Send a test message to the business's first configured Slack webhook (legacy). Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/businesses/slack/{webhook_id} Disconnect Slack Remove the business's Slack webhook URL. Parameters: - webhook_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/businesses/slack/{webhook_id}/preferences Update Slack notification preferences Toggle which notification categories are sent to Slack. Parameters: - webhook_id (path, string, required) Request body (SlackPreferencesUpdateRequest): - preferences (object, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/slack/{webhook_id}/test Test Slack webhook Send a test message to the business's configured Slack webhook. Parameters: - webhook_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/source-accounts Get source accounts List source accounts for the business, including Plaid-linked and manually uploaded. Responses: 200, 401, 403, 422 ### GET /api/v1/businesses/user-preferences/table-views List saved table views Return all DataTable saved views for the current user in the active business. Responses: 200, 401, 403, 422 ### PATCH /api/v1/businesses/user-preferences/table-views Merge saved table views Upsert one or more table view blobs. Send empty views to remove a key. Include the expected ``version`` (or ``If-Match`` header) to avoid lost updates when multiple clients patch concurrently. Parameters: - If-Match (header, string, optional) Request body (TableViewsPatchRequest): - tables (object, optional) - version (integer, optional) Responses: 200, 400, 401, 403, 409, 422 ### GET /api/v1/businesses/user-preferences/table-views/{table_key} Get saved views for one table Return the saved-views blob for a single DataTable persistKey. Parameters: - table_key (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/businesses/users List business users Get users associated with a business, optionally including advisory firm users. Parameters: - include_advisory_users (query, boolean, optional): Include users from the parent advisory firm if one exists. - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/businesses/users Add user to business Grant a user access to this business with a specified role. Request body (BusinessUserAddRequest): - id (string, required) - role (Role, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### DELETE /api/v1/businesses/users/{user_id} Remove user from business Remove a user from a specific business. Parameters: - user_id (path, string, required) Responses: 200, 401, 403, 422 ### PUT /api/v1/businesses/users/{user_id} Update user role Change a user's access level and/or sidebar section visibility in this business. Parameters: - user_id (path, string, required) Request body (BusinessUserRoleUpdateRequest): - role (Role, required) → Role - visible_sections (array · string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/users/{user_id}/role Get user role Check a user's access level in this business. Parameters: - user_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/validate-coa Validate a custom COA template Validates a custom chart of accounts template against platform requirements without creating anything. Responses: 201, 401, 422 ### DELETE /api/v1/businesses/{business_id} Delete business Schedule the deletion of a business after the grace period. Parameters: - business_id (path, string, required) Request body (BusinessDeleteRequest): - confirm_password (string · password, optional) - business_id (string, optional) - confirm_name (string, required) - preserve_dz_users (boolean, optional) Responses: 202, 401, 403, 422 ### GET /api/v1/businesses/{business_id} Get business Retrieve full business details including integrations and settings. Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id} Update business Update business details. Parameters: - business_id (path, string, required) Request body (BusinessUpdateRequest): - name (string, optional) - name_aliases (array · string, optional) - logo_url (string, optional) - default_currency (string, optional) - tax_year_end_month (integer, optional) - start_date (string · date, optional) - timezone (string, optional) - accounting_basis (string, optional) - mailbox (string, optional) - inventory_mode (string, optional) - ap_approval_enabled (boolean, optional) - ap_due_date_basis (string, optional) - ar_subledger_mode (string, optional) - auto_link_new_counterparties (boolean, optional) - auto_rename_counterparties (boolean, optional) - stripe_payout_sibling_matching (boolean, optional) - agent_close_business_day (integer, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/businesses/{business_id}/balance-sheet Get balance sheet (sectioned) Balance sheet grouped by section (Assets, Liabilities, Equity). Each section contains ledger line items with ledger_id, ledger_name, sort_code, and total_amount. Parameters: - business_id (path, string, required) - as_of_date (query, string, required): As-of date (YYYY-MM-DD) - hide_zero_rows (query, boolean, optional): Exclude line items with a zero balance - period_granularity (query, string, optional): Optional period grouping: monthly, quarterly, or yearly. When set, requires start_date and adds one as-of balance per period end between start_date and as_of_date. - start_date (query, string, optional): Start date (YYYY-MM-DD); required when period_granularity is set - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis (accrual unless changed). Cash basis recognises invoice revenue and bill expense when paid, not when issued. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/balance-sheet/analyze AI analysis of balance sheet Uses AI to analyze the balance sheet as of a given date and return structured insights. Parameters: - business_id (path, string, required) Request body (AnalyzeBalanceSheetRequest): - basis (string, optional) - as_of_date (string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cash-flow-statement Get cash flow statement Cash flow statement (indirect method) grouped by operating, investing, and financing activities. The operating section walks Net Income through non-cash add-backs and working-capital changes to Net Cash from Operating Activities. Includes ASC 230 supplemental disclosures and §5 validation results. All amounts in cents. Parameters: - business_id (path, string, required) - start_date (query, string · date, required): Start date (YYYY-MM-DD) - end_date (query, string · date, required): End date (YYYY-MM-DD) - hide_zero_rows (query, boolean, optional): Exclude line items with zero cash impact - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis. On the cash basis Net Income is cash-basis net income and AR/AP carry no balance. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cash-flow-statement/outflow-breakdown Top categories and vendors by cash outflow Returns the top N ledger categories and counterparties that powered cash outflows during the requested period, ranked by absolute cash leaving. Powers the 'Where the cash went' tile on /books/cash-flow. Parameters: - business_id (path, string, required) - start_date (query, string · date, required): Start date (YYYY-MM-DD) - end_date (query, string · date, required): End date (YYYY-MM-DD) - limit (query, integer, optional): Max rows per list (categories and vendors are returned separately) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cash-flow-statement/periodic Get cash flow statements for multiple periods Batch endpoint returning a cash flow statement for each period in the requested date range. Avoids N round-trips for monthly, quarterly and yearly views. All amounts in cents. Parameters: - business_id (path, string, required) - start_date (query, string · date, required): Start date (YYYY-MM-DD) - end_date (query, string · date, required): End date (YYYY-MM-DD) - grouping (query, string, optional): Period grouping: 'monthly', 'quarterly' or 'yearly' - hide_zero_rows (query, boolean, optional): Exclude line items with zero cash impact - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis. On the cash basis Net Income is cash-basis net income and AR/AP carry no balance. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cash-flow/analyze AI analysis of cash flow statement Uses AI to analyze the cash flow statement for the given period and return structured insights. Parameters: - business_id (path, string, required) Request body (AnalyzeCashFlowRequest): - start_date (string, required) - end_date (string, required) - basis (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/data-exports Request full business data export Start an export of all business data as a zip of CSV files. Parameters: - business_id (path, string, required) Responses: 202, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/data-exports/latest Get latest business data export The most recent full export of the business (no link). Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/data-exports/{export_id} Get business data export One export; includes a short-lived download link when ready. Parameters: - business_id (path, string, required) - export_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/deletion Get business deletion schedule Whether the business is scheduled for deletion, and when. Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/deletion/cancel Cancel scheduled business deletion Cancel a scheduled deletion before the grace period ends. Parameters: - business_id (path, string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/businesses/{business_id}/income-statement Get income statement (sectioned) Income statement grouped by section. Each section contains ledger line items with period values as top-level keys. Parameters: - business_id (path, string, required) - start_date (query, string, required): Start date (YYYY-MM-DD) - end_date (query, string, required): End date (YYYY-MM-DD) - hide_zero_rows (query, boolean, optional): Exclude line items with all-zero values - period_granularity (query, string, optional): Period grouping: monthly, quarterly, yearly, or total (one column for the whole range, keyed `start_date/end_date`) - tag_ids (query, array · string, optional): Filter by tag UUIDs — only line entries tagged with at least one of these tags are included - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis (accrual unless changed). Cash basis recognises invoice revenue and bill expense when paid, not when issued. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/income-statement-flat Get income statement (flat) Pre-flattened income statement rows for display. No transformation needed. Parameters: - business_id (path, string, required) - start_date (query, string, required): Start date (YYYY-MM-DD) - end_date (query, string, required): End date (YYYY-MM-DD) - hide_zero_rows (query, boolean, optional): Exclude line items with all-zero values - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis (accrual unless changed). Cash basis recognises invoice revenue and bill expense when paid, not when issued. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/income-statement/analyze AI analysis of income statement Uses AI to analyze the income statement for the given period and return structured insights. Parameters: - business_id (path, string, required) Request body (AnalyzeIncomeStatementRequest): - basis (string, optional) - start_date (string, required) - end_date (string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/ledger/{ledger_id}/statement Get ledger statement for a date range Returns beginning balance, transactions within the range, and ending balance for a specific ledger account. Parameters: - business_id (path, string, required) - ledger_id (path, string, required) - start_date (query, string, required): Start date (YYYY-MM-DD) - end_date (query, string, required): End date (YYYY-MM-DD) - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis (accrual unless changed). Cash basis recognises invoice revenue and bill expense when paid, not when issued. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/ledger/{ledger_id}/vendor-breakdown Get vendor/counterparty breakdown for a ledger account Returns vendors/counterparties that contributed to a ledger account total in the given date range, with amounts and percentages. Parameters: - business_id (path, string, required) - ledger_id (path, string, required) - start_date (query, string, required): Start date (YYYY-MM-DD) - end_date (query, string, required): End date (YYYY-MM-DD) - cash_flow (query, boolean, optional): When true, restrict to cash-touching journal entries and use cash flow sign convention - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis (accrual unless changed). Cash basis recognises invoice revenue and bill expense when paid, not when issued. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/ledger/{ledger_id}/vendor-period-matrix Get vendor breakdown across all periods for a ledger Returns vendor/counterparty breakdown with per-period amounts for pivot-table display. Parameters: - business_id (path, string, required) - ledger_id (path, string, required) - start_date (query, string, required): Start date (YYYY-MM-DD) - end_date (query, string, required): End date (YYYY-MM-DD) - period_granularity (query, string, optional): monthly, quarterly, or yearly - cash_flow (query, boolean, optional): When true, restrict to cash-touching journal entries and use cash flow sign convention - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis (accrual unless changed). Cash basis recognises invoice revenue and bill expense when paid, not when issued. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/ledger/{ledger_id}/vendor-transactions Get individual transactions for a vendor within a ledger Returns individual line entries for a specific counterparty within a ledger and date range. Parameters: - business_id (path, string, required) - ledger_id (path, string, required) - counterparty_name (query, string, required): Counterparty/vendor name - start_date (query, string, required): Start date (YYYY-MM-DD) - end_date (query, string, required): End date (YYYY-MM-DD) - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis (accrual unless changed). Cash basis recognises invoice revenue and bill expense when paid, not when issued. Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/businesses/{business_id}/line-entries/recategorize Recategorize line entries Move line entries to a different ledger. Used for journal-entry lines that have no bank transaction. Parameters: - business_id (path, string, required) Request body (RecategorizeLineEntriesRequest): - line_entry_ids (array · string, required) - ledger_id (string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/mailbox Provision inbound mailbox Mint an inbound mailbox slug for a business that has none, so vendor bills can be forwarded to its AP inbox. Idempotent: a business that already has a mailbox gets it back unchanged (never overwritten). Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/reports/cash-basis/bridge Accrual to cash-basis net income bridge Accrual net income, cash-basis net income and the rows that decompose the difference (invoices not yet collected, collections recognised, bills not yet paid, bill payments recognised, unapplied receipts / payments, rounding, period close). Amounts in cents; row amounts are the effect on net income. Parameters: - business_id (path, string, required) - start_date (query, string, required): Start date (YYYY-MM-DD) - end_date (query, string, required): End date (YYYY-MM-DD) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/reports/cash-basis/unapplied List cash-basis unapplied settlements Customer receipts and vendor payments booked against AR/AP that the cash-basis view could not trace to an invoice or bill. On the cash basis they are recognised as Uncategorized Income / Expense; this list lets the user find and match them. Amounts in cents. Parameters: - business_id (path, string, required) - start_date (query, string, required): Start date (YYYY-MM-DD) - end_date (query, string, required): End date (YYYY-MM-DD) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id}/stripe-subscription Update Stripe subscription Link a Stripe subscription to a business. Parameters: - business_id (path, string, required) Request body (UpdateStripeSubscriptionRequest): - stripe_subscription_id (string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/sync Get sync status Get the current account sync status for a business. Lightweight endpoint for polling. Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/trial-balance Get trial balance Trial balance listing every ledger account with debit and credit balances as of a point-in-time date. All amounts in cents. Parameters: - business_id (path, string, required) - as_of_date (query, string, required): As-of date (YYYY-MM-DD) - hide_zero_rows (query, boolean, optional): Exclude accounts with zero debit and credit balances - basis (query, string, optional): Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis (accrual unless changed). Cash basis recognises invoice revenue and bill expense when paid, not when issued. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/trial-balance/bridge Compare another system's trial balance with ours Read-only. Matches each external account to a ledger and gives every ledger a verdict: tied, intentional, offsetting_swing or unexplained. Parameters: - business_id (path, string, required) Request body (TrialBalanceBridgeRequest): - as_of_date (string, required) - rows (array · ExternalTrialBalanceRow, optional) - csv_text (string, optional) - mapping (object, optional) - intentional (array · IntentionalDifference, optional) - tolerance_cents (integer, optional) - prior_rows (array · ExternalTrialBalanceRow, optional) - prior_as_of (string, optional) - basis (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/trial-balance/diff Trial balance movement between two dates Per ledger: balance at the end of the day before `from_date`, balance at `to_date`, and the movement. Debit-positive cents. Parameters: - business_id (path, string, required) - from_date (query, string, required): First day of the window - to_date (query, string, required): Last day of the window - basis (query, string, optional): `accrual` or `cash`; defaults to the business's basis. - hide_zero_rows (query, boolean, optional): Omit ledgers with no opening or closing balance Responses: 200, 400, 401, 403, 404, 422 ## capital ### GET /api/v1/capital/lines List the credit lines this business borrows on Every line whose merchant is this business, across every lender, with the figures the lender's dashboard shows: limit, balance, available credit, next due date. Responses: 200, 401, 403, 422 ### GET /api/v1/capital/offers List capital offers open to this business Marketplace-listed, active lending programs the business does not already hold a line on (pending, active or suspended). Each offer carries the program's limit range, payback terms, annual rate and draw fee as the program defines them, the business's in-flight application to it if any, and `eligibility_preview`: a read-only look at the bank and Shopify data an assessment would measure (null when it could not be read). No assessment is run. Responses: 200, 401, 403, 422 ### POST /api/v1/capital/offers/{program_id}/apply Apply to a capital offer Starts the application flow for the offer: an underwriting assessment is requested on the lender's program with this business as the subject, exactly as the partner Apply wizard does, and returned pending with `next_step` (connect a bank, wait for the assessment, wait for the decision). Idempotent: a second call returns the application the first opened, `created: false`. `requested_limit_cents` defaults to the program's minimum and `requested_term_days` to its first term. `404` for an offer not open to this business, `409` when it already holds a line under the program or the program has no active scorecard. Parameters: - program_id (path, string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ## catalog-items ### GET /api/v1/catalog-items List catalog items List Products & Services catalog items for the business. Parameters: - active_only (query, boolean, optional): Only show active items. - item_type (query, string, optional): Filter by type: service, non_inventory, inventory, bundle. - search (query, string, optional): Fuzzy match on name or SKU. - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/catalog-items Create catalog item Create a new Products & Services catalog item. Request body (CatalogItemCreateRequest): - name (string, required) - item_type (string, optional) - sku (string, optional) - description (string, optional) - billing_rule (string, optional) - unit_label (string, optional) - unit_price (number | string, optional) - purchase_cost (integer, optional) - is_sold (boolean, optional) - is_purchased (boolean, optional) - taxable (boolean, optional) - income_ledger_id (string, optional) - expense_ledger_id (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/catalog-items/{bundle_id}/components List a bundle's components Explode a bundle catalog item into its component items + quantities. Parameters: - bundle_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/catalog-items/{bundle_id}/components Set a bundle's components Replace a bundle's component set wholesale. Parameters: - bundle_id (path, string, required) Request body (BundleComponentsSetRequest): - components (array · BundleComponentInput, optional) → BundleComponentInput Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/catalog-items/{item_id} Deactivate catalog item Deactivate a catalog item (soft delete). Parameters: - item_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/catalog-items/{item_id} Get catalog item Get details of a specific catalog item. Parameters: - item_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/catalog-items/{item_id} Update catalog item Update an existing catalog item. Parameters: - item_id (path, string, required) Request body (CatalogItemUpdateRequest): - name (string, optional) - item_type (string, optional) - sku (string, optional) - description (string, optional) - billing_rule (string, optional) - unit_label (string, optional) - unit_price (number | string, optional) - purchase_cost (integer, optional) - is_sold (boolean, optional) - is_purchased (boolean, optional) - taxable (boolean, optional) - income_ledger_id (string, optional) - expense_ledger_id (string, optional) - is_active (boolean, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ## categorization-profile ### GET /api/v1/categorization-profile Get the current business's categorization profile Returns the categorization profile (accounting basis, key personnel, convention overrides, etc.) used by the engine and AI prompt for this business. Returns ``{}`` if no profile has been configured. Responses: 200, 401, 403, 422 ### PUT /api/v1/categorization-profile Upsert the current business's categorization profile Partial-update or create the categorization profile. Accepted keys: accounting_basis, industry, key_personnel, convention_overrides, tax_remittance_ledger_id, notes, and the automation controls auto_categorize_enabled (default true), auto_categorize_min_confidence (0.5-0.99, null = default 0.8), auto_match_on_sync (default false) and counterparty_auto_merge_enabled (default true). Responses: 200, 400, 401, 403, 422 ## cfo-portal ### GET /api/v1/businesses/flux/lineage Get 4-stage money-flow provenance lineage for a GL account Trace a GL account line back through journal entries, clearing, and source feeds. Parameters: - ledger_id (query, string, optional) - account_name (query, string, optional) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/flux/narrative-packet Get CFO narrative flux close packet with subledger drill-through Build a live narrative flux close packet with subledger drill-through and optional PII redaction. Parameters: - period_end (query, string · date, optional) - materiality_bps (query, integer, optional) - redact_pii (query, boolean, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/flux/time-travel-audit Run 60-Second Time-Travel Audit across historical feeds, subledgers, and GL Scan historical transactions, bills, commerce clearing, and MCA drains in one pass. Parameters: - lookback_days (query, integer, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/alerts Get CFO financial alerts Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/ap-aging Get CFO AP aging Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/ar-aging Get CFO AR aging Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/ask Ask Regent a question from the CFO portal Parameters: - business_id (path, string, required) Request body (CfoPortalAskRequest): - question (string, required) - context_section (string, optional) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/benchmarks Get CFO benchmarks Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/board-deck Get CFO board deck summary Parameters: - business_id (path, string, required) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/board-deck/memo Generate an AI board memo/report from CFO board-deck data Generate a board-ready memo using the latest board-deck metrics. Parameters: - business_id (path, string, required) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/board-deck/memo/export Export AI board memo as PDF or HTML Export the current AI board memo in a user-selected format. Parameters: - business_id (path, string, required) Request body (CfoPortalBoardMemoExportRequest): - title (string, optional) - memo_markdown (string, required) - generated_at (string · date-time, optional) - format (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/board-deck/pdf Download board deck summary as PDF Build and download the board deck summary PDF on demand. Parameters: - business_id (path, string, required) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/buckets List all managerial buckets (default + custom) Return all managerial buckets available for this business. Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/buckets Create a custom managerial bucket Create a new custom managerial bucket for categorizing GL accounts. Parameters: - business_id (path, string, required) Request body (CustomBucketCreateRequest): - key (string, required) - label (string, required) - color (string, optional) - classification (string, optional) - sort_order (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/businesses/{business_id}/cfo-portal/buckets/{bucket_key} Delete or disable a managerial bucket Delete or disable a managerial bucket. Parameters: - business_id (path, string, required) - bucket_key (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id}/cfo-portal/buckets/{bucket_key} Update a managerial bucket Update a managerial bucket. Parameters: - business_id (path, string, required) - bucket_key (path, string, required) Request body (CustomBucketUpdateRequest): - label (string, optional) - color (string, optional) - classification (string, optional) - sort_order (integer, optional) - is_active (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/budget-vs-actual Get CFO budget vs actual Get the budget-vs-actual section with optional budget/date filters. Parameters: - business_id (path, string, required) - budget_id (query, string, optional) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/cash-forecast Get CFO 13-week cash forecast Get the cash forecast section with optional budget selection. Parameters: - business_id (path, string, required) - budget_id (query, string, optional) - apply_overrides (query, boolean, optional): When true, the working override scope is folded into the computed cell values. Used by the Demand Planner tab. The live Cash Flow Forecast tab leaves this off so unsaved what-if values don't bleed across views. - include_projected_replenishment (query, boolean, optional): When true, projected (not-yet-placed) replenishment POs from the SKU demand-forecast engine are added to a separate Projected Inventory row so operators see the cash impact of reorders they'll need to make. Off by default to keep the live Forecast tab byte-identical. - include_unapproved_ap (query, boolean, optional): When true, pending_approval and forecasted bills (not raised from a PO) are added as their own 'AP – awaiting approval' row by due date. Draft bills never count. - net_bills_against_budget (query, boolean, optional): When true, open bills coded to a budgeted expense ledger and due in the window are taken off that ledger's budget projection (floor 0), so a contractor budget line and the contractors' bills are not both counted. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/demand-plan Evaluate a what-if cash forecast scenario Run the canonical forecast twice (clean baseline + scenario) and Parameters: - business_id (path, string, required) Request body (DemandPlanScenarioRequest): - scenario_description (string, required) - overrides (array · DemandPlanScenarioOverride, optional) → DemandPlanScenarioOverride - inline_one_time_items (array · DemandPlanScenarioOneTime, optional) → DemandPlanScenarioOneTime - weeks (integer, optional) - budget_id (string, optional) - excluded_budget_ledger_ids (array · string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/one-time-items List one-time payment items applied to the cash forecast List all one-time payment items for this business. Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/one-time-items Create a one-time payment item Create a one-time payment item for the cash forecast. Parameters: - business_id (path, string, required) Request body (CashForecastOneTimeItemCreate): - label (string, required) - amount_cents (integer, required) - applies_on (string · date, required) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/one-time-items/{item_id} Delete a one-time payment item Delete a one-time payment item. Parameters: - business_id (path, string, required) - item_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/one-time-items/{item_id} Update a one-time payment item Partially update a one-time payment item. Parameters: - business_id (path, string, required) - item_id (path, string, required) Request body (CashForecastOneTimeItemUpdate): - label (string, optional) - amount_cents (integer, optional) - applies_on (string · date, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/overrides Clear all cash forecast overrides in a scope Clear every override in the matching scope (working set or version). Parameters: - business_id (path, string, required) - version_id (query, string, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/overrides List cell-level overrides for the cash forecast List overrides for either the working set or a saved version. Parameters: - business_id (path, string, required) - version_id (query, string, optional): Saved version id to scope overrides to. Omit for the user's working override set. Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/overrides Replace all cash forecast overrides in a scope Atomically replace every override row in the matching scope. Parameters: - business_id (path, string, required) Request body (CashForecastOverridesUpsert): - version_id (string, optional) - overrides (array · CashForecastOverrideInput, optional) → CashForecastOverrideInput - merge (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/overrides/{override_id} Delete a single cash forecast override row Delete a single override row by id. Parameters: - business_id (path, string, required) - override_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/settings Update Cash Forecast configuration Save Cash Forecast settings (excluded budget ledgers). Parameters: - business_id (path, string, required) Request body (CashForecastSettingsUpdateRequest): - excluded_budget_ledger_ids (array · string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/timing List fixed-cost timing rows (lag and pay days per ledger) List the budget ledgers that pay on a schedule instead of prorated. Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/timing Set fixed-cost timing rows (lag and pay days per ledger) Insert or update one timing row per ledger. Parameters: - business_id (path, string, required) Request body (CashForecastLedgerTimingUpsert): - rows (array · CashForecastLedgerTimingRow, optional) → CashForecastLedgerTimingRow Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions List saved cash forecast versions List saved versions for this business (summary view, no snapshot). Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions Save the current cash forecast configuration as a named version Snapshot the current cash forecast configuration + output. Parameters: - business_id (path, string, required) Request body (CashForecastVersionCreate): - name (string, required) - description (string, optional) - config (CashForecastVersionConfig, optional) → CashForecastVersionConfig Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions/{version_id} Delete a saved cash forecast version Delete a saved version and any overrides pinned to it. Parameters: - business_id (path, string, required) - version_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions/{version_id} Get a saved cash forecast version Get full detail for a saved version, including config + snapshot. Parameters: - business_id (path, string, required) - version_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions/{version_id} Rename or describe a saved version Update a saved version's name or description. Parameters: - business_id (path, string, required) - version_id (path, string, required) Request body (CashForecastVersionUpdate): - name (string, optional) - description (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/cash-forecast/versions/{version_id}/apply Re-apply a saved version's config to the live forecast Load a saved version into the user's working scope. Parameters: - business_id (path, string, required) - version_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/configuration Get CFO configuration Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/debt-schedule Get CFO debt schedule Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/approve-contract Approve parsed debt contract and create debt instrument Create a debt instrument from approved parsed contract terms. Parameters: - business_id (path, string, required) Request body (DebtContractApproveRequest): - contract (ParsedDebtContract, required) → ParsedDebtContract - contract_s3_key (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/covenants/{covenant_id} Delete a debt covenant Remove a covenant rule from a debt instrument. Parameters: - business_id (path, string, required) - covenant_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id} Soft-delete a debt instrument Remove a debt instrument from the schedule (soft delete). Parameters: - business_id (path, string, required) - instrument_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id} Update a debt instrument Update editable fields on an existing debt instrument. Parameters: - business_id (path, string, required) - instrument_id (path, string, required) Request body (DebtInstrumentUpdateRequest): - name (string, optional) - current_balance_cents (integer, optional) - notes (string, optional) - amount_repaid_cents (integer, optional) - revenue_share_bps (integer, optional) - total_repayment_cap_cents (integer, optional) - linked_ledger_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/covenants List covenants for a debt instrument List financial covenants attached to a debt instrument. Parameters: - business_id (path, string, required) - instrument_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/covenants Add a covenant to a debt instrument Attach a financial covenant to a loan. Parameters: - business_id (path, string, required) - instrument_id (path, string, required) Request body (DebtCovenantCreateRequest): - metric_name (string, required) - operator (string, required) - threshold_value (string, required) - measurement_frequency (string, optional) - description (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/payment-schedule Get a loan's customizable paydown table Return the persisted, editable paydown schedule for a loan. Parameters: - business_id (path, string, required) - instrument_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/payment-schedule/generate Generate or rebuild a loan's paydown table (Re)generate a loan's paydown table from its terms. Parameters: - business_id (path, string, required) - instrument_id (path, string, required) Request body (DebtScheduleGenerateRequest): - overwrite_custom (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/payment-schedule/rows Add a row to a loan's paydown table Add a user-defined payment row to a loan's paydown table. Parameters: - business_id (path, string, required) - instrument_id (path, string, required) Request body (DebtScheduleRowCreateRequest): - due_date (string · date, required) - principal_cents (integer, optional) - interest_cents (integer, optional) - note (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/payments Record a payment against a debt instrument Record a payment on a loan, posting a balanced principal/interest entry. Parameters: - business_id (path, string, required) - instrument_id (path, string, required) Request body (DebtPaymentRequest): - payment_amount_cents (integer, optional) - cash_ledger_id (string, optional) - payment_date (string · date, optional) - memo (string, optional) - transaction_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/parse-contract Parse debt contract into a draft payment schedule Parse an uploaded lending contract into structured terms and schedule. Parameters: - business_id (path, string, required) Request body (DebtContractParseRequest): - s3_key (string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/payment-schedule/rows/{row_id} Delete a loan paydown-table row Remove a row from a loan's paydown table. Parameters: - business_id (path, string, required) - row_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/payment-schedule/rows/{row_id} Edit a loan paydown-table row Edit a single paydown-table row (date, principal, interest, status). Parameters: - business_id (path, string, required) - row_id (path, string, required) Request body (DebtScheduleRowUpdateRequest): - due_date (string · date, optional) - principal_cents (integer, optional) - interest_cents (integer, optional) - status (string, optional) - note (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/flux Get CFO flux analysis Parameters: - business_id (path, string, required) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/flux/lineage Get 4-stage money-flow provenance lineage for a business GL account Trace a GL account line back through journal entries, clearing, and source feeds for ``business_id``. Parameters: - business_id (path, string, required) - ledger_id (query, string, optional) - account_name (query, string, optional) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/flux/narrative-packet Get CFO narrative flux close packet for a business Build a live narrative flux close packet for ``business_id``. Parameters: - business_id (path, string, required) - period_end (query, string · date, optional) - materiality_bps (query, integer, optional) - redact_pii (query, boolean, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/flux/time-travel-audit Run 60-Second Time-Travel Audit for a business Scan historical transactions, bills, commerce clearing, and MCA drains for ``business_id``. Parameters: - business_id (path, string, required) - lookback_days (query, integer, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/landed-cogs Get CFO landed COGS Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/managerial-bs Get CFO managerial balance sheet Parameters: - business_id (path, string, required) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/managerial-pl Get CFO managerial P&L Parameters: - business_id (path, string, required) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/monthly-close Get CFO monthly close status Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/po-forecast-settings List open POs and which forecast column they flow through List every open PO with its forecast attribution. Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/purchase-orders Get CFO purchase order pipeline Parameters: - business_id (path, string, required) - status (query, string, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/recipe-book Get CFO recipe book Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/businesses/{business_id}/cfo-portal/recipe-book/auto-assign AI auto-assign ledgers to managerial buckets AI auto-assign ledgers to managerial buckets based on account names. Parameters: - business_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id}/cfo-portal/recipe-book/managerial-builders Upsert managerial builder line account selections Save account selections for CM1/CM2 and cash-outflow builder lines. Parameters: - business_id (path, string, required) Request body (ManagerialBuildersUpdateRequest): - builders (array · ManagerialBuilderItem, optional) → ManagerialBuilderItem Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id}/cfo-portal/recipe-book/managerial-mappings Upsert managerial bucket assignments for GL accounts Save bucket assignments edited on the Recipe Book page. Parameters: - business_id (path, string, required) Request body (ManagerialMappingUpsertRequest): - mappings (array · ManagerialMappingItem, optional) → ManagerialMappingItem Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/reports-documents Get CFO reports and documents Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/shipping-analysis Get CFO shipping analysis Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/shopify Get CFO Shopify metrics Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/statements Get CFO statement bundle Parameters: - business_id (path, string, required) - start_date (query, string · date, optional) - end_date (query, string · date, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/summary Get CFO portal summary Parameters: - business_id (path, string, required) - include_series (query, boolean, optional): When true, include the 13-week trailing P&L series in ``data.pulse.weekly_series`` and run the heavier DB fan-out. - include_weekly_pl (query, boolean, optional): When true, include the 4-week P&L table rows in ``data.weekly_pl_rows``. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/unit-economics Get CFO unit economics Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id}/cfo-portal/unit-economics/settings Update Unit Economics configuration Save Unit Economics settings (Shopify vs manual AOV override). Parameters: - business_id (path, string, required) Request body (UnitEconomicsSettingsUpdateRequest): - aov_mode (string, required) - manual_aov_cents (integer, optional) - shopify_sections (array · string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/valuation Get CFO valuation inputs Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/businesses/{business_id}/cfo-portal/vendor-spend Get CFO vendor spend Get vendor spend with optional date range, grouping mode, and source filters. Parameters: - business_id (path, string, required) - start_date (query, string · date, optional) - end_date (query, string · date, optional) - group_by (query, string, optional) - sources (query, array · string, optional) Responses: 200, 401, 403, 404, 422 ## cfo-projection ### GET /api/v1/cfo-projection/actuals Get trailing actuals Trailing income statement actuals shaped for the projection page. Pass `start_month`/`end_month` (YYYY-MM) to pin an explicit window; otherwise the last `trailing_months` closed months are returned. Parameters: - trailing_months (query, integer, optional): Number of trailing months (used when start/end unset) - start_month (query, string, optional): Inclusive window start in YYYY-MM. Required together with end_month. - end_month (query, string, optional): Inclusive window end in YYYY-MM. Required together with start_month. - hide_zero_rows (query, boolean, optional): Exclude line items with all-zero values Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/cfo-projection/scenarios List scenarios List all projection scenarios for the business. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/cfo-projection/scenarios Create scenario Create a new projection scenario. Drivers are auto-seeded from trailing actuals when omitted. Request body (ScenarioCreateRequest): - name (string, optional) - base_month (string · date, optional) - projection_months (integer, optional) - revenue_drivers (object, optional) - cost_classifications (object, optional) - variable_drivers (object, optional) - fixed_drivers (object, optional) - monthly_overrides (object, optional) - tax_rate (number, optional) - interest_income_monthly (integer, optional) - interest_expense_monthly (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/cfo-projection/scenarios/active Get active scenario Get the currently active projection scenario, or null. Responses: 200, 401, 403, 422 ### POST /api/v1/cfo-projection/scenarios/from-budget/{budget_id} Create scenario from budget Derive a new projection scenario from an existing budget's line items. Parameters: - budget_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/cfo-projection/scenarios/{scenario_id} Delete scenario Soft delete a projection scenario. Parameters: - scenario_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/cfo-projection/scenarios/{scenario_id} Get scenario Get a projection scenario by ID. Parameters: - scenario_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/cfo-projection/scenarios/{scenario_id} Update scenario Partial update of scenario drivers. Parameters: - scenario_id (path, string, required) Request body (ScenarioUpdateRequest): - name (string, optional) - projection_months (integer, optional) - revenue_drivers (object, optional) - cost_classifications (object, optional) - variable_drivers (object, optional) - fixed_drivers (object, optional) - monthly_overrides (object, optional) - tax_rate (number, optional) - interest_income_monthly (integer, optional) - interest_expense_monthly (integer, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/cfo-projection/scenarios/{scenario_id}/projection Compute projection Compute a full N-month projected income statement from scenario drivers. Parameters: - scenario_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/cfo-projection/scenarios/{scenario_id}/suggest-tax-rate Suggest tax rates Use AI to suggest effective income tax rates for a projection scenario. Parameters: - scenario_id (path, string, required) Responses: 201, 401, 403, 404, 422 ## change-orders ### GET /api/v1/change-orders List change orders List change orders, optionally filtered by contract. Parameters: - contract_id (query, string, optional): Filter by contract ID - status (query, string, optional): Filter by status - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/change-orders Create change order Create a versioned amendment against a live contract. Request body (ChangeOrderCreate): - contract_id (string, required) - description (string, optional) - value_delta_cents (integer, required) - hours_delta (number | string, optional) - delta_lines (object, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/change-orders/{change_order_id} Delete change order Delete a draft change order. Parameters: - change_order_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/change-orders/{change_order_id} Get change order Get a change order by ID. Parameters: - change_order_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/change-orders/{change_order_id} Update change order Update a draft change order. Revert a sent or signed change order to draft first (this clears its signatures). Parameters: - change_order_id (path, string, required) Request body (ChangeOrderUpdate): - description (string, optional) - value_delta_cents (integer, optional) - hours_delta (number | string, optional) - delta_lines (object, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/change-orders/{change_order_id}/countersign Countersign change order Countersign and apply the value delta to the contract. Parameters: - change_order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/change-orders/{change_order_id}/revert-to-draft Revert change order to draft Send a sent or signed (not countersigned) change order back to draft so it can be edited. Clears the sent/signed timestamps and any signed file. Parameters: - change_order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/change-orders/{change_order_id}/send Email change order to customer Email the change order to the contract customer's email address (`customer_email` on the response), then mark it sent. A draft moves to `sent`; calling this on a `sent` change order re-sends the email (status unchanged, `sent_at` updated). Replies go to the user who sent it. Nothing changes when the email cannot go out: 400 `VALIDATION_873` when the customer has no email, 400 `INTEGRATION_092` when delivery fails, 403 for demo businesses, and 409 `CONFLICT_101` when it was emailed less than 5 minutes ago. Parameters: - change_order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/change-orders/{change_order_id}/sign Mark change order signed Mark a change order signed (sent -> signed). Parameters: - change_order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## client-digest-preview ### GET /api/v1/advisory-firms/{firm_id}/clients/{business_id}/digest-preview Preview a client's financial digest The data a client's weekly or monthly digest email and PDF would carry right now: health score, AR/AP, cash and runway, budget vs actual, highlights. Nothing is sent. Parameters: - firm_id (path, string, required) - business_id (path, string, required) - frequency (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/clients/{business_id}/digest-preview/pdf Download a client's financial digest PDF The branded PDF the client would receive with the digest email. Parameters: - firm_id (path, string, required) - business_id (path, string, required) - frequency (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ## client-messages — Messaging between advisory firms and their clients. ### GET /api/v1/client-messages/conversations List client conversations List conversations for the current business. Parameters: - status (query, string, optional): Filter by status - category (query, string, optional): Filter by category - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional) - include_total_count (query, boolean, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/client-messages/conversations Create a conversation Start a new conversation with the advisory firm. Request body (CreateConversationRequest): - subject (string, required) - category (ConversationCategory, optional) → ConversationCategory - message (string, required) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/client-messages/conversations/{conversation_id} Get conversation detail Get a conversation with all messages. Marks messages as read. Parameters: - conversation_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/client-messages/conversations/{conversation_id}/messages Reply to a conversation (client) Add a message to an existing conversation as a client. Parameters: - conversation_id (path, string, required) Request body (CreateMessageRequest): - body (string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/client-messages/firm/conversations List client conversations (firm) List all client conversations across the firm's businesses. Parameters: - firm_id (query, string, optional): Advisory firm ID (defaults to user's first firm) - business_id (query, string, optional): Filter by business - status (query, string, optional): Filter by status - category (query, string, optional): Filter by category - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional) - include_total_count (query, boolean, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/client-messages/firm/conversations/{conversation_id} Get conversation detail (firm) Get a conversation with all messages as an advisor. Parameters: - conversation_id (path, string, required) - firm_id (query, string, optional): Advisory firm ID Responses: 200, 401, 403, 404, 422 ### POST /api/v1/client-messages/firm/conversations/{conversation_id}/messages Reply to a conversation (advisor) Add a message to a client conversation as an advisor. Parameters: - conversation_id (path, string, required) - firm_id (query, string, optional): Advisory firm ID Request body (CreateMessageRequest): - body (string, required) Responses: 201, 400, 401, 403, 404, 422 ### PUT /api/v1/client-messages/firm/conversations/{conversation_id}/status Update conversation status Change a conversation's status (resolve, reopen, etc.). Parameters: - conversation_id (path, string, required) - firm_id (query, string, optional): Advisory firm ID Request body (UpdateConversationStatusRequest): - status (ConversationStatus, required) → ConversationStatus Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/client-messages/firm/unread-count Unread conversation count (firm) Get unread count for the advisor sidebar badge. Parameters: - firm_id (query, string, optional): Advisory firm ID Responses: 200, 401, 403, 422 ### GET /api/v1/client-messages/unread-count Unread conversation count Get the number of conversations with unread messages for sidebar badge. Responses: 200, 401, 403, 422 ## close-verification ### GET /api/v1/close/verification Close verification report Run the month-end verification checks for a period and return the exceptions: uncategorized transactions, miscategorized candidates, transfer pairing, counterparty vs description, cash inflows and manual journal entries. Parameters: - start_date (query, string, required): Period start (YYYY-MM-DD) - end_date (query, string, required): Period end (YYYY-MM-DD) - checks (query, array · string, optional): Checks to run (comma-separated; default all): uncategorized_transactions, miscategorized_candidates, transfer_pairing, counterparty_mismatch, cash_inflows, manual_journal_entries, shopify_tie_out - max_rows_per_check (query, integer, optional): Exception rows returned per check; counts always cover all rows Responses: 200, 400, 401, 403, 422 ### POST /api/v1/close/verification/apply-counterparty-defaults Apply counterparty defaults to categorized transactions Move already-categorized transactions in a period to the ledger their counterparty default names. Rows in a closed period, rows whose default cannot take the direction of the money and rows a person categorized by hand are skipped. Defaults to a dry run. Parameters: - start_date (query, string, required): Period start (YYYY-MM-DD) - end_date (query, string, required): Period end (YYYY-MM-DD) - dry_run (query, boolean, optional): Plan only; set false to move the transactions - counterparty (query, string, optional): Only rows for this counterparty (default all) - include_user_categorized (query, boolean, optional): Also move rows a person categorized by hand - plan_hash (query, string, optional): The plan_hash the dry run returned; the move is refused if the rows changed since Responses: 201, 400, 401, 403, 422 ## consolidated-reports ### GET /api/v1/advisory-firms/{firm_id}/consolidated-reports/balance-sheet Get consolidated balance sheet Uneliminated balance sheet roll-up across all businesses assigned to the advisory firm. Parameters: - firm_id (path, string, required) - as_of_date (query, string, required): Point-in-time date (YYYY-MM-DD) - apply_eliminations (query, boolean, optional): Remove intercompany due-to / due-from positions recorded by the cleanup engine from assets and liabilities - entity_group_id (query, string, optional): Optional entity group to scope the roll-up to; defaults to all active firm client businesses Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/consolidated-reports/pnl Get consolidated P&L Uneliminated income statement roll-up across all businesses assigned to the advisory firm. Parameters: - firm_id (path, string, required) - start_date (query, string, required): Period start (YYYY-MM-DD) - end_date (query, string, required): Period end (YYYY-MM-DD) - entity_group_id (query, string, optional): Optional entity group to scope the roll-up to; defaults to all active firm client businesses Responses: 200, 400, 401, 403, 404, 422 ## consolidation ### GET /api/v1/advisory-firms/{firm_id}/consolidation/runs/{run_id} Get a consolidation run Run status, rates used, totals and exceptions. Parameters: - firm_id (path, string, required) - run_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/consolidation/runs/{run_id}/eliminations List elimination lines Elimination and adjustment lines of the run (debit minus credit, cents). Parameters: - firm_id (path, string, required) - run_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/consolidation/runs/{run_id}/exceptions List consolidation exceptions Unmapped accounts, missing FX rates, unmatched intercompany and more. Parameters: - firm_id (path, string, required) - run_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/consolidation/runs/{run_id}/export Export a consolidated statement to Excel Download pl, bs, cf, eliminations or exceptions as an Excel file. Parameters: - firm_id (path, string, required) - run_id (path, string, required) - what (query, string, optional): pl, bs, cf, eliminations or exceptions Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/consolidation/runs/{run_id}/rerun Rerun a consolidation Recompute a run in place from the current books, rates and mappings. Parameters: - firm_id (path, string, required) - run_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/consolidation/runs/{run_id}/statements/{statement} Get a consolidated statement P&L (pl), balance sheet (bs) or indirect cash flow (cf) with entity columns. Parameters: - firm_id (path, string, required) - run_id (path, string, required) - statement (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id}/consolidation/intercompany-tags List intercompany tags Member ledgers tagged as intercompany with a counterparty. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id}/consolidation/intercompany-tags Replace a member's intercompany tags Tag a member's ledgers as receivable, payable, revenue, expense or investment. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Request body (SetIntercompanyTagsRequest): - business_id (string, required) - tags (array · IntercompanyTagItem, optional) → IntercompanyTagItem Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id}/consolidation/runs List consolidation runs Runs of the group, newest period first. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id}/consolidation/runs Run a consolidation Consolidate the group over a period and store the result. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Request body (RunConsolidationRequest): - period_start (string · date, required) - period_end (string · date, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id}/consolidation/settings Get consolidation settings Parent, reporting currency, mapping source, alignment and members. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/advisory-firms/{firm_id}/entity-groups/{group_id}/consolidation/settings Update consolidation settings Set reporting currency, mapping source, alignment and ownership. Parameters: - firm_id (path, string, required) - group_id (path, string, required) Request body (UpdateConsolidationSettingsRequest): - reporting_currency (string, optional) - mapping_source (string, optional) - mapping_key_type (string, optional) - period_alignment (string, optional) - intercompany_tolerance_cents (integer, optional) - members (array · ConsolidationMemberUpdate, optional) → ConsolidationMemberUpdate Responses: 200, 400, 401, 403, 404, 422 ## contractors ### GET /api/v1/contractors List contractors List vendors, optionally only those flagged as 1099 contractors. Parameters: - only_1099 (query, boolean, optional): Only 1099-flagged vendors. Responses: 200, 401, 403, 422 ### GET /api/v1/contractors/1099-report 1099 year-end report Total payments per 1099 contractor for the tax year. Parameters: - year (query, integer, required): Tax year, e.g. 2025. Responses: 200, 400, 401, 403, 422 ### PUT /api/v1/contractors/{vendor_id} Update contractor 1099 fields Set the 1099 flag, tax id, tax id type, and default box. Parameters: - vendor_id (path, string, required) Request body (ContractorUpdateRequest): - is_1099_contractor (boolean, optional) - tax_id (string, optional) - tax_id_type (string, optional) - default_1099_box (string, optional) Responses: 200, 400, 401, 403, 404, 422 ## contracts ### GET /api/v1/contracts List contracts List contracts for the business with optional filters. Parameters: - status (query, string, optional): Filter by contract status - customer_id (query, string, optional): Filter by customer ID - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/contracts Create a contract Create a contract directly from the Contracts UI. Provide either an existing order to promote (`order_id`) or a full order payload (`order`) to draft and countersign in one step. Both paths run the order through countersign, so the contract keeps a frozen order as its provenance. Request body (ContractCreate): - order_id (string, optional) - order (OrderCreate, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/contracts/cash-flow-forecast Weekly cash-inflow forecast Forward-looking weekly cash-inflow forecast projected from each live contract's order-line billing rules, bucketed into calendar weeks from the current week. Parameters: - weeks (query, integer, optional): Number of weeks to project. Responses: 200, 401, 403, 422 ### GET /api/v1/contracts/drawdowns List drawdowns (cross-contract queue) The portfolio-wide hours-approval queue. Parameters: - status (query, string, optional): Filter by drawdown status - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/contracts/drawdowns/{drawdown_id}/approve Approve a drawdown (hours gate) Approve a pending drawdown. The approver may correct the hours (the original is retained). Approval draws down hours and recognizes revenue by the hours-% method. Parameters: - drawdown_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/drawdowns/{drawdown_id}/return Return a drawdown to the submitter Return a pending drawdown entry. Parameters: - drawdown_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/inbound/hours Ingest an inbound hours submission (Slack/email reply) Turn a parsed Slack or email hours reply into a pending drawdown entry awaiting approval (the hours gate). The caller supplies the already-parsed fields; the target contract must belong to the business. Request body (HoursSubmissionRequest): - contract_id (string, required) - hours (number | string, required) - entry_date (string, required) - submitted_by (string, optional) - submitted_via (string, optional) - source_message_id (string, optional) - description (string, optional) - order_line_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/contracts/invoices Invoice review queue List contract-drafted invoices awaiting approval (invoice gate). Parameters: - contract_id (query, string, optional): Filter by contract ID - status (query, string, optional): Invoice status filter - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/contracts/invoices/reminders Send payment reminders in bulk Send payment-reminder emails for up to 100 contract invoices in one call. Applies the single-reminder rules per invoice (open/partially paid only, customer email required, 24h cooldown) and returns a per-invoice sent/skipped result instead of failing the whole batch. Request body (InvoiceReminderBatchRequest): - invoice_ids (array · string, required) Responses: 201, 401, 403, 422 ### PATCH /api/v1/contracts/invoices/{invoice_id} Edit a draft contract invoice Edit a drafted contract invoice's description, due date, and line items before approval. Line items are replaced wholesale and the invoice total is recomputed from them. Only drafts are editable — approved invoices are already billed. Parameters: - invoice_id (path, string, required) Request body (ContractInvoiceUpdateRequest): - description (string, optional) - due_date (string, optional) - line_items (array · ContractInvoiceLineUpdate, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/invoices/{invoice_id}/payments Apply a payment to a contract invoice Record a payment (amount, method, received date) against a contract invoice, transitioning it to partially/fully paid. Parameters: - invoice_id (path, string, required) Request body (ContractInvoicePaymentRequest): - amount_cents (integer, required) - method (string, optional) - received_date (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/invoices/{invoice_id}/reminder Send a payment reminder for a contract invoice Email the invoice's customer a payment reminder (amount due, due date, pay link when available). Only open or partially paid contract invoices qualify, and at most one reminder is sent per invoice per 24 hours. Parameters: - invoice_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/invoices/{invoice_id}/send Approve & send a contract invoice (invoice gate) Finalize a drafted contract invoice (draft -> open). This is when the amount becomes billed and any prepaid block books to Deferred Revenue. Parameters: - invoice_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/orders/intake-pdf Intake an order-form PDF into a draft order AI-extract an uploaded order-form PDF (referenced by its S3 key) into a DRAFT order for human review. Reuses the invoice document-extraction path. Upload the file first via the uploads endpoint, then pass the S3 key. Request body (OrderPdfIntakeRequest): - s3_key (string, required) - customer_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/contracts/reports/{report_type} Download an Order-to-Cash report (CSV/XLSX) Generate and download an O2C report as a CSV or XLSX file. Parameters: - report_type (path, string, required) - format (query, string, optional): Output format: 'csv' or 'xlsx'. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/contracts/settings Get Order-to-Cash settings Return the business's O2C configuration defaults, or system defaults if none have been set. Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/contracts/settings Update Order-to-Cash settings Persist the business's O2C configuration defaults (invoice cadence, default net days, tax treatment, hours/invoice approver roles) and return the stored settings. Request body (O2CSettings): - invoice_cadence (InvoiceCadenceEnum, optional) → InvoiceCadenceEnum - default_net_days (integer, optional) - default_tax_treatment (string, optional) - hours_approver_role (string, optional) - invoice_approver_role (string, optional) - slack_team_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/contracts/summary Portfolio summary (dashboard KPIs) Business-wide contract KPIs aggregated in SQL across ALL contracts (not a capped page): total value, billed, recognized, deferred, and counts by status. Responses: 200, 401, 403, 422 ### GET /api/v1/contracts/summary/by-type Contracted value grouped by billing rule Total contracted line value bucketed by billing rule (prepaid_block, flat, per_unit, recurring, usage_metered) for the value-by-type chart. Responses: 200, 401, 403, 422 ### DELETE /api/v1/contracts/{contract_id} Delete contract Delete a contract on which no money has moved: nothing billed or recognized, no non-draft invoices linked, no approved drawdowns. Linked draft invoices are deleted with it; the originating order is left intact. Parameters: - contract_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/contracts/{contract_id} Get contract Get a contract with billed/earned/hours burndown figures. Parameters: - contract_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/contracts/{contract_id} Edit contract Edit a contract's descriptive/schedule fields (number, first invoice date, estimated end date). Running tallies (billed/recognized/value) are maintained by the billing engine and cannot be edited. Parameters: - contract_id (path, string, required) Request body (ContractUpdate): - number (string, optional) - status (string, optional) - first_invoice_date (string · date, optional) - end_date (string · date, optional) - line_items (array · ContractLineItemUpdate, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/contracts/{contract_id}/burndown Per-line hours burndown Hours burndown broken down per order line: attributed drawdowns count against their line; unattributed drawdowns draw the prepaid block pool and are reported on the block subtotal. Per-period billed lines also expose billed hours and derived recognized revenue. Parameters: - contract_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/contracts/{contract_id}/check-completion Evaluate auto-completion Mark the contract completed when the term has elapsed or the prepaid block is fully consumed and billed. Returns the current contract state. Parameters: - contract_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/{contract_id}/credit-memo Issue a contract-level credit memo Issue a credit memo for the contract's customer (a contract discount / concession), linking the contract id into the memo description. Parameters: - contract_id (path, string, required) Request body (ContractCreditMemoRequest): - amount_cents (integer, required) - reason (string, optional) - description (string, optional) - issue_date (string · date, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/{contract_id}/draft-invoices Auto-draft invoices (invoice gate) Draft the execution invoice from the contract's billing rules. Prepaid blocks route to Deferred Revenue. Invoices are created as drafts for human review before sending. Parameters: - contract_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/contracts/{contract_id}/drawdowns List a contract's drawdowns List drawdown entries for a contract. Parameters: - contract_id (path, string, required) - status (query, string, optional): Filter by drawdown status - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 404, 422 ### POST /api/v1/contracts/{contract_id}/drawdowns Record a drawdown (hours consumed) Records hours consumed as a pending entry awaiting approval. Parameters: - contract_id (path, string, required) Request body (DrawdownCreate): - order_line_id (string, optional) - catalog_item_id (string, optional) - hours (number | string, required) - entry_date (string, required) - description (string, optional) - submitted_by (string, optional) - submitted_via (string, optional) - source_message_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/{contract_id}/generate-period-invoices Draft the next period's invoices Draft the next billing period's invoice from recurring (each_period) and per-unit (approved hours x price) order lines. Idempotent per (contract, period): a period already drafted is not re-drafted. A period whose draft was deleted is skipped by the daily billing sweep; calling this for that period drafts it again. Parameters: - contract_id (path, string, required) Request body (GeneratePeriodInvoicesRequest): - period_date (string, required) Responses: 201, 400, 401, 403, 404, 422 ### PATCH /api/v1/contracts/{contract_id}/hours Set the contract's total purchased hours Update the contract's total contracted hours (the burndown denominator). Correction path for contracts whose hour total wasn't captured at countersign (e.g. per-unit blocks). The new total cannot be lower than the hours already drawn down. Parameters: - contract_id (path, string, required) Request body (ContractHoursUpdate): - total_hours (number | string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/{contract_id}/invoices Manually draft an additional invoice Draft an additional (e.g. future-dated) invoice on the contract, outside the execution/period automation. Lines default to the contract's recurring (each-period) order lines when omitted. The draft is reviewed and sent like any other contract invoice. Parameters: - contract_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/{contract_id}/pause Pause contract Pause an active contract. Parameters: - contract_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/{contract_id}/reorder Reorder from a contract (follow-on block) Create a new draft order for the same customer/project, pre-filled from the contract's prepaid-block line(s) — a fresh block of the same qty, price, and billing rule. Lets a depleting contract spawn a follow-on order. Parameters: - contract_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/contracts/{contract_id}/resume Resume contract Resume a paused contract. Parameters: - contract_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/contracts/{contract_id}/suggested-invoices Suggested invoices to link Rank the business's unlinked (non-void, non-draft) invoices as likely matches for this contract, using deterministic heuristics: same customer, issue date inside the contract term, exact amount matches (order line / per-period / remaining value), and description-token overlap. Returns the top matches with human-readable reasons for each score. Parameters: - contract_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## counterparty-aliases ### GET /api/v1/counterparty-aliases List counterparty aliases Saved renames for this business. Each item says what it is keyed on (``key_kind``: the registry entry or the raw name) and how many transactions it names now (``transaction_count``; rows renamed by hand are not counted, since their own name wins). Removing one reverts those rows to their own stored or registry name. ``risky`` marks an alias bound to a bank or wire descriptor (``risk_reason`` says why); ``risky_only`` keeps just those. Parameters: - risky_only (query, boolean, optional): Only aliases flagged ``risky`` (bound to a bank/wire descriptor, or matching many distinct remembered names). Responses: 200, 401, 403, 422 ### DELETE /api/v1/counterparty-aliases/{alias_id} Delete a counterparty alias Delete a counterparty alias. The rows it named fall back to the Parameters: - alias_id (path, string, required) Responses: 200, 401, 403, 422 ### PATCH /api/v1/counterparty-aliases/{alias_id} Update a counterparty alias Change the display name on an existing counterparty alias. Parameters: - alias_id (path, string, required) Request body (CounterpartyAliasUpdate): - display_name (string, required) Responses: 200, 401, 403, 422 ## counterparty-defaults ### GET /api/v1/counterparty-defaults List counterparty defaults List all counterparty defaults configured for the current business. Responses: 200, 401, 403, 422 ### POST /api/v1/counterparty-defaults Create a counterparty default Create a new counterparty default. Request body (CounterpartyDefaultCreate): - registry_id (string, optional) - counterparty_name (string, optional) - default_ledger_id (string, required) - memo (string, optional) - mark_personal (boolean, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/counterparty-defaults/bulk Set one default category on many counterparties Gives every listed counterparty (up to 500) the same default category: an item with ``default_id``, or whose key already has a default, is updated; the rest are created. Each item succeeds or fails on its own (``results`` in request order). Each saved default lists its ``conflicts`` when the batch has at most 25 items (``conflicts_checked``). When every item fails the same way (a category that is not an active category ledger of this business) the request fails with that error. Request body (CounterpartyDefaultBulkRequest): - items (array · CounterpartyDefaultBulkItem, required) → CounterpartyDefaultBulkItem - default_ledger_id (string, required) - memo (string, optional) - mark_personal (boolean, optional) Responses: 201, 401, 403, 422 ### GET /api/v1/counterparty-defaults/conflicts Pre-check conflicts for a counterparty default Bank rules and other defaults that already decide this counterparty. Parameters: - counterparty_name (query, string, optional) - registry_id (query, string, optional) - ledger_id (query, string, optional): The category the default would book; when given, only entries booking a different category are returned Responses: 200, 401, 403, 422 ### DELETE /api/v1/counterparty-defaults/{default_id} Delete a counterparty default Delete a counterparty default. Parameters: - default_id (path, string, required) Responses: 200, 401, 403, 422 ### PATCH /api/v1/counterparty-defaults/{default_id} Update a counterparty default Update fields on an existing counterparty default. Parameters: - default_id (path, string, required) Request body (CounterpartyDefaultUpdate): - default_ledger_id (string, optional) - memo (string, optional) - mark_personal (boolean, optional) Responses: 200, 401, 403, 422 ## counterparty-naming ### GET /api/v1/counterparty-naming/inconsistencies Find inconsistently named counterparties Deterministic grouping of names that probably refer to the same counterparty: case/punctuation variants, legal suffixes, store numbers, common abbreviations, and near-identical spellings. Parameters: - window_days (query, integer, optional): Only consider transactions in this window - threshold (query, number, optional) - limit (query, integer, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/counterparty-naming/merge Merge counterparty groups into one name Every transaction that currently displays one of the source names gets ``target_name`` as its stored name, marked user-edited so re-syncs keep it. Rows renamed by hand to some other name are never touched. Each row keeps its registry link unless the target names a registry entry (``target_registry_id``, or the entry whose canonical name is exactly ``target_name``), which every merged row then links to. Saved renames make future transactions display the target too: one per registry entry involved and one per raw name of the unlinked rows. Request body (MergeCounterpartiesRequest): - sources (array · CounterpartyRef, required) → CounterpartyRef - target_name (string, required) - target_registry_id (string, optional) Responses: 201, 401, 403, 422 ### GET /api/v1/counterparty-naming/names List this business's counterparty names Distinct counterparty names on the business's transactions (alias and registry names applied), ranked by usage. Feeds the transaction counterparty picker so edits reuse existing names. Parameters: - q (query, string, optional): Substring filter - limit (query, integer, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/counterparty-naming/payee-lines Preview giving processor lines back to their payees Bank lines such as ``GUSTO CND - Laura Combs - US contractor payment`` pay the person named in the description. Lists the rows still stored under the processor (or no name) that would take the payee's name, the saved renames of the processor that would be removed, and rows named something else that need a person's judgement. Nothing is changed. Responses: 200, 401, 403, 422 ### POST /api/v1/counterparty-naming/payee-lines/apply Give processor lines back to their payees Applies exactly what the preview lists: removes the saved renames that show a processor's rows as one of its payees, and names each listed row for its payee as a manual rename would (registry link cleared). Rows already named something else are never changed. Safe to repeat: a second call finds nothing left to do. Responses: 201, 401, 403, 422 ### GET /api/v1/counterparty-naming/rename-impact Preview what a remembered rename would also relabel (deprecated) For a rename of ``transaction_ids`` to ``new_name`` with ``remember=true`` (a saved rename), counts the OTHER transactions the saved rename would relabel: rows on the same registry entries (``other_rows_by_registry``) and rows with the same raw name (``other_rows_by_name``). Rows renamed by hand keep their own name and are not counted. ``processor_guarded`` is true when some rows belong to a payment processor that pays many parties; those are renamed on their own. Nothing is changed. Deprecated: use ``POST /counterparty-naming/rename-impact`` (ids in the body, no 1000-id cap). Kept for one release. (deprecated) Parameters: - transaction_ids (query, string, required): Comma-separated transaction UUIDs to rename (at most 1000). - new_name (query, string, required) Responses: 200, 401, 403, 422 ### POST /api/v1/counterparty-naming/rename-impact Preview what a remembered rename would also relabel For a rename of ``transaction_ids`` to ``new_name`` with ``remember=true`` (a saved rename), counts the OTHER transactions the saved rename would relabel: rows on the same registry entries (``other_rows_by_registry``) and rows with the same raw name (``other_rows_by_name``). Rows renamed by hand keep their own name and are not counted. ``processor_guarded`` is true when some rows belong to a payment processor that pays many parties; those are renamed on their own. Nothing is changed. The ids go in the body, so a selection of any size is one request. Request body (RenameImpactRequest): - transaction_ids (array · string, required) - new_name (string, required) Responses: 200, 401, 403, 422 ### POST /api/v1/counterparty-naming/reset Reset a counterparty group to its detected names Recomputes the deterministic detected name (known merchant patterns, then descriptor cleanup) from each transaction's description, clears the registry link and any alias for the group. No AI is involved. Send ``dry_run`` to list the rows that would change with a ``plan_hash``; send that ``plan_hash`` on the apply and it is refused (VALIDATION_640) if the rows moved. Request body (ResetCounterpartyRequest): - counterparty_name (string, required) - registry_id (string, optional) - dry_run (boolean, optional) - plan_hash (string, optional) Responses: 201, 401, 403, 422 ### GET /api/v1/counterparty-naming/rules List counterparty naming rules Responses: 200, 401, 403, 422 ### POST /api/v1/counterparty-naming/rules Create a counterparty naming rule When a new transaction's raw description (or detected name) matches ``pattern`` per ``match_type``, its counterparty is set to ``canonical_name``. Set ``apply_to_existing`` to rename matching history now (rows a person already edited are left alone). Request body (NamingRuleCreate): - pattern (string, required) - match_type (string, optional) - canonical_name (string, required) - priority (integer, optional) - is_enabled (boolean, optional) - apply_to_existing (boolean, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/counterparty-naming/rules/preview Preview which existing transactions a rule would match Request body (NamingRulePreviewRequest): - pattern (string, required) - match_type (string, optional) Responses: 201, 401, 403, 422 ### DELETE /api/v1/counterparty-naming/rules/{rule_id} Delete a counterparty naming rule Parameters: - rule_id (path, string, required) Responses: 200, 401, 403, 422 ### PATCH /api/v1/counterparty-naming/rules/{rule_id} Update a counterparty naming rule Parameters: - rule_id (path, string, required) Request body (NamingRuleUpdate): - pattern (string, optional) - match_type (string, optional) - canonical_name (string, optional) - priority (integer, optional) - is_enabled (boolean, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/counterparty-naming/rules/{rule_id}/apply Apply a naming rule to existing transactions Renames matching history now; user-edited rows are skipped. Parameters: - rule_id (path, string, required) Responses: 201, 401, 403, 422 ## credit — Partner credit lines — programs, lines, card settlements, loans, daily accrual, statements, payoff quotes, payments, underwriting and versioned scorecards, card issuing, and the credit event feed. DayZero keeps the ledger and measures; the partner moves the money and makes the lending decision. ### POST /api/v1/credit/accruals/run Run the daily accrual processor DayZero internal. For every open loan: marks it past due once its due date has passed, writes one full-precision accrual row per day not yet accrued (from the day after the due date), and sets the loan's interest to the rounded sum of its rows. Fires the due-soon event ahead of each due date (D-24). Idempotent per loan per day, so it can be re-run or pointed at a past date to catch up. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Request body (AccrualRunRequest): - credit_line_id (string, optional) - through (string · date, optional) - notify_due_soon (boolean, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/credit/ad-spend Push a merchant's daily ad spend Name the merchant as on `POST /credit/bank-feeds` (`program_id` and `external_merchant_id`, or `credit_line_id`); DayZero uses its business, creating it the first time, and gives your token read access to it. Upserts one row per `platform` (`meta`, `google`, `tiktok`, `other`), ad account and day; sending a day again replaces it. `covered_from`..`covered_through` is the window your figures are complete for (a day in it without a row is no spend), explicitly attested across all platforms and accounts. Only overlapping or adjacent complete windows merge; gaps remain unknown. Row-only pushes never extend completeness. `trailing_12m_ad_spend`, the ad-spend ratios and `marketing_efficiency_ratio_90d` read this spend before the ledger (`evidence.source: partner_ad_spend`) while the window covers 90% of their actual days and the latest complete day is no more than 3 days old. Spend in another currency than the books' is kept, not counted. Changing an existing account/day currency or source operator returns 409. Request body (AdSpendPushRequest): - program_id (string, optional) - external_merchant_id (string, optional) - credit_line_id (string, optional) - merchant_legal_name (string, optional) - merchant_business_id (string, optional) - days (array · AdSpendDayItem, optional) → AdSpendDayItem - covered_from (string · date, optional) - covered_through (string · date, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/credit/adverse-actions List adverse actions Adverse actions, soonest due first, with their reasons, due date and notice status. Filter by `status`, `due_before` (on or before) and `credit_line_id`. Parameters: - status (query, string, optional): One status. - due_before (query, string · date, optional): Due on or before this date. - credit_line_id (query, string, optional): One line. - limit (query, integer, optional): Adverse-action notices per page (1-500). - cursor (query, string, optional): `next_cursor` from the last page. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/credit/adverse-actions/{adverse_action_id}.pdf Download an adverse-action notice The notice exactly as sent. Refused until it has been sent. Parameters: - adverse_action_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/adverse-actions/{adverse_action_id}/send Send an adverse-action notice Renders the approved adverse-action template, stores the PDF and emails it to the line's `merchant_email` as a borrower notice, once. A notice already sent is returned unchanged. Refused from a template that is not approved. Operator action. Parameters: - adverse_action_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/adverse-actions/{adverse_action_id}/waive Waive an adverse-action notice Closes a pending notice without sending it: `outcome` `waived` (the default) or `not_required` (counsel found none owed). `reason` is required. Operator action. Parameters: - adverse_action_id (path, string, required) Request body (AdverseActionWaiveRequest): - reason (string, optional) - outcome (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/bank-analysis Analyze partner bank data without importing bank records Read the configured source and return provisional cash movements. Request body (BankAnalysisRequest): - program_id (string, required) - external_merchant_id (string, required) - source_mode (string, required) - start_date (string · date, required) - end_date (string · date, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/bank-connections Start a merchant's bank connection The Connect step of the Apply wizard (§9.3), and the Link button of Change Payment Method (§6.2). Name the merchant (`program_id` and `external_merchant_id` while it applies, or `credit_line_id` once it has a line). DayZero uses the merchant's DayZero business, creating it the first time, gives your token read access to it, and returns a hosted Plaid Link (`hosted_link_url`, `expires_at`) for the merchant to complete in your wizard. Nothing is emailed. While one is pending for the same merchant (or line), a repeat returns it with `created: false`. When the merchant finishes, `credit.bank_connection.completed` is emitted and the bank backfill underwriting waits on starts. Request body (BankConnectionStartRequest): - program_id (string, optional) - external_merchant_id (string, optional) - credit_line_id (string, optional) - merchant_legal_name (string, optional) - merchant_email (string, optional) - merchant_business_id (string, optional) - completion_redirect_uri (string, optional) - reconnect (boolean, optional) Responses: 201, 400, 401, 403, 404, 422, 429, 503 ### GET /api/v1/credit/bank-connections/{bank_connection_id} A merchant's bank connection Where a started connection stands: `pending`, `completed` (with the accounts the merchant shared and the repayment account), `failed` (with `failure_reason`) or `expired`. Poll it from the wizard instead of the event feed if you prefer; when the merchant has finished and Plaid's notice has not reached DayZero, the read asks Plaid. A connection on another business is `404` `CREDIT_783`. Parameters: - bank_connection_id (path, string, required): The bank connection's id. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/bank-feeds Bank feeds Every bank feed on your program business, newest first, optionally for one line, merchant id or merchant business. Parameters: - credit_line_id (query, string, optional): One line's feeds. - external_merchant_id (query, string, optional): One merchant's feeds, by your id. - merchant_business_id (query, string, optional): One merchant business's feeds. Responses: 200, 401, 403, 422 ### POST /api/v1/credit/bank-feeds Register a merchant's bank feed 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`. Request body (BankFeedRegisterRequest): - app_id (string, required) - provider (string, optional) - program_id (string, optional) - external_merchant_id (string, optional) - credit_line_id (string, optional) - merchant_legal_name (string, optional) - merchant_business_id (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### DELETE /api/v1/credit/bank-feeds/{bank_feed_id} Stop a bank feed Stops syncing. The transactions and balances already on the merchant's business stay. Register the `app_id` again to resume. Parameters: - bank_feed_id (path, string, required): The bank feed to stop. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/bank-feeds/{bank_feed_id} A merchant's bank feed Where a feed stands: `pending` until the first sync lands the history, then `active`; `error` with `last_error` while the dataset cannot be read; `removed` once stopped. `accounts` lists each account with how many transactions DayZero holds, their dates and the latest balance, and says why an account is left out (`skipped_reason`). A feed on another business is `404` `CREDIT_830`. Parameters: - bank_feed_id (path, string, required): The bank feed's id. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/bank-feeds/{bank_feed_id}/ingest Push bank accounts, transactions, and balances into a bank feed For partners that pull merchant bank data in their own backend and push it directly into DayZero without BigQuery (`provider: direct_push`, or to seed a feed immediately). Each cash account gets a bank ledger on the merchant's DayZero business, posted transactions are booked with journal entries, voided transactions are hidden, and daily balance snapshots are interpolated across the history so underwriting and bank-settlement payment matching read them immediately. Idempotent on `transaction_id` and `(account_id, as_of)`. Parameters: - bank_feed_id (path, string, required): The bank feed to push bank data into. Request body (BankFeedIngestRequest): - accounts (array · BankFeedIngestAccount, optional) → BankFeedIngestAccount - transactions (array · BankFeedIngestTransaction, optional) → BankFeedIngestTransaction - balances (array · BankFeedIngestBalance, optional) → BankFeedIngestBalance Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/bank-feeds/{bank_feed_id}/sync Sync a bank feed now Starts a sync instead of waiting for the next six-hourly one, e.g. once the dataset has been shared. `queued: false` when one is already running. A removed feed is `400` `CREDIT_833`. Parameters: - bank_feed_id (path, string, required): The bank feed to sync. Responses: 202, 400, 401, 403, 404, 422 ### GET /api/v1/credit/billing-lapse-risk Will this business's API access lapse? Console operators only. For a business that operates an active credit program: `lapsed` when its billing already refuses API tokens (403 `AUTH_072`: `past_due`, `unpaid`, `canceled`, or a trial that ended) or it lacks the CFO Suite add-on every `/credit` call needs (403 `BILLING_003`), `lapsing` when it passes only on a trial that ends within `within_days`. A subscription with CFO Suite, the `partner_program` plan, and a sandbox never lapse. Read-only. Parameters: - within_days (query, integer, optional): How many days ahead to look (0 to 365, default 14). Responses: 200, 400, 401, 403, 422 ### POST /api/v1/credit/card-settlements Ingest cleared card settlements Push settled card transactions. Settlements only, never authorisations. Idempotent on the settlement ID, so re-pushing a batch reports duplicates rather than double-counting. On a per-transaction program each accepted settlement originates a loan and the acknowledgement carries its id, fee, term, and due date. A negative amount is a refund: it reduces the loan it relates to or is carried forward as credit, and the acknowledgement says which. Request body (CardSettlementIngestRequest): - credit_line_id (string, optional) - external_line_id (string, optional) - settlements (array · CardSettlementIngestItem, required) → CardSettlementIngestItem Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/cards Issue a card against a credit line Mints a card with spend controls enforced at the network — ceiling, interval, per-transaction cap, and a merchant-category allowlist. Card credentials never transit DayZero. Idempotent on `idempotency_key` per business: a repeat returns the card already issued under it. Request body (CardIssueRequest): - credit_line_id (string, required) - display_name (string, optional) - card_type (string, optional) - spend_limit_cents (integer, optional) - spend_interval (string, optional) - transaction_limit_cents (integer, optional) - cardholder_provider_user_id (string, optional) - allowed_mcc_codes (array · string, optional) - blocked_mcc_codes (array · string, optional) - auto_lock_date (string · date, optional) - idempotency_key (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/cards/reconcile-settlements Reconcile issuer transactions against settlements Lists the issuer's cleared transactions per card for the window and originates any that never arrived by webhook. A recorded settlement the issuer now reports voided or declined is reversed at once when nothing has been paid on its loan, and otherwise put on hold for an operator; with `hold_voided` false it is only reported. The nightly sweep runs this over the last 7 days when DayZero manages the cards. Request body (SettlementReconcileRequest): - credit_line_id (string, optional) - days (integer, optional) - dispute_lookback_days (integer, optional) - ingest_missing (boolean, optional) - hold_voided (boolean, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/credit/cards/register Register a partner-provisioned card For programs where the partner provisions cards in the issuer itself (`card_management: partner`). Registers the issuer card id against a credit line so cleared transactions are attributed to it. DayZero does not push spend limits to a registered card; it emits `credit.line.limit_changed` with the new available credit after every balance change and the partner pushes the limit. Idempotent on the issuer card id. Request body (CardRegisterRequest): - credit_line_id (string, required) - provider_card_id (string, required) - provider_fund_id (string, optional) - provider_user_id (string, optional) - provider (string, optional) - display_name (string, optional) - last_four (string, optional) - expiration (string, optional) - cardholder_name (string, optional) - card_type (string, optional) - spend_limit_cents (integer, optional) - spend_interval (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/cards/stripe-issuing/setup Activate Stripe Issuing capability, ToS, webhooks, and default cardholder Submits missing Stripe Issuing `business_profile` fields (`annual_revenue`, `estimated_worker_count`), records `settings.card_issuing.tos_acceptance`, requests the `card_issuing` capability, subscribes `/api/v1/webhooks/stripe` to all `issuing_*` events, and optionally creates a default `Cardholder` (`ich_...`) on an owned credit program. Live business operator action (an API token receives `403`); sandbox businesses are refused before Stripe calls. Defaults to the business connection. Platform access and platform webhook changes require a signed-in superuser. Request body (CreditStripeIssuingSetupRequest): - stripe_account_id (string, optional) - annual_revenue_cents (integer, optional) - annual_revenue_currency (string, optional) - fiscal_year_end (string, optional) - estimated_worker_count (integer, optional) - accept_tos (boolean, optional) - tos_ip (string, optional) - request_card_issuing (boolean, optional) - configure_webhooks (boolean, optional) - create_default_cardholder (boolean, optional) - program_id (string, optional) - cardholder_name (string, optional) - billing_address (object, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/cards/stripe-issuing/status Inspect Stripe Issuing approval, balance, and webhook status Checks whether the platform (or a connected `stripe_account_id`) is approved for Stripe Issuing (`card_issuing` capability), whether the Charge Card private preview (`funding_credit` / `issuing_credit_beta=v1`) is enabled, the available Issuing balance, any due onboarding fields, and whether `/api/v1/webhooks/stripe` is subscribed to all required `issuing_*` events. Accounts must belong to this business. Platform access requires a signed-in superuser; sandbox businesses use the mock card engine. Parameters: - stripe_account_id (query, string, optional): Owned Stripe account ID (`acct_...`); defaults to the business connection. Platform access is signed-in superuser only. Responses: 200, 401, 403, 422 ### POST /api/v1/credit/cards/sync Reconcile cards against the issuer The issuer emits no card-state webhook, so drift is only found by asking. A card suspended at the issuer that we still believe is active is the case this catches. Parameters: - credit_line_id (query, string, optional) Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/credit/cards/{card_id} Terminate a card Permanent. Settlements already cleared stay on the ledger and their cycles still bill: terminating stops future spend, it does not cancel debt. A terminated card is returned as it is. Parameters: - card_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/cards/{card_id}/embed-token Mint a token to display card credentials The issuer renders the number inside its own embedded component. The PAN and CVV never pass through DayZero. Parameters: - card_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422, 503 ### PATCH /api/v1/credit/cards/{card_id}/limits Update card spend controls Change a card's ceiling, interval, or category rules. Parameters: - card_id (path, string, required) Request body (CardLimitUpdateRequest): - spend_limit_cents (integer, optional) - reset_spend_limit_cap (boolean, optional) - spend_interval (string, optional) - transaction_limit_cents (integer, optional) - allowed_mcc_codes (array · string, optional) - blocked_mcc_codes (array · string, optional) - auto_lock_date (string · date, optional) - display_name (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/credit/cards/{card_id}/suspension Lift a card suspension Lifting a suspension emits credit.card.reinstated. An active card is returned as it is, with no issuer call and no event. Parameters: - card_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/cards/{card_id}/suspension Suspend a card Declines further authorisations while keeping the card's number and history — the right lever for a delinquent line, since termination cannot be undone. A suspended card is returned as it is, with no issuer call and no second event. Parameters: - card_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/compliance/held-increases List held limit increases Every limit increase held until the merchant acknowledges its disclosure, oldest first: the line, the limit in force, the held limit, and `blocked_reason` when it can no longer be applied (the program's limit envelope narrowed past it, or the line is suspended or closed). Parameters: - limit (query, integer, optional): Held increases per page (1-500). - cursor (query, string, optional): `next_cursor` from the last page. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/credit/compliance/jurisdiction-gaps Lines missing the merchant's jurisdiction Lines that are not closed and lack `merchant_legal_name`, `merchant_state` or `merchant_address`, oldest first. With `program_id`: that program's lines, whether or not its compliance policy is on yet. Without: lines on every program whose policy is on. Parameters: - program_id (query, string, optional): One program's lines. Responses: 200, 401, 403, 422 ### GET /api/v1/credit/compliance/templates List compliance templates Every disclosure and adverse-action template shipped, by kind, jurisdiction and version, with its approval. A template is a draft until approved; only an approved template whose file is unchanged (`deliverable`) is ever delivered. Operator action. Responses: 200, 401, 403, 422 ### POST /api/v1/credit/compliance/templates/{template_id}/approve Approve a compliance template Records counsel's approval of a draft: `reviewed_by`, `reviewed_on` and `signoff_document` are required; the operator and the time are recorded, and the approval covers the file exactly as it is now. Operator action. Parameters: - template_id (path, string, required) Request body (ComplianceTemplateApproveRequest): - reviewed_by (string, optional) - reviewed_on (string · date, optional) - signoff_document (string, optional) - applies_if (object, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/compliance/templates/{template_id}/preview Preview a compliance template Renders the template as a PDF (or HTML with `format=html`) from a line's figures (`credit_line_id`) or a sample line's. Any template not approved carries a DRAFT watermark on every page. Nothing is stored or sent. Operator action. Parameters: - template_id (path, string, required) - credit_line_id (query, string, optional): Use this line's figures and names. Default: a sample line. - format (query, string, optional): `pdf` or `html`. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/compliance/templates/{template_id}/retire Retire a compliance template Withdraws a template version for good: nothing new is made from it. Documents already issued from it are unchanged. Operator action. Parameters: - template_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/credit/covenants/{covenant_id} Remove a covenant and its checks Deletes the covenant and every check recorded for it. To stop checking but keep the record, send `active: false` instead. Parameters: - covenant_id (path, string, required): Covenant ID on a line this business operates. Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/credit/covenants/{covenant_id} Change a covenant Changes the threshold, comparison, warning band, selectors, label, notes or `active` flag. `active: false` stops the nightly check and keeps the history; the next check after a change is held to the new threshold. Parameters: - covenant_id (path, string, required): Covenant ID on a line this business operates. Request body (CovenantUpdate): - label (string, optional) - threshold (number, optional) - comparison (string, optional) - warn_band_bps (integer, optional) - numerator_selector (LedgerSelector, optional) - denominator_selector (LedgerSelector, optional) - active (boolean, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/cycles/assess-late Late sweep DayZero internal. Per-transaction programs: marks each loan past due against its own due date with zero grace and accrues daily interest on remaining principal (D-05, D-07, D-08). Cycle-draw programs: flags past-due cycles and charges the configured late rule. Idempotent per loan per day. Pass `dry_run` to preview. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Request body (LateAssessmentRequest): - credit_line_id (string, optional) - as_of (string · date, optional) - dry_run (boolean, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/credit/cycles/close Month-end close DayZero internal. Per-transaction programs: applies the month's accrued interest, freezes the Statement Balance, and issues the statement — the loans already exist and were originated at transaction time. Cycle-draw programs: creates the cycle's draw. Idempotent — a period already closed is skipped. Pass `dry_run` to see what would close without writing. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Request body (CycleCloseRequest): - credit_line_id (string, optional) - as_of (string · date, optional) - issue_statements (boolean, optional) - dry_run (boolean, optional) Responses: 201, 400, 401, 403, 422 ### PUT /api/v1/credit/debt-facilities Replace a merchant's existing debt facilities Name the merchant as on `POST /credit/bank-feeds` (`program_id` and `external_merchant_id`, or `credit_line_id`); DayZero uses its business, creating it the first time, and gives your token read access to it. `facilities` is the whole list: a facility sent again (same `facility_id`) is updated, one left out is removed, and an empty list attests the merchant has no debt. They land on the merchant's debt schedule, which `existing_debt_facilities` and `debt_service_coverage_ratio` read; with none attested the first reads 0 and the second uncapped cover instead of unmeasured. A `daily`, `weekly`, `biweekly` or `semi_monthly` payment counts at its yearly total (252 business days for `daily`). Request body (DebtFacilitiesRequest): - program_id (string, optional) - external_merchant_id (string, optional) - credit_line_id (string, optional) - merchant_legal_name (string, optional) - merchant_business_id (string, optional) - facilities (array · DebtFacilityItem, required) → DebtFacilityItem Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/disclosures/{disclosure_id} Get a disclosure One disclosure, as a row of its line's list: `credit_line_id`, status, figures, delivery and acknowledgement. `404` when it is not on this business. Parameters: - disclosure_id (path, string, required): The disclosure's `id`. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/disclosures/{disclosure_id}.pdf Download a disclosure The disclosure exactly as issued: the stored PDF, whose SHA-256 is the record's `pdf_sha256`. It is never re-rendered. Parameters: - disclosure_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/disclosures/{disclosure_id}/withdraw Withdraw a held limit increase Withdraws the increase a disclosure holds: it becomes `superseded` with `withdrawn_reason`, the merchant can no longer acknowledge it, and the limit in force stays. Only a held increase still awaiting acknowledgement can be withdrawn (`CREDIT_610`). Operator action. Parameters: - disclosure_id (path, string, required): The disclosure that holds the increase. Request body (HeldIncreaseWithdrawRequest): - reason (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/disputes/{dispute_id}/resolution Resolve a dispute Records how the dispute ended and lifts the hold. `merchant_won` reverses the disputed principal off the loan with the fee and the pre-hold interest in proportion; `lender_won` and `released` resume accrual from `resolved_on`; `voided` reverses the whole loan as if the transaction never cleared. Money already paid towards a reversed amount becomes credit balance. Hold days are never charged. Parameters: - dispute_id (path, string, required) Request body (CreditDisputeResolutionRequest): - outcome (string, required) - resolved_on (string · date, required) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/environment Which book am I on? The business the call resolved to, whether it is a sandbox, and for each program whether its cards come from the mock issuer or the live one. Assert on this before a test run. Responses: 200, 401, 403, 422 ### GET /api/v1/credit/event-deliveries Webhook delivery status for a page of credit events Takes the same parameters as `GET /credit/events` and returns, for each event on that page, whether it reached the partner's webhook endpoints: delivered, pending (sent once its transaction commits), retrying, failed, not_subscribed, or not_pushed (a polling program). Parameters: - after (query, integer, optional): Events after this sequence number, as on the feed. - event_types (query, string, optional): Comma-separated event types to include. - credit_line_id (query, string, optional) - program_id (query, string, optional) - order (query, string, optional): asc (default) pages forward with `after`; desc returns the latest events newest first and pages older with `before`. - before (query, integer, optional): With order=desc: events below this sequence number. - limit (query, integer, optional) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/credit/events Poll the credit event feed Every credit event in order, from a cursor. Pass the returned `next_cursor` as `after` on the following call. `order=desc` returns the newest events first and pages older with `before` (the console's view; `after` is refused with it). Program `event_delivery_mode` is polling (outbox only), webhook, or both. Replay through this feed after an outage either way. Parameters: - after (query, integer, optional): Return events after this sequence number. - event_types (query, string, optional): Comma-separated event types to include. - credit_line_id (query, string, optional) - program_id (query, string, optional) - order (query, string, optional): asc (default) pages forward with `after`; desc returns the latest events newest first and pages older with `before`. - before (query, integer, optional): With order=desc: events below this sequence number. - limit (query, integer, optional) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/credit/events/{event_id}/deliveries Webhook deliveries of one credit event The event's delivery status and every delivery row behind it, oldest first: one per endpoint on the first push, plus retries' outcomes and any redeliveries. Parameters: - event_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/finance/borrowing-base Borrowing base Eligible receivables under the program's `borrowing_base_policy` (unpaid principal, plus fees when the policy says so, less loans past the days-past-due cap, loans on hold, and each merchant's excess over the concentration limit), times the advance rate. Per-line detail; `format=csv` for the spreadsheet. Ties to the portfolio's outstanding. Parameters: - as_of (query, string · date, optional): Defaults to today (UTC). - program_id (query, string, optional) - format (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/finance/journal Credit journal for a month Every journal entry the credit program posted in the calendar month: date, entry, memo, account, debit, credit, and the line and loan behind it, with totals by account and a control that debits equal credits. `format=csv` returns the same rows as a spreadsheet with a total row. Parameters: - period (query, string, required): Calendar month, YYYY-MM. - program_id (query, string, optional) - format (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/finance/journal/push Push the credit journal to QuickBooks Sends the period's credit journal entries to the business's connected QuickBooks company, one journal entry each, and reports what happened to every entry. Safe to repeat: an entry already pushed is reported as `already_pushed` and not sent again. An entry that touches an account with no QuickBooks counterpart is skipped and named. `400 CREDIT_002` when QuickBooks is not connected. An operator action. Request body (JournalPushRequest): - period (string, required) - program_id (string, optional) - destination (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/finance/ledger-proof Ledger integrity proof Verifies every line's register (hash chain, running balance, sequence) and returns a dated report with each line's head hash. `format=pdf` returns the report as a document for auditors. Parameters: - as_of (query, string · date, optional): Defaults to today (UTC). - program_id (query, string, optional) - format (query, string, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/finance/postings Credit ledger postings for a month The journal entries the credit ledger posts to the books in a calendar month, one page of one status (`draft` or `posted`), with the month's totals by kind of event. A program in review mode holds its entries as drafts until an operator posts them. Parameters: - period (query, string, required): Calendar month, YYYY-MM. - program_id (query, string, optional): Only this program's entries. - status (query, string, optional): Which entries to list. - cursor (query, string, optional): `next_cursor` of the last page. - limit (query, integer, optional): Entries per page. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/finance/postings/post Post drafts to the books Books drafts a program in review mode prepared, oldest first, as journal entries with source Credit Ledger. Name the drafts, or a `period` and `program_id`, or neither to post every draft. A draft that cannot post says why and stays a draft. Safe to repeat. An operator action. Request body (PostDraftsRequest): - draft_ids (array · string, optional) - program_id (string, optional) - period (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/finance/postings/preview What a program will post The entry each kind of event books on the program, with the accounts it names, and how many events are already in the credit ledger that switching posting on will not post retroactively. Parameters: - program_id (query, string, required): The program to preview. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/finance/postings/{entry_id} Audit one credit ledger posting One posted journal entry, or a draft, with its accounts, the line, loan and payment behind it, the register entries and arithmetic it follows from, the record it came from (Brex charge, Payliance debit), and who posted it and when. Parameters: - entry_id (path, string, required): A journal entry id, or a draft id. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/finance/tie-out Tie out outstanding three ways Outstanding from the loan tape, from the ledger registers, and from the GL receivable accounts, with the difference and `ties` for each pair and a per-line comparison of tape and register. Parameters: - as_of (query, string · date, optional): Defaults to today (UTC). - program_id (query, string, optional) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/historical-payments/{payment_id}/reversal Mark a historical payment returned Corrects the record of a payment made before cut-over: it reads `reversed` with the date and reason. No balance moves, nothing is posted and no event is appended; a correction to the loans' figures is an adjustment of its own. The bank-feed matcher never reverses a historical payment. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - payment_id (path, string, required): The historical payment. Request body (HistoricalPaymentReversalRequest): - reversed_on (string · date, optional) - reason (string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/import-batches/{staging_id} A staged loan file's status, totals and run The batch's status and totals, and its current or last run: what it does, who started it, its progress (`rows_done` of `rows_total`, `lines_done` of `lines_total`, the phase) and heartbeat while it runs, why it stopped if it did, and once it has finished, `result`: the body the inline call returns. Poll it every two seconds while `status` is `running`. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - staging_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/import-batches/{staging_id}/documents Add statement documents to a statements history file The PDFs a staged statements file names in its `document` column, one or more `files` (10 MB each at most, up to 200 an upload), scanned for malware and stored as issued. Matched by file name at the run; a name sent again replaces the earlier document and clears the batch's dry run. A statement whose document is not added is rejected; one that names none is attached with its figures only. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - staging_id (path, string, required): The staged history file (its batch id). Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/import-batches/{staging_id}/history-report The report of a history file's last run The last dry run or apply of a staged payments or statements file: per line what was attached, duplicated and rejected (every rejected row with its reason), the control totals against what attached, and the warnings. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - staging_id (path, string, required): The staged history file (its batch id). Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/credit/import-batches/{staging_id}/mapping Correct a staged loan file's mapping Re-reads the staged rows under the mapping sent (the whole mapping: a field left out is not read) and the unit of the money, without a second upload. `save_as` also saves the mapping on the program under that name, for `mapping_name` on the next parse. An applied batch cannot be re-mapped. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - staging_id (path, string, required) Request body (ImportMappingUpdateRequest): - mapping (object, required) - amounts_in (string, required) - save_as (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/import-batches/{staging_id}/report The import report of a loan file's last run File identity (name, SHA-256), the mapping used, and per line the file's count, principal and outstanding against the book's, with every mismatch and rejected row, and who ran it when. `format=csv` and `format=pdf` return it as a document. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - staging_id (path, string, required) - format (query, string, optional): json (the default): the report as data. csv, pdf: as a document. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/interchange Interchange recognised Month-to-date, year-to-date, and lifetime interchange, estimated and reported, by line. Parameters: - program_id (query, string, optional) - as_of (query, string · date, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/credit/interchange/report Ingest the issuer's interchange report Rows from the issuer's interchange or rebate report. Each row is attributed by issuer transaction id, card id, or credit line; a row for a settlement that was already estimated supersedes the estimate and the books move by the difference. Idempotent on the row's `external_reference`. Request body (InterchangeReportRequest): - program_id (string, optional) - rows (array · InterchangeReportItem, required) → InterchangeReportItem Responses: 201, 400, 401, 403, 422 ### GET /api/v1/credit/issuer/card-transactions List the issuer's card transactions Card transactions on the Ramp account connected to this business, as DayZero last synced them, newest first. Each carries the card, the cardholder, Ramp's state, the account it is booked to in DayZero's books, and the credit line and loan when the card is registered to a line on this business. Reimbursements are left out unless `include_reimbursements=true`. Only what the Ramp sync has stored is listed: transactions on credit-line cards are loans, read them under the line. `CREDIT_742` when `start` is after `end`. Parameters: - start (query, string · date, optional): First transaction date to include (inclusive, UTC). - end (query, string · date, optional): Last transaction date to include (inclusive, UTC). - card_holder (query, string, optional): Only this cardholder's transactions (whole name, any case). - card_last_four (query, string, optional): Only transactions on the card ending in these four digits. - state (query, string, optional): Only transactions in this Ramp state, e.g. `CLEARED`. - include_reimbursements (query, boolean, optional): Also list reimbursements (`transaction_type=reimbursement`). - limit (query, integer, optional): Page size (1 to 500). - cursor (query, string, optional): `next_cursor` from the previous page, passed back unchanged. - include_total_count (query, boolean, optional): Also return `total`, the number of matching rows (one more query). Responses: 200, 400, 401, 403, 422 ### GET /api/v1/credit/issuer/cardholders List spend by cardholder Card spend per cardholder on the Ramp account connected to this business, highest spend first: transactions, net spend, spend in the last 30 days, the cards used, the newest transaction and the credit lines the cards are registered to. Declined and errored transactions are not spend. Without `start` the window opens at the first stored transaction. `CREDIT_742` when `start` is after `end`. Parameters: - start (query, string · date, optional): First transaction date to include (inclusive, UTC). - end (query, string · date, optional): Last transaction date to include (inclusive, UTC). - limit (query, integer, optional): Page size (1 to 500). - cursor (query, string, optional): `next_cursor` from the previous page, passed back unchanged. - include_total_count (query, boolean, optional): Also return `total`, the number of matching rows (one more query). Responses: 200, 400, 401, 403, 422 ### GET /api/v1/credit/issuer/cards List the issuer's cards The cards on the Ramp account connected to this business, by cardholder: last four, name, cardholder, status and spend limit, with the credit line a card is registered to. `source=live` reads Ramp now (`409 CREDIT_740` without a Ramp connection, `503 CREDIT_741` when Ramp does not answer within 20 seconds); `source=stored` builds the list from stored transactions and registered cards without calling Ramp; `source=auto` (the default) reads Ramp and falls back to the stored list, saying why in `issuer_note`. Parameters: - source (query, string, optional): `auto` (Ramp, else stored), `live` (Ramp only) or `stored`. - limit (query, integer, optional): Page size (1 to 500). - cursor (query, string, optional): `next_cursor` from the previous page, passed back unchanged. - include_total_count (query, boolean, optional): Also return `total`, the number of matching rows (one more query). Responses: 200, 400, 401, 403, 409, 422, 503 ### DELETE /api/v1/credit/limit-change-requests/{request_id} Cancel a limit-change request Withdraws a pending request; it becomes `cancelled`. An API token may cancel only a request it made (`403` otherwise); a signed-in operator may cancel any. `400` when the request is no longer pending. Parameters: - request_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/limit-change-requests/{request_id} Get a limit-change request One limit-change request. Parameters: - request_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/limit-change-requests/{request_id}/decision Approve or reject a limit-change request `approve` moves the line to the requested limit (or `limit_cents`) through the same path as `PATCH /credit/lines/{id}`: one `credit.line.limit_changed` event and one issuer push. `reject` leaves the limit alone. A console action: an API token gets `403`, and the person who made the request cannot approve it (`400`). `400` when the request is no longer pending, including one that has expired. Parameters: - request_id (path, string, required) Request body (LimitChangeRequestDecision): - decision (string, required) - note (string, optional) - limit_cents (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/limit-reviews/{review_id}/decision Apply or dismiss a proposed limit review `apply` moves the line to the recommended limit (or `limit_cents`) through the same path as `PATCH /credit/lines/{id}`: one `credit.line.limit_changed` event and one issuer push. `dismiss` leaves the limit alone. Both record `reason`. An API token may decide only when the program's `limit_change_policy` is `direct`; otherwise this is a console action (`403`). `409` when the review is not proposed, or the line's limit moved since it was run. Parameters: - review_id (path, string, required) Request body (LimitReviewDecisionRequest): - decision (string, required) - limit_cents (integer, optional) - reason (string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/credit/lines List credit lines Every line on this business, with current balances. Parameters: - program_id (query, string, optional): Filter to one program. - status (query, string, optional): Filter by line status. - external_line_id (query, string, optional): Your own id for the line, as sent when it was opened. Exact match within this business. - external_merchant_id (query, string, optional): Your own id for the merchant. Exact match within this business. - limit (query, integer, optional) - offset (query, integer, optional) - include_total_count (query, boolean, optional): Return the matching row count in an `X-Total-Count` header. The body stays an array. Responses: 200, 401, 403, 422 ### POST /api/v1/credit/lines Open a credit line Open a line on approval. Terms not supplied inherit the program's defaults. Idempotent on `external_line_id`: a repeat returns the line already open under it, as it stands, and writes nothing. Send `card` to issue the merchant's card with the line on a program whose cards DayZero issues: the response carries `card`, or `card_issue_error` when the issuer refused it (the line is open either way). Request body (CreditLineCreateRequest): - program_id (string, optional) - external_line_id (string, optional) - external_merchant_id (string, optional) - merchant_business_id (string, optional) - credit_limit_cents (integer, required) - term_days (integer, optional) - rate_bps (integer, optional) - disbursement_fee_bps (integer, optional) - cycle_anchor_day (integer, optional) - start_date (string · date, optional) - linked_account_name (string, optional) - linked_account_mask (string, optional) - plaid_account_id (string, optional) - autopay_enabled (boolean, optional) - merchant_email (string, optional) - merchant_legal_name (string, optional) - merchant_state (string, optional) - merchant_address (MerchantAddress, optional) - card (LineOpenCardRequest, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id} Credit line dashboard Limit, current balance, available credit, utilisation in basis points, start date, term, and linked account. Available credit and utilisation are returned rather than derived so the dashboard card and the statement band cannot disagree. Parameters: - credit_line_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/credit/lines/{credit_line_id} Update a credit line Change the repayment account, AutoPay, the credit limit, or the status. Parameters: - credit_line_id (path, string, required) Request body (CreditLineUpdateRequest): - linked_account_name (string, optional) - linked_account_mask (string, optional) - plaid_account_id (string, optional) - autopay_enabled (boolean, optional) - merchant_email (string, optional) - merchant_business_id (string, optional) - external_merchant_id (string, optional) - merchant_legal_name (string, optional) - merchant_state (string, optional) - merchant_address (MerchantAddress, optional) - status (CreditLineStatusEnum, optional) - reason (string, optional) - acknowledgement_override (AcknowledgementOverride, optional) - reason_code (string, optional) - credit_limit_cents (integer, optional) - limit_change_reason (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/borrower-ledger Borrower ledger Complete purchases, dated activity and mutually exclusive owed buckets. Parameters: - credit_line_id (path, string, required): Credit line UUID on the authenticated business. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/borrower-monthly-balance Borrower monthly balance Historical month-end status, roll-forward and original purchase activity. Parameters: - credit_line_id (path, string, required): Credit line UUID on the authenticated business. - month (query, string · date, required): Calendar month to reconstruct; pass its first date, YYYY-MM-01. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/borrower-monthly-balance/export Download borrower monthly balance CSV for any elapsed month; final PDF only after the month has ended. Parameters: - credit_line_id (path, string, required): Credit line UUID on the authenticated business. - month (query, string · date, required): Calendar month to reconstruct; pass its first date, YYYY-MM-01. - format (query, string, optional): CSV permits month-to-date; PDF requires a completed, reconciled month. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/borrower-preview Preview the borrower portal The borrower portal's overview page as the merchant sees it, as HTML for the console to show in a sandboxed frame. Nothing is minted: no link, no session, nothing the merchant or anyone else can open. Parameters: - credit_line_id (path, string, required): Credit line UUID on the authenticated business. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/cards List cards on a credit line Cards issued against this line, newest first. Parameters: - credit_line_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional) - include_total_count (query, boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/cards/monitor Monitor card spend and controls Per-card cleared spend, remaining headroom, and any drift between our record and the issuer's. Parameters: - credit_line_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/cards/spend-limit-sync Push available credit to the issuer as the card limit Computes available credit from the ledger and pushes it to the issuer as the spend limit on every active card on the line, so the card declines at the limit (D-15). Runs automatically after every origination and repayment; this call forces it. Parameters: - credit_line_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/cards/stripe-issuing/connect Provision or update a credit line's Stripe Connect Issuing account and CreditPolicy Creates or updates a Stripe Custom connected account (`card_issuing` + `transfers` + optional `funding_credit`) for a merchant credit line, generates an `account_onboarding` link when `return_url` and `refresh_url` are supplied, and optionally activates a Stripe Issuing Credit `CreditPolicy` or records a `FundingObligation` repayment. Accounts must belong to the business and per-line accounts must match this line. Omitted accounts reuse an existing line account or create one idempotently. Onboarding URLs must use the configured app origin. Live business operator action (an API token receives `403`); sandbox businesses are refused before Stripe calls. Parameters: - credit_line_id (path, string, required): Credit line UUID to bind the Stripe Connect account to. Request body (CreditStripeLineConnectRequest): - stripe_account_id (string, optional) - country (string, optional) - enable_funding_credit (boolean, optional) - return_url (string, optional) - refresh_url (string, optional) - activate_credit_policy (boolean, optional) - credit_limit_cents (integer, optional) - days_until_due (integer, optional) - funding_obligation_id (string, optional) - pay_amount_cents (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/covenant-checks List a line's covenant checks Every night's check on the line, newest first, optionally for one covenant. Pass `next_cursor` back as `cursor` for older nights. Parameters: - credit_line_id (path, string, required): Credit line ID. The lender's routes need a line this business operates; the borrower's read also accepts a line it borrows on. - covenant_id (query, string, optional): Only this covenant's checks. - limit (query, integer, optional): Checks per page. - cursor (query, string, optional): Pass `next_cursor` unchanged for older checks. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/covenants List a line's covenants with their last 60 nights Every covenant on the line with its most recent check and the last 60 nights (oldest first) for the dot strip. Readable by the business that operates the line (`viewer: lender`) and by the business that borrows on it, the line's `merchant_business_id` (`viewer: borrower`, read-only); `404` for anyone else. Each check's `inputs` name the borrower's ledgers and the window behind every figure. Parameters: - credit_line_id (path, string, required): Credit line ID. The lender's routes need a line this business operates; the borrower's read also accepts a line it borrows on. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/covenants Add a covenant to a line Writes a covenant the nightly sweep tests against the borrower's books from tonight on. `comparison` defaults to the kind's own (gte for the minimums, lte for max_leverage) and is required for `custom_ratio`, which also needs a numerator and a denominator selector naming at least one ledger id, type or concept (`400` otherwise). A line with no `merchant_business_id` accepts covenants but every check reads `unmeasured` until the borrower's business is linked. Parameters: - credit_line_id (path, string, required): Credit line ID. The lender's routes need a line this business operates; the borrower's read also accepts a line it borrows on. Request body (CovenantCreate): - kind (string, required) - label (string, optional) - threshold (number, required) - comparison (string, optional) - warn_band_bps (integer, optional) - numerator_selector (LedgerSelector, optional) - denominator_selector (LedgerSelector, optional) - active (boolean, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/covenants/check Check a line's covenants now Runs tonight's check for every active covenant on the line without waiting for the sweep: measures each from the borrower's books, records or re-records the night's check, emits `credit.covenant_warning` / `credit.covenant_breach` and notifies the borrower, and on a third consecutive breach files one limit-review proposal. Never changes the limit. `as_of` defaults to today. Parameters: - credit_line_id (path, string, required): Credit line ID. The lender's routes need a line this business operates; the borrower's read also accepts a line it borrows on. - as_of (query, string · date, optional): The night to read the books to; default today. Responses: 201, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/credit-balance Where a line's credit balance came from The line's carried-forward credit and the entries it is made of, newest first: each entry's `source` (`overpayment`, `refund`, `dispute`, `opening`) and `source_reference`, `amount_cents`, `consumed_cents`, `withdrawn_cents`, `remaining_cents`, `status`, and the loans that consumed it (`consumptions`). The sum of `remaining_cents` (`entries_remaining_cents`) equals `credit_balance_cents` less `unattributed_cents`, which is non-zero only on a line whose credit predates entries and has not moved since. Filter with `status` (comma-separated: `open`, `consumed`, `withdrawn`). Parameters: - credit_line_id (path, string, required) - status (query, string, optional): Comma-separated entry statuses: open, consumed, withdrawn. - limit (query, integer, optional): Entries per page (1-500). - cursor (query, string, optional): `next_cursor` from the previous page. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/disclosure Disclosure figures for a loan For a prospective single-payment loan on this line's terms: APR by the actuarial method, finance charge, total of payments, term, the payment schedule (one payment on the due date) and the prepayment terms, with the method named. Figures only; whether a disclosure is required is for the lender's counsel. Parameters: - credit_line_id (path, string, required) - principal_cents (query, integer, required): The amount to be advanced. - term_days (query, integer, optional): Defaults to the line's term. - transaction_date (query, string · date, optional): When the loan would be made. Defaults to today (UTC). Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/disclosures List a line's disclosures Every disclosure generated for the line, newest first, with its figures, template, PDF hash, delivery, acknowledgement and whether it was required. Parameters: - credit_line_id (path, string, required) - limit (query, integer, optional): Disclosures per page (1-500). - cursor (query, string, optional): `next_cursor` from the last page. - status (query, string, optional): Only these statuses, comma-separated, e.g. `pending_acknowledgement`. An unknown one is `400` `CREDIT_835`. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/disclosures Generate a disclosure now Generates a disclosure on the line's current terms and limit (`kind`: `offer` or `limit_change`) from the approved template, under the program's policy. Refused when the policy is off or its disclosure mode is `off`, or when no approved template exists. Operator action. Parameters: - credit_line_id (path, string, required) Request body (DisclosureCreateRequest): - kind (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/disputes List a line's disputes Every dispute and void on the line, newest opened first, from the issuer, reconciliation, the partner, or an operator. Parameters: - credit_line_id (path, string, required) - status (query, string, optional) - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/credit/lines/{credit_line_id}/external-merchant-id Change a line's merchant id (console) The console's line settings edit of `external_merchant_id`: the same change as `PATCH /credit/lines/{id}` with that field (the old value kept as `previous_external_merchant_id`, `409` `CREDIT_901` when another open line of the program has it), behind a step-up. Operator action: an API token receives `403`; a partner uses the `PATCH`. Parameters: - credit_line_id (path, string, required): The line to change. Request body (CreditLineMerchantIdRequest): - external_merchant_id (string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/credit/lines/{credit_line_id}/historical-payments List a line's historical payments Payments made before the line joined DayZero, attached from the previous system's records, newest first, each with its split by loan and whether that split is the previous system's or derived. They moved no balance here: the loans were imported with them in their paid amounts. `loan_id` lists one loan's. Parameters: - credit_line_id (path, string, required): The line. - loan_id (query, string, optional): Only payments split onto this loan. - limit (query, integer, optional): Page size (1-500). - cursor (query, string, optional): `next_cursor` from the previous page. - include_total_count (query, boolean, optional): Also count every payment that matches. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/ledger Credit line ledger register The append-only register every balance is derived from, in replay order, one page at a time. Pass `next_cursor` back as `after` to read the next page; filter by loan, entry type, or date. Parameters: - credit_line_id (path, string, required) - after (query, integer, optional): Return entries after this sequence number. - loan_id (query, string, optional) - entry_types (query, string, optional): Comma-separated entry types. - start (query, string · date, optional) - end (query, string · date, optional) - limit (query, integer, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/ledger/verify Verify ledger integrity Recomputes the hash chain and re-derives the balance from the entries. An append-only register has no legitimate way to fail this, so a false result means a row was altered or removed. Parameters: - credit_line_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/limit-change-requests List a line's limit-change requests Every limit-change request on the line, newest first, optionally filtered by `status`. Pass `next_cursor` back as `cursor` for the next page. Parameters: - credit_line_id (path, string, required) - status (query, string, optional) - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/limit-change-requests Request a credit-limit change Records a request to move the line's limit to `requested_limit_cents`, for a console operator to approve or reject. Open to API tokens under every `limit_change_policy`; under `direct`, `PATCH /credit/lines/{id}` applies a change at once instead. `400` when the limit is the current one or outside the program envelope; `409` when a request is already pending on the line. A request still pending after 14 days expires. Parameters: - credit_line_id (path, string, required) Request body (LimitChangeRequestCreate): - requested_limit_cents (integer, required) - reason (string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/credit/lines/{credit_line_id}/limit-reviews List a line's limit reviews Every review of the line's limit, newest first: what was measured, the limit after each stage of the formula, the triggers that fired, and whether it was proposed, applied, dismissed or no change. Pass `next_cursor` back as `cursor` for the next page. Parameters: - credit_line_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/limit-reviews/run Review a line's limit now Measures the program policy's basis and triggers for this line and records a review, whatever the cadence says. Under `apply: direct` (on a `direct` program) a change is applied at once; otherwise it is proposed. Any open proposal on the line is superseded. Returns `400` when the line's program has no enabled `limit_review_policy`. Parameters: - credit_line_id (path, string, required) Request body (LimitReviewRunRequest): - as_of (string · date, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/linked-accounts The merchant's linked bank accounts For Change Payment Method (§6.2): every bank account the line's merchant has linked on DayZero, with its Plaid id, name, last four, type, institution and connection state, and which one is on the line. Record another with `PATCH /credit/lines/{id}` (`plaid_account_id`, `linked_account_mask`, `linked_account_name`); connect a new one with `POST /credit/bank-connections` and `credit_line_id`. Never carries account or routing numbers. Parameters: - credit_line_id (path, string, required): The line whose merchant's accounts to list. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/loans List loans on a line One row per card transaction, oldest first, with the platform cursor envelope. Filter by status and by a date range on transaction date or due date. Status is authoritative: a client must not compute it from dates or balances. Parameters: - credit_line_id (path, string, required) - status (query, string, optional): Comma-separated loan states. - start (query, string · date, optional) - end (query, string · date, optional) - date_basis (query, string, optional) - cycle_id (query, string, optional): Loans originated in this period. - limit (query, integer, optional) - cursor (query, string, optional) - include_total_count (query, boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/loans/import Import existing loans onto a line Launch with live cards and open loans (D-29): loads loans that already exist on the partner's previous system with their paid buckets and interest to date, keyed by the original issuer transaction id so attribution survives the migration (D-33). Idempotent on that id; one bad row is rejected without sinking the batch. Daily accrual resumes from the day after `accrued_through`. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - credit_line_id (path, string, required) Request body (LoanImportRequest): - as_of (string · date, optional) - dry_run (boolean, optional) - expected_count (integer, optional) - expected_principal_cents (integer, optional) - expected_outstanding_cents (integer, optional) - allow_cross_line_duplicates (boolean, optional) - loans (array · LoanImportItem | object, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/monitoring-observations List observation-only underwriting monitoring Newest first. Configure monitoring_policy on the program; default off. Parameters: - credit_line_id (path, string, required): Credit line ID owned by the operator business. - limit (query, integer, optional): Maximum observations per page. - cursor (query, integer, optional): Pass next_cursor unchanged to read older observations. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/notices List notices sent on a line Borrower notices emailed to the line's `merchant_email`, newest first, cursor-paged. Each names its kind, the event it reported (none for a collections notice), the subject, and the SES message id. Parameters: - credit_line_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional): `next_cursor` from the previous page. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/notifications List a line's in-app notifications The merchant's in-app notifications on this line, newest first, cursor-paged: kind, severity, title, body, suggested action, the figures, and whether you marked it read or dismissed. `unread_count` is the line's unread total, for a badge. Parameters: - credit_line_id (path, string, required): The line. - kind (query, string, optional): Only these kinds, comma-separated: due_soon, past_due, loan_paid, statement_issued, limit_changed, collections. An unknown one is `400` `CREDIT_816`. - since (query, string · date-time, optional): Only notifications created at or after this time (UTC). - unread_only (query, boolean, optional): Only notifications neither read nor dismissed. - limit (query, integer, optional): Page size. - cursor (query, string, optional): `next_cursor` from the previous page. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/partner-statements/{statement_id}/document Download a statement the previous system issued The document of a statement attached from the previous system, as it was issued, never regenerated. A statement attached with its figures only has none (`400` `CREDIT_794`). Parameters: - credit_line_id (path, string, required): The line. - statement_id (path, string, required): The attached statement (`partner_statements[].id`). Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/payment-aliases List a line's payment aliases Every identifier this merchant's incoming payments are known by. Parameters: - credit_line_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional) - include_total_count (query, boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/payment-aliases Record a payment alias Register an identifier a merchant's money arrives under — the sender name their bank stamps on a wire, a reference they quote, an account mask. Resolution then becomes a lookup rather than a guess at a name (§10.8). An alias already pointing at another line is refused rather than reassigned. Parameters: - credit_line_id (path, string, required) Request body (PaymentAliasCreateRequest): - alias (string, required) - alias_type (string, optional) - source (string, optional) - note (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/payment-matches List the bank-settlement decisions on a line Every decision the bank-settlement matcher took for this line, newest bank date first: `settled` (a pending payment confirmed as at the bank date), `returned` (a payment reversed as an ACH return), `ambiguous` (more than one payment fit, nothing applied) and `unmatched_candidate` (looks like this line's repayment, but the sender is not a recorded alias). `rule` says which rule decided and `notes` the evidence. Pass `unresolved=true` for the rows waiting on an operator. Parameters: - credit_line_id (path, string, required) - kind (query, string, optional): Comma-separated: settled, returned, ambiguous, unmatched_candidate. - unresolved (query, boolean, optional): Only ambiguous and candidate rows no one has decided. - limit (query, integer, optional) - cursor (query, string, optional): `next_cursor` from the last page. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/payments List payments on a line Payments newest first, with their allocations and status, cursor-paged. Parameters: - credit_line_id (path, string, required) - status (query, string, optional): Comma-separated: pending, recorded, settled, reversed. - limit (query, integer, optional) - cursor (query, string, optional) - include_total_count (query, boolean, optional) - include_historical (query, boolean, optional): Also list the payments made before the line joined DayZero, attached from the previous system's records, each marked `historical: true`. They moved no balance here. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/payoff-quote Quote the payoff amount What it takes to pay off as at a date: unpaid principal, the unpaid disbursement fee, and interest accrued to that date (plus, on a future date, the interest projected to it), less any early-payoff rebate and plus any prepayment penalty on a cycle draw. Request this rather than reusing the displayed balance: principal, fee and accrued interest settle separately, so the balance alone is not the payoff amount. On a per-transaction line a past date the line's book has already been processed beyond (a later accrual run or payment) is refused with `CREDIT_730`; today and later dates are always quoted. Parameters: - credit_line_id (path, string, required) - as_of (query, string · date, optional): Quote date. Defaults to today; on a sandbox whose clock was run forward, to the day it was run to. - loan_ids (query, string, optional): Comma-separated loan ids to quote. Omit for every open loan. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/portal-sessions List borrower-portal links The line's portal sessions, newest first, with expiry, revocation, views and scopes. Tokens are never returned. Parameters: - credit_line_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/lines/{credit_line_id}/portal-sessions Mint a borrower-portal link Returns a URL to the hosted, lender-branded borrower portal for this line. The URL holds a secret token and is returned once. The link works for `ttl_hours` (1 to 720) or until revoked. Without `scopes`, a link minted while the line has a disclosure awaiting acknowledgement also carries `acknowledge`. A `credit:read` token may mint links with the read scopes only. Parameters: - credit_line_id (path, string, required) Request body (PortalSessionCreateRequest): - ttl_hours (integer, optional) - scopes (array · string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/schedule Repayment schedule Every open loan, earliest due first, with its due date, days to due, what closes it on `as_of`, and its payoff on the due date and 30 and 60 days later (from `as_of` once past due), clamped to `horizon_days`. Priced by the same computation as the payoff quote, so the figures agree. Per-transaction programs only. Parameters: - credit_line_id (path, string, required) - as_of (query, string · date, optional): Schedule date. Defaults to today (UTC); on a sandbox whose clock was run forward, to the day it was run to. - horizon_days (query, integer, optional): How far ahead projections run, in days from as_of. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/statements List statements One row per closed cycle: period, issued date, due date, status, amount due, and a download link. The due date is fixed at close and must not be derived from the issued date. Parameters: - credit_line_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/statements/{cycle_id} Get a rendered statement The statement document for one period: the roll-forward, every loan on it with its term, due date, interest and payments, and the amount due. `format=pdf` returns the document carrying the program's branding and lending entity; `format=csv` returns the transaction-level spreadsheet; `format=html` the printable page. The partner provides the download affordance and nothing else. The issued part is the snapshot written at close and never changes; `since_statement` lists what has touched the statement's loans since it was issued and ends in what they owe now. `view=issued` (the default for json, pdf and html) returns the loan rows as issued; `view=current` (the default for csv) recomputes them from today's records. pdf and html are always the issued document. Parameters: - credit_line_id (path, string, required) - cycle_id (path, string, required) - format (query, string, optional): json (the default): the statement as data. html, pdf: the issued document. csv: the transaction-level spreadsheet. - view (query, string, optional): issued: the loan rows exactly as the statement was issued. current: recomputed from today's records. Defaults to current for csv and issued otherwise; current is refused for pdf and html (CREDIT_641), and any other value is CREDIT_640. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/subledger Transactions tab: summary band, loan rows, period history Per-transaction programs: the summary band (Total Balance and Statement Balance, which are different figures), one row per card transaction with its loan id, fee, term, due date, accrued interest, outstanding and status, and the period history. Filters run server-side on loan status and on a date range by transaction date or due date, with a cursor over the rows. Selecting a period re-renders the band for it. Cycle-draw programs return the roll-forward band and cycle rows. Parameters: - credit_line_id (path, string, required) - cycle_id (query, string, optional): Render the band for this period. Defaults to the latest. - status (query, string, optional): Comma-separated loan states (active, past_due, paid, written_off, voided, reversed) or cycle states. - start (query, string · date, optional): Range start (inclusive). - end (query, string · date, optional): Range end (inclusive). - date_basis (query, string, optional): Which date the range applies to. - limit (query, integer, optional): Loan rows per page. - cursor (query, string, optional): `loans_next_cursor` from the previous page. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/lines/{credit_line_id}/subledger/export Export the Transactions tab as CSV One row per loan with the same server-side filters as the subledger, as a CSV download (D-23). Parameters: - credit_line_id (path, string, required) - status (query, string, optional) - start (query, string · date, optional) - end (query, string · date, optional) - date_basis (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/loans/{loan_id} Get one loan One loan with its balances. Parameters: - loan_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/loans/{loan_id}/adjustments List a loan's adjustments Waivers and goodwill credits on one loan, newest first, cursor-paged. Parameters: - loan_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional): `next_cursor` from the previous page. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/loans/{loan_id}/adjustments Adjust a loan Waive part of a loan's unpaid fee (`waive_fee`) or accrued interest (`waive_interest`), or credit its unpaid principal as goodwill (`goodwill_credit`). The amount may not exceed what is outstanding in that bucket. Posts an `adjustment` ledger entry with the reason as its memo and, when the program posts to the GL, a journal entry to Fee Waivers, Interest Waivers or Goodwill Credits. A loan brought to zero is paid on `effective_on` and emits `credit.loan.paid`. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - loan_id (path, string, required) Request body (CreditLoanAdjustmentRequest): - type (string, required) - amount_cents (integer, required) - reason (string, required) - effective_on (string · date, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/loans/{loan_id}/dispute Open a dispute on a loan Puts the loan on hold while the merchant's dispute of the card transaction runs: no interest accrues for hold days, the loan is out of days past due, AutoPay and the amount due, and its balance is shown flagged. Omit `amount_cents` to dispute the whole transaction. Idempotent on `provider_dispute_id`, otherwise on the loan's open dispute. Parameters: - loan_id (path, string, required) Request body (CreditDisputeOpenRequest): - amount_cents (integer, optional) - reason (string, required) - provider_dispute_id (string, optional) - opened_on (string · date, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/loans/{loan_id}/write-off Write off a loan Charges a loan off under the collections policy (D-31). Omit the amount to write off everything outstanding and close the loan; supply one to reduce principal only and leave it open. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - loan_id (path, string, required) Request body (CreditLoanWriteOffRequest): - written_off_on (string · date, optional) - amount_cents (integer, optional) - memo (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/me Describe this API token The business the token acts on, the token's scopes, business limit, expiry and fingerprint, whether the credit API is open to it (`credit_api_enabled`, with `disabled_reasons`), the programs the business operates (only the token's own when it is limited to one, `token.program_id`), each with the `measurement_source_mode` and `bank_feed_provider` to use, and the public key to seal Shopify tokens with (`shopify_transport`). `x-business-id` is optional: a token limited to one business uses it; otherwise the header is required (`409` `CREDIT_TOKEN_BUSINESS_AMBIGUOUS`, with `data.business_count`), and when sent must be one of the token's own businesses (`403` `AUTH_070`). API tokens only (`403` `CREDIT_900`). Readable with `credit`, `credit:read`, `api` and `read_only`; not with `credit:payments` or `credit:mapping` alone. Responses: 200, 401, 403, 409, 422 ### GET /api/v1/credit/merchant-data What DayZero holds for a merchant's underwriting One entry per data source (bank, shopify, meta_ads, profile, debt_facilities, ad_spend, receivables): `provided`, `not_provided` or `stale`, when it last arrived, how many rows, the criterion keys it feeds and what to send when it is missing. Only the bank is `required`: underwriting waits for it, and a missing optional source leaves its measures unmeasured. Name the merchant by `merchant_business_id`, `credit_line_id`, or `program_id` with `external_merchant_id`. Creates nothing; an unknown merchant is `404` `CREDIT_836`. Parameters: - program_id (query, string, optional): Your program, with `external_merchant_id`. - external_merchant_id (query, string, optional): Your id for the merchant. - credit_line_id (query, string, optional): The merchant's line. - merchant_business_id (query, string, optional): The merchant's DayZero business. Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/credit/merchant-profile Set a merchant's profile Name the merchant as on `POST /credit/bank-feeds` (`program_id` and `external_merchant_id`, or `credit_line_id`); DayZero uses its business, creating it the first time, and gives your token read access to it. Records the merchant's start date (`business_started_on`), legal form, NAICS code, MCC, industry, country and currency. Fields left out keep what an earlier call set. `months_in_business` reads the declared start date first (`evidence.basis: declared`); without one it infers the age from the first Shopify order or bank transaction (`basis: inferred`). The currency becomes the business's while its books are empty. Request body (MerchantProfileRequest): - program_id (string, optional) - external_merchant_id (string, optional) - credit_line_id (string, optional) - merchant_legal_name (string, optional) - merchant_business_id (string, optional) - business_started_on (string · date, optional) - legal_entity_type (string, optional) - naics_code (string, optional) - mcc (string, optional) - industry (string, optional) - country (string, optional) - currency (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/notifications List in-app notifications across lines Every line's in-app notifications on the business, newest first, cursor-paged. Narrow with `program_id` or `credit_line_id`; `unread_count` is the unread total in that scope. Parameters: - program_id (query, string, optional): Only this program's lines. - credit_line_id (query, string, optional): Only this line. - kind (query, string, optional): Only these kinds, comma-separated: due_soon, past_due, loan_paid, statement_issued, limit_changed, collections. An unknown one is `400` `CREDIT_816`. - since (query, string · date-time, optional): Only notifications created at or after this time (UTC). - unread_only (query, boolean, optional): Only notifications neither read nor dismissed. - limit (query, integer, optional): Page size. - cursor (query, string, optional): `next_cursor` from the previous page. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/credit/notifications/{notification_id} Get an in-app notification One notification, as a row of the lists: `credit_line_id`, kind, copy, figures and read state. Reading it marks nothing. `404` `CREDIT_815` when it is not on this business. Parameters: - notification_id (path, string, required): The notification's `id`. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/notifications/{notification_id}/dismiss Dismiss an in-app notification Sets `dismissed_at`, and `read_at` if it was unread, once each: dismissing it again keeps the first times. A dismissed notification is still listed; `unread_only=true` leaves it out. Takes no body. Parameters: - notification_id (path, string, required): The notification's `id`. Responses: 201, 401, 403, 404, 422 ### POST /api/v1/credit/notifications/{notification_id}/read Mark an in-app notification read Sets `read_at`, once: marking it again keeps the first time. Takes no body. Parameters: - notification_id (path, string, required): The notification's `id`. Responses: 201, 401, 403, 404, 422 ### DELETE /api/v1/credit/payment-aliases/{alias_id} Delete a payment alias Stop resolving this identifier to a line. Parameters: - alias_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/payment-matches/{match_id}/override Confirm or reject a bank-settlement match Console operators only. `confirm` settles the payment as at the bank date (or, for an `ach_return` row, reverses it) through the ordinary payment path; name the payment with `payment_id` when the row does not point at one. It must be on the row's line and for the bank amount. Confirming closes the same transaction's open rows on other lines. `reject` records that the transaction is not this line's payment. A row that already settled or reversed a payment cannot be overridden: reverse the payment instead. Parameters: - match_id (path, string, required) Request body (PaymentMatchOverrideRequest): - action (string, required) - payment_id (string, optional) - note (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/payments Record a payment Records a debit the partner executed and returns the allocation and corrected balances in one response. Allocation is not selectable: oldest loan first, and within a loan accrued interest, then the disbursement fee, then principal (D-10, D-11). `paid_on` is the date the money landed. Send `pending: true` to record an initiated debit without allocating, then confirm settlement. Pass `loan_id` for the per-row Pay action, subject to the per-loan minimum (D-09). Idempotent on `external_payment_id`. Request body (PaymentRecordRequest): - credit_line_id (string, optional) - external_line_id (string, optional) - external_payment_id (string, required) - amount_cents (integer, required) - paid_on (string · date, required) - method (string, optional) - loan_id (string, optional) - pending (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/payments/preview Preview a payment What a payment of `amount_cents` would retire if it were recorded on `as_of`: the interest, fee and principal it clears on each loan, what is left over, and the balances afterwards. It runs the same accrual and allocation as recording a payment and then discards the result, so nothing is written and no event is emitted. Pass `loan_id` to aim it at one loan; the per-loan minimum applies exactly as it does when recording. Request body (PaymentPreviewRequest): - credit_line_id (string, optional) - external_line_id (string, optional) - amount_cents (integer, required) - as_of (string · date, optional) - loan_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/payments/resolve Resolve an inbound payment to a credit line Given the description an incoming payment arrives with, return the credit line it belongs to. A line id comes back only on an exact match against a recorded alias; a partial overlap is returned as a candidate for a person to confirm and never as a match. Nothing is recorded here — take the id and post the payment as usual. Parameters: - description (query, string, required): Sender name or reference. Responses: 200, 401, 403, 422 ### POST /api/v1/credit/payments/{payment_id}/reversal Reverse a failed payment Unwinds a returned debit exactly as it was applied and re-accrues from the failure date. The merchant is not charged interest for the period the payment was pending. Parameters: - payment_id (path, string, required) Request body (PaymentReversalRequest): - reversed_on (string · date, required) - reason (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/payments/{payment_id}/settlement Confirm a pending payment settled The money landed: a pending payment is allocated as at the settled date, which is the date the payment counts from (§10.6). A payment recorded without `pending` is simply stamped. Repeating the call with the same `settled_on` returns the payment unchanged; a different date for a settled payment is refused with `CREDIT_731`. Parameters: - payment_id (path, string, required) Request body (PaymentSettlementRequest): - settled_on (string · date, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/credit/portal-sessions/{session_id} Revoke a borrower-portal link The link stops working immediately. Revoking twice is harmless. Parameters: - session_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/portfolio Portfolio, aging, and allowance Sums over the book: outstanding by component, past-due aging in the program's allowance buckets with the reserve each implies, month-to-date interest and fee income, originations, payments, write-offs, and the lifetime default rate. Optionally one program. Parameters: - program_id (query, string, optional) - as_of (query, string · date, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/credit/portfolio/loan-tape Loan tape (CSV) One row per loan with every balance and date, for the fund and its lenders. Ties to the portfolio figures exactly. Parameters: - program_id (query, string, optional) - as_of (query, string · date, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/credit/programs List lending programs Every program this business operates, with its policy status. Parameters: - limit (query, integer, optional) - offset (query, integer, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/credit/programs Create a lending program Stand up a partner lending program. The program carries the parameter envelope, the policy positions, statement branding, and the card-issuing configuration, so onboarding a second partner is a row rather than a build. Operator action: an API token receives `403`. Needs the Credit Ledger add-on (403 `BILLING_003`), which a business that already runs a program keeps. Request body (CreditProgramCreateRequest): - slug (string, required) - display_name (string, required) - status (ProgramStatusEnum, optional) → ProgramStatusEnum - force_activate (ForceActivateRequest, optional) - lending_model (LendingModel, optional) → LendingModel - limit_min_cents (integer, optional) - limit_max_cents (integer, optional) - allowed_term_days (array · integer, optional) - default_rate_bps (integer, optional) - default_disbursement_fee_bps (integer, optional) - max_float_days (integer, optional) - allocation_order (AllocationOrder, optional) → AllocationOrder - loan_ordering (LoanOrdering, optional) → LoanOrdering - interest_accrual_start (InterestAccrualStart, optional) → InterestAccrualStart - minimum_payment_cents (integer, optional) - due_soon_days (integer, optional) - underwriting_wait_days (integer, optional) - auto_approve_default (boolean, optional) - gl_posting_enabled (boolean, optional) - gl_posting_review (boolean, optional) - gl_funding_ledger_id (string, optional) - gl_cash_ledger_id (string, optional) - interest_cap_pct_of_principal_bps (integer, optional) - card_management (string, optional) - deferred_fee_recognition (boolean, optional) - email_statements (boolean, optional) - marketplace_listed (boolean, optional) - marketplace_blurb (string, optional) - notices (CreditNoticeSettings, optional) - compliance (CompliancePolicy, optional) - bank_settlement_matching (boolean, optional) - alert_slack_channel (string, optional) - alert_emails (array · string, optional) - allowance_policy (object, optional) - borrowing_base_policy (BorrowingBasePolicy, optional) - interchange_source (string, optional) - interchange_bps (integer, optional) - statement_balance_mode (string, optional) - allocation_scope (string, optional) - cycle_boundary_basis (string, optional) - cycle_close_rule (string, optional) - cycle_anchor_day (integer, optional) - excess_credit_disposition (string, optional) - collections_policy (object, optional) - monitoring_policy (MonitoringPolicy, optional) - limit_review_policy (LimitReviewPolicy, optional) - limit_change_policy (string, optional) - late_terms (object, optional) - early_payoff_terms (object, optional) - underwriting_decision_policy (UnderwritingDecisionPolicy, optional) - underwriting_criteria (array · object, optional) - legal_lending_entity (string, optional) - statement_branding (object, optional) - covenants (object, optional) - event_delivery_mode (EventDeliveryMode, optional) → EventDeliveryMode - bank_link_redirect_uris (array · string, optional) - event_delivery_locked (boolean, optional) - sandbox_email_recipients (array · string, optional) - sandbox_email_redirect_to (string, optional) - issuing_enabled (boolean, optional) - issuing_provider (string, optional) - custom_terms_enabled (boolean, optional) - issuer_config (object, optional) - bank_feed_config (object, optional) - portal_frame_ancestors (array · string, optional) - ramp_spend_program_id (string, optional) - issuer_timezone (string, optional) - ramp_cardholder_user_id (string, optional) - allowed_mcc_codes (array · string, optional) - blocked_mcc_codes (array · string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/credit/programs/{program_id} Get a lending program One program, including which policy rules are still undecided. Parameters: - program_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/credit/programs/{program_id} Update a lending program Supplying `late_terms`, `early_payoff_terms`, or `underwriting_criteria` is what settles the corresponding open decision: the guarded code paths stop raising once a rule body exists. Moving a live program to `active` from another status is refused (`CREDIT_660`) while a blocking launch check fails, unless the patch carries `force_activate` with a reason. Operator action: an API token receives `403`. Parameters: - program_id (path, string, required) Request body (CreditProgramUpdateRequest): - display_name (string, optional) - status (ProgramStatusEnum, optional) - lending_model (LendingModel, optional) - limit_min_cents (integer, optional) - limit_max_cents (integer, optional) - allowed_term_days (array · integer, optional) - default_rate_bps (integer, optional) - default_disbursement_fee_bps (integer, optional) - allocation_order (AllocationOrder, optional) - loan_ordering (LoanOrdering, optional) - interest_accrual_start (InterestAccrualStart, optional) - minimum_payment_cents (integer, optional) - due_soon_days (integer, optional) - underwriting_wait_days (integer, optional) - auto_approve_default (boolean, optional) - gl_posting_enabled (boolean, optional) - gl_posting_review (boolean, optional) - gl_funding_ledger_id (string, optional) - gl_cash_ledger_id (string, optional) - interest_cap_pct_of_principal_bps (integer, optional) - card_management (string, optional) - deferred_fee_recognition (boolean, optional) - email_statements (boolean, optional) - marketplace_listed (boolean, optional) - marketplace_blurb (string, optional) - notices (CreditNoticeSettings, optional) - compliance (CompliancePolicy, optional) - bank_settlement_matching (boolean, optional) - alert_slack_channel (string, optional) - alert_emails (array · string, optional) - allowance_policy (object, optional) - borrowing_base_policy (BorrowingBasePolicy, optional) - interchange_source (string, optional) - interchange_bps (integer, optional) - issuing_provider (string, optional) - custom_terms_enabled (boolean, optional) - issuer_config (object, optional) - bank_feed_config (object, optional) - portal_frame_ancestors (array · string, optional) - statement_balance_mode (string, optional) - allocation_scope (string, optional) - cycle_close_rule (string, optional) - cycle_anchor_day (integer, optional) - excess_credit_disposition (string, optional) - collections_policy (object, optional) - monitoring_policy (MonitoringPolicy, optional) - limit_review_policy (LimitReviewPolicy, optional) - limit_change_policy (string, optional) - late_terms (object, optional) - early_payoff_terms (object, optional) - underwriting_decision_policy (UnderwritingDecisionPolicy, optional) - underwriting_criteria (array · object, optional) - legal_lending_entity (string, optional) - statement_branding (object, optional) - covenants (object, optional) - event_delivery_mode (EventDeliveryMode, optional) - bank_link_redirect_uris (array · string, optional) - event_delivery_locked (boolean, optional) - sandbox_email_recipients (array · string, optional) - sandbox_email_redirect_to (string, optional) - issuing_enabled (boolean, optional) - ramp_spend_program_id (string, optional) - issuer_timezone (string, optional) - ramp_cardholder_user_id (string, optional) - allowed_mcc_codes (array · string, optional) - blocked_mcc_codes (array · string, optional) - force_activate (ForceActivateRequest, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/card-management Switch who manages a program's cards Plans moving the program's `card_management` to `target`, per line and per card: `keep`, `adopt` (a registered card whose fund the program's issuer connection can see), `leave_with_partner` (with the reason), or `stays_with_dayzero` (a DayZero card on a program moving to the partner; it stays DayZero-managed and is still pushed). `dry_run` defaults to true and changes nothing. With `dry_run: false` the field is written, adoptable cards are adopted and their limit pushed once, and one `credit.line.limit_changed` is emitted per line whose managers changed. Applying the same target again changes nothing. Operator action. Parameters: - program_id (path, string, required) Request body (CardManagementSwitchRequest): - target (string, required) - dry_run (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/programs/{program_id}/event-delivery How a program's credit events reach you The program's `event_delivery_mode`, whether an operator holds it (`event_delivery_locked`), whether events are pushed, and how many active endpoints on the business subscribe to a credit event. Parameters: - program_id (path, string, required): The program. Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/credit/programs/{program_id}/event-delivery Start or stop pushing a program's credit events Set `event_delivery_mode` to `both` to have every credit event also POSTed, signed, to the business's active endpoints subscribed to it (register them with `POST /webhooks/o2c`), or back to `polling`. The event feed is written in both modes and stays the record. Repeatable: the mode it already has changes nothing. Turning the push on with no active endpoint subscribed to a credit event is `400` `CREDIT_820`. Refused with `403` `CREDIT_818` while an operator holds the mode (`event_delivery_locked`), and `403` `CREDIT_819` on a program an operator set to `webhook`. Parameters: - program_id (path, string, required): The program. Request body (CreditEventDeliveryRequest): - event_delivery_mode (string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/history/import Dry-run or attach a staged payments or statements history file Attaches a staged history file across the program's lines, in the request, under one savepoint: with `dry_run` (the default), or a control total that does not match, nothing is attached. A payment is attached with the split the previous system gave it, or a split derived oldest loan first and interest, fee, principal within a loan, against what each loan carried as paid at import, recorded on the row; it must be dated before the line's cut-over and never splits more onto a loan than the loan carried as paid. A statement is attached as issued, outside every DayZero statement period. Nothing moves a balance, posts a journal or appends an event. Idempotent on the partner's payment or statement id. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - program_id (path, string, required): The program. Request body (HistoryImportRequest): - staging_id (string, required) - dry_run (boolean, optional) - expected_count (integer, optional) - expected_amount_cents (integer, optional) - dry_run_token (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/history/import/parse Upload a payments or statements history file Phase 2 of the migration (Appendix E): stage the previous system's payments (`kind=payments`) or statements (`kind=statements`) as CSV or XLSX, beside the loan file. The mapping is inferred (or given as `mapping`, a JSON object of field to column) and every row is staged for seven days with its problems; nothing is attached. A payments file has one row per payment, or one per loan a payment was split across, each repeating the payment's id, amount and date; a row without a loan has its split derived at the run. A statements file has one row per statement, naming its document. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - program_id (path, string, required): The program. Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/programs/{program_id}/import-batches A program's loan files, newest first Every loan file staged on the program, newest first, paged. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - program_id (path, string, required) - limit (query, integer, optional): Page size (1-100). - cursor (query, string, optional): `next_cursor` from the previous page. - kind (query, string, optional): Which files: `loans` (the default), or the history files `payments` or `statements`. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/programs/{program_id}/integration-guide Integration blueprint and code snippets for a program Returns the tailored integration steps and ready-to-run cURL, TypeScript and Python snippets for connecting an external system to this credit program (`open_line`, `connect_bank`, `ingest_settlements`, `record_payment`, `consume_events`), along with the program's card issuer, bank feed provider, event delivery mode and paired sandbox business id. Parameters: - program_id (path, string, required): The program's id. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/loans/import Dry-run or apply a staged loan file across the program Fans the staged rows out to each line's loan import (1,000 rows per call) under one savepoint. With `dry_run` (the default), or any control total that does not match across the whole file, nothing is written, not one line; otherwise every line is written together. `create_missing_lines` opens a line for each key the program lacks, with `line_defaults`, through the ordinary line opening (so the program's limit envelope applies); a refusal rejects that line's rows. `mode` says where it runs: in the request (`201` with the per-line results, the totals against the control totals, and the report id), or as a background job (`202` with the batch, `status` `running`; poll `GET /credit/import-batches/{id}` for its progress and, when it finishes, the same result). `auto`, the default, runs up to 1,000 rows in the request. One run at a time per program. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - program_id (path, string, required) Request body (ProgramLoanImportRequest): - staging_id (string, required) - dry_run (boolean, optional) - as_of (string · date, optional) - expected_count (integer, optional) - expected_principal_cents (integer, optional) - expected_outstanding_cents (integer, optional) - create_missing_lines (boolean, optional) - line_defaults (ImportLineDefaults, optional) - mode (string, optional) - allow_cross_line_duplicates (boolean, optional) - dry_run_token (string, optional) - history (boolean, optional) Responses: 201, 202, 400, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/loans/import/from-partner-pull Build and stage the migration file from a stored pull Sandbox only: pulls are kept on a sandbox business (`CREDIT_090` elsewhere), so this is the console's rehearsal of the cut-over; the live book is built from the same files by an operator script. Reads the pull's merchants and transactions tables and builds the launch import (Appendix E): one row per loan with a balance, keyed on the Brex transaction id; its paid amounts are what Tie's system assessed less what it reports outstanding, per loan or from the merchant's balance split over its loans oldest first (D-58); its interest good through `pull_date` and, above the program's ceiling, loaded at the ceiling (D-59). With `since`, the tail: the transactions that posted from that date, loaded as they posted (D-60). The file is staged on the program's loan import, and `run` is what to send with `staging_id` to `POST /credit/programs/{id}/loans/import` for the dry run and the apply. `report` is the exceptions report: rows refused and why, the lines and which are not open yet, interest reduced to the ceiling, loans repaid before cut-over (phase 2), and the control totals. `open_lines` also opens each merchant's line with its own terms, a merchant with no balance included, and sets its email, legal name and address; send it before the apply. `400` `CREDIT_770` when `since` is after `pull_date`, `CREDIT_771` when nothing would be imported, `CREDIT_772` for a mapping field the builder does not read, `CREDIT_773` for a cut-over pull with no merchants table. Parameters: - program_id (path, string, required): The program to stage the file on. Request body (MigrationFromPullRequest): - pull_id (string, required) - pull_date (string · date, required) - since (string · date, optional) - roles (object, optional) - mapping (MigrationFieldMapping | string, optional) - balance_basis (string, optional) - line_key (string, optional) - open_lines (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/loans/import/parse Upload a loan file and infer its mapping Step one of the loan migration wizard. Upload the previous system's export as CSV or XLSX (10 MB and 20,000 rows at most). DayZero infers which column is which (header names first, then the values), or starts from `mapping_name` (a mapping saved on the program, or the built-in `brex`), with `mapping` (a JSON object of field to column) applied by hand on top. Every row is normalised to the loan import shape and staged for seven days; nothing is written to the book. Returns the columns with sample values, the mapping with a confidence and reason per field, the unit of the money, the rows grouped by line key, the keys with no line on the program, and the row problems. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - program_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/mcc-allowlist/apply Apply an MCC allow list Writes `codes` as the program's `allowed_mcc_codes`, pushes the restriction to every live DayZero-managed card on the program's lines (as the Ramp categories the MCCs fall under), and records the source and, for an upload, the file's SHA-256 in the audit log. A card the issuer refuses is reported in `cards` and does not undo the list. `codes: []` with `unrestricted: true` clears the list as a recorded decision. Operator action. Parameters: - program_id (path, string, required) Request body (MccAllowlistApplyRequest): - codes (array · string, optional) - source (string, required) - file_sha256 (string, optional) - unrestricted (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/mcc-allowlist/preview Preview an MCC allow list Builds the allow-list table from one source: an uploaded card export (`multipart/form-data` with a `file` part, CSV or JSON), the program's own settlements over `window_days` (`source: settlements`), or a curated list (`source: preset`, `preset: ad_spend`). Every source returns the same table: per MCC its description, transactions, spend, the Ramp category it reaches the issuer as or `unmapped`, and whether it is suggested. Changes nothing. Operator action. Parameters: - program_id (path, string, required) Request body: - source (string, required) - window_days (integer, optional) - preset (string, optional) - min_count (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/programs/{program_id}/partner-keys List a program's partner API keys The live API keys held to this program, whoever created them, with `has_active_key` and `expiring_soon` (an active key expiring within 30 days). Never a key's secret. Operator action: an API token receives `403`; owners and admins of the business only. Parameters: - program_id (path, string, required): The credit program's id. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/partner-keys Create a partner API key for a program Mint a `credit` key (`access: full`), a `credit:read` key (`read`), a `credit:mapping` key (`mapping`) or a `credit:payments` key (`payments`) limited to this business and this program, named after the program unless `name` is sent and expiring in `expires_in_days` (default and cap 365). The key is in `token`, shown only in this response; the partner stores it as `DAYZERO_API_TOKEN`. Operator action: an API token receives `403`; owners and admins only, with the two-factor step-up of `POST /tokens` (`AUTH_050`, `AUTH_056`) and its API access rule (`AUTH_069`). Parameters: - program_id (path, string, required): The credit program's id. Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/programs/{program_id}/partner-keys/{token_id}/check Test a program's partner API key What `GET /credit/me` would answer for one of the program's keys, worked out as the key's owner with the same code: the `/credit/me` body as `me`, or the exact error. Never the key's secret. Operator action: an API token receives `403`; owners and admins only. Parameters: - program_id (path, string, required): The credit program's id. - token_id (path, string, required): The partner key's id. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/partner-keys/{token_id}/revoke Revoke a program's partner API key Revoke one of the program's keys at once, whoever created it. Operator action: an API token receives `403`; owners and admins only. Parameters: - program_id (path, string, required): The credit program's id. - token_id (path, string, required): The partner key's id. Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/partner-keys/{token_id}/rotate Rotate a program's partner API key Mint a replacement that keeps the key's scope, business and program limits, and keep the old key working for `overlap_hours` (default 24). Only the key's creator may rotate it (`403` `AUTH_112` otherwise). Operator action: an API token receives `403`; same step-up as creating a key. Parameters: - program_id (path, string, required): The credit program's id. - token_id (path, string, required): The partner key's id. Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/programs/{program_id}/readiness Launch readiness of a program The program's launch checks, evaluated now. Nothing is stored. Each check carries `key`, `area`, `status` (pass, warn, fail, not_applicable), `blocking`, `summary`, `detail`, `subjects` and `resolve` (`kind` console, api or staff, and its `target`). `ready` is true when no blocking check fails. Parameters: - program_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/readiness/evaluate Evaluate and store a program's launch readiness Console operators only. Evaluates the checks and stores the result (`source: manual`, with its `result_id`). The nightly sweep compares each night's checks with the last stored result to alert on a check that passed and now fails. Each check carries `key`, `area`, `status` (pass, warn, fail, not_applicable), `blocking`, `summary`, `detail`, `subjects` and `resolve` (`kind` console, api or staff, and its `target`). `ready` is true when no blocking check fails. Parameters: - program_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/credit/programs/{program_id}/scorecards List a program's scorecards Each scorecard with its versions, newest first. The default scorecard's active version is what an assessment uses when it names none. A program whose criteria were set before versions existed, or through `PATCH /credit/programs/{id}`, shows them here as an active version. Parameters: - program_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/scorecards Create a scorecard Console operators only. Starts a scorecard whose first version is a draft: copied from `copy_from_version_id`, built from the supplied criteria, or — with neither — copied from the program's active scorecard. Nothing is used by an assessment until a version is validated, approved and activated. Parameters: - program_id (path, string, required) Request body (ScorecardCreateRequest): - name (string, required) - description (string, optional) - copy_from_version_id (string, optional) - criteria (array · object, optional) - manual_checks (array · object, optional) - grade_bands (array · object, optional) - scoring (object, optional) - is_default (boolean, optional) - required_approvals (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/programs/{program_id}/scorecards/from-seed Start the scorecard from a seed Console operators only. Creates a draft version from a seed DayZero ships (`GET /credit/scorecard-seeds` lists them; `standard` is the launch credit-line scorecard) on the program's default scorecard, or as the first version of a new one. The active version's criteria stay as the program layer. The draft is not validated, approved or activated: that is the existing review step. Sending it again while that draft is open and unchanged returns it with `created: false`; any other open draft is refused (`CREDIT_678`). Parameters: - program_id (path, string, required) Request body (ScorecardSeedRequest): - seed (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/readiness Launch readiness of every program Every program on the business, newest first, each with its launch checks evaluated now. Nothing is stored. Each check carries `key`, `area`, `status` (pass, warn, fail, not_applicable), `blocking`, `summary`, `detail`, `subjects` and `resolve` (`kind` console, api or staff, and its `target`). `ready` is true when no blocking check fails. Parameters: - limit (query, integer, optional): Programs per page. - cursor (query, string, optional): `next_cursor` of the last page. Responses: 200, 400, 401, 403, 422 ### POST /api/v1/credit/receivables Push a merchant's invoices to its customers Name the merchant as on `POST /credit/bank-feeds` (`program_id` and `external_merchant_id`, or `credit_line_id`); DayZero uses its business, creating it the first time, and gives your token read access to it. Upserts invoices by `invoice_id` (customer, amount, issued, due and paid dates). `revenue_concentration_top_customer` reads them when the merchant has no DayZero invoices (`evidence.source: partner_receivables`): the top customer's share of the last 365 days' invoiced total, void invoices left out. Request body (ReceivablesPushRequest): - program_id (string, optional) - external_merchant_id (string, optional) - credit_line_id (string, optional) - merchant_legal_name (string, optional) - merchant_business_id (string, optional) - invoices (array · ReceivableItem, required) → ReceivableItem Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/sandbox/advance Move the sandbox clock Sandbox only. Runs the daily sweep as of `to`, which catches up every accrual day and closes every period that ended. Statements are not emailed. Request body (SandboxAdvanceRequest): - to (string · date, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/credit/sandbox/bank-connections/{bank_connection_id}/complete Finish a sandbox bank connection Sandbox only. Does what the merchant does in Link: `completed` lands a synthetic bank (by default one checking account, Sandbox Business Checking ending 0000) on the merchant's business, marked as already synced, and finishes the connection as a live one finishes: the accounts, the repayment account on the line, `credit.bank_connection.completed`. `exited` fails it (`credit.bank_connection.failed`). A connection that is no longer pending is `400` `CREDIT_786`; a live business is `400` `CREDIT_090`. Parameters: - bank_connection_id (path, string, required): The sandbox bank connection to finish. Request body (SandboxBankConnectionCompleteRequest): - outcome (string, optional) - institution_name (string, optional) - accounts (array · SandboxBankAccountSpec, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/sandbox/card-transactions Clear, void or dispute a card transaction Sandbox only. Reports a transaction on a mock-issued card the way Ramp's webhook would, and sends it through the same ingest: a `cleared` purchase becomes a loan with no call from you, a negative amount is a refund, a `voided` one reverses the loan (or holds it when money was paid on it), a `disputed` one opens a hold. Returns what happened. A card on a live issuer program is `CREDIT_710`; a void or dispute of a transaction the book does not hold is `CREDIT_711`. Request body (SandboxCardTransactionRequest): - card_id (string, required) - kind (string, optional) - amount_cents (integer, optional) - merchant_name (string, optional) - merchant_category_code (string, optional) - settled_on (string · date, optional) - issuer_transaction_id (string, optional) - refund_of_issuer_transaction_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/sandbox/jobs/{job_id} A sandbox job Its status (`queued`, `running`, `succeeded`, `failed`), the request, and the result when it succeeded or the error when it failed. `stale` is true for a job still queued or running past its one-hour limit: it will not finish, and nothing was written. Parameters: - job_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/credit/sandbox/lines/{credit_line_id} Delete one sandbox line Sandbox only. Deletes one credit line and everything under it (events, ledger, payments, loans, settlements, cycles, cards, assessments, the walk recorded on it) and forgets its cards on the mock issuer. The business's other lines, programs and scorecards stay. Send `confirm` as the line's id or `"DELETE"` (`CREDIT_761` otherwise). Refused with `409` `CREDIT_760` while a sandbox job is queued or running on the business. Parameters: - credit_line_id (path, string, required): The sandbox line to delete. Request body (SandboxLineDeleteRequest): - confirm (string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/credit/sandbox/partner-export Seed the sandbox from a partner export Sandbox only. `multipart/form-data` with a `transactions` file and optional `merchants` and `payments` files (DynamoDB export or scan output, a JSON list, or a CSV), or a `pull_id` from `POST /credit/sandbox/partner-pulls` in their place (both, or neither, is `CREDIT_684`; `roles` says which table of the pull is which when it could not be worked out), the `program_id` to seed, and an optional `mapping` (JSON naming the partner's fields, or `auto`). The merchants file may carry `disbursement_fee_bps`, `rate_bps` and `merchant_legal_name`, used to open new lines (a line the merchant already has keeps its own terms; the plan lists any the file contradicts). Two optional files, uploaded with files or with a `pull_id`: `opening_loans` (loans open before the export starts, with their fee, paid buckets and interest to date, loaded through the loan import as at `opening_as_of`, which is then required and must be before every transaction, payment and write-off: `CREDIT_755`, `CREDIT_756`) and `write_offs` (merchant, the loan's transaction id, `written_off_on`, optional `amount`; applied in date order with the payments, interest stopping on the day). Returns the plan as figures and as text, and warnings for any value that looks like a real person's email or phone number. A dry run (`200`) unless `dry_run` is `false`: then everything a run would refuse is refused here, and the book is written by a sandbox job (`202` with the job; poll `GET /credit/sandbox/jobs/{id}` until `succeeded`, when `result` is this response with `counts`, including each payment, opening loan or write-off the engine refused and why). One seed at a time per program (`CREDIT_757`). Applying is refused while warnings stand unless `allow_unredacted` is `true` with a `reason`, which is logged and audited. Responses: 200, 202, 400, 401, 403, 404, 422 ### GET /api/v1/credit/sandbox/partner-pulls List registered pulls Sandbox only. The business's pulls, newest first, each with its tables (item counts and roles), whether it is redacted, when it was scanned and when it expires. Expired pulls are removed when this is called. Parameters: - limit (query, integer, optional): Pulls per page (1-200). - cursor (query, string, optional): `next_cursor` from the last page. - include_total_count (query, boolean, optional): Also count every pull the business has registered. Responses: 200, 400, 401, 403, 422 ### POST /api/v1/credit/sandbox/partner-pulls Register a pull of a partner's data Sandbox only. `multipart/form-data` with the pull's `manifest` (manifest.json) and every NDJSON file it names as `files`. Each file's SHA-256 is checked against the manifest (`CREDIT_681`), the files are read for real emails and phone numbers whatever the manifest says, and a pull that is not redacted is refused (`CREDIT_673`) unless `allow_unredacted` is `true` with a `reason` (`CREDIT_674`). `roles` (JSON of role to table name) says which table is `transactions`, `merchants` or `payments`; the rest are worked out from the columns, and a table that cannot be placed keeps a null role. The files are stored for 30 days. Seed from it with `pull_id` on `POST /credit/sandbox/partner-export`. Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/credit/sandbox/partner-pulls/{pull_id} Delete a registered pull Sandbox only. Removes the pull and its stored files. Books already seeded from it are not touched. Parameters: - pull_id (path, string, required): The pull to delete. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/sandbox/provision Create the paired sandbox Console operators only, on the live business. Creates " (Sandbox)": a sandbox business with the same firm links and members (same roles), a copy of every credit program's configuration issuing from the mock issuer, and each program's active scorecard versions. No lines, loans or cards. Mints a `credit` API token limited to the sandbox and returns it once (`token`). Calling it again returns the same sandbox (`created: false`) and mints a token only with `mint_token: true`. DayZero staff acting by elevation get no membership and no token (`token_note`), and `mint_token: true` from them is 403 `CREDIT_584`. 400 `CREDIT_580` on a sandbox; 400 `CREDIT_582` when the paired business is no longer a sandbox. Request body (SandboxProvisionRequest): - mint_token (boolean, optional) - token_expires_in_days (integer, optional) Responses: 201, 400, 401, 403, 404, 422, 429 ### POST /api/v1/credit/sandbox/reset Start the sandbox over Sandbox only. Deletes every credit line on this business and everything under it (events, ledger, payments, loans, settlements, cycles, cards, assessments) and clears the mock issuer. Programs and scorecards stay. Send `confirm: "RESET"`. Refused with `409` `CREDIT_760` while a sandbox job (a generated book) is queued or running on the business. Request body (SandboxResetRequest): - confirm (string, required) Responses: 201, 400, 401, 403, 409, 422 ### POST /api/v1/credit/sandbox/scenarios/appendix-b Stage the Appendix B book Sandbox only. Seeds one line with the FRD Appendix B book: five March settlements, March's close, a $30,000 payment on 15 April, and closes through `as_of`. Built through the same services as a partner-export seed. Idempotent per `external_line_id`. Request body (AppendixBScenarioRequest): - program_id (string, required) - external_line_id (string, optional) - as_of (string · date, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/sandbox/scenarios/portfolio-50 Generate a whole sandbox book from a seed Sandbox only. Queues a job that generates `merchants` merchants (default 50) over `months` months (default 6) from `seed` through the real services: lines opened, settlements and refunds ingested, statements closed and interest accrued month by month, payments recorded on time, late and in part, one returned, one dispute, one write-off, and lines at every collections stage. Poll `GET /credit/sandbox/jobs/{id}` until `status` is `succeeded` or `failed`. The same seed, size and `as_of` always give the same book (`result.loan_tape_digest`). Asking again while the seed's job is queued or running returns that job (`created: false`), unless it is `stale` (past its one-hour limit): that job is recorded `failed` and a new one is queued. Request body (PortfolioScenarioRequest): - seed (integer, optional) - merchants (integer, optional) - months (integer, optional) - program_id (string, optional) - as_of (string · date, optional) Responses: 202, 400, 401, 403, 404, 422 ### POST /api/v1/credit/sandbox/sync-config Copy program configuration to the sandbox again Console operators only, on the live business. Copies every program's configuration onto the paired sandbox's copy (creating a copy for a program added since), and copies any scorecard version the live business has activated since, making it active on the sandbox. Makes the sandbox's memberships, firm links and client access mirror the live business (`access`), clears alert destinations a copy still shares with live, and lists sandbox tokens held by DayZero staff who are not members (`superuser_tokens`). Reports what changed per program. Never touches lines, loans or cards. 400 `CREDIT_581` when there is no paired sandbox. Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/sandbox/walks Record a walk of Appendix B Sandbox only. Keeps the result of a walk run by the validator (`scripts/admin/credit/validate_credit_e2e.py`) as the sandbox's last walk, which the live business's launch checklist reads. The walk passes only if every step was judged and matched: a step with a null `passed` is not a pass. The statements' close and due dates are read from the line and stored with it. Staging the book records a walk too; this one replaces it as the latest. Request body (SandboxWalkRequest): - program_id (string, required) - credit_line_id (string, required) - steps (array · SandboxWalkStep, required) → SandboxWalkStep Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/scorecard-backtests/{backtest_id} Get a backtest Progress while it runs; on completion, the per-criterion pass, required-fail and unmeasured counts, the score distribution, the grade mix and one row per business. Parameters: - backtest_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/scorecard-backtests/{backtest_id}/export Download a backtest as CSV One row per business: the roll-up, then each criterion's value, threshold and result. Parameters: - backtest_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/scorecard-seeds The scorecard seeds DayZero ships Every seed a program's scorecard can be started from: one per `_scorecard_seed.json` file in the API's seeds folder, with the name and description the file carries and what it holds. Pass an `id` as `seed` to `POST /credit/programs/{id}/scorecards/from-seed`. Responses: 200, 401, 403, 422 ### GET /api/v1/credit/scorecard-versions/{from_version_id}/diff/{to_version_id} Compare two scorecard versions Criteria and manual checks added, removed or changed from the first version to the second, with before and after for each changed field, and whether grade bands or scoring differ. To see which businesses come out differently, run a backtest with `compare_version_id`. Parameters: - from_version_id (path, string, required) - to_version_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/credit/scorecard-versions/{version_id} Discard a draft version Console operators only. Deletes a draft; any other status answers 409. The audit trail keeps what was discarded. Parameters: - version_id (path, string, required) Responses: 200, 401, 403, 404, 409, 422 ### GET /api/v1/credit/scorecard-versions/{version_id} Get a scorecard version The version's criteria, manual checks, grade bands and scoring policy, its lifecycle, and the report from its last validation. Parameters: - version_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/credit/scorecard-versions/{version_id} Edit a draft version Console operators only, and drafts only: any other status answers 409. Each section supplied replaces that section whole. Rows may be unfinished; the validator says what is missing. Editing a validated draft returns it to `draft`. Parameters: - version_id (path, string, required) Request body (ScorecardVersionUpdateRequest): - criteria (array · object, optional) - manual_checks (array · object, optional) - grade_bands (array · object, optional) - scoring (object, optional) - change_note (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/credit/scorecard-versions/{version_id}/activate Activate an approved version Console operators only, with a fresh two-factor check. New assessments use this version from now on; the one that was active is retired. Assessments already requested keep the version they were requested against. Only an `approved` version (or a retired one, to roll back) can be activated — 409 otherwise. Parameters: - version_id (path, string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/credit/scorecard-versions/{version_id}/approve Record approval of a validated version Console operators only, with a fresh two-factor check. Records the partner's sign-off — who approved, a note saying where that is on record, and optionally the document. Only a `validated` version can be approved (409 otherwise). A scorecard that needs more than one approval becomes `approved` on the last. Parameters: - version_id (path, string, required) Request body (ScorecardApproveRequest): - approver_name (string, required) - note (string, optional) - attachment_s3_key (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/credit/scorecard-versions/{version_id}/backtest Backtest a version over a cohort Console operators only. Queues a run of the version over up to 500 businesses and returns the job; poll `GET /credit/scorecard-backtests/{id}` until `status` is `completed` or `failed`. Each business is measured once and scored; pass `compare_version_id` to score it under a second version too and learn which businesses come out differently. Measures only: no assessment is created and no event is emitted. Parameters: - version_id (path, string, required) Request body (ScorecardBacktestRequest): - business_ids (array · string, optional) - firm_id (string, optional) - limit_mode (string, optional) - requested_limit_cents (integer, optional) - requested_limits_cents (object, optional) - requested_term_days (integer, optional) - as_of (string · date, optional) - compare_version_id (string, optional) Responses: 202, 400, 401, 403, 404, 422 ### GET /api/v1/credit/scorecard-versions/{version_id}/backtests List a version's backtests Recent backtests, newest first, with summaries but not per-business rows. Parameters: - version_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/scorecard-versions/{version_id}/preview Test a version against a business Measures the business and returns exactly what an assessment would: per-criterion value, resolved threshold, pass, fail or unmeasured with the reason, the score, the grade and `required_failed`. Nothing is saved and no event is emitted. Works on any version, drafts included. `passed: null` is unmeasured, not failed. `decision` is always null. Parameters: - version_id (path, string, required) Request body (ScorecardPreviewRequest): - business_id (string, optional) - requested_limit_cents (integer, optional) - requested_term_days (integer, optional) - as_of (string · date, optional) - segment (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/scorecard-versions/{version_id}/validate Validate a scorecard version Checks every criterion and stores the report on the version: each key has a measurer (a required one must), units agree with the measure, comparators and conditions are well-formed, weights are 0 or more. A draft with no errors becomes `validated`; warnings do not block. `validator_report.messages` addresses each finding to its row and field. It stores the report and can move the draft, so it needs the same permission as any write: a viewer, or a `credit:read` token, is refused with 403. Parameters: - version_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/scorecards/validate Validate a scorecard before putting it on a program The framework for the partner's underwriting scorecard (§9.4). Checks the criteria shape and reports which keys DayZero can measure today. Unmeasured keys are allowed and report as unmeasured on every assessment; a *required* unmeasured key means an assessment can never pass, so it is called out. Nothing is saved: put the scorecard on the program with `PATCH /credit/programs/{id}` (`underwriting_criteria`), or author it as a version under `/credit/programs/{id}/scorecards`. `messages` addresses each finding to its row and field; pass `strict: true` for the rules a version must meet to be approved. Request body (ScorecardValidateRequest): - underwriting_criteria (array · object, required) - manual_checks (array · object, optional) - grade_bands (array · object, optional) - scoring (object, optional) - strict (boolean, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/credit/scorecards/{scorecard_id} Get a scorecard One scorecard with its versions. Parameters: - scorecard_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/credit/scorecards/{scorecard_id} Update a scorecard's settings Console operators only. Rename it, make it the program's default, or set how many recorded approvals a version needs (`required_approvals`). The rules themselves are changed through a draft version. Making it the default changes the rules new assessments are measured against, so, like activating a version, it asks for a fresh two-factor check; so does lowering `required_approvals`, which removes a sign-off. Renaming it or raising `required_approvals` does not. Parameters: - scorecard_id (path, string, required) Request body (ScorecardUpdateRequest): - name (string, optional) - description (string, optional) - is_default (boolean, optional) - required_approvals (integer, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit/scorecards/{scorecard_id}/audit A scorecard's audit trail Who created, edited, validated, approved, activated or retired each version, and when, with the before and after. DayZero's internal record: these are not events on the partner feed. Parameters: - scorecard_id (path, string, required) - version_id (query, string, optional): Limit to one version. - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/scorecards/{scorecard_id}/versions List a scorecard's versions Versions, newest first, without their definitions. Parameters: - scorecard_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/scorecards/{scorecard_id}/versions Start a new draft version Console operators only. A version cannot be edited once it leaves draft, so changing an approved or active scorecard means a new draft copied from it. One draft may be open per scorecard; a second answers 409 with the open draft's id. Parameters: - scorecard_id (path, string, required) Request body (ScorecardDraftCreateRequest): - copy_from_version_id (string, optional) - change_note (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/credit/shopify-pull Pull a merchant's Shopify underwriting data with a salted ephemeral token For partners that hold the merchant's Shopify Admin API token in their own vault and pass it encrypted (`PBKDF2-HMAC-SHA256` with a per-request random `salt` + `AES-256-GCM` bound to `shop_domain` + salted SHA-256 `token_hash`). DayZero decrypts the token only in memory, queries Shopify for orders, daily sales and refund summaries, disputes, and Shopify Capital balance transactions onto the merchant's DayZero business, and discards the plaintext token. Only the irreversible salted SHA-256 fingerprint (`sha256:{salt}:{hash}`) is stored in the database. Request body (ShopifyPullRequest): - program_id (string, optional) - external_merchant_id (string, optional) - credit_line_id (string, optional) - merchant_legal_name (string, optional) - merchant_business_id (string, optional) - shop_domain (string, required) - encrypted_token (string, required) - salt (string, required) - iv (string, required) - auth_tag (string, required) - token_hash (string, required) - key_id (string, optional) - wrapped_key (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/statements List statements across every line Every issued statement on the business's lines, newest period first: borrower, line, period, issued and due dates, status, the issued opening and closing balance, interest and fees, and the PDF and CSV links. `credit_line_id` narrows it to one line. Parameters: - credit_line_id (query, string, optional): Only this line. - cursor (query, string, optional): `next_cursor` of the last page. - limit (query, integer, optional): Statements per page. Responses: 200, 400, 401, 403, 422 ### POST /api/v1/credit/sweeps/daily Run the daily credit sweep DayZero internal; the nightly schedule runs this per business. Runs every step of the nightly sweep in order (the steps are listed under What runs on DayZero's schedule in the guide, and each run's `steps` names them). Each step that fails is recorded and the rest still run (`status: partial`); the run is logged under `GET /credit/sweeps/runs/{run_id}`. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Request body (DailySweepRequest): - as_of (string · date, optional) - accrue (boolean, optional) - close_periods (boolean, optional) - push_spend_limits (boolean, optional) - sync_cards (boolean, optional) - reconcile_settlements (boolean, optional) - recognize_fees (boolean, optional) - recognize_interchange (boolean, optional) - snapshot_bank_balances (boolean, optional) - email_statements (boolean, optional) - send_notices (boolean, optional) - run_assessments (boolean, optional) - alert_adverse_actions (boolean, optional) - review_limits (boolean, optional) - verify_ledgers (boolean, optional) - check_covenants (boolean, optional) - evaluate_readiness (boolean, optional) - run_collections (boolean, optional) - match_bank_settlements (boolean, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/credit/sweeps/runs List daily-sweep runs The daily sweep's runs for this business, newest first: when each ran and for which date, what started it (`scheduled`, `manual`, `sandbox_advance`), its status (`succeeded`, `partial` when a step failed and the rest ran, `failed`), and every step with its status, counts and duration. Parameters: - status (query, string, optional): Comma-separated: running, succeeded, partial, failed. - limit (query, integer, optional) - cursor (query, string, optional): `next_cursor` from the last page. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/credit/sweeps/runs/{run_id} Get one daily-sweep run One run with every step. Parameters: - run_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/sweeps/runs/{run_id}/rerun-step Re-run one step of a daily-sweep run Runs the step again for the run's date and records the attempt on the run: the step's status and counts are replaced, the attempt is added to its `reruns`, and the run's status is recomputed. The money steps are idempotent per loan per day; a step that calls out (bank balances, card sync) calls out again. A live business may not re-run a date that has not happened; a sandbox may. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - run_id (path, string, required) Request body (SweepStepRerunRequest): - step (string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/underwriting/assessments List underwriting assessments Assessments for this business, newest first. Parameters: - credit_line_id (query, string, optional) - limit (query, integer, optional) - cursor (query, string, optional) - include_total_count (query, boolean, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/credit/underwriting/assessments Request an underwriting assessment Returns a pending assessment. Bank backfill, categorisation, and trailing-ratio history can take up to three days, so callers must not assume a synchronous answer — poll the get endpoint or subscribe to the completion event. While it waits, `waiting_on` names the data still landing and `wait_deadline` when the sweep completes it regardless. The result is evidence: approve or decline the completed assessment with `POST /credit/underwriting/assessments/{assessment_id}/decision`. The assessment is measured against the active version of the program's scorecard unless `scorecard_version_id` names another, and records which one. Send `requested_limit_cents`: rules written as a multiple of the limit report unmeasured without it. An unknown `program_id` is `404`; a program with no active scorecard (and no `scorecard_version_id` or `criteria_override` in the request) is `409` `CREDIT_POLICY_UNDECIDED`. Request body (UnderwritingAssessmentRequest): - measurement_source_mode (string, optional) - credit_line_id (string, optional) - external_application_id (string, optional) - program_id (string, optional) - criteria_override (array · object, optional) - scorecard_version_id (string, optional) - requested_limit_cents (integer, optional) - requested_term_days (integer, optional) - subject_business_id (string, optional) - evaluate_if_ready (boolean, optional) - auto_approve (boolean, optional) - external_merchant_id (string, optional) - merchant_legal_name (string, optional) - merchant_email (string, optional) - merchant_state (string, optional) - merchant_address (MerchantAddress, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/credit/underwriting/assessments/{assessment_id} Get an underwriting assessment Each criterion carries its value, the threshold it was measured against, a pass or fail, and the source the figure came from. Assessment `status: failed` means unusable evidence, not a decline. `status: pending` with `waiting_on` means data is still arriving. A completed assessment with `auto_approval.status: held` and reason `manual_checks_pending` awaits required reviews; `not_eligible` and its `reasons` mean automatic approval was blocked, not declined. Only `decision.status: declined` is a final decline. Failed criteria and checks alone neither create nor send a decline notice. `decision` is null until the lender records one (see `POST /credit/underwriting/assessments/{assessment_id}/decision`). The decision's internal `note` and `decided_by` are in the console's view only, never an API token's. Parameters: - assessment_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/underwriting/assessments/{assessment_id}/adverse-action Adverse-action reasons for an assessment The scorecard criteria the assessment measured and failed, required ones first and then by weight, each with what was measured, the threshold, which side of it the figure fell, and a template sentence. Empty while the assessment is pending or when nothing failed. No notice is sent. Parameters: - assessment_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/credit/underwriting/assessments/{assessment_id}/audit An assessment's review trail Manual-check attestations and note changes on the assessment, newest first. Parameters: - assessment_id (path, string, required) - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit/underwriting/assessments/{assessment_id}/completion Complete an underwriting assessment Scores measured figures against the program's criteria set and closes the assessment. Returns per-criterion value, threshold, pass or fail, and source, plus roll-up counts and a weighted score. A criterion we could not measure comes back `passed: null` rather than false — those call for opposite actions. No recommendation is returned at any point. The figures are the caller's own, so a token cannot score a live merchant with them: open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - assessment_id (path, string, required) Request body (UnderwritingCompletionRequest): - measured_values (object, required) - financials (object, optional) - evidence (object, optional) - segment (string, optional) - manual_checks (array · ManualCheckAttestation, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit/underwriting/assessments/{assessment_id}/decision Record the lender's decision on an assessment Records `approved` or `declined` on a completed assessment, with an optional `merchant_message` shown to the merchant as written and an internal `note` (never returned to an API token or put in an event). Approving opens the merchant's line through the path auto-approval uses (`approved_limit_cents` and `approved_term_days` default to the requested ones and must fit the program, `CREDIT_512` and `CREDIT_513`), or links the line already open for the merchant; `open_line: false` records the approval and opens nothing. If the line cannot be opened nothing is recorded. Declining queues the adverse-action notice when the program's compliance policy has it on. Emits `credit.underwriting.decided`. One decision per assessment: repeating it returns the record (`200`), a different one is `409` `CREDIT_553`; a pending or failed assessment is `409` `CREDIT_552`. An API token with the `credit` scope, or a console operator (a live business needs a fresh two-factor check). Parameters: - assessment_id (path, string, required): The completed assessment to decide. Request body (UnderwritingDecisionRequest): - decision (string, required) - decline_reason_codes (array · string, optional) - merchant_message (string, optional) - note (string, optional) - approved_limit_cents (integer, optional) - approved_term_days (integer, optional) - approved_rate_bps (integer, optional) - open_line (boolean, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/credit/underwriting/assessments/{assessment_id}/manual-checks/{check_id} Attest a manual check Records a person's review of one of the scorecard's manual checks — the policy items no data can measure. `attested` means reviewed and satisfied; `exception` means reviewed with an exception noted; `failed` means reviewed and not satisfied; `pending` clears an earlier attestation. A check with `evidence_required` needs an `attachment_s3_key`. Manual checks never change the score. On an `auto_approve` assessment held for its `required` checks (`auto_approval.status: held`), attesting the last one opens the line (`decided_via: auto`). A required check `failed` blocks automatic approval; only a final decline queues an adverse-action record. Parameters: - assessment_id (path, string, required) - check_id (path, string, required) Request body (ManualCheckAttestRequest): - status (string, required) - note (string, optional) - attachment_s3_key (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/credit/underwriting/assessments/{assessment_id}/notes Save reviewer notes on an assessment Free-text notes from whoever reviewed the assessment. Notes are not the decision: approve or decline with `POST /credit/underwriting/assessments/{assessment_id}/decision`. Parameters: - assessment_id (path, string, required) Request body (AssessmentNotesRequest): - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit/underwriting/assessments/{assessment_id}/run Measure and complete an assessment from DayZero data DayZero internal; the daily sweep runs this for every pending assessment. Measures each criterion that has a registered measurer from the categorised ledger, the bank feed, and the debt schedule, and completes the assessment with the figures and their evidence. Criteria without a measurer are reported unmeasured, never failed. No verdict is returned. The sweep waits for the merchant's bank backfill, categorisation and Shopify sync (up to the program's `underwriting_wait_days`) and reports what it is waiting on in `waiting_on`; this call does not wait, and completes at once with whatever data exists. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`). Parameters: - assessment_id (path, string, required) Request body (UnderwritingRunRequest): - as_of (string · date, optional) - segment (string, optional) - fail_if_unmeasurable (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit/underwriting/measurers Criterion keys DayZero can measure Every key a scorecard may name and be measured on: its unit, source, how far back it reads, the connections a merchant needs for it to produce a figure, and the evidence it returns. Parameters: - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/credit/underwriting/scorecard-vocabulary What a scorecard may be written with Comparators, units, threshold bases, the facts a condition may test, scoring policies and manual-check statuses. An editor builds its controls from this, so it needs no change when one is added. `score_formula` states how `score_bps` is computed. Responses: 200, 401, 403, 422 ### GET /api/v1/credit/underwriting/subject-businesses Businesses a scorecard can be tested against Every business the caller can access, grouped by the workspace it belongs to, with the credit line it holds on this operator when it has one. These are the businesses a preview or a backtest may name. Parameters: - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 401, 403, 422 ## credit-bank-activity ### GET /api/v1/credit-bank-activity/bank-accounts Credit List Bank Accounts The Plaid-connected bank ledgers of one business. Parameters: - bank_business_id (query, string, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/credit-bank-activity/bank-businesses Credit List Bank Businesses Businesses whose bank accounts this caller may link to a program. Responses: 200, 401, 403, 422 ### GET /api/v1/credit-bank-activity/items Credit List Bank Activity Bank activity looked at, newest bank date first. Parameters: - kind (query, string, optional) - status (query, string, optional) - limit (query, integer, optional) - cursor (query, string, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/credit-bank-activity/items/reject Credit Reject Bank Activity Many Reject several held items at once. Request body (CreditBankActivityBulkRejectRequest): - note (string, optional) - ignore_sender (boolean, optional) - activity_ids (array · string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit-bank-activity/items/{activity_id}/approve Credit Approve Bank Activity Record a held item on its suggested line, or reassign it to another. Parameters: - activity_id (path, string, required) Request body (CreditBankActivityApproveRequest): - credit_line_id (string, optional) - remember_alias (boolean, optional) - note (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit-bank-activity/items/{activity_id}/reject Credit Reject Bank Activity Not this program's money: nothing is recorded and it is not asked again. Parameters: - activity_id (path, string, required) Request body (CreditBankActivityRejectRequest): - note (string, optional) - ignore_sender (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit-bank-activity/items/{activity_id}/undo Credit Undo Bank Activity Take back a recorded repayment or draw and put the item back in review. Parameters: - activity_id (path, string, required) Request body (CreditBankActivityUndoRequest): - note (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit-bank-activity/links Credit List Bank Links Every bank ledger linked to this business's programs. Responses: 200, 401, 403, 422 ### POST /api/v1/credit-bank-activity/links Credit Save Bank Link Link a bank ledger to a program, or change the existing link. Request body (CreditBankLinkRequest): - program_id (string, required) - bank_business_id (string, optional) - ledger_id (string, required) - start_on (string · date, required) - enabled (boolean, optional) - auto_apply (boolean, optional) - hold_unmatched_deposits (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### PATCH /api/v1/credit-bank-activity/links/{link_id} Credit Update Bank Link Change a link's start date, switch it off, or hold everything for review. Parameters: - link_id (path, string, required) Request body (CreditBankLinkUpdate): - start_on (string · date, optional) - enabled (boolean, optional) - auto_apply (boolean, optional) - hold_unmatched_deposits (boolean, optional) - ignored_senders (array · string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit-bank-activity/payout-rules Credit List Payout Rules How each program recognises payouts made on a borrower's behalf. Parameters: - program_id (query, string, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/credit-bank-activity/payout-rules Credit Create Payout Rule Recognise payouts to a payee as draws, for one borrower or the one named. Request body (CreditPayoutRuleRequest): - program_id (string, required) - payee_pattern (string, required) - credit_line_id (string, optional) - fallback_credit_line_id (string, optional) - expected_fee_bps (integer, optional) - enabled (boolean, optional) - note (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### PATCH /api/v1/credit-bank-activity/payout-rules/{rule_id} Credit Update Payout Rule Change a payout rule, or switch it off. Parameters: - rule_id (path, string, required) Request body (CreditPayoutRuleUpdate): - payee_pattern (string, optional) - credit_line_id (string, optional) - fallback_credit_line_id (string, optional) - expected_fee_bps (integer, optional) - enabled (boolean, optional) - note (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit-bank-activity/scan Credit Scan Bank Activity Read every linked ledger from its start date now, as a sync would. Responses: 201, 401, 403, 422 ## credit-memos — Customer credits that can be applied to invoices. ### GET /api/v1/credit-memos List credit memos List all credit memos for the business with optional filtering. Parameters: - customer_id (query, string, optional): Filter by customer ID - status (query, CreditMemoStatusEnum, optional): Filter by status - has_remaining_balance (query, boolean, optional): Only show memos with remaining balance - search (query, string, optional): Search by credit memo number (e.g. CM-0001) - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/credit-memos Create credit memo Create a new credit memo in draft status. Request body (CreditMemoCreate): - customer_id (string, required) - amount_cents (integer, required) - restocking_fee_cents (integer, optional) - reason (CreditMemoReasonEnum, optional) → CreditMemoReasonEnum - description (string, optional) - invoice_id (string, optional) - issue_date (string · date, optional) - line_items (array · CreditMemoLineItem, optional) - internal_notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/credit-memos/customers/{customer_id}/credits Get customer available credits Get summary of available credits for a customer. Parameters: - customer_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/credit-memos/suggest AI credit memo suggestions Get AI-powered credit memo suggestions based on customer patterns. Responses: 201, 401, 403, 422 ### DELETE /api/v1/credit-memos/{credit_memo_id} Delete credit memo Delete a draft or voided credit memo. A voided memo's journal entries are deleted with it. Parameters: - credit_memo_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/credit-memos/{credit_memo_id} Get credit memo Get a specific credit memo by ID. Parameters: - credit_memo_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/credit-memos/{credit_memo_id} Update credit memo Update a draft credit memo. Parameters: - credit_memo_id (path, string, required) Request body (CreditMemoUpdate): - amount_cents (integer, optional) - reason (CreditMemoReasonEnum, optional) - description (string, optional) - invoice_id (string, optional) - issue_date (string · date, optional) - line_items (array · CreditMemoLineItem, optional) - internal_notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/credit-memos/{credit_memo_id}/apply Apply credit memo to invoice Apply a portion or all of a credit memo to an invoice. Parameters: - credit_memo_id (path, string, required) Request body (CreditMemoApplicationCreate): - invoice_id (string, required) - amount_cents (integer, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit-memos/{credit_memo_id}/issue Issue credit memo Issue a draft credit memo, making it available for application. Parameters: - credit_memo_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit-memos/{credit_memo_id}/unapply Un-apply credit memo from invoice Remove (un-link) a credit memo from an invoice, restoring balances. Parameters: - credit_memo_id (path, string, required) Request body (CreditMemoUnapply): - invoice_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/credit-memos/{credit_memo_id}/void Void credit memo Void a credit memo. Requires a reason. Parameters: - credit_memo_id (path, string, required) Request body (CreditMemoVoid): - reason (string, required) Responses: 201, 400, 401, 403, 404, 422 ## customer-statements ### GET /api/v1/customer-statements/{customer_id} Get customer statement Build an A/R statement for a customer over a date range. Parameters: - customer_id (path, string, required) - start_date (query, string · date, optional): Start of the statement period (defaults to 1 year ago). - end_date (query, string · date, optional): End of the statement period (defaults to today). - as_of_date (query, string · date, optional): Aging as-of date (defaults to end_date). Responses: 200, 401, 403, 404, 422 ### POST /api/v1/customer-statements/{customer_id}/send Email customer statement Build and email an A/R statement to the customer. Parameters: - customer_id (path, string, required) Request body (SendStatementRequest): - start_date (string · date, optional) - end_date (string · date, optional) - as_of_date (string · date, optional) - custom_message (string, optional) - cc_email (string, optional) Responses: 201, 400, 401, 403, 404, 422 ## customers — Customer records for invoicing and AR. ### GET /api/v1/customers List customers Retrieve all customers for the business with optional filtering. Parameters: - id (query, string, optional): Filter by specific customer ID - email (query, string, optional): Filter by customer email address - search (query, string, optional): Fuzzy search customers by name (uses trigram matching) - status (query, string, optional): Filter by status: active, inactive, or blocked - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/customers Create customer Create a new customer record for the business. Request body (CustomerCreateRequest): - name (string, required) - email (string · email, required) - address (string, optional) - phone (string, optional) - tax_id (string, optional) - website (string, optional) - notes (string, optional) - credit_limit_cents (integer, optional) - default_payment_term_id (string, optional) - status (CounterpartyStatus, optional) → CounterpartyStatus - category (string, optional) - invoice_footer (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/customers/analyze-payment-behavior AI payment behavior analysis Get AI-powered customer payment behavior analysis. Responses: 201, 401, 403, 422 ### POST /api/v1/customers/auto-categorize Bulk AI auto-categorize uncategorized customers Schedule AI categorization for every customer in the business that currently has no category. Returns immediately; the actual LLM calls and DB writes happen in a background task. Refresh the customer list to observe progress. Responses: 201, 401, 403, 404, 422 ### POST /api/v1/customers/bulk-upload Bulk upload customers from CSV Upload a CSV file to create multiple customers at once. Duplicate emails are skipped. Returns created/skipped counts and per-row errors. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/customers/bulk-upload/template Download bulk customer upload CSV template Get a sample CSV template with the expected columns for bulk customer upload. Responses: 200, 401, 403, 422 ### POST /api/v1/customers/categorize AI categorize customer Use AI to suggest a category for a customer based on their information. Parameters: - name (query, string, required): Customer name - email (query, string, optional): Customer email - website (query, string, optional): Customer website - address (query, string, optional): Customer address Responses: 201, 401, 403, 422 ### POST /api/v1/customers/check-duplicates Check for duplicate customers Check if a customer already exists using name, email, tax ID similarity. Parameters: - name (query, string, required): Customer name to check - email (query, string, optional): Email to check - tax_id (query, string, optional): Tax ID to check - exclude_id (query, string, optional): Customer ID to exclude (for updates) Responses: 201, 401, 403, 422 ### DELETE /api/v1/customers/{customer_id} Delete customer Soft delete a customer record. The customer is marked as deleted and hidden from list endpoints, but remains retrievable by ID so existing references on invoices and other records stay intact. Parameters: - customer_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/customers/{customer_id} Get customer Retrieve a specific customer by their unique ID. Parameters: - customer_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/customers/{customer_id} Update customer Update an existing customer's information. Parameters: - customer_id (path, string, required) Request body (CustomerUpdateRequest): - id (string, optional) - name (string, optional) - email (string · email, optional) - address (string, optional) - phone (string, optional) - tax_id (string, optional) - website (string, optional) - notes (string, optional) - credit_limit_cents (integer, optional) - default_payment_term_id (string, optional) - status (CounterpartyStatus, optional) - category (string, optional) - invoice_footer (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/customers/{customer_id}/contacts List customer contacts Retrieve all contacts for a customer. Parameters: - customer_id (path, string, required) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 404, 422 ### POST /api/v1/customers/{customer_id}/contacts Create customer contact Add a new contact to a customer. Parameters: - customer_id (path, string, required) Request body (EntityContactCreateRequest): - name (string, required) - email (string · email, optional) - phone (string, optional) - role (string, optional) - is_primary (boolean, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/customers/{customer_id}/contacts/{contact_id} Delete customer contact Delete a customer contact. Parameters: - customer_id (path, string, required) - contact_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/customers/{customer_id}/contacts/{contact_id} Get customer contact Retrieve a specific customer contact. Parameters: - customer_id (path, string, required) - contact_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/customers/{customer_id}/contacts/{contact_id} Update customer contact Update an existing customer contact. Parameters: - customer_id (path, string, required) - contact_id (path, string, required) Request body (EntityContactUpdateRequest): - name (string, optional) - email (string · email, optional) - phone (string, optional) - role (string, optional) - is_primary (boolean, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ## daily-brief ### GET /api/v1/books/daily-brief Regent Daily Brief Aggregated home-screen payload for the Books shell. Returns six tiles: categorization, AP drafts, anomalies, close score, burn/runway, and AI spend. Each tile is computed independently and degrades gracefully if its upstream data isn't ready. Responses: 200, 401, 403, 422 ### GET /api/v1/books/standup Regent proactive morning standup Returns the proactive morning post Regent would publish into the home shell chat: a greeting, a markdown summary, four highlight KPIs, and a list of action cards with pre-wired endpoints (Void duplicates, Approve bill, View blockers). The frontend renders this as the first message in the home conversation so the user can act without prompting. Responses: 200, 401, 403, 422 ## dashboards ### GET /api/v1/dashboards List dashboards Cursor-paginated list of dashboards visible to the caller: their own, ones assigned to them, and business-visible ones. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/dashboards Create a dashboard Create an empty dashboard (widgets are added separately). Request body (CreateDashboardRequest): - title (string, required) - description (string, optional) - visibility (string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/dashboards/assignable-users List assignable users Users of this business a dashboard can be assigned to. Responses: 200, 401, 403, 422 ### POST /api/v1/dashboards/models/build Build an approved model plan Evaluate a draft model against live ledger data and persist it as a dashboard whose widgets are its sheets. The draft must have come from `/models/import` or the `plan_model` chat tool, and expires an hour after it was created. Request body (BuildModelRequest): - draft_id (string, required) - visibility (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/dashboards/models/drafts/{draft_id} Read a proposed model in full The complete plan behind a draft: **every** row of every sheet, the formula or resolved ledgers behind each one, and a sample column of real values. Parameters: - draft_id (path, string, required) - full (query, boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### PATCH /api/v1/dashboards/models/drafts/{draft_id} Edit a proposed model before building it Change the period axis or an assumption value on a draft and get the re-planned model back — re-resolved against the chart of accounts and re-evaluated, so the effect of the edit is visible before anything is built. Parameters: - draft_id (path, string, required) Request body (ReviseDraftRequest): - title (string, optional) - assumptions (object, optional) - grain (string, optional) - start (string · date, optional) - end (string · date, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/dashboards/models/import Import a reference workbook as a model plan Parse an uploaded .xlsx into a draft model and return it for review. **Nothing is persisted** — the importer cannot know which ledgers feed the workbook's data rows, and guessing would produce a model that renders a clean grid of wrong numbers. The response carries a `confidence` score, the sheets skipped as raw data exports, and the formulas that could not be translated, so the caller can resolve them before calling `/models/build`. Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/dashboards/{dashboard_id} Delete a dashboard Soft-delete a dashboard. Parameters: - dashboard_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/dashboards/{dashboard_id} Get a dashboard Fetch the full DashboardSpec for rendering. Parameters: - dashboard_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/dashboards/{dashboard_id} Update a dashboard Patch title, description, or visibility. Parameters: - dashboard_id (path, string, required) Request body (UpdateDashboardRequest): - title (string, optional) - description (string, optional) - visibility (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/dashboards/{dashboard_id}/assignments Set dashboard assignments Replace the set of users assigned to this dashboard, optionally changing its visibility at the same time. Parameters: - dashboard_id (path, string, required) Request body (AssignUsersRequest): - user_ids (array · string, optional) - visibility (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/export Export a dashboard to Excel, CSV, or PDF Queue an asynchronous export of this dashboard and return a task id. Poll the standard report task-status endpoint (`GET /api/v1/task/{task_id}`) for progress and the download link — this reuses the report pipeline rather than adding a second one. Parameters: - dashboard_id (path, string, required) Request body (ExportDashboardRequest): - output_format (string, optional) - widget_ids (array · string, optional) - include_empty (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/model/refresh Re-derive a model from current ledger data Recompute every sheet. Unlike a snapshot dashboard's refresh, this re-runs the **model**, so a journal entry booked since the last render moves every dependent line — not only the rows whose source tool happened to be re-executed. Parameters: - dashboard_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/dashboards/{dashboard_id}/model/workbook Download a model as a live-formula Excel workbook Stream the model as an .xlsx whose computed cells hold **real Excel formulas** — subtotals, roll-forwards and assumption references stay live, so an analyst can change a rate in the Assumptions sheet and watch every dependent line move. Parameters: - dashboard_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/refresh Refresh a dashboard's widgets now Re-run every refreshable widget source immediately, as the caller — the same code path as a scheduled refresh, with the caller's live permissions applied per tool. Editors only, because the refreshed snapshots are what everyone sharing the dashboard sees. Widgets that fail keep their previous snapshot and report `last_refresh_error`. Parameters: - dashboard_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/dashboards/{dashboard_id}/schedule Delete the refresh schedule Remove the schedule. The dashboard and its widgets are untouched. Parameters: - dashboard_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/dashboards/{dashboard_id}/schedule Get the refresh schedule Return this dashboard's refresh schedule, including its last/next run times and the error from the most recent failed run. Responds with `schedule: null` when no schedule is configured — absence of a schedule is a normal state, not a 404. Parameters: - dashboard_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/dashboards/{dashboard_id}/schedule Update the refresh schedule Patch the cadence or enabled state. Any cadence change — including re-enabling a disabled schedule — re-derives `next_run_at` from now, so a schedule that was paused for a long time does not fire immediately on resume. Parameters: - dashboard_id (path, string, required) Request body (DashboardRefreshScheduleUpdate): - frequency (string, optional) - day_of_week (integer, optional) - day_of_month (integer, optional) - hour_utc (integer, optional) - timezone (string, optional) - is_enabled (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/schedule Create a refresh schedule Schedule a recurring background refresh of this dashboard's widget sources. A dashboard may have at most one schedule — returns 400 if one already exists (PATCH it instead). Parameters: - dashboard_id (path, string, required) Request body (DashboardRefreshScheduleRequest): - frequency (string, optional) - day_of_week (integer, optional) - day_of_month (integer, optional) - hour_utc (integer, optional) - timezone (string, optional) - is_enabled (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/share Create a public share link Mint a token-protected public URL that renders this dashboard read-only for anyone who holds the link — no DayZero account needed. The raw token is returned in this response **exactly once**; only its SHA-256 digest is stored, so it cannot be recovered later (mint a new link instead). Parameters: - dashboard_id (path, string, required) Request body (CreateDashboardShareRequest): - expires_in_hours (integer, optional) - slug (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/dashboards/{dashboard_id}/shares List share links Every share link for this dashboard — active, expired and revoked — newest first, with view counts. Raw tokens are never re-emitted, so rows identify a link by id and slug only. Parameters: - dashboard_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/dashboards/{dashboard_id}/shares/{share_id} Revoke a share link Revoke one link. The public viewer 404s immediately — the cached payload is dropped as part of the revoke. Idempotent for a link that was already revoked. Parameters: - dashboard_id (path, string, required) - share_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/dashboards/{dashboard_id}/versions List dashboard versions Newest-first version history for this dashboard. Rows are skinny — the stored spec is omitted; fetch a single version to preview it. Parameters: - dashboard_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/versions Save a dashboard version Capture the dashboard's current title, description, visibility and widgets as a new numbered version. This is an explicit user action — editing a dashboard or refreshing its widgets does NOT create a version. At most 25 versions are retained per dashboard; saving past that prunes the oldest. Parameters: - dashboard_id (path, string, required) Request body (SaveVersionRequest): - change_summary (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/dashboards/{dashboard_id}/versions/{version_id} Get a dashboard version Fetch one stored version including its full spec. Parameters: - dashboard_id (path, string, required) - version_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/versions/{version_id}/restore Restore a dashboard version Roll the dashboard back to a stored version. The version's spec is re-validated against the current schema first (a 400 means the version predates an incompatible schema change), and the state being overwritten is saved as a new version first — so the restore itself is undoable via `undo_version_number`. Parameters: - dashboard_id (path, string, required) - version_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/widgets Add a widget Add a widget from a chat card ('Add to dashboard') or manually. The snapshot payload is stored verbatim; a source tool, when provided, must be a READ tool. Parameters: - dashboard_id (path, string, required) Request body (AddWidgetRequest): - title (string, required) - widget_type (string, required) - layout (WidgetLayout, optional) - source (WidgetSource, optional) - snapshot (WidgetSnapshot, optional) - body (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/widgets/reorder Reorder widgets Set a new widget order via a list of widget_ids. Parameters: - dashboard_id (path, string, required) Request body (ReorderWidgetsRequest): - widget_ids (array · string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/dashboards/{dashboard_id}/widgets/{widget_id} Remove a widget Remove one widget from the dashboard. Parameters: - dashboard_id (path, string, required) - widget_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/dashboards/{dashboard_id}/widgets/{widget_id} Update a widget Patch a widget's title, layout, or (text widgets) body. Parameters: - dashboard_id (path, string, required) - widget_id (path, string, required) Request body (UpdateWidgetRequest): - title (string, optional) - layout (WidgetLayout, optional) - body (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/dashboards/{dashboard_id}/widgets/{widget_id}/alert Create an alert on a metric widget Create a threshold alert rule bound to a metric widget. The rule is evaluated against the widget's **stored snapshot** — it never re-executes the widget's source tool, so the alert is exactly as fresh as the dashboard itself. Returns 400 if the widget is not a metric widget or if `value_path` does not resolve to a number in the current snapshot. Parameters: - dashboard_id (path, string, required) - widget_id (path, string, required) Request body (CreateWidgetAlertRequest): - name (string, optional) - threshold_value (integer, required) - threshold_direction (string, required) - value_path (string, optional) - channels (array · string, optional) - check_frequency (string, optional) - cooldown_hours (integer, optional) - description (string, optional) - slack_channel (string, optional) Responses: 201, 400, 401, 403, 404, 422 ## dashboards-public ### GET /api/v1/public/dashboards/{token} Public dashboard viewer (unauthenticated) Resolve a share token to a read-only, redacted dashboard. Returns 404 for unknown, expired, revoked, or deleted targets — the four are indistinguishable on purpose. Rate-limited per IP and cached for 60 seconds; the payload reflects each widget's stored snapshot, so it is exactly as fresh as the dashboard itself. Parameters: - token (path, string, required) Responses: 200, 404, 422, 429 ## data-rooms ### GET /api/v1/data-rooms List data rooms Every data room, newest first; tokens are never re-emitted. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 404, 422 ### POST /api/v1/data-rooms Assemble a data room Build a draft room for a purpose: one snapshot item per section. Sections a source cannot supply are listed as unavailable. Payroll detail and bank account details stay off unless named in `opt_in_sections`. Admins only. Request body (AssembleDataRoomRequest): - purpose (string, required) - title (string, optional) - period_end (string · date, optional) - include_sections (array · string, optional) - opt_in_sections (array · string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/data-rooms/{room_id} Get a data room Get one data room with its items (without content or token). Parameters: - room_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/data-rooms/{room_id}/access-log Data room access log Newest 200 views and downloads; IP and user agent are hashed. Parameters: - room_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/data-rooms/{room_id}/items Switch data room items on or off Draft rooms only. Turning on a sensitive item needs `confirm_sensitive`. Parameters: - room_id (path, string, required) Request body (UpdateDataRoomItemsRequest): - items (array · UpdateDataRoomItemRequest, required) → UpdateDataRoomItemRequest - confirm_sensitive (boolean, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/data-rooms/{room_id}/publish Publish a data room Sign the manifest of included items and mint the public link. The raw token is returned here **exactly once**. Expiry is 1-90 days. Parameters: - room_id (path, string, required) Request body (PublishDataRoomRequest): - expires_in_days (integer, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/data-rooms/{room_id}/revoke Revoke a data room The public page and downloads stop resolving at once. Idempotent. Parameters: - room_id (path, string, required) Responses: 201, 401, 403, 404, 422 ## data-rooms-public ### GET /api/v1/public/data-rooms/{token} Public data room viewer (unauthenticated) Resolve a share token to the signed manifest and items, with `verified` recomputed server-side on every request. Returns 404 for unknown, expired or revoked tokens, indistinguishably. Writes a view to the access log. Rate-limited per IP. Parameters: - token (path, string, required) Responses: 200, 404, 422, 429 ### GET /api/v1/public/data-rooms/{token}/items/{item_id}/download Download one data room item (unauthenticated) Return one signed item's snapshot as a JSON file and write a download to the access log. 404 for unknown, expired or revoked tokens and for items outside the signed manifest. Rate-limited per IP. Parameters: - token (path, string, required) - item_id (path, string, required) Responses: 200, 404, 422, 429 ### GET /api/v1/public/data-rooms/{token}/items/{item_id}/file Download the file a data room item carries (unauthenticated) Return the close package zip a signed item carries, only while it still matches the SHA-256 in the item's signed content, and write a download to the access log. 404 for unknown, expired or revoked tokens, items without a file and files changed since publishing. Rate-limited per IP. Parameters: - token (path, string, required) - item_id (path, string, required) Responses: 200, 404, 422, 429 ## deals ### GET /api/v1/o2c/deals List deals List pipeline deals for the business with stage / expansion / text-search filters and cursor pagination. Always returns the total matching count alongside the page. Parameters: - stage (query, string, optional): Filter by exact deal stage. - is_expansion (query, boolean, optional): Filter by new-customer (false) vs. expansion (true). - search (query, string, optional): Case-insensitive search across name / prospect / contact. - owner (query, string, optional): Filter by sales rep / deal owner (case-insensitive exact match; see GET /o2c/deals/owners). Pass `__unassigned__` for deals with no owner yet. - cursor (query, string, optional): Pagination cursor - direction (query, string, optional): Which way to walk from `cursor`. Send `prev` with the page's `prev_cursor` to page backwards. - limit (query, integer, optional): Page size - sort_by (query, string, optional): Column to sort by. - descending (query, boolean, optional): Sort direction. Responses: 200, 401, 403, 422 ### POST /api/v1/o2c/deals Create a deal Create a pipeline deal. Provide either `prospect_name` (before a real customer record exists) or `customer_id` (an expansion deal on an existing customer). `stage` defaults to `prospecting`. Request body (DealCreate): - prospect_name (string, optional) - customer_id (string, optional) - name (string, optional) - contact_name (string, optional) - contact_email (string, optional) - source (string, optional) - stage (string, optional) - is_expansion (boolean, optional) - expected_value_cents (integer, optional) - expected_hours (number | string, optional) - expected_term_months (integer, optional) - expected_start_date (string · date, optional) - expected_close_date (string · date, optional) - notes (string, optional) - owner_name (string, optional) - deal_type (string, optional) - revenue_type (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/o2c/deals/bulk Bulk-create deals Create up to 250 pipeline deals in one request — the import path behind the Pipeline page's Import button, for moving an existing pipeline spreadsheet in. Request body (DealBulkCreateRequest): - deals (array · DealBulkRow, required) → DealBulkRow Responses: 201, 400, 401, 403, 422 ### GET /api/v1/o2c/deals/owners List sales reps with deals Every distinct sales rep / deal owner on the business's deals, with their deal counts, plus how many deals have no owner yet. Feeds the pipeline's owner filter chips, which need the full roster rather than whichever owners happen to be on the current page. Responses: 200, 401, 403, 422 ### GET /api/v1/o2c/deals/pipeline Pipeline view: forecast metrics + deals Stage-weighted pipeline forecast metrics (computed over all open deals) plus a filtered, paginated deals page with `effective_stage` computed server-side (deal.stage, or the linked order's live status once converted). Parameters: - stage (query, string, optional): Filter the deals page by stage. - is_expansion (query, boolean, optional): Filter the deals page by new-customer vs. expansion. - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size - sort_by (query, string, optional): Column to sort by. - descending (query, boolean, optional): Sort direction. Responses: 200, 401, 403, 422 ### GET /api/v1/o2c/deals/{deal_id} Get deal Get a single deal with its customer/project relationships. Parameters: - deal_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/o2c/deals/{deal_id} Edit deal Edit a deal's stage, notes, owner / deal type / revenue type, and expected-commercials estimates. Blocked once the deal has converted to an order (`order_id` set) -- manage it from Orders instead. Stage changes are validated against the model's allowed transitions. Parameters: - deal_id (path, string, required) Request body (DealUpdate): - stage (string, optional) - notes (string, optional) - owner_name (string, optional) - deal_type (string, optional) - revenue_type (string, optional) - expected_value_cents (integer, optional) - expected_hours (number | string, optional) - expected_term_months (integer, optional) - expected_start_date (string · date, optional) - expected_close_date (string · date, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/o2c/deals/{deal_id}/create-order Convert a deal into a customer/project/draft order One-way handoff into Order-to-Cash (`CreateOrderFromDealService`): creates a customer if the deal has none yet, a project beneath it (unique per customer, case-insensitive), and a draft order pre-filled from the deal's estimates -- then freezes the deal by stamping `customer_id` / `project_id` / `order_id`. Atomic: any failure rolls back every write. Fails if the deal has already converted. Parameters: - deal_id (path, string, required) Request body (DealCreateOrderRequest): - project_name (string, required) - order_description (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/o2c/deals/{deal_id}/mark-lost Mark a deal lost Close an open deal as lost with a required reason. Parameters: - deal_id (path, string, required) Request body (DealMarkLostRequest): - reason (string, required) - note (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/o2c/deals/{deal_id}/reopen Reopen a lost deal Restore a closed_lost deal to whatever stage it was in right before it was marked lost. Pre-handoff only -- a deal that has already converted to an order (`order_id` set) can never be reopened here. Parameters: - deal_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## decisions ### GET /api/v1/decisions List decisions The business's rulings, newest first. Parameters: - kind (query, string, optional): Filter by kind - subject (query, string, optional): Counterparty name or policy key - active_on (query, string · date, optional): Only rulings in force on this date - cursor (query, string, optional) - limit (query, integer, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/decisions Record a decision Record a ruling. One already in force for the subject ends where this starts. Request body (DecisionCreate): - kind (string, required) - subject (string, required) - ruling (string, required) - ruling_label (string, optional) - effective_from (string · date, optional) - effective_to (string · date, optional) - notes (string, optional) - source (string, optional) Responses: 201, 401, 403, 422 ### DELETE /api/v1/decisions/{decision_id} End a decision End the ruling today. The row stays in the log with its end date. Parameters: - decision_id (path, string, required) Responses: 200, 401, 403, 422 ### PATCH /api/v1/decisions/{decision_id} Update a decision Change a ruling's notes, label, end date or ruling. Parameters: - decision_id (path, string, required) Request body (DecisionUpdate): - ruling (string, optional) - ruling_label (string, optional) - effective_to (string · date, optional) - notes (string, optional) Responses: 200, 401, 403, 422 ## deferred-revenue ### GET /api/v1/deferred-revenue List deferred invoices Deferred invoices with their schedules and remaining balances. Parameters: - status (query, DeferralStatusEnum, optional): Filter by deferral status - customer_id (query, string, optional): Filter by customer - limit (query, integer, optional): Page size - offset (query, integer, optional): Offset Responses: 200, 401, 403, 422 ### GET /api/v1/deferred-revenue/invoices/{invoice_id} Get an invoice's deferral An invoice's deferral, if any, and how much of it can be deferred. Parameters: - invoice_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/deferred-revenue/invoices/{invoice_id} Defer an invoice Route an invoice's revenue to Deferred Revenue and schedule it. Parameters: - invoice_id (path, string, required) Request body (DeferInvoiceRequest): - deferred_amount_cents (integer, optional) - unit (DeferralUnitEnum, optional) → DeferralUnitEnum - method (DeferralMethodEnum, optional) → DeferralMethodEnum - period_count (integer, required) - total_units (number | string, optional) - start_date (string · date, optional) - revenue_ledger_name (string, optional) - periods (array · DeferralPeriodInput, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/deferred-revenue/matrix Deferred revenue matrix Deferred invoices (rows) against recognition months (columns). Parameters: - status (query, DeferralStatusEnum, optional): Filter by deferral status Responses: 200, 401, 403, 422 ### POST /api/v1/deferred-revenue/recognize Run recognition Post every deferred revenue entry that has come due. Request body (RunRecognitionRequest): - as_of (string · date, optional) Responses: 201, 401, 403, 422 ### GET /api/v1/deferred-revenue/recognized Recognized revenue Recognized revenue by period, method and source, with upcoming totals for drill-down. Parameters: - start_date (query, string · date, optional): Only periods ending on/after this date - end_date (query, string · date, optional): Only periods ending on/before this date - limit (query, integer, optional): Page size, in groups - offset (query, integer, optional): Offset, in groups Responses: 200, 401, 403, 422 ### GET /api/v1/deferred-revenue/{deferral_id} Get a deferral One deferred revenue schedule with all of its periods. Parameters: - deferral_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/deferred-revenue/{deferral_id} Update deferral terms Re-cut the not-yet-posted part of a recognition schedule. Parameters: - deferral_id (path, string, required) Request body (UpdateDeferralTermsRequest): - unit (DeferralUnitEnum, optional) - method (DeferralMethodEnum, optional) - period_count (integer, optional) - total_units (number | string, optional) - start_date (string · date, optional) - revenue_ledger_name (string, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/deferred-revenue/{deferral_id}/cancel Undo a deferral Release the remaining deferred balance back to revenue. Parameters: - deferral_id (path, string, required) Request body (CancelDeferralRequest): - as_of (string · date, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/deferred-revenue/{deferral_id}/periods/{period_id} Fill in a period's numerator Enter the units burned down in a period so it can post. Parameters: - deferral_id (path, string, required) - period_id (path, string, required) Request body (SetPeriodUnitsRequest): - units (number | string, required) - recognition_date (string · date, optional) - post_now (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ## delayed-charges ### GET /api/v1/delayed-charges List delayed charges List all delayed charges for the business with optional filtering. Parameters: - search (query, string, optional): Search delayed charges by description - customer_id (query, string, optional): Filter by customer ID - status (query, DelayedChargeStatusEnum, optional): Filter by status - type (query, DelayedChargeTypeEnum, optional): Filter by type - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/delayed-charges Create delayed charge Create a new delayed charge or credit in pending status. Request body (DelayedChargeCreate): - type (string, optional) - customer_id (string, required) - amount (integer, required) - description (string, required) - line_items (array · DelayedChargeLineItem, optional) - service_date (string, optional) - internal_notes (string, optional) - currency (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/delayed-charges/customers/{customer_id}/pending Get customer pending charges Get pending delayed charges for a specific customer. Parameters: - customer_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/delayed-charges/{charge_id} Delete delayed charge Delete a pending delayed charge. Parameters: - charge_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/delayed-charges/{charge_id} Get delayed charge Get a specific delayed charge by ID. Parameters: - charge_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/delayed-charges/{charge_id} Update delayed charge Update a pending delayed charge. Parameters: - charge_id (path, string, required) Request body (DelayedChargeUpdate): - type (string, optional) - customer_id (string, optional) - amount (integer, optional) - description (string, optional) - line_items (array · DelayedChargeLineItem, optional) - service_date (string, optional) - internal_notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ## document-requests ### GET /api/v1/document-requests List document requests (client) List documents your accountant has asked you to upload. Parameters: - status (query, string, optional): Filter by status: open, fulfilled, cancelled - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional) - include_total_count (query, boolean, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/document-requests/count Open document request count (client) Number of pending document requests for the sidebar badge. Responses: 200, 401, 403, 422 ### GET /api/v1/document-requests/firm List document requests (firm) List all document requests across the firm's businesses. Parameters: - firm_id (query, string, optional): Advisory firm ID - business_id (query, string, optional): Filter by business - status (query, string, optional): Filter by status - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional) - include_total_count (query, boolean, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/document-requests/firm/businesses/{business_id} Request a document from a client (firm) Ask a client business to upload a specific document. Parameters: - business_id (path, string, required) Request body (CreateDocumentRequest): - title (string, required) - description (string, optional) - due_date (string · date, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/document-requests/firm/count Open document request count (firm) Number of still-pending document requests across the firm. Parameters: - firm_id (query, string, optional): Advisory firm ID Responses: 200, 401, 403, 422 ### POST /api/v1/document-requests/firm/{request_id}/cancel Cancel a document request (firm) Withdraw a request the client no longer needs to fulfill. Parameters: - request_id (path, string, required) - firm_id (query, string, optional): Advisory firm ID Responses: 201, 401, 403, 404, 422 ### GET /api/v1/document-requests/firm/{request_id}/download Download an uploaded document (firm) Get a short-lived link to the file the client uploaded. Parameters: - request_id (path, string, required) - firm_id (query, string, optional): Advisory firm ID Responses: 200, 401, 403, 404, 422 ### GET /api/v1/document-requests/{request_id}/download Download an uploaded document (client) Get a short-lived link to the file you uploaded. Parameters: - request_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/document-requests/{request_id}/fulfill Upload a requested document (client) Securely upload the file your accountant requested. Parameters: - request_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## documents-public ### GET /api/v1/public/documents/{token} Public shared-document viewer (unauthenticated) Resolve a share token to the stored HTML page. Returns 404 for unknown, expired, or revoked tokens — the three are indistinguishable on purpose. Rate-limited per IP. Parameters: - token (path, string, required) Responses: 200, 422 ## estimates ### GET /api/v1/estimates List estimates List all estimates for the business with optional filtering. Parameters: - search (query, string, optional): Search estimates by description - customer_id (query, string, optional): Filter by customer ID - status (query, EstimateStatusEnum, optional): Filter by status - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/estimates Create estimate Create a new estimate in draft status. Request body (EstimateCreate): - customer_id (string, required) - line_items (array · EstimateLineItem, required) → EstimateLineItem - due_date (string, optional) - expiration_date (string, optional) - description (string, optional) - internal_notes (string, optional) - currency (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/estimates/{estimate_id} Delete estimate Delete a draft estimate. Parameters: - estimate_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/estimates/{estimate_id} Get estimate Get a specific estimate by ID. Parameters: - estimate_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/estimates/{estimate_id} Update estimate Update a draft or sent estimate. Parameters: - estimate_id (path, string, required) Request body (EstimateUpdate): - customer_id (string, optional) - line_items (array · EstimateLineItem, optional) - due_date (string, optional) - expiration_date (string, optional) - description (string, optional) - internal_notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/estimates/{estimate_id}/accept Accept estimate Accept an estimate (sent -> accepted). Parameters: - estimate_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/estimates/{estimate_id}/convert Convert estimate to invoice Convert an accepted or draft estimate to an invoice. Parameters: - estimate_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/estimates/{estimate_id}/decline Decline estimate Decline an estimate (sent -> declined). Parameters: - estimate_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/estimates/{estimate_id}/send Send estimate Send an estimate to the customer (draft -> sent). Parameters: - estimate_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## expense-reports ### GET /api/v1/expense-reports List expense reports List employee expense reports with optional filtering. Parameters: - status (query, ExpenseReportStatusEnum, optional): Filter by status - search (query, string, optional): Search title, description, or number - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/expense-reports Create expense report Create a draft expense report with line items. Request body (ExpenseReportCreateRequest): - title (string, optional) - description (string, optional) - currency (string, optional) - lines (array · ExpenseReportLineInput, required) → ExpenseReportLineInput Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/expense-reports/{report_id} Delete expense report Delete a draft expense report. Parameters: - report_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/expense-reports/{report_id} Get expense report Get a single expense report with line items. Parameters: - report_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/expense-reports/{report_id} Update expense report Update a draft expense report. Parameters: - report_id (path, string, required) Request body (ExpenseReportUpdateRequest): - title (string, optional) - description (string, optional) - lines (array · ExpenseReportLineInput, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/expense-reports/{report_id}/approve Approve expense report Approve a submitted expense report and accrue it to the books (Dr each line's expense account / Cr Reimbursements Payable). Every line needs an expense account by now: send `line_ledgers` to set or change them. The submitter can't approve their own report; only owners, admins and advisory-firm staff can approve. Parameters: - report_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/expense-reports/{report_id}/reimburse Reimburse expense report Record that an approved expense report was paid and post the payment (Dr Reimbursements Payable / Cr the bank account given). Send `bank_transaction_id` when the payment is already in the bank feed: the payment is then booked through that transaction (it is recategorized to Reimbursements Payable and dated when it cleared), so it is counted once. Without it the bank is credited directly and `warnings` explains how the feed's copy gets matched later. Parameters: - report_id (path, string, required) Request body (ExpenseReportReimburseRequest): - bank_ledger_id (string, required) - payment_date (string · date, optional) - payment_reference (string, optional) - bank_transaction_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/expense-reports/{report_id}/reimbursement-candidates List bank transactions that could be the reimbursement Bank-feed transactions on `bank_ledger_id` that `reimburse` accepts as `bank_transaction_id`: payments out for exactly the report total that are uncategorized (or on Reimbursements Payable) and not linked to anything else, newest first. Parameters: - report_id (path, string, required) - bank_ledger_id (query, string, required): Bank or cash account the employee was paid from Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/expense-reports/{report_id}/reject Reject expense report Send a submitted or approved expense report back to the employee as a draft, with a reason. Rejecting an approved report reverses its accrual journal entry with an entry dated today; an accrual in a closed period is left untouched and the reversal's memo says so. Refused when today is in a closed period. A reimbursed report can't be rejected. Parameters: - report_id (path, string, required) Request body (ExpenseReportRejectRequest): - reason (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/expense-reports/{report_id}/submit Submit expense report Submit a draft expense report for approval. Parameters: - report_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## firm-capital ### POST /api/v1/firm/capital/fix-blockers Create a to-do for each of a client's blockers Reads the client's blockers as they stand and leaves the caller one to-do per blocker on that client (source `firm_capital`); a blocker that already has an open to-do is skipped. `404` for a client outside the firm. Parameters: - firm_id (query, string, optional): The firm acting; defaults to the caller's staff firm. Request body (FirmCapitalFixBlockersRequest): - business_id (string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/firm/capital/overview The firm's capital desk One row per client the caller can see, ranked fundable first: Trust Scorecard grade, data readiness with its blockers, the best listed program the client would qualify for (published limit range and a read-only pre-check of the program's active scorecard over the client's books), existing lines and headroom, and `one_fix_away` when exactly one blocker remains. Totals: clients fundable now and the capital available. No assessment is run and nothing is decided. Parameters: - firm_id (query, string, optional): The firm to read; defaults to the caller's staff firm. Responses: 200, 401, 403, 422 ### POST /api/v1/firm/capital/prequalify Pre-qualify a client for a listed offer Records a referral and, when the caller holds write permission on the client, opens the client's application to the program through the same marketplace flow the client would use (idempotent per client and program; the lender's scorecard and decision follow as for any application). Without write permission the client's owner gets a to-do asking them to apply. Any referral compensation must be disclosed to the client and may require state licensing. `404` for a client outside the firm or an offer not open to it. Parameters: - firm_id (query, string, optional): The firm acting; defaults to the caller's staff firm. Request body (FirmCapitalPrequalifyRequest): - business_id (string, required) - program_id (string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ## fixed-assets — Asset tracking, depreciation schedules, and disposal. ### GET /api/v1/fixed-assets List fixed assets List all fixed assets. Parameters: - status (query, string, optional): Filter by status - category_id (query, string, optional): Filter by category - search (query, string, optional): Search by asset name - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/fixed-assets Create fixed asset Create a new fixed asset. Request body (FixedAssetCreate): - name (string, required) - description (string, optional) - asset_number (string, optional) - serial_number (string, optional) - purchase_date (string · date, required) - original_cost (integer, required) - salvage_value (integer, optional) - useful_life_months (integer, optional) - depreciation_method (DepreciationMethod, optional) → DepreciationMethod - location (string, optional) - notes (string, optional) - category_id (string, optional) - vendor_id (string, optional) - in_service_date (string · date, optional) - total_expected_units (integer, optional) - opening_accumulated_depreciation (integer, optional) - go_live_date (string · date, optional) - depreciation_expense_ledger_id (string, optional) Responses: 201, 401, 403, 422 ### GET /api/v1/fixed-assets/categories List asset categories List all asset categories. Responses: 200, 401, 403, 422 ### POST /api/v1/fixed-assets/categories Create asset category Create a new asset category. Request body (AssetCategoryCreate): - name (string, required) - description (string, optional) - default_useful_life_months (integer, optional) - default_depreciation_method (DepreciationMethod, optional) → DepreciationMethod - default_salvage_percent (integer, optional) - asset_ledger_id (string, optional) - depreciation_expense_ledger_id (string, optional) - accumulated_depreciation_ledger_id (string, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/fixed-assets/categories/seed-defaults Seed default categories Seed default asset categories (Equipment, Vehicles, etc.). Responses: 201, 401, 403, 422 ### DELETE /api/v1/fixed-assets/categories/{category_id} Delete asset category Delete an asset category. Parameters: - category_id (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/fixed-assets/categories/{category_id} Get asset category Get a specific asset category. Parameters: - category_id (path, string, required) Responses: 200, 401, 403, 422 ### PATCH /api/v1/fixed-assets/categories/{category_id} Update asset category Update an asset category. Parameters: - category_id (path, string, required) Request body (AssetCategoryUpdate): - name (string, optional) - description (string, optional) - default_useful_life_months (integer, optional) - default_depreciation_method (DepreciationMethod, optional) - default_salvage_percent (integer, optional) - asset_ledger_id (string, optional) - depreciation_expense_ledger_id (string, optional) - accumulated_depreciation_ledger_id (string, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/fixed-assets/depreciation-matrix Depreciation schedule matrix Depreciation pivoted to months across the top and assets down the side. Parameters: - start_date (query, string · date, optional): Earliest period to include (YYYY-MM-DD) - end_date (query, string · date, optional): Latest period to include (YYYY-MM-DD) - include_posted (query, boolean, optional): Include already-posted periods - include_scheduled (query, boolean, optional): Include queued (not yet posted) periods Responses: 200, 401, 403, 422 ### GET /api/v1/fixed-assets/depreciation-preview Preview depreciation Preview the next depreciation run. Parameters: - period_date (query, string · date, required): Period date (first of month) Responses: 200, 401, 403, 422 ### POST /api/v1/fixed-assets/from-transactions Create asset from transactions Capitalize ledger transactions into a fixed asset. Request body (CreateAssetFromTransactionsRequest): - ledger_id (string, required) - transaction_ids (array · string, optional) - line_entry_ids (array · string, optional) - expense_ledger_id (string, optional) - name (string, required) - useful_life_months (integer, optional) - depreciation_method (DepreciationMethod, optional) → DepreciationMethod - in_service_date (string · date, optional) - salvage_value (integer, optional) - auto_place_in_service (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/fixed-assets/generate-schedules Queue depreciation schedules Queue draft depreciation entries for active assets that have none. Responses: 201, 401, 403, 422 ### POST /api/v1/fixed-assets/post-scheduled-depreciation Post due scheduled depreciation Post every queued depreciation entry whose date has arrived. Request body (PostScheduledDepreciationRequest): - as_of (string · date, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/fixed-assets/run-depreciation Run depreciation Run depreciation for a period. Request body (RunDepreciationRequest): - period_date (string · date, required) - asset_ids (array · string, optional) - create_journal_entries (boolean, optional) Responses: 201, 401, 403, 422 ### GET /api/v1/fixed-assets/scheduled-journal-entries List scheduled journal entries Depreciation journal entries queued to post on their future dates. Parameters: - through_date (query, string · date, optional): Only entries queued on or before this date - limit (query, integer, optional): Maximum entries to return Responses: 200, 401, 403, 422 ### POST /api/v1/fixed-assets/suggest-capitalization AI capitalization suggestions Get AI-powered suggestions for transactions that should be capitalized. Responses: 201, 401, 403, 422 ### POST /api/v1/fixed-assets/suggest-capitalization/start Start AI capitalization suggestions as a background job Starts the capitalization scan as a background job and returns its workflow_id immediately. Stream the id via the task status endpoint; the finished job's result holds the same payload as the synchronous route. Responses: 201, 401, 403, 422 ### DELETE /api/v1/fixed-assets/{asset_id} Delete fixed asset Delete a fixed asset. Parameters: - asset_id (path, string, required) - force (query, boolean, optional): Also delete posted depreciation entries and every journal entry posted for this asset (capitalization, depreciation, disposal). Use when the asset was set up by mistake. Responses: 200, 401, 403, 422 ### GET /api/v1/fixed-assets/{asset_id} Get fixed asset Get a specific fixed asset. Parameters: - asset_id (path, string, required) Responses: 200, 401, 403, 422 ### PATCH /api/v1/fixed-assets/{asset_id} Update fixed asset Update a fixed asset. Parameters: - asset_id (path, string, required) Request body (FixedAssetUpdate): - name (string, optional) - description (string, optional) - asset_number (string, optional) - serial_number (string, optional) - category_id (string, optional) - vendor_id (string, optional) - salvage_value (integer, optional) - useful_life_months (integer, optional) - depreciation_method (DepreciationMethod, optional) - total_expected_units (integer, optional) - location (string, optional) - notes (string, optional) - opening_accumulated_depreciation (integer, optional) - go_live_date (string · date, optional) - depreciation_expense_ledger_id (string, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/fixed-assets/{asset_id}/depreciation-entries Get depreciation entries Get all depreciation entries for an asset. Parameters: - asset_id (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/fixed-assets/{asset_id}/depreciation-schedule Get depreciation schedule Get the full depreciation schedule for an asset. Parameters: - asset_id (path, string, required) Responses: 200, 401, 403, 422 ### POST /api/v1/fixed-assets/{asset_id}/dispose Dispose asset Dispose of an asset (sell, trade, scrap, etc.). Parameters: - asset_id (path, string, required) Request body (DisposeAssetRequest): - disposal_date (string · date, required) - disposal_method (DisposalMethod, required) → DisposalMethod - disposal_amount (integer, optional) - disposal_notes (string, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/fixed-assets/{asset_id}/place-in-service Place asset in service Place an asset in service to begin depreciation. Parameters: - asset_id (path, string, required) Request body (PlaceInServiceRequest): - in_service_date (string · date, required) - capitalization (string, optional) - offset_ledger_id (string, optional) - opening_accumulated_depreciation (integer, optional) - go_live_date (string · date, optional) Responses: 201, 401, 403, 422 ## fx-rates ### GET /api/v1/fx/exposure FX exposure preview Per-currency open AR/AP exposure and unrealized gain/loss. Parameters: - as_of_date (query, string · date, required): Revaluation date. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/fx/rates List FX rates List stored FX rates for the business. Responses: 200, 401, 403, 422 ### POST /api/v1/fx/rates Upsert FX rate Create or update an FX rate for a (base, quote) pair on a date. Request body (FxRateUpsertRequest): - base_currency (string, required) - quote_currency (string, required) - rate (number | string, required) - as_of_date (string · date, required) - source (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/fx/revalue Post FX revaluation Revalue open foreign AR/AP and post the adjusting JE. Request body (FxRevaluationRequest): - as_of_date (string · date, required) - post (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ## gmail ### GET /api/v1/gmail/connect-url Get Gmail OAuth connect URL Generate a URL to redirect the user to Google for authorization. Personal connection: links the signed-in user's own mailbox. Responses: 200, 400, 401, 422 ### DELETE /api/v1/gmail/disconnect Disconnect Gmail Revoke the Google grant (best effort) and delete the stored connection. DayZero never stored any email content. Responses: 200, 400, 401, 422 ### GET /api/v1/gmail/oauth/callback Gmail OAuth callback Handle the Google OAuth redirect. Called by Google, not the frontend. Parameters: - code (query, string, optional): Authorization code from Google - state (query, string, optional): OAuth state nonce - error (query, string, optional): Set by Google when the user denies consent Responses: 200, 422 ### GET /api/v1/gmail/status Gmail connection status Returns the signed-in user's Gmail connection state and health. Responses: 200, 401, 422 ## headcount ### GET /api/v1/headcount-plans List headcount plans List the business's headcount plans with their totals. Parameters: - status (query, HeadcountPlanStatusEnum, optional): Filter by status: draft, active, approved, closed - fiscal_year (query, integer, optional): Filter by fiscal year - search (query, string, optional): Name search - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 400, 401, 403, 422 ### POST /api/v1/headcount-plans Create headcount plan Create an empty headcount plan. Request body (HeadcountPlanCreateRequest): - name (string, required) - fiscal_year (integer, required) - status (HeadcountPlanStatusEnum, optional) → HeadcountPlanStatusEnum - notes (string, optional) Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/headcount-plans/{plan_id} Delete headcount plan Soft delete a plan; its positions are kept for audit. Parameters: - plan_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/headcount-plans/{plan_id} Get headcount plan Get a headcount plan with its positions. Parameters: - plan_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/headcount-plans/{plan_id} Update headcount plan Change a plan's name, fiscal year, status or notes. Parameters: - plan_id (path, string, required) Request body (HeadcountPlanUpdateRequest): - name (string, optional) - fiscal_year (integer, optional) - status (HeadcountPlanStatusEnum, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/headcount-plans/{plan_id}/copy Copy headcount plan Duplicate a plan and its positions as a new draft. Parameters: - plan_id (path, string, required) Request body (HeadcountPlanCopyRequest): - name (string, required) - fiscal_year (integer, required) - include_cancelled (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/headcount-plans/{plan_id}/export Export headcount projection The projection as a CSV or XLSX file. Parameters: - plan_id (path, string, required) - format (query, string, optional): csv or xlsx - months (query, integer, optional) - start_month (query, string, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/headcount-plans/{plan_id}/plan-vs-actual Headcount plan vs actual Planned salary against payroll gross pay, by position and month. Parameters: - plan_id (path, string, required) - months (query, integer, optional): Months to compare - start_month (query, string, optional): First month, YYYY-MM (default: January of the fiscal year) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/headcount-plans/{plan_id}/positions List positions Every position in a headcount plan. Parameters: - plan_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/headcount-plans/{plan_id}/positions Add position Add a position to a headcount plan. Parameters: - plan_id (path, string, required) Request body (PlannedPositionCreateRequest): - title (string, required) - department (string, optional) - annual_salary_cents (integer, required) - benefits_multiplier (integer, optional) - start_date (string · date, required) - end_date (string · date, optional) - status (PositionStatusEnum, optional) → PositionStatusEnum - notes (string, optional) - ledger_id (string, optional) - employee_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/headcount-plans/{plan_id}/positions/bulk Add positions in bulk Add up to 500 positions at once (a pasted roster). Parameters: - plan_id (path, string, required) Request body (PlannedPositionBulkCreateRequest): - positions (array · PlannedPositionCreateRequest, required) → PlannedPositionCreateRequest Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/headcount-plans/{plan_id}/positions/{position_id} Delete position Remove a position from a headcount plan. Parameters: - plan_id (path, string, required) - position_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/headcount-plans/{plan_id}/positions/{position_id} Update position Change a position in a headcount plan. Parameters: - plan_id (path, string, required) - position_id (path, string, required) Request body (PlannedPositionUpdateRequest): - title (string, optional) - department (string, optional) - annual_salary_cents (integer, optional) - benefits_multiplier (integer, optional) - start_date (string · date, optional) - end_date (string · date, optional) - status (PositionStatusEnum, optional) - notes (string, optional) - ledger_id (string, optional) - employee_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/headcount-plans/{plan_id}/projection Headcount projection Month by position grid of fully loaded cost. Parameters: - plan_id (path, string, required) - months (query, integer, optional): Months to project - start_month (query, string, optional): First month, YYYY-MM (default: January of the fiscal year) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/headcount-plans/{plan_id}/push-to-budget Push headcount plan to budget Write the plan's monthly cost into a draft budget. Parameters: - plan_id (path, string, required) Request body (HeadcountPushToBudgetRequest): - budget_id (string, optional) - budget_name (string, optional) - dry_run (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ## intents ### POST /api/v1/intents/route Route user intent Classify a Command-K query and return the appropriate action. Request body (IntentRequest): - query (string, required) Responses: 201, 401, 403, 422 ## intercompany-cleanup ### GET /api/v1/advisory-firms/{firm_id}/access-requests List aggregated parent-side access requests Case B candidates grouped by the expected counterparty account: '12 transactions, $148,200 — second leg expected in Parent Brex — request access'. Parameters: - firm_id (path, string, required) - session_id (query, string, optional): Scope to one session Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/account-map Get the firm Account Master Map Every map entry for the firm, auto-seeded from all Plaid accounts across the firm's businesses that have no entry yet, with ingestion coverage windows computed from transaction data. Only ``entity_role`` requires human input. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/account-map Add an external account stub to the map Registers an account the firm does not ingest (e.g. the parent company's card) so orphan classification can point at it. Parameters: - firm_id (path, string, required) Request body (AccountMapEntryCreate): - display_name (string, required) - entity_role (string, optional) - business_id (string, optional) - last4 (string, optional) - account_type (string, optional) - notes (string, optional) - known_description_strings (array · string, optional) Responses: 201, 401, 403, 404, 422 ### DELETE /api/v1/advisory-firms/{firm_id}/account-map/{entry_id} Delete an external account map entry Only external stubs can be deleted; linked entries reseed from the connected account. Parameters: - firm_id (path, string, required) - entry_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/advisory-firms/{firm_id}/account-map/{entry_id} Update an account map entry Parameters: - firm_id (path, string, required) - entry_id (path, string, required) Request body (AccountMapEntryUpdate): - entity_role (string, optional) - display_name (string, optional) - last4 (string, optional) - account_type (string, optional) - notes (string, optional) - known_description_strings (array · string, optional) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/candidates/bulk-resolve Confirm or reject match candidates Confirming applies the booking side effects: same-business pairs retarget to the transfers ledger, cross-entity pairs book due-to/due-from plus an elimination entry, parent legs book due-from-parent on our side only. Every confirmation also feeds rule learning and the account map's known description strings. Parameters: - firm_id (path, string, required) Request body (BulkResolveRequest): - candidate_ids (array · string, required) - action (string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/candidates/{candidate_id}/context Drill-in context for one match candidate Full journal lines per leg plus the history of confirmed pairs between the same two accounts — everything needed to judge the candidate without leaving the review queue. Parameters: - firm_id (path, string, required) - candidate_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/cleanup-badge Open intercompany review-queue count Lightweight count of proposed candidates awaiting review — drives the Cleanup sidebar badge. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/advisory-firms/{firm_id}/cleanup-sessions List cleanup sessions for a firm Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/cleanup-sessions Start a historical cleanup session Creates a cleanup session over the given entities and date window, then kicks off the matching workflow. Poll the session for status and counters. Parameters: - firm_id (path, string, required) Request body (CleanupSessionCreate): - date_start (string · date, required) - date_end (string · date, required) - business_ids (array · string, optional) - date_tolerance_days (integer, optional) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/cleanup-sessions/{session_id} Get a cleanup session with progress counters Parameters: - firm_id (path, string, required) - session_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/cleanup-sessions/{session_id}/candidates List match candidates for a session Impact-sorted (amount desc), cursor-paginated. Filter by ``case`` (internal_transfer | parent_intercompany | data_gap | hidden_detail) and ``status`` (proposed | confirmed | rejected | applied). Parameters: - firm_id (path, string, required) - session_id (path, string, required) - case (query, string, optional): Filter by case type - status (query, string, optional): Filter by status - cursor (query, string, optional) - limit (query, integer, optional) - direction (query, string, optional) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/cleanup-sessions/{session_id}/run Re-run matching for a session (iterative clearing) Confirmed pairs drop out of the pool, so each re-run surfaces the next layer of matches. Parameters: - firm_id (path, string, required) - session_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/cleanup-sessions/{session_id}/workpaper Download the cleanup session workpaper (PDF) Audit-ready summary of one cleanup session: scope, account map snapshot, every resolved candidate, and what remains open. Parameters: - firm_id (path, string, required) - session_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/intercompany-balances Standing due-to / due-from balances per entity Derived from posted intercompany ledger entries; powers the firm dashboard widget. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/resolutions List resolution batches (history) Every bulk-resolve call is a batch: who resolved what, when, and how much was booked. Batches are the unit of undo. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/resolutions/{batch_id}/undo Undo a resolution batch Unwinds every booking from the batch: retargeted journal lines return to their prior ledgers, categorization methods are restored, elimination entries are removed, and the candidates reopen as proposed. Learning writes are not reversed. Parameters: - firm_id (path, string, required) - batch_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/settlement-proposals Pairwise net intercompany positions ready to settle Derived from open elimination entries: who owes whom, net, per entity pair. Largest positions first. Parameters: - firm_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/advisory-firms/{firm_id}/settlements Record an intercompany settlement (netting entry) Books a netting journal entry in each entity (debit due-to / credit due-from) after the repayment transfer has been matched, and marks the pair's open eliminations as posted. Refuses to net more than both gross balances support. Parameters: - firm_id (path, string, required) Request body (RecordSettlementRequest): - payer_business_id (string, required) - payee_business_id (string, required) - amount_cents (integer, required) - settlement_date (string · date, required) - memo (string, optional) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/advisory-firms/{firm_id}/tracker-candidates List match candidates found outside any session Pairs the always-on tracker proposed after bank syncs, with no cleanup session attached. Impact-sorted (amount desc), cursor-paginated. Same ``case`` and ``status`` filters as the session list. Parameters: - firm_id (path, string, required) - case (query, string, optional): Filter by case type - status (query, string, optional): Filter by status - cursor (query, string, optional) - limit (query, integer, optional) - direction (query, string, optional) Responses: 200, 401, 403, 422 ## inventory:accounts_payable ### GET /api/v1/inventory/accounts-payable List Inventory AP bills List bills generated by a Purchase Order (those with source_inventory_order_id set). Supports optional status filtering. Parameters: - status (query, string, optional): Comma-separated list of bill statuses to include. - limit (query, integer, optional): Max bills to return. Responses: 200, 401, 403, 422 ### POST /api/v1/inventory/accounts-payable/{bill_id}/three-way-match Recompute the three-way match for a bill Forces a fresh PO -> Receipt -> Invoice comparison for the bill and writes the outcome onto `bill.match_status` and the variance columns. Idempotent. Parameters: - bill_id (path, string, required) - qty_tolerance (query, integer, optional): Unit tolerance before a qty drift is flagged. - price_tolerance_cents (query, integer, optional): Cents tolerance before a price drift is flagged. - price_tolerance_pct (query, number, optional): Percent-of-PO-total tolerance (combined with cents floor). Responses: 201, 401, 403, 404, 422 ## inventory:activity ### GET /api/v1/inventory/activity List inventory activity Return the N most recent inventory activity events (PO submit/ready/shipped/received/canceled, etc.). Parameters: - limit (query, integer, optional) Responses: 200, 401, 403, 422 ## inventory:adjustments — Inventory quantity and value adjustments. ### POST /api/v1/inventory/adjustments Create manual inventory adjustment Create a manual inventory adjustment for a variant at a specific location. If no location is specified, the adjustment is applied to the default location. Request body (InventoryAdjustmentRequest): - variant_id (string, required) - quantity_change (number | string, required) - unit_cost_cents (integer, optional) - effective_date (string · date, optional) - reason (string, required) - reason_code (string, optional) - location_id (string, optional) Responses: 201, 401, 403, 422 ## inventory:cost_history ### GET /api/v1/inventory/cost-history Landed COGS history Return cost snapshots grouped by variant for the last N months. Powers the Landed COGS sparkline + material/freight/processing breakdown. Parameters: - months (query, integer, optional): Window size in months (default 12). Responses: 200, 401, 403, 422 ## inventory:costing ### POST /api/v1/inventory/costing/adjustments/post Post inventory cost true-ups, recosts and PPV Posts what the consumption ledger owes the GL: true-ups of units shipped before stock arrived, recosts from backdated receipts, and purchase price variances, one entry per day and kind, never into a closed period. Idempotent. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/inventory/costing/consumptions List cost-lot consumptions The consumption ledger: which lot each unit left or came back to, at what cost, for which order, invoice, adjustment or count. Parameters: - variant_id (query, string, optional): Only this variant - source_type (query, string, optional): e.g. shopify_fulfillment, invoice_line, adjustment - source_id (query, string, optional): Order, invoice, ... id - limit (query, integer, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/inventory/costing/write-downs/apply Propose an inventory write-down to NRV Recompute the preview, refuse a changed plan_hash, and queue one create_journal_entry proposed change: Dr Inventory Write-Down / Cr Inventory Reserve for the reserve change (reversed for a release), dated as_of. Nothing posts until a person approves it. Request body (WriteDownApplyRequest): - rows (array · WriteDownRowInput, required) → WriteDownRowInput - as_of (string · date, optional) - plan_hash (string, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/inventory/costing/write-downs/preview Preview an inventory write-down to NRV Per SKU: on-hand quantity, carrying cost (open lots), net realizable value, the reserve needed and the change from what is already reserved. Writes nothing; plan_hash goes to /apply. Request body (WriteDownPreviewRequest): - rows (array · WriteDownRowInput, required) → WriteDownRowInput - as_of (string · date, optional) Responses: 201, 400, 401, 403, 422 ## inventory:counts ### GET /api/v1/inventory/counts List cycle counts List recent cycle counts, optionally filtered by status. Parameters: - status (query, string, optional): Filter by status: draft | in_progress | posted | cancelled. - limit (query, integer, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/inventory/counts Start a cycle count Create a draft cycle / physical count at a location. Request body (StartCountRequest): - location_id (string, required) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/inventory/counts/{count_id} Get a cycle count Return one cycle count with all lines + variant metadata. Parameters: - count_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/inventory/counts/{count_id}/cancel Cancel a cycle count Mark a count as cancelled without posting adjustments. Parameters: - count_id (path, string, required) Responses: 201, 401, 403, 404, 409, 422 ### POST /api/v1/inventory/counts/{count_id}/lines Add or scan a line Add a line by `variant_id`, `barcode`, or `sku`. Re-scans of the same variant update the existing line. Parameters: - count_id (path, string, required) Request body (AddCountLineRequest): - variant_id (string, optional) - barcode (string, optional) - sku (string, optional) - counted_quantity (number, optional) - reason (string, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### PUT /api/v1/inventory/counts/{count_id}/lines/{line_id} Record a counted quantity Record / update the counter's measured quantity on a line. Parameters: - count_id (path, string, required) - line_id (path, string, required) Request body (SubmitCountLineRequest): - counted_quantity (number, required) - reason (string, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/inventory/counts/{count_id}/post Post a cycle count Finalize the count, emitting one manual inventory adjustment per non-zero variance line. Parameters: - count_id (path, string, required) Responses: 201, 401, 403, 404, 409, 422 ### POST /api/v1/inventory/counts/{count_id}/preview-post Preview posting a cycle count Side-effect free. Per inventory category: book vs counted value and the delta, plus the journal lines posting would write (to the category ledger when inventory ledgers are mapped, else Inventory) and a plan_hash. Pass plan_hash to POST /counts/{id}/post to refuse the post if anything moved since. Parameters: - count_id (path, string, required) Responses: 201, 401, 403, 404, 422 ## inventory:forecast ### POST /api/v1/inventory/forecast/recompute Recompute SKU demand forecasts Recompute and persist statistical demand forecasts and safety stock for every SKU with recent sales. Normally run nightly by a background job; this endpoint forces an immediate refresh. Responses: 201, 401, 403, 404, 422 ### GET /api/v1/inventory/forecast/skus List per-SKU demand forecasts Return the most recently computed statistical demand forecast for each SKU, including the weekly forecast curve, service-level safety stock, suggested reorder point, order-up-to level, and backtest accuracy. Read-only. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/inventory/forecast/skus/{variant_id} Get one SKU's demand forecast detail Return a single SKU's statistical forecast (curve, safety stock, reorder point, order-up-to, accuracy) together with its recent actual weekly demand history, so the UI can overlay history vs forecast with a confidence band. Read-only. Parameters: - variant_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## inventory:import — Bulk import inventory data from CSV or external systems. ### POST /api/v1/inventory/import/analyze Analyze spreadsheet (async) Upload an Excel or CSV file. Returns a task_id immediately; the AI analysis runs in the background. Poll GET /analyze/{task_id} for the result. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/inventory/import/analyze/{task_id} Poll analysis status Returns 'pending', 'completed' (with result), or 'failed'. Parameters: - task_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/inventory/import/apply Apply import Execute the confirmed import: create locations, products, variants, and set inventory levels. All changes happen in a single transaction. Request body (ApplyRequest): - file_id (string, required) - locations (array · ApplyLocationDecision, optional) → ApplyLocationDecision - products (array · ApplyProductDecision, optional) → ApplyProductDecision - levels (array · ApplyLevelDecision, optional) → ApplyLevelDecision Responses: 201, 400, 401, 403, 422 ### POST /api/v1/inventory/import/preview Preview import After reviewing the AI analysis, confirm column mappings and sheet selections. Returns a full preview of locations, products, and inventory levels to be created. Request body (PreviewRequest): - file_id (string, required) - selected_sheets (array · string, required) - sheet_mappings (array · SheetMappingConfirmation, required) → SheetMappingConfirmation - location_decisions (array · LocationDecision, optional) → LocationDecision Responses: 201, 400, 401, 403, 422 ## inventory:landed_cost_allocations ### GET /api/v1/inventory/landed-cost-allocations/orders List allocatable purchase orders Return received/completed POs that can absorb landed cost, with per-order unit and variant counts so the UI can suggest a split. Parameters: - limit (query, integer, optional): Max POs to return. Responses: 200, 401, 403, 422 ### GET /api/v1/inventory/landed-cost-allocations/{bill_id} List a bill's landed cost allocations Return every landed-cost allocation recorded for the bill plus a reconciliation summary (allocated vs. unallocated cents). Parameters: - bill_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/inventory/landed-cost-allocations/{bill_id} Replace a bill's landed cost allocations Set the full list of landed-cost allocations for a bill. Existing allocations are reversed first, then the requested targets are applied to the cost snapshots — idempotent. The allocated total may not exceed the bill amount. Parameters: - bill_id (path, string, required) Request body (LandedCostAllocationCreateRequest): - targets (array · LandedCostAllocationTarget, optional) → LandedCostAllocationTarget Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/inventory/landed-cost-allocations/{bill_id}/{allocation_id} Remove a landed cost allocation Delete one allocation and reverse the exact per-unit cost it added back out of the affected cost snapshots. Parameters: - bill_id (path, string, required) - allocation_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## inventory:ledger_settings ### GET /api/v1/inventory/ledger-settings Get inventory ledger settings The ledgers that hold each inventory category (raw materials, packaging, finished goods) plus the manufacturing-fee, accrued inventory and adjustment offsets. configured is true once a finished-goods ledger is set. Responses: 200, 401, 403, 422 ### PUT /api/v1/inventory/ledger-settings Update inventory ledger settings Map inventory categories to ledgers. Omitted fields are left alone; null clears one. Every id must be an active ledger of this business. Request body (InventoryLedgerSettingsUpdate): - raw_materials_ledger_id (string, optional) - packaging_ledger_id (string, optional) - finished_goods_ledger_id (string, optional) - manufacturing_fees_ledger_id (string, optional) - accrued_inventory_ledger_id (string, optional) - inventory_adjustments_ledger_id (string, optional) - cogs_basis (string, optional) - invoice_cogs_recognition (string, optional) - landed_cost_basis (string, optional) Responses: 200, 400, 401, 403, 422 ## inventory:locations — Warehouse and storage location management. ### GET /api/v1/inventory/locations List inventory locations List all inventory locations for the business with optional filtering. Parameters: - location_type (query, LocationTypeEnum, optional): Filter by location type - include_archived (query, boolean, optional): Include archived locations - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size - include_total_count (query, boolean, optional): Include total count Responses: 200, 401, 403, 422 ### POST /api/v1/inventory/locations Create location Create a new inventory location. Request body (LocationCreate): - name (string, required) - code (string, optional) - location_type (LocationTypeEnum, optional) → LocationTypeEnum - address_line1 (string, optional) - address_line2 (string, optional) - city (string, optional) - state (string, optional) - postal_code (string, optional) - country (string, optional) - is_default (boolean, optional) - is_active (boolean, optional) - contact_name (string, optional) - contact_email (string, optional) - contact_phone (string, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/inventory/locations/default Get default location Get the default location for the business. Responses: 200, 401, 403, 404, 422 ### GET /api/v1/inventory/locations/summaries Get inventory summaries for all locations Get inventory summaries for all locations of the business in a single request. Parameters: - include_archived (query, boolean, optional): Include archived locations Responses: 200, 401, 403, 422 ### DELETE /api/v1/inventory/locations/{location_id} Delete location Delete a location. Cannot delete if it has inventory or is the default. Parameters: - location_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/inventory/locations/{location_id} Get location Get a specific location by ID. Parameters: - location_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/inventory/locations/{location_id} Update location Update an existing location. Parameters: - location_id (path, string, required) Request body (LocationUpdate): - name (string, optional) - code (string, optional) - location_type (LocationTypeEnum, optional) - address_line1 (string, optional) - address_line2 (string, optional) - city (string, optional) - state (string, optional) - postal_code (string, optional) - country (string, optional) - is_default (boolean, optional) - is_active (boolean, optional) - archived (boolean, optional) - contact_name (string, optional) - contact_email (string, optional) - contact_phone (string, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/locations/{location_id}/archive Archive location Archive a location (soft delete). Cannot archive the default location. Parameters: - location_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/inventory/locations/{location_id}/inventory Get inventory at location Get all inventory levels at a specific location. Parameters: - location_id (path, string, required) - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 404, 422 ### POST /api/v1/inventory/locations/{location_id}/set-default Set as default location Set a location as the default for new inventory. Parameters: - location_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/inventory/locations/{location_id}/summary Get location inventory summary Get summary of inventory at a location. Parameters: - location_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## inventory:lots ### GET /api/v1/inventory/lots/expiring List expiring cost lots Return non-exhausted cost lots with an `expiration_date` within the next `within_days` days. Powers the 'Expiring soon' badge on the inventory overview. Parameters: - within_days (query, integer, optional): Lookahead window in days (default 30). - include_expired (query, boolean, optional): When false, exclude lots whose `expiration_date` is already in the past. - limit (query, integer, optional) Responses: 200, 401, 403, 422 ## inventory:payments — Payments linked to inventory orders. ### GET /api/v1/inventory/payments List inventory payments Retrieve payments made to vendors for inventory orders. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ## inventory:po_import ### POST /api/v1/inventory/po-import/analyze Analyze manufacturer PO spreadsheet (async) Upload an Excel or CSV manufacturer purchase order. Returns a task_id immediately; poll GET /analyze/{task_id} for column mappings and metadata. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/inventory/po-import/analyze/{task_id} Poll PO analysis status Returns 'pending', 'completed' (with result), or 'failed'. Parameters: - task_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/inventory/po-import/apply Create purchase order from import Create a draft purchase order from confirmed line items and vendor. Unmatched SKUs require variant_id overrides or must be skipped. Request body (POApplyRequest): - file_id (string, required) - vendor_id (string, required) - po_number (string, required) - name (string, required) - description (string, optional) - line_decisions (array · POLineDecision, optional) → POLineDecision - selected_sheets (array · string, required) - sheet_mappings (array · POSheetMappingConfirmation, required) → POSheetMappingConfirmation Responses: 201, 400, 401, 403, 422 ### POST /api/v1/inventory/po-import/preview Preview PO import with SKU matching After reviewing AI column mappings, returns line items with SKU match status against the product catalog. Request body (POPreviewRequest): - file_id (string, required) - selected_sheets (array · string, required) - sheet_mappings (array · POSheetMappingConfirmation, required) → POSheetMappingConfirmation Responses: 201, 400, 401, 403, 422 ## inventory:production — Production orders and bill-of-materials management. ### GET /api/v1/inventory/production/recipes List recipes List production recipes for the business. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/inventory/production/recipes Create recipe Create a new production recipe with materials, output variants, and processing steps. Request body (RecipeCreateRequest): - name (string, required) - description (string, optional) - output_unit_name (string, optional) - output_unit_weight (number, optional) - output_unit_weight_unit (string, optional) - conversion_params (object, optional) - materials (array · RecipeMaterialBase, optional) → RecipeMaterialBase - output_variants (array · RecipeOutputVariantBase, optional) → RecipeOutputVariantBase - processing_steps (array · RecipeProcessingStepBase, optional) → RecipeProcessingStepBase Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/inventory/production/recipes/{recipe_id} Delete recipe Soft-delete a production recipe. Parameters: - recipe_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/inventory/production/recipes/{recipe_id} Get recipe Get a production recipe with all children. Parameters: - recipe_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/inventory/production/recipes/{recipe_id} Update recipe Update a production recipe. Children are replaced if provided. Parameters: - recipe_id (path, string, required) Request body (RecipeUpdateRequest): - name (string, optional) - description (string, optional) - output_unit_name (string, optional) - output_unit_weight (number, optional) - output_unit_weight_unit (string, optional) - conversion_params (object, optional) - materials (array · RecipeMaterialBase, optional) - output_variants (array · RecipeOutputVariantBase, optional) - processing_steps (array · RecipeProcessingStepBase, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/production/recipes/{recipe_id}/duplicate Duplicate recipe Deep-clone a recipe and all its children. Parameters: - recipe_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/inventory/production/runs List production runs List production runs for the business. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/inventory/production/runs Create production run Create a new production run from a recipe. Costs are computed immediately. Request body (RunCreateRequest): - recipe_id (string, required) - name (string, optional) - total_units (integer, required) - unit_sale_price (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/inventory/production/runs/{run_id} Get production run Get a production run with its cost breakdown. Parameters: - run_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/inventory/production/runs/{run_id} Update production run Update run parameters and recalculate costs. Parameters: - run_id (path, string, required) Request body (RunUpdateRequest): - name (string, optional) - total_units (integer, optional) - unit_sale_price (integer, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/production/runs/{run_id}/calculate What-if calculation Recalculate costs without persisting. Override total_units and/or unit_sale_price. Parameters: - run_id (path, string, required) Request body (RunCalculateRequest): - total_units (integer, optional) - unit_sale_price (integer, optional) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/inventory/production/runs/{run_id}/cancel Cancel production run Cancel a run. A draft run only changes status. A completed run is undone exactly: its on-hand movements are reversed, consumed cost lots get their units back, its output lots are removed and its production transfer entry is reversed (dated reversal_date, default today). Refused with nothing changed when goods the run made were already sold, used or moved (VALIDATION_892) or the run was completed before completions were recorded (VALIDATION_893). A cancelled run can be completed again. Parameters: - run_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/production/runs/{run_id}/complete Complete production run Mark a run as completed: consume material cost lots and create output lots, take the components out of on-hand stock and add the finished goods, at location_id or the business's default location. Refused (VALIDATION_890, nothing moved) when a stock-tracked component's available stock there is short. A component with no stock history, or a stock item whose recipe unit differs from its stock unit, keeps its on-hand and is listed in warnings. When inventory ledgers are mapped (PUT /inventory/ledger-settings) it also posts one production transfer entry dated completion_date: Cr raw materials / packaging for the cost consumed, Cr accrued inventory for processing-step cost, Cr accrued inventory (or AP with tolling_bill_id) for tolling_cents, Dr finished goods for the total. Without the mapping journal_entry is null and reason says why. Parameters: - run_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## inventory:products — Product catalog with SKUs, costs, and variants. ### GET /api/v1/inventory/products List products Retrieve all products with optional filtering and pagination. Parameters: - type (query, string, optional): Filter by product type ('manual' or 'shopify') - category (query, string, optional): Filter by category (e.g. 'Finished Goods', 'Ingredients', 'Packaging') - include_variants (query, boolean, optional): Whether to include variant details - archived (query, boolean, optional): Filter by archived status (true/false/null for all) - search (query, string, optional): Fuzzy search term (trigram-similarity matching against the entity's primary text columns). Trimmed; ignored when blank. - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 404, 422 ### POST /api/v1/inventory/products Create product Create a new product for the specified business. A connected Stripe account is **not** required; Stripe Catalog sync happens later when variants are added with Stripe connected. Request body (ProductCreateRequest): - name (string, required) - type (string, required) - category (string, optional) - tracks_expiration (boolean, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/inventory/products/lookup Lookup variant by barcode or SKU Resolve a single variant by a scannable identifier. Tries barcode first, then falls back to SKU. Used by receiving, cycle counting, and point-of-sale flows. Parameters: - barcode (query, string, optional): Scannable barcode (UPC/EAN/QR). - sku (query, string, optional): Stock Keeping Unit fallback. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/products/unit-costs/apply Apply unit cost bulk update Apply confirmed unit-cost updates from a validated CSV upload. Request body (UnitCostBulkApplyRequest): - updates (array · UnitCostBulkUpdateRowInput, required) → UnitCostBulkUpdateRowInput - effective_date (string · date, optional) - revalue_on_hand (boolean, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/inventory/products/unit-costs/export Export unit costs CSV Download a CSV of active variants with current unit costs. Edit the new_unit_cost column and re-upload via the bulk update flow. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/inventory/products/unit-costs/preview Preview unit cost bulk update Validate parsed CSV rows and preview cost changes before applying. Request body (UnitCostBulkPreviewRequest): - rows (array · UnitCostBulkUpdateRowInput, required) → UnitCostBulkUpdateRowInput Responses: 201, 400, 401, 403, 422 ### GET /api/v1/inventory/products/variants List product variants Retrieve all variants with optional filtering by product. Parameters: - product_id (query, string, optional): Filter by parent product ID - archived (query, boolean, optional): Filter by archived status - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 404, 422 ### POST /api/v1/inventory/products/variants Create product variant Create a new product variant. When the business has Stripe connected, the variant is mirrored to Stripe Catalog (Product + Price); otherwise the variant is created locally with empty Stripe IDs and can be synced later. Request body (VariantCreateRequest): - product_id (string, optional) - unit_price (integer, optional) - unit_cost (integer, optional) - unit_cost_precise (number, optional) - name (string, optional) - sku (string, optional) - manufacturer_sku (string, optional) - barcode (string, optional) - uom (string, optional) - purchase_uom (string, optional) - purchase_uom_factor (number | string, optional) - inventory_category (string, optional) - default_vendor_id (string, optional) - tax_code_id (string, optional) - initial_inventory_quantity (integer, optional) - initial_inventory_quantity_date (string · date-time, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### DELETE /api/v1/inventory/products/variants/{id} Delete product variant Archive a variant (default), or permanently delete it with `permanent=true`. Permanent deletion is rejected when the variant has linked inventory, order, shipment, transfer, or count records. Parameters: - id (path, string · uuid, required) - permanent (query, boolean, optional): Permanently delete instead of archiving. Only allowed when the variant has no linked records. - product_id (query, string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/inventory/products/variants/{id} Get product variant Retrieve a specific variant by ID. Parameters: - id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/inventory/products/variants/{id} Update product variant Update an existing variant. Parameters: - id (path, string · uuid, required) Request body (VariantUpdateRequest): - id (string, optional) - product_id (string, optional) - unit_price (integer, optional) - name (string, optional) - sku (string, optional) - manufacturer_sku (string, optional) - barcode (string, optional) - unit_cost (integer, optional) - unit_cost_precise (number, optional) - uom (string, optional) - purchase_uom (string, optional) - purchase_uom_factor (number | string, optional) - inventory_category (string, optional) - default_vendor_id (string, optional) - tax_code_id (string, optional) - archived (boolean, optional) - initial_inventory_quantity (integer, optional) - initial_inventory_quantity_date (string · date-time, optional) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/inventory/products/variants/{id}/location-quantities Set variant location opening quantities Set absolute on-hand quantities for this variant at each location without creating inventory adjustment journal entries. Parameters: - id (path, string · uuid, required) Request body (SetVariantLocationQuantitiesRequest): - location_quantities (array · VariantLocationQuantityInput, required) → VariantLocationQuantityInput - effective_at (string · date-time, optional) Responses: 200, 400, 401, 403, 404, 422 ### PATCH /api/v1/inventory/products/variants/{variant_id}/locations/{location_id}/reorder-settings Update variant reorder settings at a location Set or clear the per-location reorder point and reorder quantity for a variant. Parameters: - variant_id (path, string · uuid, required) - location_id (path, string · uuid, required) Request body (UpdateReorderSettingsRequest): - reorder_point (number, optional) - reorder_quantity (number, optional) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/inventory/products/{id} Delete product Delete or archive a product. Parameters: - id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/inventory/products/{id} Get product Retrieve a specific product by ID. Parameters: - id (path, string · uuid, required) - include_variants (query, boolean, optional): Whether to include variant details Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/inventory/products/{id} Update product Update an existing product. Parameters: - id (path, string · uuid, required) - include_variants (query, boolean, optional): Whether to include variant details Request body (ProductUpdateRequest): - id (string, optional) - name (string, optional) - type (string, optional) - category (string, optional) - tracks_expiration (boolean, optional) - archived (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/products/{id}/convert-to-variant Convert product to variant Move a product's variants under another product and archive the source. Parameters: - id (path, string · uuid, required) Request body (ConvertProductToVariantRequest): - target_product_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ## inventory:reorder ### POST /api/v1/inventory/reorder/cash-impact Preview the cash impact of a reorder Model the effect of placing one or more (not-yet-created) purchase orders on the 13-week cash forecast. Runs the live forecast with and without the proposed POs and returns the delta -- including how far the projected cash low point moves -- so the operator can see the cash impact of a reorder before committing to it. Request body (ReorderCashImpactRequest): - proposed_pos (array · ProposedPurchaseOrder, optional) → ProposedPurchaseOrder - weeks (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/reorder/draft Draft purchase orders from reorder suggestions Materialize reorder suggestions as draft purchase orders, one per vendor. Variants without a preferred vendor are skipped. Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/inventory/reorder/suggestions Suggest reorders from reorder points Return vendor-grouped reorder suggestions for variants whose available quantity has fallen to or below the per-location reorder point. Read-only. Responses: 200, 401, 403, 404, 422 ## inventory:reports ### GET /api/v1/inventory/reports/adjustment-reasons Adjustments grouped by reason Aggregates `inventory` ledger rows whose `correction_reason` is set (i.e. manual adjustments and cycle-count posts) by reason code. Returns count, signed units, and a $-impact estimate using each variant's stored `unit_cost`. Use ``since``/``until`` ISO-8601 strings to scope the window (defaults to all-time). Parameters: - since (query, string · date-time, optional): Inclusive lower bound (ISO-8601). Omit for all-time. - until (query, string · date-time, optional): Exclusive upper bound (ISO-8601). Omit for now. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/inventory/reports/aging Inventory aging report Bucket remaining cost-lot quantities (and dollars) by lot age (0-30 / 31-60 / 61-90 / 91-180 / 180+ days). Optionally returns the per-variant detail with the oldest received_at. Parameters: - detail (query, boolean, optional): Include per-variant breakdown sorted by oldest lot age. - detail_limit (query, integer, optional): Cap on per-variant detail rows when `detail=true`. Responses: 200, 401, 403, 422 ### GET /api/v1/inventory/reports/gl-reconciliation Inventory subledger vs GL tie-out Compare the inventory valuation with every inventory-type ledger as of a date and list the reconciling items. Parameters: - as_of_date (query, string · date, optional): Tie-out date (YYYY-MM-DD). Omit for today. Responses: 200, 401, 403, 422 ### GET /api/v1/inventory/reports/margin-by-sku Margin-by-SKU report (actual revenue and booked COGS) Returns per-variant actual revenue and booked COGS from Shopify and invoice lines over the lookback window, plus current price, landed cost and per-unit margin. Powers the Landed COGS 'Truth' tab. Parameters: - lookback_days (query, integer, optional): Trailing window (days) used to compute revenue + units sold. - limit (query, integer, optional): Max variants returned (sorted by trailing revenue desc). Responses: 200, 401, 403, 422 ### GET /api/v1/inventory/reports/uncosted-skus SKUs on hand with no cost List variants whose units on hand have no cost lot behind them. Parameters: - limit (query, integer, optional): Max rows returned. Responses: 200, 401, 403, 422 ### GET /api/v1/inventory/reports/valuation Inventory valuation as of a date Return the on-hand inventory value (in cents) under the business's costing method, now or as of a date, grouped by location, category, or vendor. Parameters: - group_by (query, string, optional): Bucketing dimension: 'location' (default), 'category', or 'vendor'. - as_of_date (query, string · date, optional): Valuation date (YYYY-MM-DD). Omit for right now. Responses: 200, 401, 403, 422 ### GET /api/v1/inventory/reports/valuation/snapshots Period-end valuation snapshots List the period-end inventory valuation snapshots. Responses: 200, 401, 403, 422 ## inventory:shipments — Inbound and outbound shipment tracking. ### GET /api/v1/inventory/shipments List shipments Retrieve all shipments for inventory orders. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/inventory/shipments Create shipment Record a received shipment and update inventory. Request body (ShipmentCreateRequest): - fees (array · Fee, optional) - status (string, optional) - line_items (array · LineItem, optional) - description (string, optional) - tracking_number (string, optional) - expected_arrival_date (string · date-time, optional) - shipped_date (string · date-time, optional) - received_date (string · date, optional) - location_id (string, optional) Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/inventory/shipments/{id} Delete shipment Delete a shipment record. Parameters: - id (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/inventory/shipments/{id} Get shipment Retrieve a specific shipment with line items. Parameters: - id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/inventory/shipments/{id} Update shipment Update a shipment's details. Parameters: - id (path, string, required) Request body (ShipmentUpdateRequest): - fees (array · Fee, optional) - status (string, optional) - line_items (array · LineItem, optional) - description (string, optional) - tracking_number (string, optional) - expected_arrival_date (string · date-time, optional) - shipped_date (string · date-time, optional) - received_date (string · date, optional) - location_id (string, optional) - version (integer, optional) Responses: 200, 401, 403, 422 ## inventory:standard_costs ### GET /api/v1/inventory/cogs/standard List standard costs Standard cost rows per variant with the dates each is in force, and the business's cogs_basis. as_of keeps the rows in force that day. Parameters: - variant_id (query, string, optional): Only this variant's rows - as_of (query, string · date, optional): Only rows in force on this date - cursor (query, string, optional): next_cursor of a page - limit (query, integer, optional) Responses: 200, 400, 401, 403, 422 ### PUT /api/v1/inventory/cogs/standard Set standard costs Insert or update standard costs keyed by (variant, effective_from), from rows or csv_text (sku/variant, from, to, cost in dollars, basis, note). Refused when a variant's ranges would overlap. dry_run returns the plan only. Request body (StandardCostSetRequest): - rows (array · StandardCostRowIn, optional) - csv_text (string, optional) - dry_run (boolean, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/inventory/cogs/standard/apply Draft the standard-cost COGS adjustment Recompute the preview, refuse a changed plan_hash, and queue one create_journal_entry proposed change per source with a delta (Dr/Cr COGS against inventory, dated to_date). Nothing posts until a person approves it. Request body (StandardCogsApplyRequest): - from_date (string · date, required) - to_date (string · date, required) - plan_hash (string, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/inventory/cogs/standard/preview Preview the standard-cost COGS re-rate Per source (shopify, invoice) and variant: units sold in the window, the cost in force, standard COGS, the COGS the source recorded, and the delta. Writes nothing; plan_hash goes to /apply. Parameters: - from_date (query, string · date, required): First sale day (YYYY-MM-DD) - to_date (query, string · date, required): Last sale day (YYYY-MM-DD) Responses: 201, 400, 401, 403, 422 ## inventory:supply_chain ### GET /api/v1/inventory/supply-chain Get inventory supply chain map Return a single payload of nodes (locations with on-hand + alerts) and edges (open POs + in-transit transfers) for the Supply Chain Map. Responses: 200, 401, 403, 422 ## inventory:transfer_suggestions ### GET /api/v1/inventory/transfer-suggestions/suggestions Suggest site-to-site transfers Return (donor, receiver, quantity) suggestions for variants with surplus at one location and deficit at another. Parameters: - surplus_pct (query, number, optional): Donor must hold this much above its own reorder point. - limit (query, integer, optional) Responses: 200, 401, 403, 404, 422 ## inventory:transfers — Inter-location inventory transfers. ### GET /api/v1/inventory/transfers List inventory transfers List all inventory transfers for the business with optional filtering. Parameters: - status (query, TransferStatusEnum, optional): Filter by status - from_location_id (query, string, optional): Filter by source location - to_location_id (query, string, optional): Filter by destination location - search (query, string, optional): Search transfer number, locations, tracking, carrier, or notes - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/inventory/transfers Create transfer Create a new inventory transfer between locations. Request body (TransferCreate): - transfer_number (string, optional) - from_location_id (string, required) - to_location_id (string, required) - transfer_date (string · date, optional) - expected_arrival_date (string · date, optional) - tracking_number (string, optional) - carrier (string, optional) - shipping_cost (integer, optional) - expected_freight_cost (integer, optional) - notes (string, optional) - items (array · TransferItemCreate, required) → TransferItemCreate Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/inventory/transfers/in-transit List in-transit transfers Get all transfers currently in transit with cursor-based pagination. Parameters: - search (query, string, optional): Search transfer number, locations, tracking, carrier, or notes - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### GET /api/v1/inventory/transfers/pending List pending transfers Get all draft and pending transfers awaiting shipment with cursor-based pagination. Parameters: - search (query, string, optional): Search transfer number, locations, tracking, carrier, or notes - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### GET /api/v1/inventory/transfers/summary Get transfer summary Get summary of transfers by status and in-transit inventory. Responses: 200, 401, 403, 422 ### DELETE /api/v1/inventory/transfers/{transfer_id} Delete transfer Delete a transfer. Only draft/pending transfers can be deleted. Parameters: - transfer_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/inventory/transfers/{transfer_id} Get transfer Get a specific transfer by ID. Parameters: - transfer_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/inventory/transfers/{transfer_id} Update transfer Update an existing transfer. Only draft/pending transfers can be updated. Parameters: - transfer_id (path, string, required) Request body (TransferUpdate): - transfer_number (string, optional) - transfer_date (string · date, optional) - expected_arrival_date (string · date, optional) - tracking_number (string, optional) - carrier (string, optional) - shipping_cost (integer, optional) - expected_freight_cost (integer, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/transfers/{transfer_id}/cancel Cancel transfer Cancel a transfer. Reverses inventory changes if already shipped. Parameters: - transfer_id (path, string, required) Request body (TransferCancelRequest): - reason (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/transfers/{transfer_id}/items Add item to transfer Add an item to an existing transfer. Only works for draft/pending transfers. Parameters: - transfer_id (path, string, required) Request body (TransferItemAddRequest): - variant_id (string, required) - quantity (integer, required) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/inventory/transfers/{transfer_id}/items/{item_id} Remove item from transfer Remove an item from a transfer. Only works for draft/pending transfers. Parameters: - transfer_id (path, string, required) - item_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/transfers/{transfer_id}/receive Receive transfer Mark transfer as received. Adds inventory to destination location. Parameters: - transfer_id (path, string, required) Request body (TransferReceiveRequest): - received_date (string · date, optional) - items (array · TransferItemReceive, required) → TransferItemReceive - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/inventory/transfers/{transfer_id}/ship Ship transfer Mark transfer as shipped (in-transit). Deducts inventory from source location. Parameters: - transfer_id (path, string, required) Request body (TransferShipRequest): - transfer_date (string · date, optional) - tracking_number (string, optional) - carrier (string, optional) - expected_freight_cost (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ## invitations ### POST /api/v1/invitations/{token}/accept Accept a pending invitation Process a pending invitation for the authenticated user. Adds the user to the firm (and grants business access for client invitations) then marks the invitation as accepted. Idempotent: returns success if already accepted. Parameters: - token (path, string, required) Responses: 201, 400, 401, 404, 422 ### GET /api/v1/invitations/{token}/preview Preview invitation details (public) Returns non-sensitive invitation details for rendering the invite signup page. No authentication required -- the token itself is the proof. Parameters: - token (path, string, required) Responses: 200, 422 ## invoices — Accounts receivable — create, finalize, and track invoice payments. ### GET /api/v1/invoices List invoices Retrieve invoices with optional filtering by customer, product, or status. Parameters: - id (query, array · string, optional): Filter by specific invoice UUIDs (repeatable). Batch-fetch a known set of invoices in one request instead of one GET /invoices/{id} per id. - customer_id (query, string, optional): Filter by customer UUID - product_id (query, string, optional): Filter by product UUID - variant_id (query, string, optional): Filter by variant UUID - status (query, array · string, optional): Filter by status. Supports repeated params (?status=open&status=partially-paid) or bracket notation (?status[]=open&status[]=partially-paid). - search (query, string, optional): Search invoices by number, description, line item description, or customer name (case-insensitive partial match) - number (query, string, optional): Exact invoice number match (case-insensitive). Use this instead of `search` when resolving one known invoice number. - due_date_from (query, string · date, optional): Only invoices due on or after this date (YYYY-MM-DD) - due_date_to (query, string · date, optional): Only invoices due on or before this date (YYYY-MM-DD) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/invoices Create invoice Create a new invoice for a customer. Optionally include 'recurring' config to also create a recurring template. Request body (InvoiceCreateRequest): - customer_id (string, required) - currency (string, optional) - line_items (array · LineItemRequest, required) → LineItemRequest - due_date (string, required) - issue_date (string, optional) - invoice_number (string, optional) - description (string, optional) - fulfillment_location_id (string, optional) - project_id (string, optional) - payment_term_id (string, optional) - tax_exempt (boolean, optional) - recurring (InvoiceRecurringConfig, optional) - historical (boolean, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/invoices/aging AR aging summary Returns accounts receivable aging data grouped by customer with Current, 1-30, 31-60, 61-90, and 91+ day buckets. Includes per-invoice detail for drill-down. Responses: 200, 401, 403, 422 ### POST /api/v1/invoices/ai-create AI-extract draft invoices from documents Upload pasted text, PDFs, images, Excel files, or a CSV to extract draft invoice entities using AI. Returns draft invoices ready for user review before creation. Request body (InvoiceAICreatePayloadRequest): - pasted_text (string, optional) - pasted_text_s3_key (string, optional) - single_invoice_s3_keys (array · string, optional) - multi_invoice_s3_key (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/invoices/batch Batch create invoices Create invoices for multiple customers in one action, optionally sweeping delayed charges. Request body (BatchInvoiceRequest): - items (array · BatchInvoiceItem, required) → BatchInvoiceItem - include_delayed_charges (boolean, optional) - finalize (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/invoices/bulk List all invoices (bulk) Retrieve all invoices with efficient cursor-based pagination. Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/invoices/bulk Bulk create invoices Create multiple invoices from CSV data in a single request. Request body (InvoiceBulkRequest): - s3_key (string, optional) - finalize (boolean, optional) - allow_duplicates (boolean, optional) - historical (boolean, optional) - preview (boolean, optional) - allow_partial (boolean, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/invoices/bulk-payments Bulk mark invoices paid Mark a selection of invoices paid in one call, recording the payment date you supply and optionally matching one or more bank transactions to each invoice. Request body (BulkMarkInvoicesPaidRequest): - invoices (array · BulkInvoicePaymentRow, required) → BulkInvoicePaymentRow - paid_on (string · date-time, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/invoices/cash-receipts Weekly cash receipts reconciliation Returns a weekly breakdown of cash received (bank deposits) versus amounts applied to invoices and bills. Highlights unapplied deposits to aid reconciliation. Parameters: - start_date (query, string, optional): Report start date (YYYY-MM-DD). Default: 12 weeks ago. - end_date (query, string, optional): Report end date (YYYY-MM-DD). Default: today. Responses: 200, 401, 403, 422 ### POST /api/v1/invoices/cash-receipts/dismiss Dismiss a transaction from cash receipts Mark a bank transaction as not a customer deposit so it is excluded from the Cash Receipts Reconciliation totals and weekly breakdown. Request body (CashReceiptDismissRequest): - transaction_id (string, required) - reason (string, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/invoices/cash-receipts/restore Restore a dismissed cash receipt Un-dismiss a transaction so it reappears in the Cash Receipts Reconciliation report and totals. Parameters: - transaction_id (query, string, required): UUID of the transaction to restore. Responses: 201, 401, 403, 404, 422 ### GET /api/v1/invoices/cash-receipts/week-detail Cash receipts week detail Returns individual deposit transactions for a given week, including which invoices and bills each deposit was applied to. Parameters: - week_start (query, string, required): Monday of the target week (YYYY-MM-DD). Responses: 200, 400, 401, 403, 422 ### GET /api/v1/invoices/collections AR collections dashboard Returns overdue invoices plus AR collection workflow run history and recorded collection reminder emails when present in the database. Responses: 200, 401, 403, 422 ### PATCH /api/v1/invoices/collections/settings Update collections settings Turn automatic friendly reminders on or off. When on, the weekly collections run emails customers whose invoices are 1-30 days overdue; firm and final notices always wait for a person. Request body (CollectionSettingsUpdate): - auto_send_reminders (boolean, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/invoices/deposit-candidates List deposit candidates Return income transactions that may represent customer deposits. Filters to posted income transactions with unallocated balances, useful for the AI deposit sidebar on the invoices page. Parameters: - limit (query, integer, optional): Max results Responses: 200, 401, 403, 422 ### POST /api/v1/invoices/drafts/bulk-delete Bulk delete draft invoices Delete many draft invoices in one call: name them with `invoice_ids`, or set `all_drafts` (optionally with a due-date window) to clear every draft. Only drafts can be deleted: a selection that includes any other status is refused whole (400) and nothing is deleted. Each deletion runs the single-invoice path in its own savepoint, so a draft that cannot be deleted is reported without blocking the rest. Request body (BulkDeleteDraftInvoicesRequest): - invoice_ids (array · string, optional) - all_drafts (boolean, optional) - start_date (string · date, optional) - end_date (string · date, optional) - dry_run (boolean, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/invoices/match Trigger payment matching Run the payment matching engine to find likely bank transactions for open invoices. When auto_match is true, high-confidence matches (>= 0.85) are auto-linked; otherwise all matches are surfaced as suggestions. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/invoices/metrics Get invoice metrics Retrieve aggregated invoice metrics for the business: total outstanding balance and total overdue balance. Responses: 200, 401, 403, 422 ### GET /api/v1/invoices/scheduled Upcoming scheduled invoices Forward-looking list of invoices that will auto-draft on their scheduled day — future occurrences of active recurring invoice templates and upcoming contract billing periods — within the horizon. Parameters: - days (query, integer, optional): Horizon in days to project scheduled invoices forward (default 90, max 730). Only bounds templates/contracts without an explicit end date — a recurring template with an end date always projects its full remaining run through that date, regardless of this value. Responses: 200, 401, 403, 422 ### GET /api/v1/invoices/suggestions List payment suggestions List auto-detected payment match suggestions for the business. Parameters: - status (query, string, optional): Filter by status: pending, accepted, rejected, expired - min_confidence (query, number, optional): Minimum confidence - limit (query, integer, optional): Max results Responses: 200, 401, 403, 422 ### POST /api/v1/invoices/suggestions/{suggestion_id}/accept Accept payment suggestion Accept an auto-detected payment suggestion. Creates an InvoicePayment record and updates the invoice status. Parameters: - suggestion_id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/invoices/suggestions/{suggestion_id}/reject Reject payment suggestion Dismiss an auto-detected payment suggestion. Parameters: - suggestion_id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/invoices/{invoice_id} Delete invoice Permanently delete a draft, void, or uncollectible invoice. Parameters: - invoice_id (path, string · uuid, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/invoices/{invoice_id} Get invoice Retrieve a specific invoice with all details and line items. Parameters: - invoice_id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/invoices/{invoice_id} Update invoice Update invoice details. Optionally include 'recurring' config to create a recurring template. Parameters: - invoice_id (path, string · uuid, required) Request body (InvoiceUpdateRequest): - id (string, required) - customer_id (string, optional) - line_items (array · LineItemRequest, optional) - due_date (string, optional) - invoice_date (string, optional) - invoice_number (string, optional) - description (string, optional) - fulfillment_location_id (string, optional) - project_id (string, optional) - payment_term_id (string, optional) - tax_exempt (boolean, optional) - contract_id (string, optional) - revenue_treatment (string, optional) - recurring (InvoiceRecurringConfig, optional) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/invoices/{invoice_id}/delivered Mark Invoice Delivered Mark an invoice as delivered to the customer. Parameters: - invoice_id (path, string · uuid, required) - delivered_on (query, string, required): Delivered date (ISO 8601 format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/invoices/{invoice_id}/finalize Finalize invoice Lock an invoice and change status from draft to pending. Parameters: - invoice_id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/invoices/{invoice_id}/journal-entry Generate invoice journal entry Create the finalization journal entry for an invoice that has none linked. Parameters: - invoice_id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/invoices/{invoice_id}/journal-entry/link Attach journal entry to invoice Link an existing journal entry to an invoice. Parameters: - invoice_id (path, string · uuid, required) Request body (JournalEntryLinkRequest): - journal_entry_id (string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### PUT /api/v1/invoices/{invoice_id}/paid Mark Invoice Paid Mark an invoice as paid. Parameters: - invoice_id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/invoices/{invoice_id}/payment-link Get invoice payment link Return the Stripe-hosted payment link for an invoice so it can be paid online. Read-only — available once the invoice has been finalized/sent. Parameters: - invoice_id (path, string · uuid, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/invoices/{invoice_id}/payments List invoice payments Retrieve all payment records for a specific invoice. Parameters: - invoice_id (path, string · uuid, required) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 404, 422 ### POST /api/v1/invoices/{invoice_id}/payments Add payment to invoice Link a bank transaction as payment against an invoice. Supports split payments (one transaction paying multiple invoices) and partial payments (multiple transactions paying one invoice). Parameters: - invoice_id (path, string · uuid, required) Request body (InvoicePaymentRequest): - transaction_id (string, required) - amount (integer, required) - paid_on (string · date-time, optional) - fee_cents (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/invoices/{invoice_id}/payments/{payment_id} Remove payment from invoice Un-link a payment record from an invoice and recalculate status. Parameters: - invoice_id (path, string · uuid, required) - payment_id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/invoices/{invoice_id}/payments/{payment_id} Update payment on invoice Edit the amount or date of an existing payment record. Parameters: - invoice_id (path, string · uuid, required) - payment_id (path, string · uuid, required) Request body (InvoicePaymentUpdateRequest): - amount (integer, optional) - paid_on (string · date-time, optional) - fee_cents (integer, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/invoices/{invoice_id}/payments/{payment_id}/move Move payment to another invoice Move a linked payment (or part of it) from this invoice onto another one in a single step — the fix for a deposit applied to the wrong invoice. Parameters: - invoice_id (path, string · uuid, required) - payment_id (path, string · uuid, required) Request body (InvoicePaymentMoveRequest): - target_invoice_id (string, required) - amount (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/invoices/{invoice_id}/pdf Get fresh invoice PDF URL Get a fresh PDF download URL for this invoice from Stripe. URLs expire, so call this when you need to download. Parameters: - invoice_id (path, string · uuid, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/invoices/{invoice_id}/pdf/internal Download DayZero-generated invoice PDF Stream a PDF rendered by DayZero (not the Stripe-hosted one), including the business's custom footer text and banking details block. Works for any invoice, including drafts and invoices without Stripe integration. Parameters: - invoice_id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/invoices/{invoice_id}/send Send invoice via email Send an invoice to the customer via email. Optionally attach the PDF and CC the sender. Parameters: - invoice_id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/invoices/{invoice_id}/stripe/sync Check invoice payment in Stripe Read the invoice's live payment state from Stripe (paid, processing, failed, awaiting payment) and, when Stripe has collected it but the invoice is still open here, record the payment. Parameters: - invoice_id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/invoices/{invoice_id}/suggestions List suggestions for invoice List auto-detected payment match suggestions for a specific invoice. Parameters: - invoice_id (path, string · uuid, required) - status (query, string, optional): Filter by status Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/invoices/{invoice_id}/uncollectible Mark invoice uncollectible Write off an invoice's remaining balance as bad debt. Parameters: - invoice_id (path, string · uuid, required) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/invoices/{invoice_id}/unpaid Mark Invoice Unpaid Revert a manually-marked-paid invoice back to open/partially paid. Parameters: - invoice_id (path, string · uuid, required) - unlink_payments (query, boolean, optional): Unlink every bank payment linked to the invoice first, so an invoice settled by linked payments reopens too. The bank transactions are kept and can be linked to another invoice. Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/invoices/{invoice_id}/void Void invoice Cancel an invoice by setting its status to void. Parameters: - invoice_id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ## journal-entries — Double-entry bookkeeping with balanced debit/credit lines. ### GET /api/v1/journal-entries List journal entries Retrieve journal entries with filtering by date, ledger, source, and text search. Parameters: - id (query, array · string, optional): Filter by journal entry IDs (comma-separated UUIDs) - description (query, string, optional): Filter by description (partial match) - invoice_id (query, string, optional): Filter by linked invoice UUID - ledger_id (query, string, optional): Filter by ledger account UUID (returns entries with line entries affecting this ledger) - source (query, array · string, optional): Filter by one or more backend origins: manual, invoice, bill, credit_memo, transaction, stripe, shopify, plaid, ramp, square, system. Also accepts hand_typed (manual entries a person keyed in), bulk_upload (manual entries posted from a spreadsheet upload) and credit_ledger (entries a credit program posted) - creation_method (query, JournalEntryCreationMethodEnum, optional): Filter by creation method: ai (system-generated) or manual (user-typed) - start_date (query, string, optional): Filter entries on or after this date (ISO 8601: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ) - end_date (query, string, optional): Filter entries on or before this date (ISO 8601: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ) - search (query, string, optional): Search journal entries by entry number (e.g. JE-0015, 15), description, source, line memo, ledger/account name, or line amount (case-insensitive partial match) - created_by_user_id (query, string, optional): Filter by the user id that created the entry (entries made before attribution was recorded have none) - linked_to (query, string, optional): Filter by linked source document: bill, invoice, credit_memo, vendor_credit, or none (no link) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/journal-entries Create journal entry Create a new double-entry journal entry with balanced line entries. Request body (JournalEntryCreateRequest): - description (string, optional) - currency (string, optional) - date (string · date, optional) - line_entries (array · JournalLineEntryCreate, optional) - invoice_id (string, optional) - inventory_order_id (string, optional) - combine_duplicate_lines (boolean, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/journal-entries/bulk-upload/post Post bulk journal entries Create all journal entries from a previously validated bulk upload file. Refused (400) unless this s3_key was previewed in the last 24 hours without errors and the file is unchanged (VALIDATION_571/572/573), or when plan_hash is sent and differs from the preview's (VALIDATION_640). Request body (BulkJournalEntryUploadRequest): - s3_key (string, required) - plan_hash (string, optional) Responses: 202, 400, 401, 403, 404, 422 ### POST /api/v1/journal-entries/bulk-upload/preview Preview bulk journal entry upload Parse and validate a CSV/Excel file of journal entries without creating anything. Returns a structured preview with per-entry validation. Request body (BulkJournalEntryUploadRequest): - s3_key (string, required) - plan_hash (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/journal-entries/bulk-upload/template Download bulk JE upload template Get a bulk journal entry XLS template pre-populated with the business's chart of accounts. Responses: 200, 401, 403, 422 ### DELETE /api/v1/journal-entries/{journal_entry_id} Delete journal entry Delete a journal entry and all its associated line entries. Parameters: - journal_entry_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/journal-entries/{journal_entry_id} Get journal entry Retrieve a single journal entry with all its line entries. Parameters: - journal_entry_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/journal-entries/{journal_entry_id} Update journal entry Update an existing journal entry's description, date, or line entries. Parameters: - journal_entry_id (path, string, required) Request body (JournalEntryUpdateRequest): - description (string, optional) - date (string, optional) - line_entry_changes (object, optional) - invoice_id (string, optional) - inventory_order_id (string, optional) - credit_memo_id (string, optional) - vendor_credit_id (string, optional) - production_run_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### PATCH /api/v1/journal-entries/{journal_entry_id}/attachment Attach file to journal entry Upload and attach a document file to a journal entry. Parameters: - journal_entry_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/journal-entries/{journal_entry_id}/reverse Reverse journal entry Create an offsetting journal entry that mirrors the original with flipped debits and credits. Parameters: - journal_entry_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## ledgers — Chart of accounts — asset, liability, equity, revenue, and expense accounts. ### GET /api/v1/ledgers List ledgers Retrieve chart of accounts (ledgers) for the business. Parameters: - id (query, array · string, optional): Filter by specific ledger UUIDs - name (query, string, optional): Filter by ledger name (partial match) - type (query, string, optional): Filter by type: asset, liability, equity, revenue, expense - status (query, string, optional): Filter by status: active, inactive - include_balances (query, boolean, optional): Fill each ledger's `balance` (cents) from the books as of `as_of_date`. Off by default: `balance` is then null. - as_of_date (query, string, optional): Balance date (YYYY-MM-DD) for include_balances; defaults to today - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/ledgers Create ledger Create a new account in the chart of accounts. Request body (LedgerCreateRequest): - name (string, required) - currency (string, optional) - editable (boolean, optional) - type (string, optional) - description (string, optional) - account_number (string, optional) - status (string, optional) - debit_credit (string, optional) - sort_code (integer, optional) - sub_type (string, optional) - report_cash_flow (boolean, optional) - financial_account_type (string, optional) - parent_id (string, optional) - cash_flow_section (CashFlowSectionEnum, optional) - cfs_class (CashFlowClassEnum, optional) - depreciation_tag (DepreciationTagEnum, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/ledgers/apply-coa Apply AI-generated COA Apply an AI-generated or custom chart of accounts template to the business, upserting over existing ledgers. Protected ledgers (system, required, bank-linked) are skipped. Existing custom ledgers not present in the template are deactivated. Request body (CustomCoaTemplate): - ledgers (array · CustomCoaLedger, required) → CustomCoaLedger Responses: 201, 400, 401, 403, 422 ### POST /api/v1/ledgers/bulk-update Bulk update ledgers Update multiple ledgers in a single request. Request body (LedgerBulkUpdateRequest): - updates (array · object, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/ledgers/cleanup/analyze Analyse the chart of accounts for cleanup Deterministic cleanup analysis: near-duplicate accounts, accounts with no recent activity, wrong account types, single-child parents and naming inconsistencies. Saves a draft plan; nothing is changed. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/ledgers/cleanup/plans/latest Get the latest cleanup plan The newest cleanup plan that was not discarded, or none. Responses: 200, 401, 403, 422 ### GET /api/v1/ledgers/cleanup/plans/{plan_id} Get a cleanup plan One plan with its actions, findings and approval state. Parameters: - plan_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/ledgers/cleanup/plans/{plan_id} Edit a draft cleanup plan Switch individual proposed actions off or on, allow a cross-type merge explicitly, or discard the plan. Only a draft can be edited. Parameters: - plan_id (path, string, required) Request body (CoaCleanupPlanPatchRequest): - actions (array · CoaCleanupActionToggle, optional) → CoaCleanupActionToggle - override_cross_type (array · string, optional) - discard (boolean, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/ledgers/cleanup/plans/{plan_id}/file File a cleanup plan for approval Create ONE proposed change for the plan's enabled actions. Approving it applies them as a single automation run that can be undone. Parameters: - plan_id (path, string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/ledgers/deletion-status/{workflow_id} Get ledger deletion status Poll for ledger cascade deletion workflow status. Parameters: - workflow_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/ledgers/merge Merge ledgers Merge one or more source ledgers into a target ledger, reassigning all transactions and journal entries. Request body (LedgerMergeRequest): - source_ledger_ids (array · string, required) - target_ledger_id (string, required) - new_name (string, optional) - confirmation (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/ledgers/suggest-cash-flow Suggest cash flow classifications Get deterministic suggestions for cash flow statement classifications based on ledger types and sub-types. Responses: 201, 401, 403, 422 ### POST /api/v1/ledgers/suggest-cleanup AI account cleanup suggestions Get AI-powered suggestions for chart of accounts cleanup. Read-only; rate limited per user and gated on monthly AI quota. Responses: 200, 401, 403, 422, 429 ### DELETE /api/v1/ledgers/{ledger_id} Delete ledger Permanently delete a ledger/account. Parameters: - ledger_id (path, string, required) Responses: 200, 401, 403, 404, 409, 422 ### GET /api/v1/ledgers/{ledger_id} Get ledger Retrieve a specific ledger/account with full details. Parameters: - ledger_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/ledgers/{ledger_id} Update ledger Update an existing ledger account. Parameters: - ledger_id (path, string, required) Request body (LedgerUpdateRequest): - name (string, optional) - type (string, optional) - description (string, optional) - account_number (string, optional) - status (string, optional) - debit_credit (string, optional) - sort_code (integer, optional) - sub_type (string, optional) - report_cash_flow (boolean, optional) - cash_flow_section (CashFlowSectionEnum, optional) - cfs_class (CashFlowClassEnum, optional) - depreciation_tag (DepreciationTagEnum, optional) - editable (boolean, optional) - parent_id (string, optional) - financial_account_type (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/ledgers/{ledger_id}/cascade Cascade delete ledger Start a Temporal workflow that deletes a ledger and all dependent records. Poll GET /ledgers/deletion-status/{workflow_id} for progress. Parameters: - ledger_id (path, string, required) Responses: 200, 202, 400, 401, 403, 404, 422 ### GET /api/v1/ledgers/{ledger_id}/cascade-preview Preview ledger cascade delete Preview dependent records that would be deleted when permanently removing a ledger. Parameters: - ledger_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ## loans ### POST /api/v1/loans/accrue-interest Run interest accrual across all active loans Accrue interest on every active loan through a date. Request body (LoanRunAccrualsRequest): - through_date (string · date, required) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/loans/subledger Loan subledger summary grouped by counterparty Business-wide loan subledger grouped by counterparty. Parameters: - direction (query, DebtDirectionEnum, optional): Filter by direction: `lend` or `borrow`. Responses: 200, 400, 401, 403, 422 ### POST /api/v1/loans/{instrument_id}/accrue-interest Accrue interest on one loan Accrue interest on one loan through a date. Parameters: - instrument_id (path, string, required) Request body (LoanAccrueInterestRequest): - through_date (string · date, required) - memo (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### PATCH /api/v1/loans/{instrument_id}/counterparty Re-tag a loan's counterparty type Re-tag the counterparty classification of a loan. Parameters: - instrument_id (path, string, required) Request body (LoanCounterpartyUpdateRequest): - counterparty_type (LoanCounterpartyTypeEnum, required) → LoanCounterpartyTypeEnum Responses: 200, 401, 403, 404, 422 ### POST /api/v1/loans/{instrument_id}/disbursements Record an additional loan disbursement Record an additional draw/advance on an existing loan. Parameters: - instrument_id (path, string, required) Request body (LoanDisbursementRequest): - amount_cents (integer, required) - cash_ledger_id (string, required) - disbursement_date (string · date, optional) - memo (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/loans/{instrument_id}/subledger Get a loan's subledger register A single loan's full subledger register, oldest entry first. Parameters: - instrument_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/loans/{instrument_id}/write-off Write off a loan Write off all (default) or part of a loan's balance. Parameters: - instrument_id (path, string, required) Request body (LoanWriteOffRequest): - write_off_date (string · date, optional) - principal_cents (integer, optional) - memo (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ## managerial-key-mappings ### GET /api/v1/businesses/{business_id}/managerial-key-mappings Get the managerial key mapping table One row per ledger in the chart of accounts (all account types) with a ``keys`` object holding the mapped category under every active key type, ``null`` where unmapped. Parameters: - business_id (path, string, required) - key_type (query, string, optional): Return only this key type's column. - only_mapped (query, boolean, optional): Drop ledgers that have no value under any returned key. Responses: 200, 400, 401, 403, 422 ### PUT /api/v1/businesses/{business_id}/managerial-key-mappings Bulk upsert managerial key mappings Apply ``[{ledger_id, key_type, value}]`` cells. A ``null`` value clears the cell; cells not referenced are left untouched. Responds with the refreshed table. Parameters: - business_id (path, string, required) Request body (ManagerialKeyMappingUpsertRequest): - items (array · ManagerialKeyMappingItem, optional) → ManagerialKeyMappingItem Responses: 200, 400, 401, 403, 422 ### GET /api/v1/businesses/{business_id}/managerial-key-mappings/export.csv Export the managerial key mapping table as CSV Flat CSV with one row per ledger and one column per active key type. Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/businesses/{business_id}/managerial-key-mappings/key-types List managerial key types Return every key type (column) of the Managerial Key Mapping table. The two built-in defaults are always present and flagged ``is_default: true`` even before they have been customised. Parameters: - business_id (path, string, required) Responses: 200, 401, 403, 422 ### POST /api/v1/businesses/{business_id}/managerial-key-mappings/key-types Create a managerial key type Add a new key type (a column of the mapping table). The key is a lowercase slug and must be unique within the business. Parameters: - business_id (path, string, required) Request body (ManagerialKeyTypeCreateRequest): - key (string, required) - label (string, required) - description (string, optional) - sort_order (integer, optional) Responses: 201, 400, 401, 403, 409, 422 ### DELETE /api/v1/businesses/{business_id}/managerial-key-mappings/key-types/{key} Delete a managerial key type Remove a key type. Refused while the key still has ledger mappings unless ``force=true``, which deletes those mappings too. Built-in defaults are deactivated rather than removed. Parameters: - business_id (path, string, required) - key (path, string, required) - force (query, boolean, optional): Also delete this key type's ledger mappings. Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/businesses/{business_id}/managerial-key-mappings/key-types/{key} Update a managerial key type Relabel, reorder, or (de)activate a key type. Updating a built-in default materialises its definition row. Parameters: - business_id (path, string, required) - key (path, string, required) Request body (ManagerialKeyTypeUpdateRequest): - label (string, optional) - description (string, optional) - sort_order (integer, optional) - is_active (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ## mandates-public ### GET /api/v1/public/mandates/verify Verify a payment mandate signature (unauthenticated) Whether `signature` matches the stored canonical mandate `mandate_id`. Returns `valid` with the per-payment ceiling band, or `invalid`; never an amount, a vendor or a name. Rate-limited per IP. Parameters: - mandate_id (query, string, required) - signature (query, string, required) Responses: 200, 422, 429 ## mcp-approvals ### GET /api/v1/mcp-approvals/{approval_id} Get a waiting MCP write The write an MCP client is waiting to run: tool, business, summary, arguments, expiry and decision. Only for the user it belongs to, signed in to the app. Parameters: - approval_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/mcp-approvals/{approval_id}/decision Approve or decline a waiting MCP write Record the signed-in user's decision. The MCP client runs an approved write once with confirm_write; a declined one is discarded. Not available to API tokens: a person decides in the app. Parameters: - approval_id (path, string, required) Request body (McpApprovalDecisionRequest): - approve (boolean, required) - note (string, optional) - always_allow (boolean, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ## mcp-connections ### GET /api/v1/mcp-connections/connections List MCP connections External MCP servers connected to this business, with their tools. Responses: 200, 401, 403, 422 ### POST /api/v1/mcp-connections/connections Connect an MCP server Connect a server that needs no sign-in or a static API key / bearer header. The server is contacted once to verify it and read its tools. Request body (McpConnectionCreateRequest): - name (string, required) - server_url (string, required) - auth_type (string, optional) - headers (object, optional) - trust_read_only_hints (boolean, optional) Responses: 201, 400, 401, 403, 409, 422 ### DELETE /api/v1/mcp-connections/connections/{connection_id} Disconnect an MCP server Deletes the connection and its stored credentials. Parameters: - connection_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/mcp-connections/connections/{connection_id} Get an MCP connection Parameters: - connection_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/mcp-connections/connections/{connection_id} Update an MCP connection Rename, switch off, change trust policy (trust the server's read-only hints, block individual tools) or replace the stored API key. Parameters: - connection_id (path, string, required) Request body (McpConnectionUpdateRequest): - name (string, optional) - enabled (boolean, optional) - trust_read_only_hints (boolean, optional) - blocked_tools (array · string, optional) - read_tools (array · string, optional) - headers (object, optional) - agents_enabled (boolean, optional) - agent_role_ids (array · string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/mcp-connections/connections/{connection_id}/refresh-tools Refresh an MCP server's tool list Parameters: - connection_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/mcp-connections/oauth/callback External MCP OAuth callback Handle the redirect from an MCP server's authorization page. Parameters: - code (query, string, optional): Authorization code - state (query, string, optional): Single-use OAuth state nonce - error (query, string, optional): Set when the user denies access Responses: 200, 422 ### POST /api/v1/mcp-connections/oauth/start Start OAuth for an MCP server Discover the server's authorization endpoints, register DayZero as a client, and return the URL to send the admin to. Also sets a browser-binding cookie the callback requires. Request body (McpOAuthStartRequest): - name (string, required) - server_url (string, required) - trust_read_only_hints (boolean, optional) - oauth_client_id (string, optional) - oauth_client_secret (string, optional) Responses: 200, 400, 401, 403, 409, 422 ## meta-ads ### GET /api/v1/meta-ads/accounts List Meta ad accounts The ad accounts the connected Meta user can read, with sync settings. Responses: 200, 400, 401, 403, 422 ### POST /api/v1/meta-ads/accounts/refresh Re-list Meta ad accounts Ask Meta again which ad accounts the token can read. Responses: 201, 400, 401, 403, 422 ### PATCH /api/v1/meta-ads/accounts/{account_id} Update a Meta ad account's sync setting Include or exclude one ad account from the spend pull. Parameters: - account_id (path, string, required) Request body (MetaAdAccountUpdateRequest): - sync_enabled (boolean, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/meta-ads/billing-statements Read Meta supplier-statement reconciliations Read up to 100 statements with current spend, payment and evidence checks. This is separate from the lag-based estimate. Responses: 200, 401, 403, 422 ### POST /api/v1/meta-ads/billing-statements Record a Meta supplier statement Record invoice evidence, opening/closing payables, tax/credits and explicit bank-charge allocations in original currency minor units. Saves a draft; posts no journal entries. Request body (MetaAdsBillingStatementRequest): - ad_account_id (string · uuid, required) - reference (string, required) - evidence_reference (string, required) - period_start (string · date, required) - period_end (string · date, required) - currency (string, required) - spend_minor (integer, required) - tax_minor (integer, optional) - credits_minor (integer, optional) - opening_payable_minor (integer, required) - closing_payable_minor (integer, required) - charge_allocations (object, optional) Responses: 201, 400, 401, 403, 409, 422 ### PUT /api/v1/meta-ads/billing-statements/{statement_id} Edit a draft Meta supplier statement Edit evidence before confirmation. Reopen a confirmed statement first; confirmed allocations cannot silently change. Parameters: - statement_id (path, string · uuid, required) Request body (MetaAdsBillingStatementRequest): - ad_account_id (string · uuid, required) - reference (string, required) - evidence_reference (string, required) - period_start (string · date, required) - period_end (string · date, required) - currency (string, required) - spend_minor (integer, required) - tax_minor (integer, optional) - credits_minor (integer, optional) - opening_payable_minor (integer, required) - closing_payable_minor (integer, required) - charge_allocations (object, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/meta-ads/billing-statements/{statement_id}/review Confirm or reopen Meta billing evidence Confirm only if spend, payable roll-forward and allocated charges agree. Serializes confirmations to prevent reusing a charge. Reopen to release allocations and edit. Parameters: - statement_id (path, string · uuid, required) Request body (MetaAdsBillingReviewRequest): - action (string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/meta-ads/connect-url Get Meta Ads connect URL Generate the Facebook Login URL that grants DayZero read access to the user's ad accounts. Works for a first connection and for reconnecting after the long-lived token expires. Responses: 200, 400, 401, 403, 422 ### POST /api/v1/meta-ads/data-deletion Meta data deletion callback Called by Meta when a person asks for their data to be deleted. Verifies the signed_request, deletes that person's Meta Ads connections with their ad accounts and pulled spend, and answers with Meta's required {url, confirmation_code}. Responses: 201, 400, 422 ### GET /api/v1/meta-ads/data-deletion/{confirmation_code} Meta data deletion status Public status page for a Meta data deletion request: the link Meta shows the person. Deletion runs before the code is issued, so a valid code always reads as deleted. Parameters: - confirmation_code (path, string, required) Responses: 200, 404, 422 ### POST /api/v1/meta-ads/deauthorize Meta deauthorize callback Called by Meta when a person removes DayZero from their Facebook settings. Verifies the signed_request and flags that person's Meta Ads connections for reconnect; nothing is deleted. Responses: 201, 400, 422 ### DELETE /api/v1/meta-ads/disconnect Disconnect Meta Ads Remove the Meta connection, its ad accounts and the pulled spend. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/meta-ads/oauth/callback Meta Ads OAuth callback Handle the Facebook Login redirect. Called by Meta, not the SPA. Parameters: - code (query, string, optional): Authorization code from Meta - state (query, string, optional): Single-use state nonce - error (query, string, optional): Set when the person declined - error_description (query, string, optional) Responses: 200, 422 ### GET /api/v1/meta-ads/performance Read attribution-aware Meta performance Cached campaign/ad-set/ad conversions and value for exactly one action type, split by account, currency and attribution cohort. ROAS is conversion value divided by spend; missing legacy metrics stay unavailable. Does not sum reach or overlapping event types. Parameters: - since (query, string · date, required) - until (query, string · date, required) - level (query, string, optional) - action_type (query, string, optional) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/meta-ads/reconciliation Meta ad spend vs. charges in the books Compare what Meta reports as spend with the Meta charges (FACEBK, META ADS, ...) that reached the books through bank and card feeds, per calendar month (or one window) and per currency, with the spend still unbilled at each period's edges and a status per period. Also lists Meta charges booked outside Advertising & Marketing. Read-only. Parameters: - since (query, string · date, optional): First day, YYYY-MM-DD (default: first day of the month two months ago) - until (query, string · date, optional): Last day, YYYY-MM-DD (default: today) - period (query, string, optional): 'month' for calendar months, 'window' for one period Responses: 200, 400, 401, 403, 422 ### POST /api/v1/meta-ads/reconciliation/fix-miscategorized Fix miscategorized Meta Ads charges Propose a pending change to recategorize Meta Ads charges booked outside Advertising & Marketing to the business's Advertising & Marketing expense ledger. Responses: 200, 400, 401, 403, 422 ### POST /api/v1/meta-ads/reconciliation/propose-accrual Propose unbilled Meta Ads spend accrual Propose a reversing month-end accrual for unbilled Meta Ads spend as of the period end date. Responses: 200, 400, 401, 403, 422 ### PATCH /api/v1/meta-ads/settings Update Meta Ads sync settings Change auto-sync, the trailing re-pull window, or the backfill depth. Request body (MetaAdsSettingsUpdateRequest): - insights_level (string, optional) - attribution_windows (array · string, optional) - auto_sync_enabled (boolean, optional) - lookback_days (integer, optional) - initial_backfill_days (integer, optional) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/meta-ads/spend Meta ad spend Spend between two dates (inclusive), grouped by day, ad account or campaign. Amounts are in each account currency's minor unit and are never summed across currencies. Parameters: - since (query, string · date, optional): First day, YYYY-MM-DD (default: 30 days ago) - until (query, string · date, optional): Last day, YYYY-MM-DD (default: today) - group_by (query, string, optional) - account_id (query, array · string, optional): Restrict to these ad account ids (DayZero ids) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/meta-ads/status Meta Ads connection status Connection health, token expiry, the ad accounts found, and spend totals for the last 30 days per currency. Responses: 200, 401, 403, 422 ### POST /api/v1/meta-ads/sync Pull Meta ad spend Pull campaign-level daily spend for every enabled ad account via Temporal, falling back to an inline run when Temporal is unreachable. Responses: 201, 400, 401, 403, 422 ## mileage ### GET /api/v1/mileage List mileage trips Trips with totals, optionally filtered by year, dates, customer, project or billable. Parameters: - year (query, integer, optional): Calendar year. - date_from (query, string · date, optional) - date_to (query, string · date, optional) - customer_id (query, string, optional) - project_id (query, string, optional) - billable (query, boolean, optional) - include_inactive (query, boolean, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/mileage Create mileage trip Log a trip. The year's rate is snapshotted unless overridden. Request body (MileageTripCreateRequest): - trip_date (string · date, required) - miles (number, required) - purpose (string, required) - start_location (string, optional) - end_location (string, optional) - customer_id (string, optional) - project_id (string, optional) - class_id (string, optional) - billable (boolean, optional) - rate_cents_per_mile (number, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/mileage/add-to-expense-report Add trips to an expense report Append unbooked trips to a draft USD expense report as lines. Request body (AddTripsToExpenseReportRequest): - trip_ids (array · string, required) - expense_report_id (string, required) - ledger_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/mileage/export Export trips as CSV The filtered trips as a CSV download. Parameters: - year (query, integer, optional) - date_from (query, string · date, optional) - date_to (query, string · date, optional) - customer_id (query, string, optional) - project_id (query, string, optional) - billable (query, boolean, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/mileage/post Post trips as expense journal entries Post each unbooked trip as Dr expense / Cr offset. Refused for trip dates in a closed accounting period. Request body (PostTripsRequest): - trip_ids (array · string, required) - expense_ledger_id (string, required) - offset_ledger_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/mileage/rates List mileage rates Explicit per-year mileage rates plus the configured default. Responses: 200, 401, 403, 422 ### DELETE /api/v1/mileage/rates/{year} Remove mileage rate for a year Remove the explicit rate so the year uses the default again. Parameters: - year (path, integer, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/mileage/rates/{year} Get mileage rate for a year The rate in force for a year (the default when none is set). Parameters: - year (path, integer, required) Responses: 200, 401, 403, 422 ### PUT /api/v1/mileage/rates/{year} Set mileage rate for a year Set the cents-per-mile rate for a year. Existing trips keep the rate they were saved with. Parameters: - year (path, integer, required) Request body (MileageRateRequest): - rate_cents_per_mile (number, required) Responses: 200, 400, 401, 403, 422 ### DELETE /api/v1/mileage/{trip_id} Delete mileage trip Soft-delete a trip that isn't on a report or posted. Parameters: - trip_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/mileage/{trip_id} Get mileage trip Get a single trip. Parameters: - trip_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/mileage/{trip_id} Update mileage trip Update a trip. Date, miles and rate are locked once the trip is on an expense report or posted. Parameters: - trip_id (path, string, required) Request body (MileageTripUpdateRequest): - trip_date (string · date, optional) - miles (number, optional) - purpose (string, optional) - start_location (string, optional) - end_location (string, optional) - customer_id (string, optional) - project_id (string, optional) - class_id (string, optional) - billable (boolean, optional) - rate_cents_per_mile (number, optional) Responses: 200, 400, 401, 403, 404, 422 ## month-end-packages ### GET /api/v1/month-end-packages List month-end packages List all month-end packages requested for the business. Parameters: - status (query, string, optional): Filter by status: queued, in_progress, ready, failed - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/month-end-packages Queue a month-end package build Persist a queued package row and start the Temporal build workflow. Request body (MonthEndPackageCreateRequest): - accounting_period_id (string, optional) - period_start (string · date, optional) - period_end (string · date, optional) - report_format (MonthEndPackageFormatEnum, optional) → MonthEndPackageFormatEnum - selected_reports (array · string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/month-end-packages/{package_id} Get month-end package Get a single month-end package by id (poll for build progress). Parameters: - package_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/month-end-packages/{package_id}/download Get download URL Generate a short-lived presigned S3 URL for the package zip. Parameters: - package_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ## nexus ### GET /api/v1/nexus/exposure Nexus exposure by state Destination sales per state against each state's economic nexus threshold, highest share first. Thresholds are unverified. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/nexus/recompute Recompute nexus exposure Measure every state now; raises notifications on upward moves. Responses: 201, 401, 403, 404, 422 ### GET /api/v1/nexus/registrations List sales tax registrations States the business recorded as registered. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/nexus/registrations Mark a state registered Record that the business is registered to collect sales tax in a state. This only records it; DayZero does not register anything. Request body (NexusRegistrationCreate): - state (string, required) - registration_number (string, optional) - registered_at (string · date, optional) - filing_frequency (string, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### DELETE /api/v1/nexus/registrations/{state} Clear a registration Clear a registration recorded by mistake (soft delete). Parameters: - state (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### PATCH /api/v1/nexus/registrations/{state} Update a registration Edit the registration number, date, filing frequency or notes. Parameters: - state (path, string, required) Request body (NexusRegistrationUpdate): - registration_number (string, optional) - registered_at (string · date, optional) - filing_frequency (string, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/nexus/thresholds Nexus threshold reference table The versioned reference table of economic nexus thresholds. Every entry is unverified; this is not legal or tax advice. Responses: 200, 401, 403, 422 ## notes — Internal notes attached to businesses and entities. ### GET /api/v1/notes List notes for a business Retrieve all notes for the current business, ordered by pinned then most recently updated. Responses: 200, 401, 403, 422 ### POST /api/v1/notes Create a note Create a new note for the current business. Request body (NoteCreateRequest): - title (string, optional) - body (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/notes/bulk Bulk-create notes (localStorage migration) Create multiple notes at once, used to migrate existing localStorage notes to the database. Request body (NoteBulkCreateRequest): - notes (array · NoteCreateRequest, required) → NoteCreateRequest Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/notes/reminders/{reminder_id} Cancel a reminder Deactivate a scheduled reminder. Parameters: - reminder_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/notes/{note_id} Delete a note Soft-delete a note. Parameters: - note_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/notes/{note_id} Get a single note Retrieve a single note by ID. Parameters: - note_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/notes/{note_id} Update a note Partially update a note's title, body, or pinned status. Parameters: - note_id (path, string, required) Request body (NoteUpdateRequest): - title (string, optional) - body (string, optional) - pinned (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/notes/{note_id}/attachments Register note attachment Register a new attachment for a note after successful S3 upload. Parameters: - note_id (path, string, required) Request body (NoteAttachmentCreateRequest): - file_name (string, required) - file_size (integer, required) - mime_type (string, required) - s3_key (string, required) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/notes/{note_id}/attachments/upload-url Get upload URL for note attachment Generate a presigned URL to upload a file to S3 for a note. Parameters: - note_id (path, string, required) Request body (NoteAttachmentUploadUrlRequest): - file_name (string, required) - mime_type (string, required) - file_size (integer, required) Responses: 201, 401, 403, 404, 422 ### DELETE /api/v1/notes/{note_id}/attachments/{attachment_id} Delete note attachment Soft-delete a note attachment. Parameters: - note_id (path, string, required) - attachment_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/notes/{note_id}/attachments/{attachment_id}/download-url Get download URL for note attachment Generate a presigned URL to download a note attachment. Parameters: - note_id (path, string, required) - attachment_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/notes/{note_id}/notify Notify business users about a note Send an inbox notification about this note to all users of the business. The note must have a non-empty body. Parameters: - note_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/notes/{note_id}/reminders List reminders for a note Get all active reminders for a specific note. Parameters: - note_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/notes/{note_id}/reminders Schedule a reminder for a note Set a one-time or recurring notification reminder for a note. Pick a date/time and optionally set recurrence (daily, weekly, monthly). Parameters: - note_id (path, string, required) Request body (ReminderCreateRequest): - scheduled_at (string · date-time, required) - recurrence (ReminderRecurrence, optional) → ReminderRecurrence Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/notes/{note_id}/rewrite AI rewrite of note body Use AI to rewrite the note body. Returns a preview; the caller must PATCH to apply. Parameters: - note_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## notification-preferences — Manage email and in-app notification settings. ### GET /api/v1/preferences/notifications/topics Get Topic Overrides Endpoint Return the per-topic channel overrides for the current user. Responses: 200, 422 ### PUT /api/v1/preferences/notifications/topics Update Topic Overrides Endpoint Replace the per-topic channel override map for the current user. Request body (TopicChannelOverridesUpdate): - overrides (object, optional) Responses: 200, 422 ## notifications ### GET /api/v1/notifications List notifications Get the caller's notification feed across all scopes Parameters: - scope (query, NotificationScopeEnum, optional): Scope: 'me' (default), 'business', or 'firm' - scope_id (query, string, optional): Required when scope is 'business' or 'firm' - status (query, array · NotificationStatusEnum, optional): Filter to one or more statuses - topic (query, array · NotificationTopicEnum, optional): Filter to one or more topics - severity (query, array · NotificationSeverityEnum, optional): Filter to one or more severities - include_terminal (query, boolean, optional): Include resolved + dismissed rows - include_snoozed (query, boolean, optional): Include snoozed rows whose timer hasn't elapsed - include_live (query, boolean, optional): Merge live alerts (low cash, plaid stale, etc.) as virtual rows when a business context is available. - live_business_id (query, string, optional): When scope='me', merge live alerts for this specific business id. Ignored for scope='business' which uses scope_id as the business context. - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size - sort (query, NotificationSortEnum, optional): Sort order: 'newest' (default), 'oldest', 'severity', or 'unread' Responses: 200, 400, 401, 403, 422 ### POST /api/v1/notifications/bulk/dismiss Bulk dismiss Dismiss a batch of notifications. Request body (BulkIdsRequest): - notification_ids (array · string, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/notifications/bulk/seen Bulk mark seen Mark a batch of notifications as seen. Request body (BulkIdsRequest): - notification_ids (array · string, required) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/notifications/count Notification count Unread (``new`` only) count for the bell badge by default. Pass ``unread_only=false`` for the legacy open (new + seen) count. Parameters: - scope_business_id (query, string, optional): Optional: scope to a single business - business_id (query, string, optional): Deprecated alias for `scope_business_id` - unread_only (query, boolean, optional): When true (default), count only unread (``new``) rows. When false, count open rows (``new`` + ``seen`` + expired snoozes). Responses: 200, 401, 403, 422 ### POST /api/v1/notifications/dismiss-all Dismiss all matching notifications Server-authoritative: dismisses EVERY open notification the caller can see that matches the optional scope/topic/severity filters (plus matching live alerts) — not just the page the client has loaded. Request body (BulkAllRequest): - scope (NotificationScopeEnum, optional) → NotificationScopeEnum - scope_id (string, optional) - topic (array · NotificationTopicEnum, optional) - severity (array · NotificationSeverityEnum, optional) - live_business_id (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/notifications/mark-all-seen Mark all matching notifications seen Server-authoritative: marks EVERY notification the caller can see that matches the optional scope/topic/severity filters as seen — not just the page the client has loaded. Request body (BulkAllRequest): - scope (NotificationScopeEnum, optional) → NotificationScopeEnum - scope_id (string, optional) - topic (array · NotificationTopicEnum, optional) - severity (array · NotificationSeverityEnum, optional) - live_business_id (string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/notifications/stream Stream notifications (SSE) Server-Sent Events stream of new notifications for the caller. Responses: 200, 401, 403, 422 ### GET /api/v1/notifications/topic-counts Per-topic notification counts Counts grouped by topic for the filter chip row Parameters: - scope_business_id (query, string, optional): Optional: scope to a single business - business_id (query, string, optional): Deprecated alias for `scope_business_id` Responses: 200, 401, 403, 422 ### GET /api/v1/notifications/{notification_id} Get a single notification Fetch a notification by ID. Auto-marks 'new' rows as 'seen'. Parameters: - notification_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/notifications/{notification_id}/dismiss Dismiss a notification Dismiss (terminal). Virtual notifications use the dismissal table. Parameters: - notification_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### PUT /api/v1/notifications/{notification_id}/pin Pin or unpin a notification Toggle whether a notification is pinned to the top of the feed. Parameters: - notification_id (path, string, required) Request body (SetPinnedRequest): - pinned (boolean, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/notifications/{notification_id}/resolve Resolve a notification Mark resolved (terminal — no further transitions) Parameters: - notification_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/notifications/{notification_id}/seen Mark notification as seen Manually mark a notification as seen Parameters: - notification_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/notifications/{notification_id}/snooze Snooze a notification Snooze a notification until a specific timestamp. Parameters: - notification_id (path, string, required) Request body (SnoozeRequest): - until (string · date-time, required) Responses: 201, 400, 401, 403, 404, 422 ## o2c-webhooks ### GET /api/v1/webhooks/o2c List outbound webhook endpoints List the business's registered webhook endpoints (secret never returned). A credit-scoped token sees only endpoints subscribed to credit events alone. Parameters: - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/webhooks/o2c Register an outbound webhook endpoint Register a URL to receive O2C and/or partner credit events. An unknown event type is refused with 400 naming it. Leave out `secret` and DayZero generates one. The response includes the plaintext `secret` exactly once — store it to verify `X-DayZero-Signature` (`v1=` HMAC-SHA256 of `{timestamp}.{body}`). Registering only credit events at a URL an endpoint subscribed only to credit events already has returns that endpoint (`created: false`, `secret: null`, its subscriptions and `is_active` set as sent), so a partner can call this on every start; `POST /{endpoint_id}/rotate-secret` then gives a new secret, the old one signing too for `overlap_minutes`. Request body (WebhookEndpointCreate): - url (string, required) - event_types (array · string, required) - secret (string, optional) - is_active (boolean, optional) - description (string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/webhooks/o2c/event-types List subscribable webhook event types Every event an endpoint can subscribe to, with its group, a description, whether it is delivered in the standard envelope, and a sample `data` body. The same list validates `event_types` on create and update. Responses: 200, 401, 403, 422 ### DELETE /api/v1/webhooks/o2c/{endpoint_id} Delete a webhook endpoint Delete a webhook endpoint (and its delivery history). Parameters: - endpoint_id (path, string, required) Responses: 204, 401, 403, 404, 422 ### GET /api/v1/webhooks/o2c/{endpoint_id} Get a webhook endpoint Get a single webhook endpoint by ID. Parameters: - endpoint_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/webhooks/o2c/{endpoint_id} Change a webhook endpoint Change the `url`, replace `event_types`, or set `is_active`. Omitted fields are unchanged. Deactivating stops deliveries, and queued retries to it are given up. Parameters: - endpoint_id (path, string, required) Request body (WebhookEndpointUpdate): - url (string, optional) - event_types (array · string, optional) - is_active (boolean, optional) - description (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/webhooks/o2c/{endpoint_id}/deliveries List an endpoint's delivery history Delivery records for the endpoint, oldest first, including `status` (pending/sending/succeeded/retrying/failed), `attempts`, the last `response_code` and first 1 KB of `response_body`, `error`, `latency_ms`, and `next_retry_at` when a retry is queued. Filter by `status`, `event_type`, and `since`. Parameters: - endpoint_id (path, string, required) - status (query, string, optional): Only deliveries in this status, e.g. 'failed'. - event_type (query, string, optional): Only this event type. - since (query, string · date-time, optional): Only deliveries recorded at or after this time. - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 404, 422 ### POST /api/v1/webhooks/o2c/{endpoint_id}/deliveries/{delivery_id}/redeliver Redeliver a webhook delivery Send the delivery's payload to the endpoint again, now. The result is a new delivery linked by `redelivery_of`, carrying the original's `X-DayZero-Delivery-Id` so the receiver can drop a duplicate; the attempt is made during this call (15 seconds at most), so the response carries its `status`, `response_code` and `attempts`. A failed attempt follows the normal retry ladder; an original still waiting to be sent or retried is stopped and marked failed. An original being sent at this moment is refused with `409` `CREDIT_646`. Parameters: - endpoint_id (path, string, required) - delivery_id (path, string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/webhooks/o2c/{endpoint_id}/rotate-secret Rotate an endpoint's signing secret Mint a new secret, returned in this response only. For `overlap_minutes` (default and maximum 60) the old secret keeps signing too: each delivery carries `X-DayZero-Signature` (new secret) and `X-DayZero-Signature-Previous` (old secret). Parameters: - endpoint_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/webhooks/o2c/{endpoint_id}/test-fire Fire a test event POST a synthetic event of `event_type` to this endpoint only, with `"test": true` in the body, signed like a real delivery. A credit event type is sent in the credit event envelope. Unlike a real event, the attempt is made during this call, so the response carries what the receiver answered. Parameters: - endpoint_id (path, string, required) - event_type (query, string, required): Event type to fire, e.g. 'credit.loan.originated' Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/webhooks/slack/o2c-hours Slack webhook: inbound O2C hours submission Receives the `/hours` slash command and `app_mention` events from Slack and turns them into pending drawdown entries awaiting approval. Requests are verified against the Slack signing secret; the Slack workspace must be linked to a business via the O2C settings `slack_team_id`. Responses: 200, 403 ## oauth — OAuth 2.0 authorization code flow for third-party integrations. ### POST /api/v1/oauth2/exchange Exchange Code Exchange a single-use code or refresh token for access + refresh tokens. Responses: 200, 422 ### POST /api/v1/oauth2/partner/token Partner client-credentials token Exchange a signed client assertion for a short-lived access token. Responses: 200, 400, 401, 422, 429 ### POST /api/v1/oauth2/refresh Refresh Token Exchange refresh token for new access token. Responses: 200, 422 ### POST /api/v1/oauth2/token Get Token Issue OAuth access + refresh tokens for a user. Responses: 200, 422 ## oauth-grants ### GET /api/v1/oauth/grants List connected apps List active MCP OAuth grants for the current user Responses: 200, 401, 422 ### DELETE /api/v1/oauth/grants/{grant_id} Revoke connected app Revoke access for a connected OAuth client. Parameters: - grant_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/oauth/grants/{grant_id}/revoke Revoke connected app Revoke access for a connected OAuth client (POST alias). Parameters: - grant_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## onboarding — User and business onboarding workflows. ### POST /api/v1/onboarding/ai-discover Get next AI discovery question Given the account type and conversation so far, returns the next personalised question for the onboarding discovery flow. Request body (AIDiscoverRequest): - account_type (string, required) - conversation (array · ConversationMessage, optional) → ConversationMessage Responses: 201, 400, 422, 429, 500 ### POST /api/v1/onboarding/ai-recommend Generate personalised add-on recommendations Analyses the full discovery conversation, extracts a structured business profile, and returns personalised add-on recommendations. Request body (AIRecommendRequest): - account_type (string, required) - conversation (array · ConversationMessage, required) → ConversationMessage Responses: 201, 400, 422, 429, 500 ### POST /api/v1/onboarding/complete Complete onboarding after Stripe Checkout Called after the user completes Stripe Checkout. Retrieves the session, creates the business, firm, and HubSpot records. Request body (CompleteOnboardingRequest): - stripe_session_id (string, required) Responses: 201, 400, 409, 422, 429 ### POST /api/v1/onboarding/prepare-checkout Create Stripe Checkout session for onboarding Collects plan and add-on selections, creates a Stripe Checkout session with a 30-day free trial. Business is NOT created until /complete is called. Fully Managed (dz-managed) and Firm Enterprise start with a free pilot and are refused with 400 VALIDATION_912. Request body (PrepareCheckoutRequest): - account_type (string, required) - business_name (string, required) - mailbox (string, required) - default_currency (string, optional) - tax_year_end_month (integer, optional) - selected_addons (array · string, optional) - trial_agreed (boolean, required) - billing_interval (string, optional) - firm_name (string, optional) - firm_plan_tier (string, optional) - ein (string, optional) - logo_url (string, optional) - address (string, optional) - num_full_time_accountants (integer, optional) - num_part_time_accountants (integer, optional) - current_tools (array · string, optional) - referral_source (string, optional) - referred_by_email (string, optional) - utm_source (string, optional) - utm_medium (string, optional) - utm_campaign (string, optional) - utm_term (string, optional) - utm_content (string, optional) - gclid (string, optional) - fbclid (string, optional) - landing_page (string, optional) - referrer (string, optional) - success_path (string, optional) - cancel_path (string, optional) Responses: 201, 400, 409, 422, 429, 503 ### GET /api/v1/onboarding/profile Resume in-progress onboarding Returns the persisted onboarding profile (conversation, learned profile fields, recommendations, account_type) for the current user. Used by the Welcome wizard to restore wizard state after a refresh. Responses: 200, 401, 422 ### POST /api/v1/onboarding/upload-url Get pre-signed upload URL for onboarding assets Returns a pre-signed S3 PUT URL for uploading a firm logo during onboarding (no business context required). Request body (OnboardingUploadUrlRequest): - filename (string, required) - content_type (string, optional) Responses: 201, 400, 422, 429 ## orders ### GET /api/v1/orders List orders List order forms for the business with optional filters. Parameters: - status (query, string, optional): Filter by order status - customer_id (query, string, optional): Filter by customer ID - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/orders Create order Create a new draft order with per-line billing rules. Request body (OrderCreate): - customer_id (string, required) - project_id (string, optional) - order_description (string, optional) - order_start_date (string, optional) - first_invoice_date (string, optional) - term_months (integer, optional) - discount_cents (integer, optional) - tax_treatment (string, optional) - currency (string, optional) - lines (array · OrderLineInput, optional) → OrderLineInput Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/orders/from-estimate/{estimate_id} Create order from estimate Convert a draft or accepted estimate into a new draft order. The customer, currency, description, and line items carry over (every line billed as a one-time `flat` fee); an optional `project_id` in the body attaches the order to a project. The estimate is marked converted and linked to the order — converting it a second time (or converting it to an invoice afterwards) is rejected. Parameters: - estimate_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/orders/{order_id} Delete order Delete an order. Allowed for draft, sent, and signed orders (nothing financial has happened yet); a countersigned order can only be deleted after its contract is deleted. Parameters: - order_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/orders/{order_id} Get order Get a single order with its lines. Parameters: - order_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/orders/{order_id} Update order Update a draft order (optionally replacing all lines; the order value is recomputed from them). Revert a sent/signed order to draft first to edit it. Parameters: - order_id (path, string, required) Request body (OrderUpdate): - customer_id (string, optional) - project_id (string, optional) - order_description (string, optional) - order_start_date (string, optional) - first_invoice_date (string, optional) - term_months (integer, optional) - discount_cents (integer, optional) - tax_treatment (string, optional) - currency (string, optional) - lines (array · OrderLineInput, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/orders/{order_id}/attach-contract-file Attach the executed contract file Attach an uploaded executed-contract PDF (the `s3_key` from `POST /upload`, or a URL) to a sent, signed or countersigned order. Completes the presign → upload → attach flow so countersign can freeze the document reference into the contract. Attaching to a **sent** order also marks it signed — the executed copy is the customer's signature — so the stage can be finished. Parameters: - order_id (path, string, required) Request body (OrderAttachContractFileRequest): - signed_contract_file_url (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/orders/{order_id}/countersign Countersign order Countersign a signed order. Freezes the order (the audit baseline) and instantiates a live contract (signed -> countersigned). Parameters: - order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/orders/{order_id}/mark-sent Mark order sent (no email) Move a draft order to sent with no customer-facing side effect. Internal approval path for orders signed out-of-band or backfilled — this path will never notify the customer. (Note: v1 has no outbound order email yet, so today this behaves identically to the send endpoint.) Parameters: - order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/orders/{order_id}/remind-signer Remind the customer to sign Email the order's customer contact a signature reminder referencing the order number. Only valid while a signature is outstanding (status sent or signed); at most one reminder per order per 24 hours. The response's `signer_reminder_sent_at` reflects the send. Parameters: - order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/orders/{order_id}/revert-to-draft Revert order to draft Send a sent or signed (not countersigned) order back to draft so it can be edited. Clears the sent/signed timestamps and any signed contract file. Parameters: - order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/orders/{order_id}/send Send order for signature Send a draft order for signature (draft -> sent). Parameters: - order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/orders/{order_id}/sign Mark order signed Mark a sent order as signed by the customer (sent -> signed). Parameters: - order_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## orders-esign ### GET /api/v1/orders/{order_id}/esign Get an order's e-signature status Current envelope status for the order — refreshed live from the provider when credentials are configured, otherwise the stored snapshot. 400 when the order has no envelope. Parameters: - order_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/orders/{order_id}/esign/send Send an order for e-signature Create an e-signature envelope for a draft or sent order and email it to the customer contact for signing. The request supplies the document (an https URL or an uploaded `s3_key`) since order PDFs are rendered client-side. A draft order is moved to `sent`. Returns 400 when e-signature is not configured, the order is in the wrong status, the customer has no email, or an envelope is already out. Parameters: - order_id (path, string, required) Request body (ESignSendRequest): - document_url (string, required) - subject (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/webhooks/esign E-signature provider webhook Inbound envelope-event receiver for the e-signature provider (DocuSign Connect). Deliveries are authenticated by HMAC-SHA256 signature over the raw body; unsigned or mis-signed deliveries get 403. Envelope `completed` marks the order signed; `declined` and `voided` are recorded. Redeliveries are idempotent. Responses: 200, 400, 403 ## payliance ### POST /api/v1/payliance/bank-candidates List Payliance Bank Candidates Find bank rows for a selected settlement or return total without applying a match. Request body (PaylianceBankCandidatesRequest): - transaction_ids (array · string, required) - kind (string, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/payliance/connect Connect Payliance Verify reporting access and store an encrypted per-business API key. Request body (PaylianceConnectRequest): - api_key (string · password, required) - environment (string, optional) - sync_from (string · date, required) Responses: 201, 401, 403, 422 ### GET /api/v1/payliance/credit-line-candidates Credit Line Candidates Search this lender's merchants for explicit repayment attribution. Parameters: - search (query, string, required) Responses: 200, 401, 403, 422 ### DELETE /api/v1/payliance/disconnect Disconnect Payliance Remove credentials while retaining imported reconciliation evidence. Responses: 200, 401, 403, 422 ### GET /api/v1/payliance/exceptions Open Payliance exceptions Unlinked debits, debits waiting on settlement, returns and review rows. Parameters: - days (query, integer, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/payliance/match-bank Match Payliance Bank Match one or multiple ACH items to an exact bank deposit or return total. Request body (PaylianceBankMatchRequest): - transaction_ids (array · string, required) - kind (string, optional) - bank_transaction_id (string, required) Responses: 201, 401, 403, 422 ### GET /api/v1/payliance/payer-mappings List payer to credit line mappings Each mapped payer, its credit line and how many debits wait on it. Responses: 200, 401, 403, 422 ### POST /api/v1/payliance/payer-mappings Map a Payliance payer to a credit line Map a payer by an imported row, or by the account holder name. Request body (PaylianceMapPayerRequest): - credit_line_id (string, required) - transaction_id (string, optional) - payer_name (string, optional) - account_last4 (string, optional) - use_last4 (boolean, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/payliance/payer-mappings/bulk Preview or apply many payer mappings at once Map several payers to credit lines by account holder name. Request body (PaylianceBulkMapRequest): - items (array · PaylianceBulkMapItem, required) → PaylianceBulkMapItem - apply (boolean, optional) - link_waiting (boolean, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/payliance/payer-mappings/csv Preview or apply payer mappings from a CSV or XLSX Read payer to credit line rows from a file; see the bulk endpoint. Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/payliance/payer-mappings/{mapping_id} Remove a payer mapping Remove a mapping; repayments already recorded keep their links. Parameters: - mapping_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/payliance/payer-mappings/{mapping_id}/link-waiting Link a mapped payer's waiting debits now Record up to 100 of the payer's unlinked debits, oldest first. Parameters: - mapping_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/payliance/status Get Payliance Status Read connection health without exposing credentials. Responses: 200, 401, 403, 422 ### POST /api/v1/payliance/sync Sync Payliance Queue an idempotent background sync of transactions, settlements and returns. Responses: 201, 401, 403, 422 ### GET /api/v1/payliance/transactions List Payliance Transactions List imported ACH evidence with cursor pagination. Parameters: - cursor (query, string, optional) - limit (query, integer, optional) - reference (query, string, optional): Search all imported payment references or authorization IDs before pagination. Responses: 200, 401, 403, 422 ### POST /api/v1/payliance/transactions/{transaction_id}/match-payment Match Payliance Payment Link an existing repayment, or explicitly reconcile a distinct landed debit. Parameters: - transaction_id (path, string, required) Request body (PayliancePaymentMatchRequest): - payment_id (string, optional) - distinct_payment (PaylianceDistinctPaymentRequest, optional) Responses: 201, 401, 403, 422 ### GET /api/v1/payliance/transactions/{transaction_id}/payment-candidates List Payliance Payment Candidates Offer same-amount repayments for explicit operator matching. Parameters: - transaction_id (path, string, required) - credit_line_id (query, string, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/payliance/transactions/{transaction_id}/record-repayment Record Repayment Record a missing repayment from Payliance evidence; never initiate a debit. Parameters: - transaction_id (path, string, required) Request body (PaylianceRecordRepaymentRequest): - credit_line_id (string, required) Responses: 201, 401, 403, 422 ## payment-advisory — AI-powered payment recommendations and cash flow optimization. ### GET /api/v1/payment-advisory/firm-summary Get consolidated AP summary for firm Get AP outstanding/overdue summary across all firm client businesses. Responses: 200, 401, 403, 422 ### GET /api/v1/payment-advisory/recommendations Get payment recommendations Get prioritized payment recommendations for outstanding bills. Responses: 200, 401, 403, 422 ## payment-terms — Net payment terms (Net 30, Due on Receipt, etc.). ### GET /api/v1/payment-terms List payment terms List all payment terms for the business. Parameters: - active_only (query, boolean, optional): Only show active terms - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/payment-terms Create payment term Create a new payment term. Request body (PaymentTermCreateRequest): - name (string, required) - days_until_due (integer, required) - discount_percent (number | string, optional) - discount_days (integer, optional) - is_default (boolean, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/payment-terms/default Get default payment term Get the default payment term for the business. Responses: 200, 401, 403, 404, 422 ### POST /api/v1/payment-terms/seed-defaults Seed default payment terms Seed default payment terms for the business (if none exist). Responses: 201, 401, 403, 422 ### DELETE /api/v1/payment-terms/{term_id} Deactivate payment term Deactivate a payment term (soft delete). Parameters: - term_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/payment-terms/{term_id} Get payment term Get details of a specific payment term. Parameters: - term_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/payment-terms/{term_id} Update payment term Update an existing payment term. Parameters: - term_id (path, string, required) Request body (PaymentTermUpdateRequest): - name (string, optional) - days_until_due (integer, optional) - discount_percent (number | string, optional) - discount_days (integer, optional) - is_default (boolean, optional) - is_active (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ## payroll ### GET /api/v1/payroll/gusto/lines List Gusto bank lines, classified Every Gusto debit on the business's bank accounts in the date range, classified from its bank descriptor: net (one lump per payroll), tax, contractor_us / contractor_intl (CND / ICD, with the payee when the line names one), reimbursement, fee, wire (a payroll funded by wire) or unknown. Each row shows its current category and whether a Gusto reconciliation already applied it. Amounts are cents. Parameters: - start_date (query, string · date, required): First bank date (YYYY-MM-DD) - end_date (query, string · date, required): Last bank date (YYYY-MM-DD) - bank_ledger_id (query, string, optional): Only this bank account (default: all) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/payroll/gusto/reconcile/apply Apply the Gusto payroll reconciliation Recomputes the preview's plan from the same inputs and applies it: splits each NET lump one leg per employee (each leg names the employee), creates the per-pay-period Gusto bills for tax and reimbursement debits and pays them with the bank rows (or pays an open Gusto bill of the same amount), renames and categorizes contractor and fee rows, and saves the register as pay runs. Each row is applied on its own; failures are listed. Rows already applied are skipped, so repeating the call is safe. Pass plan_hash from the preview to refuse a plan that changed since. Request body (GustoApplyRequest): - reports (array · GustoReportInput, optional) → GustoReportInput - bank_ledger_id (string, optional) - start_date (string · date, required) - end_date (string · date, required) - ledger_overrides (GustoLedgerOverrides, optional) - amount_tolerance_cents (integer, optional) - create_bills (boolean, optional) - plan_hash (string, optional) - transaction_ids (array · string, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/payroll/gusto/reconcile/preview Preview the Gusto payroll reconciliation Reads the Gusto exports given (Payroll Journal / Register, Contractor Payments, Bank Transactions; uploaded via s3_key or pasted), matches them to the Gusto bank rows in the range and returns the plan: per row the new description, counterparty, ledger, the per-employee split of each NET lump, and the accrual bill each TAX / reimbursement debit pays; plus everything left outstanding on either side and a plan_hash for apply. Nothing is changed. Request body (GustoReconcileRequest): - reports (array · GustoReportInput, optional) → GustoReportInput - bank_ledger_id (string, optional) - start_date (string · date, required) - end_date (string · date, required) - ledger_overrides (GustoLedgerOverrides, optional) - amount_tolerance_cents (integer, optional) - create_bills (boolean, optional) Responses: 200, 400, 401, 403, 422 ## pending-change-rounds ### GET /api/v1/pending-change-rounds List approval rounds Approval rounds for this business, newest first. Parameters: - status (query, string, optional): open, submitted, decided, expired, or a comma-separated list - cursor (query, string, optional): next_cursor from the last page - limit (query, integer, optional): Page size (max 100) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/pending-change-rounds Open an approval round Open a round to batch proposed changes into. Add changes with POST /pending-changes and its round_id, then submit it. Request body (ApprovalRoundCreateRequest): - title (string, required) - period_start (string · date, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/pending-change-rounds/{round_id} Get an approval round One round with its changes, tier 3 first, then by dollar impact. Parameters: - round_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/pending-change-rounds/{round_id}/approve Approve a round, all except Approve every waiting change in the round except except_ids. Tier 3 changes are never batch-approved; they stay waiting. Not available to API tokens: a person approves in the app. Parameters: - round_id (path, string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/pending-change-rounds/{round_id}/reject Reject a round Reject every change still waiting in the round. A reason is required. Not available to API tokens. Parameters: - round_id (path, string, required) Request body (ApprovalRoundRejectRequest): - reason (string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/pending-change-rounds/{round_id}/submit Submit an approval round Ask for a decision: the round stops taking changes, the owner and admins are told once, and it expires in seven days. Parameters: - round_id (path, string, required) Responses: 200, 401, 403, 404, 409, 422 ## pending-changes ### GET /api/v1/pending-changes List proposed changes Proposed changes for this business, newest first. Parameters: - status (query, string, optional): pending, approved, applied, rejected, failed, expired, or a comma-separated list - cursor (query, string, optional): next_cursor from the last page - limit (query, integer, optional): Page size (max 100) - round_id (query, string, optional): One approval round, or 'none' for changes in no round - agent_run_id (query, string, optional): Only the changes one agent run proposed Responses: 200, 400, 401, 403, 422 ### POST /api/v1/pending-changes Propose a change Store a previewed write for a person to approve in the app. Nothing is applied until someone approves it. Request body (PendingChangeCreateRequest): - tool_name (string, required) - arguments (object, required) - preview (object | array · object, required) - plan_hash (string, optional) - summary (string, required) - reason (string, optional) - round_id (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/pending-changes/approve-in-order Approve changes in dependency order Apply the chosen changes of one run earliest dependency first, stopping at the first failure. `dry_run` only returns the order. Request body (ApproveInOrderRequest): - change_ids (array · string, required) - dry_run (boolean, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/pending-changes/settings Get approval settings Materiality (tier 3 at or above it) and the deputy approver. Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/pending-changes/settings Change approval settings Set the materiality and/or the deputy approver. Owners and admins only, signed in to the app: an API token (an agent) never changes approval settings. Request body (ApprovalSettingsUpdate): - approval_materiality_cents (integer, optional) - approval_deputy_user_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/pending-changes/stats Approval statistics Per tool: proposed, approved, rejected, expired, approval rate and median minutes to a decision; per decided round: batch size and time from submit to decision. Parameters: - days (query, integer, optional): Look-back window in days (default 90) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/pending-changes/{change_id} Get a proposed change One proposed change with its arguments, preview and diff. Parameters: - change_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/pending-changes/{change_id}/approve Approve a proposed change Apply the change server-side as the signed-in approver. Not available to API tokens: a person approves in the app. Parameters: - change_id (path, string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/pending-changes/{change_id}/reject Reject a proposed change Close the change without applying it. A reason (note, 3+ characters) is required. Not available to API tokens. Parameters: - change_id (path, string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ## people ### GET /api/v1/people List people The roster with a headcount summary. Pay fields are null unless the caller may see pay (pay_visible). Parameters: - status (query, string, optional): active, new, notice, inactive, terminated - employment_type (query, string, optional): w2, contractor_us, contractor_offshore - department (query, string, optional) - search (query, string, optional) - include_terminated (query, boolean, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/people Add a person Add one person to the roster. Display name is required. Request body (PersonCreateRequest): - display_name (string, required) - first_name (string, optional) - last_name (string, optional) - email (string, optional) - job_title (string, optional) - department (string, optional) - manager_id (string, optional) - manager_name (string, optional) - status (string, optional) - employment_type (string, optional) - pay_type (string, optional) - monthly_rate_cents (integer, optional) - hourly_rate_cents (integer, optional) - expected_monthly_hours (number, optional) - state (string, optional) - remote (boolean, optional) - business_unit (string, optional) - billing_entity (string, optional) - aliases (array · string, optional) - counterparty_name (string, optional) - vendor_id (string, optional) - has_insurance (boolean, optional) - start_date (string · date, optional) - end_date (string · date, optional) - termination_reason (string, optional) - equipment_returned (boolean, optional) - final_pay_cents (integer, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 409, 422 ### GET /api/v1/people/access Your access to People full (owners and admins of the business or its firm: everything, including pay, and changes), roster (chosen by one of them: read-only, no pay) or none. Full access also returns viewer_ids, the users chosen to see the roster without pay. Responses: 200, 401, 403, 422 ### PUT /api/v1/people/access Choose who else sees People Replace the users, besides owners and admins, who may see the roster. They see it read-only and without pay. Owners and admins only. Request body (PeopleAccessUpdateRequest): - viewer_ids (array · string, required) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/people/import/apply Apply a previewed roster import Create and update the people exactly as the preview showed. The plan_hash must match; a roster that changed in between is refused. Request body (PeopleImportApplyRequest): - rows (array · PersonImportRow, required) → PersonImportRow - plan_hash (string, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/people/import/preview Preview a roster import Upload a CSV or XLSX roster. Finds the header row, maps columns by name, matches each line to an existing person by name, alias or counterparty name, and returns what applying would do plus a plan_hash. Nothing is written. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/people/import/template Roster import template A CSV with the columns the roster import understands. Responses: 200, 401, 403, 422 ### GET /api/v1/people/org-chart Org chart The roster as a reporting tree built from each person's manager, with subtree headcount, commitment (when the caller may see pay) and what the books paid each person in the last full month. Parameters: - include_terminated (query, boolean, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/people/payments What the books paid each person, by month Bank outflows whose counterparty is a person's name, alias or counterparty name, plus the per-employee legs of split payroll debits, summed per calendar month. Parameters: - months (query, integer, optional): Trailing calendar months. Responses: 200, 401, 403, 422 ### DELETE /api/v1/people/{person_id} Remove a person Remove a roster row that has no pay history. People with pay statements cannot be removed; mark them terminated instead. Parameters: - person_id (path, string, required) Responses: 200, 401, 403, 404, 409, 422 ### GET /api/v1/people/{person_id} Get a person One roster row. Parameters: - person_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/people/{person_id} Update a person Change the fields sent; everything else stays. Parameters: - person_id (path, string, required) Request body (PersonUpdateRequest): - display_name (string, optional) - first_name (string, optional) - last_name (string, optional) - email (string, optional) - job_title (string, optional) - department (string, optional) - manager_id (string, optional) - manager_name (string, optional) - status (string, optional) - employment_type (string, optional) - pay_type (string, optional) - monthly_rate_cents (integer, optional) - hourly_rate_cents (integer, optional) - expected_monthly_hours (number, optional) - state (string, optional) - remote (boolean, optional) - business_unit (string, optional) - billing_entity (string, optional) - aliases (array · string, optional) - counterparty_name (string, optional) - vendor_id (string, optional) - has_insurance (boolean, optional) - start_date (string · date, optional) - end_date (string · date, optional) - termination_reason (string, optional) - equipment_returned (boolean, optional) - final_pay_cents (integer, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/people/{person_id}/ledger One person's ledger Journal lines about the person: linked to them on the roster, or unlinked and named like them. Folded into months by pay component (pay, bonus, burden, reimbursement) with what is owed to them (payable) and advanced to them (advance), all time. Owners and admins only. Parameters: - person_id (path, string, required) - months (query, integer, optional): Trailing calendar months. - lines_limit (query, integer, optional): Most lines returned. Responses: 200, 401, 403, 404, 422 ## posting-defaults ### GET /api/v1/posting-defaults Get invoice posting defaults The ledgers invoices post to for sales, receivables, cost of goods sold and inventory. A role left empty uses the system ledger. Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/posting-defaults Update invoice posting defaults Set the ledger for any of the four invoice posting roles, or send null to go back to the system ledger. Omitted roles are unchanged. Inactive ledgers and ledgers of the wrong account type are refused. Only new postings use the change; entries already posted stay. Request body (PostingDefaultsUpdate): - invoice_sales_ledger_id (string, optional) - invoice_cogs_ledger_id (string, optional) - invoice_inventory_ledger_id (string, optional) - invoice_ar_ledger_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/posting-defaults/preview Preview invoice posting defaults How many existing finalized-invoice entries sit on the system ledgers and how many on the configured ones. Read-only. Parameters: - limit (query, integer, optional): Sample entries to list Responses: 200, 401, 403, 404, 422 ## projects ### GET /api/v1/projects List projects List projects, optionally filtered by status or customer. Parameters: - status (query, string, optional): Filter by status: active, completed, on_hold. - customer_id (query, string, optional): Filter by customer. - include_inactive (query, boolean, optional) - code (query, string, optional): Exact project code match (case-insensitive). - name (query, string, optional): Exact project name match (case-insensitive). - search (query, string, optional): Partial match against project code or name. Responses: 200, 401, 403, 422 ### POST /api/v1/projects Create project Create a new project. Request body (ProjectCreateRequest): - name (string, required) - code (string, optional) - description (string, optional) - status (string, optional) - customer_id (string, optional) - start_date (string · date, optional) - end_date (string · date, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/projects/bulk Bulk create projects Create up to 100 projects in one request with per-row customer resolution. Rows may pass customer_name instead of customer_id — an exact case-insensitive match auto-resolves; ambiguous or unmatched names fail only that row (CUSTOMER_AMBIGUOUS / CUSTOMER_NOT_FOUND with candidate customers) unless create_missing_customers is true, in which case unmatched customers are created inline. Request body (ProjectBulkCreateRequest): - rows (array · ProjectBulkCreateRow, required) → ProjectBulkCreateRow - create_missing_customers (boolean, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/projects/profitability Project profitability Revenue, expense, and net profit broken down by project. Parameters: - start_date (query, string · date, required): Period start (inclusive). - end_date (query, string · date, required): Period end (inclusive). Responses: 200, 400, 401, 403, 422 ### DELETE /api/v1/projects/{project_id} Deactivate project Soft-delete (deactivate) a project. Parameters: - project_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/projects/{project_id} Get project Get a single project. Parameters: - project_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/projects/{project_id} Update project Update an existing project. All fields optional. Parameters: - project_id (path, string, required) Request body (ProjectUpdateRequest): - name (string, optional) - code (string, optional) - description (string, optional) - status (string, optional) - customer_id (string, optional) - start_date (string · date, optional) - end_date (string · date, optional) - is_active (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/projects/{project_id}/permanent Delete project permanently Permanently delete a project row. Rejected when the project is still tagged on invoices, journal entry lines, time entries, contracts, orders or deals unless `force` is set. Parameters: - project_id (path, string, required) - force (query, boolean, optional): Delete even when records are tagged to the project, clearing their project tag. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/projects/{project_id}/profitability Single project profitability Revenue, expense, and net profit for one project. Parameters: - project_id (path, string, required) - start_date (query, string · date, required): Period start (inclusive). - end_date (query, string · date, required): Period end (inclusive). Responses: 200, 400, 401, 403, 404, 422 ## provider-feeds ### GET /api/v1/provider-feeds/{provider} Bookkeeping feed settings The ledger, start date and on/off state for one provider. Parameters: - provider (path, string, required) Responses: 200, 400, 401, 403, 422 ### PUT /api/v1/provider-feeds/{provider} Choose the ledger and start date Pick an existing ledger or name a new one, and the first date to post. Parameters: - provider (path, string, required) Request body (ProviderFeedConfigureRequest): - ledger_id (string, optional) - new_ledger_name (string, optional) - start_date (string · date, required) - hold_unattributed_credit (boolean, optional) - post_date_basis (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### PUT /api/v1/provider-feeds/{provider}/enabled Switch posting on or off Turning it on lets every sync post new rows; it does not post by itself. Parameters: - provider (path, string, required) Request body (ProviderFeedEnableRequest): - enabled (boolean, required) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/provider-feeds/{provider}/post Post now Post what is eligible now, once, even while automatic posting is off. Parameters: - provider (path, string, required) Request body (ProviderFeedPostRequest): - allow_duplicate_ids (array · string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/provider-feeds/{provider}/preview Preview what posting would do Every row that would post, link to a credit entry, or be held and why. Parameters: - provider (path, string, required) Responses: 200, 400, 401, 403, 422 ## purchase-orders ### GET /api/v1/purchase-orders List inventory orders Retrieve all purchase orders with their status and totals. Parameters: - status (query, string, optional): Filter by order status - vendor_id (query, string, optional): Filter by vendor ID - search (query, string, optional): Search PO number, name, description, vendor, or status - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/purchase-orders Create inventory order Create a new purchase order for inventory restocking. Request body (InventoryOrderCreate): - vendor_id (string, required) - status (string, required) - name (string, required) - po_number (string, required) - line_items (array · LineItem, optional) - fees (array · Fee, optional) - payments (array · Payment-Input, optional) - description (string, optional) - total (integer, optional) - balance (integer, optional) - shipping_cost (integer, optional) - ship_from_location_id (string, optional) - ship_to_location_id (string, optional) - production_run_id (string, optional) - expected_delivery_date (string · date, optional) - payment_term_id (string, optional) - expected_paid_on (string · date, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/purchase-orders/pdf Get order PDFs Get download URLs for order PDFs. Parameters: - order_ids (query, string, optional): Comma-separated order UUIDs Responses: 200, 401, 403, 422 ### DELETE /api/v1/purchase-orders/{id} Delete inventory order Permanently delete a purchase order. Only draft/submitted purchase orders with no linked receipts, bills, or journal entries can be deleted; cancel the order instead once it has progressed further. Parameters: - id (path, string · uuid, required) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/purchase-orders/{id} Get inventory order Retrieve a specific purchase order with line items. Parameters: - id (path, string · uuid, required) - order_id (query, string, optional) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/purchase-orders/{id} Update inventory order Update purchase order details with optimistic locking support. Parameters: - id (path, string · uuid, required) Request body (InventoryOrderUpdate): - vendor_id (string, optional) - status (string, optional) - name (string, optional) - po_number (string, optional) - line_items (array · LineItem, optional) - fees (array · Fee, optional) - payments (array · Payment-Input, optional) - description (string, optional) - total (integer, optional) - balance (integer, optional) - version (integer, optional) - shipping_cost (integer, optional) - ship_from_location_id (string, optional) - ship_to_location_id (string, optional) - production_run_id (string, optional) - expected_delivery_date (string · date, optional) - payment_term_id (string, optional) - expected_paid_on (string · date, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### POST /api/v1/purchase-orders/{id}/cancel Cancel purchase order Cancel a PO and reverse any in-transit transfer. Parameters: - id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{id}/mark-in-production Mark purchase order in production Transition PO to 'in_production'. Parameters: - id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{id}/mark-partially-received Mark purchase order partially received Transition PO to 'partially_received'. Set by the shipment flow when at least one shipment has been received but more is still pending against the PO. Parameters: - id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{id}/mark-ready Mark purchase order ready Transition PO to 'ready' (goods produced, not yet shipped). Parameters: - id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{id}/mark-shipped Mark purchase order shipped Transition PO to 'shipped' and create an in-transit transfer. Parameters: - id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{id}/payments Record payment for purchase order Link a bank transaction to a purchase order as a payment. Parameters: - id (path, string · uuid, required) Request body (OrderPaymentRequest): - transaction_id (string, required) - amount (integer, required) - paid_on (string · date-time, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{id}/recalculate-totals Recalculate order totals Recalculate order total from line items and payments. Parameters: - id (path, string · uuid, required) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{id}/receive Receive purchase order Transition PO to 'received', flip linked Bill from forecasted to received, mark linked transfer as received, write cost snapshots, and post received quantities to on-hand inventory at ship_to_location_id (skipped when a received shipment is already associated with the PO, since that path writes inventory itself). Parameters: - id (path, string · uuid, required) - received_on (query, string · date, optional): Day the goods arrived (YYYY-MM-DD, default today); dates the lots and the receipt entry. A closed period refuses it. Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{id}/submit Submit purchase order Transition PO to 'submitted' and create a forecasted bill. Parameters: - id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{order_id}/pdf Generate order PDF Generate or regenerate a PDF purchase order document. Parameters: - order_id (path, string · uuid, required) Responses: 201, 401, 403, 404, 422 ### GET /api/v1/purchase-orders/{po_id}/financing-preview Preview funding a purchase order from a credit line For the PO's total (its remaining balance once partly received): the 13-week cash forecast with the PO paid from cash and with it financed, each with its lowest week and balance; and, for each active line the business holds under a per-transaction program, the available credit against the PO amount and an estimated cost of funding it over `term_days` (simple interest at the program's `default_rate_bps` plus the disbursement fee), labelled an estimate. Read-only. Parameters: - po_id (path, string, required) - term_days (query, integer, optional): Price the estimate over this term; defaults to each line's term. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-orders/{po_id}/financing-request Request funding of a purchase order from a credit line Records a `po_financing_intents` row for the PO and the chosen line. When the amount exceeds the line's available credit, a limit-change request for the shortfall is created through the existing limit-change service, so the program's `limit_change_policy` governs who approves it, and the intent records that request's id. The lender is alerted and the business is notified. This does not move money and does not create a loan: actual draws happen on card spend under the existing per-transaction model. Parameters: - po_id (path, string, required) Request body (PoFinancingRequest): - line_id (string, required) - term_days (integer, optional) - amount_cents (integer, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ## purchase-requisitions ### GET /api/v1/purchase-requisitions List purchase requisitions List purchase requisitions with optional filtering. Parameters: - status (query, PurchaseRequisitionStatusEnum, optional): Filter by status - vendor_id (query, string, optional): Filter by vendor ID - search (query, string, optional): Search description or number - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/purchase-requisitions Create purchase requisition Create a draft purchase requisition with line items. Request body (PurchaseRequisitionCreateRequest): - description (string, optional) - vendor_id (string, optional) - currency (string, optional) - lines (array · PurchaseRequisitionLineInput, required) → PurchaseRequisitionLineInput Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/purchase-requisitions/{requisition_id} Delete purchase requisition Soft-delete a draft purchase requisition. Parameters: - requisition_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/purchase-requisitions/{requisition_id} Get purchase requisition Get a single purchase requisition with line items. Parameters: - requisition_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/purchase-requisitions/{requisition_id} Update purchase requisition Update a draft purchase requisition. Parameters: - requisition_id (path, string, required) Request body (PurchaseRequisitionUpdateRequest): - description (string, optional) - vendor_id (string, optional) - lines (array · PurchaseRequisitionLineInput, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-requisitions/{requisition_id}/approve Approve purchase requisition Approve a submitted purchase requisition. Parameters: - requisition_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-requisitions/{requisition_id}/convert Convert purchase requisition Convert an approved requisition to a purchase order or bill. Parameters: - requisition_id (path, string, required) Request body (PurchaseRequisitionConvertRequest): - target (PurchaseRequisitionConvertTargetEnum, required) → PurchaseRequisitionConvertTargetEnum - vendor_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-requisitions/{requisition_id}/reject Reject purchase requisition Reject a submitted purchase requisition. Parameters: - requisition_id (path, string, required) Request body (PurchaseRequisitionRejectRequest): - reason (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/purchase-requisitions/{requisition_id}/submit Submit purchase requisition Submit a draft requisition for approval. Parameters: - requisition_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## quickbooks ### GET /api/v1/quickbooks/connect-url Get QuickBooks OAuth connect URL Generate a URL to redirect the user to Intuit for authorization. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/quickbooks/coverage-report QuickBooks import coverage report Enumerate every supported QuickBooks object type, its DayZero native target model, and how many were imported. Responses: 200, 400, 401, 403, 404, 422 ### DELETE /api/v1/quickbooks/disconnect Disconnect QuickBooks Remove the QuickBooks integration and revoke stored credentials. Responses: 200, 400, 401, 403, 422 ### GET /api/v1/quickbooks/disconnected QuickBooks disconnect landing (Intuit Disconnect URL) Where Intuit sends the browser after a user removes DayZero from inside QuickBooks (Apps > My apps). Configure this path, with ``?realmId=`` appended, as the app's Disconnect URL in the Intuit developer portal. The stored grant is verified with Intuit before anything changes. The redirect is identical whether or not the realm is known, so the landing cannot be used to probe which companies are connected. Parameters: - realmId (query, string, optional): QBO company id Responses: 200, 422 ### POST /api/v1/quickbooks/import Start QuickBooks migration import Import everything from the chosen start date forward (accounts, customers, vendors, items, documents, transactions, payments, and journals) plus a single opening-balance JE as of the day before. Parameters: - start_date (query, string, optional): Import everything dated on/after this date (YYYY-MM-DD). The opening balance is posted as of the day before. - phases (query, array · string, optional): Optional subset of document/posting sections to import (e.g. invoices, bills, payments). Omit to import everything. Master data and the opening balance always import. Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/quickbooks/import-settings Get QuickBooks importer settings How the importer reads this company (e.g. which accounts are the Ramp card), plus its bank and card accounts to pick from. Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/quickbooks/import-settings Update QuickBooks importer settings Save how the importer reads this company before an import. Request body (QuickBooksImportSettingsUpdate): - ramp_card_account_ids (array · string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/quickbooks/import/cancel Cancel the running QuickBooks migration import Stop the in-flight import (Temporal cancels the workflow; the page being written is rolled back) and mark the run cancelled. Records already committed stay and a later import resumes past them. Responses: 201, 401, 403, 404, 422 ### GET /api/v1/quickbooks/migration-report QuickBooks migration QA report Compare the QuickBooks Trial Balance against local ledger balances. Parameters: - as_of_date (query, string, optional): As-of date (YYYY-MM-DD) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/quickbooks/oauth/callback QuickBooks OAuth callback Handle the Intuit OAuth redirect. Called by Intuit, not the frontend. Parameters: - state (query, string, required): OAuth state nonce - code (query, string, optional): Authorization code from Intuit - realmId (query, string, optional): QBO company id - error (query, string, optional): OAuth error code (e.g. access_denied) when no code Responses: 200, 422 ### GET /api/v1/quickbooks/status QuickBooks connection status Returns connection health and migration import status. Responses: 200, 401, 403, 422 ### GET /api/v1/quickbooks/sync/account-mappings QuickBooks account mapping Every active DayZero ledger with the QuickBooks account it is paired with. Account names come from the cached account list (`GET /sync/qbo-accounts`). Responses: 200, 401, 403, 422 ### PUT /api/v1/quickbooks/sync/account-mappings/{ledger_id} Set a ledger's QuickBooks account Pair the ledger with one QuickBooks account (checked with QuickBooks), or clear the pairing with `qbo_account_id: null`. `409 INTEGRATION_138` when the account is paired with another ledger. Parameters: - ledger_id (path, string, required) Request body (QuickBooksAccountMappingUpdate): - qbo_account_id (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/quickbooks/sync/activity Recent QuickBooks sync activity The latest records pushed to and pulled from QuickBooks. Parameters: - limit (query, integer, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/quickbooks/sync/issues List QuickBooks sync issues Newest first. `status` open (default), resolved, ignored or all; `kind` push_failed, pull_failed, conflict, unmapped, tieout_drift, period_locked, double_count_risk, connection or duplicate_entries. Each item lists the actions it accepts (`repair`: open the repair preview). Parameters: - status (query, string, optional): open | resolved | ignored | all - kind (query, string, optional): Filter by issue kind - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/quickbooks/sync/issues/{issue_id}/actions Resolve a QuickBooks sync issue retry: queue the record again (or re-read it from QuickBooks). keep_dayzero: overwrite QuickBooks with DayZero's version. keep_quickbooks: overwrite DayZero with QuickBooks' version. ignore: close the issue without changing either side. `400 INTEGRATION_136` when the action does not apply. Parameters: - issue_id (path, string · uuid, required) Request body (QuickBooksSyncIssueActionRequest): - action (string, required) - note (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/quickbooks/sync/migration-verified Confirm the QuickBooks migration report Record that the migration report was checked. A re-import clears it. Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/quickbooks/sync/pause Pause the QuickBooks sync Stop pulling and pushing until resumed. Changes keep queuing. Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/quickbooks/sync/payment-write-receipts Read unconfirmed QuickBooks payment write receipts Exact original request bodies awaiting provider confirmation, scoped to the currently connected company. Reading does not resend a write. Responses: 200, 401, 403, 422 ### POST /api/v1/quickbooks/sync/payment-write-receipts/{receipt_id}/resolve Resolve an unconfirmed QuickBooks payment write Lookup never re-POSTs. Bind an existing object after review, or explicitly verify non-creation after a fresh lookup and five-minute cooldown. A changed object creates a group conflict. A new attempt follows the normal approval policy. Parameters: - receipt_id (path, string · uuid, required) Request body (QuickBooksPaymentReceiptResolveRequest): - action (string, required) - qbo_id (string, optional) - reviewed_in_quickbooks (boolean, optional) - accept_changed (boolean, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/quickbooks/sync/push-approve Approve held QuickBooks changes Send reviewed changes to QuickBooks. Rejects stale previews with 409. Request body (QuickBooksPushReviewRequest): - rows (array · QuickBooksPushReviewRow, required) → QuickBooksPushReviewRow Responses: 201, 400, 401, 403, 409, 422 ### GET /api/v1/quickbooks/sync/push-preview Preview held QuickBooks changes Read the next 50 waiting changes without writing to QuickBooks. Responses: 200, 401, 403, 422 ### POST /api/v1/quickbooks/sync/push-reject Reject held QuickBooks changes Keep reviewed changes in DayZero only. Rejects stale previews with 409. Request body (QuickBooksPushReviewRequest): - rows (array · QuickBooksPushReviewRow, required) → QuickBooksPushReviewRow Responses: 201, 400, 401, 403, 409, 422 ### GET /api/v1/quickbooks/sync/qbo-accounts QuickBooks chart of accounts Active QuickBooks accounts for the mapping picker, read through the connection and cached for 10 minutes (`refresh=true` re-reads). Parameters: - refresh (query, boolean, optional): Bypass the 10-minute cache Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/quickbooks/sync/repair Repair the QuickBooks sync Apply the previewed repair. Removes second entries by deleting them (the original stays; entries in closed periods are never changed), closes stale conflicts and leftover queue rows and refreshes stale QuickBooks versions. Idempotent. `409 INTEGRATION_140` when the sync changed since the preview, `409 INTEGRATION_101` while a sync runs. Request body (QuickBooksRepairRequest): - plan_hash (string, required) - include (array · string, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### GET /api/v1/quickbooks/sync/repair-preview Preview a QuickBooks sync repair What a repair would fix now, with a sample of each finding: leftover queue rows, conflicts that were DayZero's own changes coming back, documents with a second QuickBooks entry (exact or differing; the original is kept), records left for review (closed period, unclear which entry to keep) and stale QuickBooks versions. Reads QuickBooks; writes nothing. Send `plan_hash` to `POST /sync/repair`. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/quickbooks/sync/resume Resume the QuickBooks sync Clear the pause and catch up in both directions. Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/quickbooks/sync/run Sync with QuickBooks now Queue an inbound sync and, in two_way mode, a push. Each side reports queued, already_running or skipped. Responses: 201, 400, 401, 403, 404, 422 ### PATCH /api/v1/quickbooks/sync/settings Change the QuickBooks sync mode or settings Partial update. `mode` off -> mirror needs a completed import (`400 INTEGRATION_130`); -> two_way also sets `cutover_date` (default today, not in the future) and queues DayZero records dated on/after it for QuickBooks; -> off stops the sync and deletes nothing. `bank_feed_owner` keys must be bank/card ledgers of the business. Returns the new status. Request body (QuickBooksSyncSettingsUpdate): - mode (string, optional) - cutover_date (string · date, optional) - push (object, optional) - bank_feed_owner (object, optional) - require_approval (boolean, optional) - auto_create_accounts (boolean, optional) - pull_attachments (boolean, optional) - replicate_imported_entries (boolean, optional) - auto_repair (boolean, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/quickbooks/sync/status QuickBooks live sync status Sync mode, health, pause state, cutover date, settings, last inbound/outbound/tie-out times, outbox counts by status, open issue counts by kind, and the feed owner of every bank/card ledger. Responses: 200, 401, 403, 422 ### POST /api/v1/quickbooks/webhooks QuickBooks webhook Receive Intuit QuickBooks Online change notifications (legacy eventNotifications or CloudEvents). Verifies intuit-signature, stores each entity change and starts the inbound sync for every affected business. 401 on a bad signature, 503 when webhooks are not configured or the delivery could not be stored (Intuit retries). Responses: 201 ## reconciliations — Bank statement reconciliation with AI-assisted matching. ### GET /api/v1/reconciliations List reconciliations List reconciliations for the business. Parameters: - status (query, string, optional): Filter by status - limit (query, integer, optional): Page size - offset (query, integer, optional): Pagination offset - include_total_count (query, boolean, optional): Include total count (expensive - avoid if possible) Responses: 200, 401, 403, 422 ### POST /api/v1/reconciliations Create reconciliation Create a new bank reconciliation (with S3 key). Request body (ReconciliationCreateRequest): - ledger_id (string, required) - source_type (string, optional) - statement_s3_key (string, optional) - start_date (string · date-time, required) - end_date (string · date-time, required) - statement_filename (string, optional) - opening_balance (integer, optional) - closing_balance (integer, optional) - auto_start (boolean, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/reconciliations/upload Create reconciliation with upload Create a new bank reconciliation with direct file upload. Parameters: - ledger_id (query, string, required): ID of ledger to reconcile against - start_date (query, string · date-time, required): Statement period start date - end_date (query, string · date-time, required): Statement period end date - opening_balance (query, integer, optional): Opening balance in cents - closing_balance (query, integer, optional): Closing balance in cents - auto_start (query, boolean, optional): Auto-start processing workflow Responses: 201, 401, 403, 422 ### GET /api/v1/reconciliations/{reconciliation_id} Get reconciliation Get reconciliation details. Parameters: - reconciliation_id (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/reconciliations/{reconciliation_id}/balance Get balance validation Get balance validation for the reconciliation. Parameters: - reconciliation_id (path, string, required) Responses: 200, 401, 403, 422 ### GET /api/v1/reconciliations/{reconciliation_id}/balance-report Get statement-vs-books balance report Tie the statement to the ledger for one reconciliation. Parameters: - reconciliation_id (path, string, required) Responses: 200, 401, 403, 422 ### POST /api/v1/reconciliations/{reconciliation_id}/complete Complete reconciliation Complete and lock the reconciliation. Parameters: - reconciliation_id (path, string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/reconciliations/{reconciliation_id}/explain-matches AI match explanations Get AI-powered explanations for reconciliation matches. Parameters: - reconciliation_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/reconciliations/{reconciliation_id}/matches/approve Approve match Approve a transaction match. Parameters: - reconciliation_id (path, string, required) Request body (MatchApprovalRequest): - statement_txn_id (string, required) - ledger_txn_ids (array · string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/reconciliations/{reconciliation_id}/matches/bulk-approve Bulk approve matches Bulk approve transaction matches. Parameters: - reconciliation_id (path, string, required) Request body (BulkApproveRequest): - min_confidence (number, optional) - statement_txn_ids (array · string, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/reconciliations/{reconciliation_id}/matches/bulk-reject Bulk reject matches Bulk reject/remove approved matches. Parameters: - reconciliation_id (path, string, required) Request body (BulkRejectRequest): - statement_txn_ids (array · string, required) Responses: 201, 401, 403, 422 ### POST /api/v1/reconciliations/{reconciliation_id}/matches/reject Reject match Reject/remove an approved match. Parameters: - reconciliation_id (path, string, required) Request body (MatchRejectionRequest): - statement_txn_id (string, required) Responses: 201, 401, 403, 422 ### GET /api/v1/reconciliations/{reconciliation_id}/pdf Download reconciliation PDF Download reconciliation report as PDF. Parameters: - reconciliation_id (path, string, required) Responses: 200, 401, 403, 422 ### POST /api/v1/reconciliations/{reconciliation_id}/start Start reconciliation processing Start or restart reconciliation processing. Parameters: - reconciliation_id (path, string, required) Responses: 201, 401, 403, 422 ## recurring — Recurring invoice and bill templates with auto-generation. ### GET /api/v1/recurring List recurring templates List all recurring templates for the business with optional filtering. Parameters: - recurrence_type (query, app__models__recurring_templates__RecurrenceTypeEnum, optional): Filter by type (invoice or bill) - status (query, RecurringStatusEnum, optional): Filter by status - customer_id (query, string, optional): Filter by customer ID (for invoice templates) - vendor_id (query, string, optional): Filter by vendor ID (for bill templates) - search (query, string, optional): Search name, description, frequency, status, or counterparty - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/recurring Create recurring template Create a new recurring invoice or bill template. Request body (RecurringTemplateCreate): - name (string, required) - currency (string, optional) - frequency (FrequencyEnum, required) → FrequencyEnum - days_until_due (integer, optional) - day_of_month (integer, optional) - day_of_week (integer, optional) - end_date (string · date, optional) - max_occurrences (integer, optional) - notes (string, optional) - recurrence_type (app__api__v1__schemas__recurring__recurring__RecurrenceTypeEnum, required) → app__api__v1__schemas__recurring__recurring__RecurrenceTypeEnum - start_date (string · date, required) - customer_id (string, optional) - auto_send (boolean, optional) - contract_id (string, optional) - vendor_id (string, optional) - template_data (object, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/recurring/bills List recurring bill templates List all recurring bill templates for the business. Parameters: - status (query, RecurringStatusEnum, optional): Filter by status - vendor_id (query, string, optional): Filter by vendor ID - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### GET /api/v1/recurring/invoices List recurring invoice templates List all recurring invoice templates for the business. Parameters: - status (query, RecurringStatusEnum, optional): Filter by status - customer_id (query, string, optional): Filter by customer ID - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/recurring/suggest-templates AI recurring template suggestions Get AI-powered suggestions for recurring transaction templates. Responses: 201, 401, 403, 422 ### DELETE /api/v1/recurring/{template_id} Delete recurring template Delete a recurring template. This action cannot be undone. Parameters: - template_id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/recurring/{template_id} Get recurring template Get a specific recurring template by ID. Parameters: - template_id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/recurring/{template_id} Update recurring template Update an existing recurring template. Parameters: - template_id (path, string · uuid, required) Request body (RecurringTemplateUpdate): - name (string, optional) - currency (string, optional) - frequency (FrequencyEnum, optional) - days_until_due (integer, optional) - day_of_month (integer, optional) - day_of_week (integer, optional) - end_date (string · date, optional) - max_occurrences (integer, optional) - notes (string, optional) - template_data (object, optional) - auto_send (boolean, optional) - customer_id (string, optional) - vendor_id (string, optional) - contract_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/recurring/{template_id}/cancel Cancel recurring template Cancel a recurring template. This cannot be undone. Parameters: - template_id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/recurring/{template_id}/clone Clone recurring template Create a copy of an existing recurring template with optional overrides. Parameters: - template_id (path, string · uuid, required) Request body (RecurringTemplateClone): - name (string, optional) - start_date (string · date, optional) - customer_id (string, optional) - vendor_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/recurring/{template_id}/history Get recurring template history Get all bills or invoices generated from this recurring template. Parameters: - template_id (path, string · uuid, required) - limit (query, integer, optional): Maximum items to return Responses: 200, 401, 403, 404, 422 ### POST /api/v1/recurring/{template_id}/pause Pause recurring template Pause an active recurring template. No new documents will be generated until resumed. Parameters: - template_id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/recurring/{template_id}/resume Resume recurring template Resume a paused recurring template. Next occurrence will be recalculated. Parameters: - template_id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/recurring/{template_id}/skip Skip next occurrence Skip the next scheduled occurrence without generating a document. Parameters: - template_id (path, string · uuid, required) Responses: 201, 400, 401, 403, 404, 422 ## regent-slack ### GET /api/v1/regent-slack/channels Slack channels Team chat can mirror to The connected workspace's public channels and the private ones Regent is in (archived left out, up to 200), by name. `400` when Regent in Slack is not connected or lacks channel access. Responses: 200, 400, 401, 403, 422 ### POST /api/v1/regent-slack/clarifications/{clarification_id}/send-card Send a 1-click transaction clarification card to Slack Posts an interactive Slack Block Kit card for a transaction clarification with up to 3 quick-reply category buttons. Parameters: - clarification_id (path, string, required) Request body (RegentSlackSendClarificationCardRequest): - channel (string, required) - suggested_categories (array · string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/regent-slack/events Slack Events API Receives @mentions and DMs for Regent. Verifies Slack's signature, acks immediately and answers in the background. Responses: 201 ### GET /api/v1/regent-slack/install-url Get the Add Regent to Slack URL Slack authorization URL that installs Regent into a workspace for this business. Sets the browser-binding cookie the callback requires. Responses: 200, 400, 401, 403, 422 ### DELETE /api/v1/regent-slack/installation Disconnect Regent from Slack Remove this business's Slack workspace and revoke its bot token. Responses: 200, 401, 403, 422 ### GET /api/v1/regent-slack/installation Regent in Slack status Whether a Slack workspace is connected to this business. Responses: 200, 401, 403, 422 ### PUT /api/v1/regent-slack/installation/team-chat-channel Mirror Team chat jobs to a Slack channel Pick the channel every Team chat job posts to (Regent joins it); its thread carries the job's questions, proposed changes with Approve / Reject, and its result. `channel_id: null` turns the mirror off. Request body (RegentSlackTeamChatChannelRequest): - channel_id (string, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/regent-slack/intake-triage Triage a forwarded contract or invoice and post an interactive Slack card Evaluates duplicate bill risk, multi-month prepaid amortization, 1099/W-9 compliance, and Smart Pay working-capital float, then posts an interactive Slack Block Kit card with 1-click actions. Request body (RegentSlackIntakeTriageRequest): - channel (string, required) - vendor_name (string, required) - amount_cents (integer, required) - description (string, optional) - due_date (string, optional) - service_months (integer, optional) - bill_number (string, optional) - has_w9_on_file (boolean, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/regent-slack/interactions Slack interactivity Handles Regent's interactive Slack Block Kit button clicks (write approvals, rejections, and 1-click transaction clarifications). Responses: 201 ### GET /api/v1/regent-slack/link-url Get the Sign in with Slack URL Slack sign-in URL that links the Slack account you sign in with to your DayZero account. Sets the browser-binding cookie the callback requires. Responses: 200, 400, 401, 422 ### GET /api/v1/regent-slack/link/callback Sign in with Slack callback Slack redirects here after the person signs in to link accounts. Parameters: - state (query, string, required) - code (query, string, optional) - error (query, string, optional) Responses: 200, 422 ### GET /api/v1/regent-slack/links Your linked Slack accounts Slack accounts that Regent answers as you. Responses: 200, 422 ### DELETE /api/v1/regent-slack/links/{link_id} Unlink a Slack account Regent stops answering that Slack account as you. Parameters: - link_id (path, string, required) Responses: 200, 422 ### GET /api/v1/regent-slack/oauth/callback Add to Slack callback Slack redirects here after a workspace install. Parameters: - state (query, string, required) - code (query, string, optional) - error (query, string, optional) Responses: 200, 422 ## replenishment ### GET /api/v1/replenishment/proposals List replenishment proposals Forecast-driven purchase orders with their funding choice, newest first. Each carries the SKU's weeks of cover and stockout week, the draft PO, the line picked (or cash) with its estimated cost, the 13-week cash trough paid from cash and financed, the repayment weeks and the proposed change that approves it. Lapsed proposals are expired on read. Parameters: - status (query, string, optional): One status or a comma-separated list: proposed, approved, ordered, funded, dismissed, expired. - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/replenishment/proposals/run Run the replenishment proposer now For every SKU whose demand forecast crosses its reorder point inside the vendor's lead time: draft a PO at the default vendor, read it against the business's credit lines, pick the cheapest line with headroom (or cash) and file one proposed change. Nothing is ordered or funded until a person approves it. One open proposal per SKU and location; a SKU already proposed is skipped. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/replenishment/proposals/{proposal_id}/dismiss Dismiss a replenishment proposal Decline the proposal. Its proposed change is rejected with the reason and its draft PO is canceled while still a draft. `409` when it is no longer waiting. Parameters: - proposal_id (path, string, required) Responses: 200, 400, 401, 403, 404, 409, 422 ## reports — Financial report generation (P&L, Balance Sheet, Trial Balance, etc.). ### GET /api/v1/reports List reports Retrieve all reports for a business with pagination. Parameters: - client_visible_only (query, boolean, optional) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/reports Generate report Queue a report for generation and return task ID for tracking. Request body (ReportCreateRequest): - report_name (string, required) - period_type (ReportPeriodType, optional) - tax_year (integer, optional) - tax_quarter (integer, optional) - start_date (string, optional) - end_date (string, optional) - comparison_period_type (ReportPeriodType, optional) - comparison_tax_year (integer, optional) - comparison_tax_quarter (integer, optional) - comparison_start_date (string, optional) - comparison_end_date (string, optional) - ledger_id (string, optional) - instance_id (string, optional) - file_s3_key (string, optional) - s3_keys (array · string, optional) - tag_group_id (string, optional) - tag_ids (array · string, optional) - additional_params (object, optional) - visible_to_client (boolean, optional) - output_format (ReportOutputFormat, optional) → ReportOutputFormat Responses: 202, 400, 401, 403, 404, 422 ### GET /api/v1/reports/download Download report (proxy) Download a report/export file. Validates ownership and audits the download, then 307-redirects to a short-TTL presigned S3 URL so the transfer happens directly against S3; falls back to a same-origin proxy stream if presigning is unavailable. Parameters: - s3_key (query, string, required) - filename (query, string, optional) - inline (query, boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/reports/import-templates List import templates Every CSV template the app can import — chart of accounts, customers, vendors, transactions, invoices, bills, journal entries — with column definitions derived from the importers themselves, per-file download URLs and a ZIP URL bundling all of them with a README each. Responses: 200, 401, 403, 422 ### GET /api/v1/reports/import-templates.zip Download all import templates as a ZIP A ZIP with one folder per template holding the CSV and a README.md (columns, required/optional, formats, an example, and which page to upload it on), an INDEX.md, and — when this business has active ledgers — the bulk journal-entry .xlsx with its Ledgers sheet. Responses: 200, 401, 403, 422 ### GET /api/v1/reports/import-templates/{template_key}.csv Download one import template CSV One template's CSV (header row + example rows). Parameters: - template_key (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/reports/import-templates/{template_key}.md Download one import template README One template's README (markdown): columns, formats, example, upload page. Parameters: - template_key (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/reports/preview-info Report preview availability Report whether a server-rendered PNG preview is available for a report/export file, and how many pages it has. Validates ownership exactly like /download. Renders and caches every page (capped at 20) on the first call for a key; later calls are served from cache. Parameters: - s3_key (query, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/reports/preview-page Report preview page image Return one rendered page of a report/export preview as a raw PNG image. Validates ownership exactly like /download. Renders and caches on a cache miss. Parameters: - s3_key (query, string, required) - page (query, integer, required): 1-based page number. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/reports/subledger-gl-reconciliation Sub-ledger to GL reconciliation Compare AR/AP sub-ledger open balances against their GL control-account balances, as of a date, with one row per customer and per vendor. Parameters: - as_of_date (query, string · date, optional): Balances and open documents as of this date (default today). - parent_ledger_id (query, string, optional): Reconcile only this control account (and its sub-ledgers); a liability ledger is read as the payables side. Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/reports/suggest AI report suggestions Get AI-powered report suggestions for the business. Responses: 201, 401, 403, 422 ### GET /api/v1/reports/types Get supported report types Retrieve a list of all supported report types with their metadata. Responses: 200, 401, 403, 422 ### DELETE /api/v1/reports/{report_id} Delete report Delete a report and remove its associated S3 file. Parameters: - report_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/reports/{report_id} Get report Retrieve a specific report by ID. Parameters: - report_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/reports/{report_id} Update report sharing Share a generated report to the client portal or take it back. Firm staff and business admins only. Parameters: - report_id (path, string, required) Request body (ReportUpdateRequest): - visible_to_client (boolean, required) Responses: 200, 400, 401, 403, 404, 422 ## revenue-schedules ### GET /api/v1/revenue-schedules List revenue schedules List deferred-revenue tranches across all sources. Parameters: - source (query, RevenueSourceEnum, optional): Filter by source - limit (query, integer, optional): Page size - offset (query, integer, optional): Offset Responses: 200, 401, 403, 422 ### POST /api/v1/revenue-schedules/preorders Book a pre-order Collect pre-order cash to deferred revenue (releases on fulfillment). Request body (PreorderBookRequest): - order_reference (string, required) - amount_cents (integer, required) - order_date (string · date, optional) - receive_via (string, optional) - revenue_ledger_name (string, optional) - currency (string, optional) - reference_id (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/revenue-schedules/preorders/fulfill Recognize a pre-order on fulfillment Release a parked pre-order tranche into revenue (point-in-time). Request body (PreorderFulfillRequest): - order_reference (string, required) - fulfillment_date (string · date, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/revenue-schedules/recognize Run recognition Post all due tranches the unified engine owns for this business. Responses: 201, 401, 403, 422 ### GET /api/v1/revenue-schedules/waterfall Deferred-revenue waterfall Remaining deferred revenue scheduled to release, by month. Parameters: - source (query, RevenueSourceEnum, optional): Filter by source Responses: 200, 401, 403, 422 ## sales-receipts ### GET /api/v1/sales-receipts List sales receipts List sales receipts and refund receipts for the business. Parameters: - receipt_type (query, string, optional): Filter by type: sale or refund. - status (query, string, optional): Filter by status: posted or void. - customer_id (query, string, optional): Filter by customer. - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/sales-receipts Create sales receipt Create and post a sales receipt (or refund receipt). Request body (SalesReceiptCreateRequest): - receipt_type (string, optional) - customer_id (string, optional) - receipt_date (string · date, optional) - deposit_to_ledger_id (string, required) - income_ledger_id (string, optional) - line_items (array · SalesReceiptLineItem, required) → SalesReceiptLineItem - tax_total (integer, optional) - number (string, optional) - memo (string, optional) - currency (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/sales-receipts/{receipt_id} Get sales receipt Get details of a specific sales/refund receipt. Parameters: - receipt_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/sales-receipts/{receipt_id}/void Void sales receipt Void a sales/refund receipt and post a reversing journal entry. Parameters: - receipt_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## scenarios ### GET /api/v1/scenarios List scenarios This business's forks, newest first, with the headline deltas. Parameters: - status (query, string, optional): queued | running | ready | failed | applied | discarded - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/scenarios Fork the company and simulate a decision Queues a scenario: the business is copied into a sandbox, the typed changes (`price_change_pct`, `vendor_cost_change_pct`, `headcount_add`, `take_credit_line`, `cut_spend`, `delay_po`, `one_time_item`) are applied to the copy's cash forecast, and the baseline and scenario are stored with their diff. Poll `GET /scenarios/{id}` until `status` is `ready`. The copy is deleted afterwards unless `keep_clone` is true. At most two forks may be queued or running per business (`409`). Request body (ScenarioForkCreate): - title (string, required) - decision (array · PriceChange | VendorCostChange | HeadcountAdd | TakeCreditLine | CutSpend | DelayPo | OneTimeItem, required) - horizon_weeks (integer, optional) - keep_clone (boolean, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/scenarios/parse Describe a decision in words Reads a sentence into typed changes for review; nothing is simulated or saved. Purchase orders and budget lines are matched to this business's ids only; clauses no change type covers come back in `unparsed`. Request body (ScenarioParseRequest): - text (string, required) - horizon_weeks (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/scenarios/{scenario_id} Get a scenario The fork with its baseline and scenario summaries (weekly ending cash, lowest week, P&L proxy, covenant status, trust grade) and the diff once `status` is `ready` or `applied`. Parameters: - scenario_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/scenarios/{scenario_id}/apply File the decision as proposed changes Turns a ready fork's changes into real proposals on the live business: forecast-cell changes become one cash forecast overrides proposal, one-time items and a credit draw's cash legs become one-time item proposals, a PO delay becomes a purchase order date proposal, and a credit draw over the line's headroom becomes a limit-change request the lender decides. Every proposal waits in Proposed Changes. What has no write behind it is returned as `manual`. `409` unless `status` is `ready`. Parameters: - scenario_id (path, string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/scenarios/{scenario_id}/discard Discard a scenario Marks the fork discarded and deletes a kept sandbox copy. `409` while the fork is still queued or running. Parameters: - scenario_id (path, string, required) Responses: 201, 401, 403, 404, 409, 422 ## search — Full-text search across transactions, contacts, and entities. ### GET /api/v1/search Global search Search across products, variants, customers, invoices, vendors, and more. Parameters: - entity_type (query, string, optional): Limit to: products, variants, customers, invoices, vendors, transactions, journal_entries, ledgers, emails - date_from (query, string, optional): Results after this date (ISO 8601: YYYY-MM-DD) - date_to (query, string, optional): Results before this date (ISO 8601: YYYY-MM-DD) - search_term (query, string, required) - limit (query, integer, optional): Pagination limit - cursor (query, string, optional): Cursor for pagination - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/search/natural AI natural language search Search using natural language queries. Responses: 201, 401, 403, 422 ## subscriptions — Manage recurring subscription billing for customers. ### GET /api/v1/subscriptions/ List detected recurring transactions Detect recurring transactions from transaction history using counterparty and frequency analysis. Parameters: - lookback_days (query, integer, optional): Days to look back - sort_by (query, string, optional): Sort: cost_desc, cost_asc, frequency, confidence_desc, recent, occurrences_desc Responses: 200, 401, 403, 422 ### PUT /api/v1/subscriptions/ Update a detected recurring transaction Override the display name, monthly cost, frequency, or add notes to a detected recurring transaction. Request body (UpdateSubscriptionRequest): - counterparty_key (string, required) - registry_id (string, optional) - custom_name (string, optional) - custom_amount_cents (integer, optional) - custom_frequency (string, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/subscriptions/analyze AI subscription analysis Get AI-powered subscription analysis for optimization opportunities. Responses: 201, 401, 403, 422 ### POST /api/v1/subscriptions/create-templates Create recurring bill templates from detected patterns Turn detected recurring spend into recurring bill templates in one call: name the rows (`counterparty_keys`, as listed by `GET /`) or take every row at or above `min_confidence`. Vendor, amount, cadence and first date come from the detection (re-run server-side). A row with no vendor of that name, a semi-annual row, or a vendor that already has an open template on that cadence is skipped with a reason; each row is isolated. `dry_run` plans without creating. Request body (CreateTemplatesFromDetectionRequest): - counterparty_keys (array · string, optional) - min_confidence (number, optional) - lookback_days (integer, optional) - vendor_overrides (object, optional) - dry_run (boolean, optional) - plan_hash (string, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/subscriptions/dismiss Dismiss a detected recurring transaction Mark a counterparty as not recurring. It won't appear in future results. Request body (app__api__v1__schemas__subscriptions__DismissRequest): - counterparty_key (string, required) - registry_id (string, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/subscriptions/history Monthly spend history for recurring transactions Returns per-month totals and per-counterparty breakdown for charting. Parameters: - lookback_days (query, integer, optional): Days to look back Responses: 200, 401, 403, 422 ### POST /api/v1/subscriptions/restore Restore a dismissed recurring transaction Undo a previous dismissal so the recurring transaction appears again. Request body (RestoreRequest): - counterparty_key (string, required) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/subscriptions/settings Get recurring transaction budget settings Responses: 200, 401, 403, 422 ### PUT /api/v1/subscriptions/settings Set monthly recurring transaction limit Set or remove the monthly recurring transaction budget. Pass null to remove the limit. Request body (SetLimitRequest): - monthly_limit_cents (integer, optional) Responses: 200, 400, 401, 403, 422 ### GET /api/v1/subscriptions/summary Recurring transactions summary for dashboard Returns total monthly cost, budget limit, and top 5 recurring transactions. Responses: 200, 401, 403, 422 ## tags — Custom tag groups and tags for categorizing entities. ### POST /api/v1/entity-tags Attach tag to entity Attach a tag to a specific entity (transaction, invoice, bill, etc.). Idempotent: re-attaching the same tag returns the existing attachment. Request body (EntityTagCreate): - tag_id (string, required) - model_type (string, required) - model_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/entity-tags/batch Batch fetch tags for multiple entities Fetch tags for many entities of the same type in a single request. Returns a mapping of entity id -> its tags; entities with no tags are omitted. Replaces per-row GET /entity-tags/{model_type}/{model_id} calls to avoid request fan-out (and the edge rate limiting it causes). Request body (BulkEntityTagsRequest): - model_type (string, required) - model_ids (array · string, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/entity-tags/bulk-attach Bulk attach tags to an entity Attach multiple tags to a single entity at once Request body (BulkEntityTagCreate): - tag_ids (array · string, required) - model_type (string, required) - model_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/entity-tags/bulk-attach-many Bulk attach tags to many entities Attach one or more tags to many entities of the same type in a single request. Idempotent; existing attachments are skipped. Replaces the per-entity request fan-out used for bulk tagging a table selection. Request body (BulkEntityTagAttachManyRequest): - tag_ids (array · string, required) - model_type (string, required) - model_ids (array · string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/entity-tags/bulk-detach Bulk detach tags from an entity Remove multiple tags from a single entity at once Request body (BulkEntityTagRemove): - tag_ids (array · string, required) - model_type (string, required) - model_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/entity-tags/{model_type}/{model_id} Get tags for an entity Retrieve all tags attached to a specific entity with cursor-based pagination Parameters: - model_type (path, string, required) - model_id (path, string, required) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 400, 401, 403, 422 ### DELETE /api/v1/entity-tags/{tag_id}/{model_type}/{model_id} Detach tag from entity Remove a tag from a specific entity Parameters: - tag_id (path, string, required) - model_type (path, string, required) - model_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/tag-groups List tag groups Retrieve all tag groups for the current business Parameters: - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/tag-groups Create tag group Create a new tag group for organizing tags Request body (TagGroupCreate): - name (string, required) - description (string, optional) Responses: 201, 400, 401, 403, 422 ### DELETE /api/v1/tag-groups/{tag_group_id} Delete tag group Delete a tag group. This will also delete all tags in the group. Parameters: - tag_group_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/tag-groups/{tag_group_id} Get tag group Retrieve a specific tag group by ID Parameters: - tag_group_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/tag-groups/{tag_group_id} Update tag group Update an existing tag group Parameters: - tag_group_id (path, string, required) Request body (TagGroupUpdate): - name (string, optional) - description (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/tags List tags Retrieve all tags for the current business, optionally filtered by tag group or fuzzy name search Parameters: - tag_group_id (query, string, optional): Filter tags by tag group ID - search (query, string, optional): Fuzzy search tags by name (trigram similarity) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/tags Create tag Create a new tag, optionally in a tag group Request body (TagCreate): - name (string, required) - description (string, optional) - tag_group_id (string, optional) Responses: 201, 400, 401, 403, 409, 422 ### POST /api/v1/tags/suggest AI tag suggestions Get AI-powered tag name suggestions based on existing tags and optional context Request body (TagSuggestRequest): - existing_tags (array · string, optional) - context (string, optional) Responses: 201, 401, 403, 422 ### DELETE /api/v1/tags/{tag_id} Delete tag Delete a tag. This will remove the tag from all entities. Parameters: - tag_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/tags/{tag_id} Get tag Retrieve a specific tag by ID Parameters: - tag_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/tags/{tag_id} Update tag Update an existing tag Parameters: - tag_id (path, string, required) Request body (TagUpdate): - name (string, optional) - description (string, optional) - tag_group_id (string, optional) Responses: 200, 400, 401, 403, 404, 409, 422 ### GET /api/v1/tags/{tag_id}/entities/{model_type} Get entities with a tag Retrieve all entities of a specific type that have a particular tag Parameters: - tag_id (path, string, required) - model_type (path, string, required) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 400, 401, 403, 404, 422 ## tax — Tax rate configuration and tax calculations. ### GET /api/v1/tax/codes List tax codes List all tax codes for the business. Parameters: - active_only (query, boolean, optional): Only show active codes Responses: 200, 401, 403, 422 ### POST /api/v1/tax/codes Create tax code Create a new tax code. Request body (TaxCodeCreateRequest): - code (string, required) - name (string, required) - description (string, optional) - is_taxable (boolean, optional) Responses: 201, 400, 401, 403, 409, 422 ### POST /api/v1/tax/codes/seed-defaults Seed default tax codes Seed default tax codes for the business (if none exist). Responses: 200, 401, 403, 422 ### DELETE /api/v1/tax/codes/{code_id} Deactivate tax code Deactivate a tax code (soft delete). Parameters: - code_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/tax/codes/{code_id} Get tax code Get details of a specific tax code. Parameters: - code_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/tax/codes/{code_id} Update tax code Update an existing tax code. Parameters: - code_id (path, string, required) Request body (TaxCodeUpdateRequest): - code (string, optional) - name (string, optional) - description (string, optional) - is_taxable (boolean, optional) - is_active (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/tax/dedupe-imported Dedupe imported tax data Deactivate duplicate tax rates and codes created by integration imports. Responses: 200, 401, 403, 422 ### GET /api/v1/tax/rates List tax rates List all tax rates for the business. Parameters: - active_only (query, boolean, optional): Only show active rates - country (query, string, optional): Filter by country - state (query, string, optional): Filter by state Responses: 200, 401, 403, 422 ### POST /api/v1/tax/rates Create tax rate Create a new tax rate. Request body (TaxRateCreateRequest): - name (string, required) - rate (number | string, required) - tax_type (string, optional) - country (string, optional) - state (string, optional) - county (string, optional) - city (string, optional) - tax_liability_ledger_id (string, optional) - is_default (boolean, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/tax/rates/default Get default tax rate Get the default tax rate for the business. Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/tax/rates/{rate_id} Deactivate tax rate Deactivate a tax rate (soft delete). Parameters: - rate_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/tax/rates/{rate_id} Get tax rate Get details of a specific tax rate. Parameters: - rate_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/tax/rates/{rate_id} Update tax rate Update an existing tax rate. Parameters: - rate_id (path, string, required) Request body (TaxRateUpdateRequest): - name (string, optional) - rate (number | string, optional) - tax_type (string, optional) - country (string, optional) - state (string, optional) - county (string, optional) - city (string, optional) - tax_liability_ledger_id (string, optional) - is_default (boolean, optional) - is_active (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/tax/suggest-rates AI tax rate suggestions Get AI-powered tax rate suggestions for the business. Responses: 201, 401, 403, 422 ## tax-deadlines ### GET /api/v1/books/tax-deadlines Upcoming tax and filing deadlines Deadlines computed from the business's tax settings (fiscal year, active sales-tax rates, 1099 contractors). Reminders only, not tax advice; the response carries the disclaimer. Parameters: - horizon_days (query, integer, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/books/tax-deadlines/sync-todos Add upcoming deadlines to my to-dos Adds a dated to-do (with a reminder a week ahead) for each deadline in the next 60 days that is not already on the caller's list. Safe to repeat. Responses: 201, 401, 403, 422 ## time-entries ### GET /api/v1/time-entries List time entries List time entries, optionally filtered by customer/project/status. Parameters: - customer_id (query, string, optional): Filter by customer. - project_id (query, string, optional): Filter by project. - status (query, string, optional): Filter by status: unbilled, billed. - include_inactive (query, boolean, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/time-entries Create time entry Log a new time entry. Request body (TimeEntryCreateRequest): - entry_date (string · date, required) - duration_minutes (integer, required) - description (string, optional) - person_name (string, optional) - customer_id (string, optional) - project_id (string, optional) - catalog_item_id (string, optional) - billable (boolean, optional) - rate_cents (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/time-entries/add-expenses-to-invoice Add expenses to invoice Append billable vendor expenses to a draft invoice. Request body (AddExpensesToInvoiceRequest): - invoice_id (string, required) - document_link_ids (array · string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/time-entries/add-to-invoice Add time to invoice Append billable time entries to a draft invoice and mark billed. Request body (AddToInvoiceRequest): - invoice_id (string, required) - time_entry_ids (array · string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/time-entries/billable List billable time Unbilled, billable time entries with computed billable amount. Parameters: - customer_id (query, string, optional): Filter by customer. - project_id (query, string, optional): Filter by project. Responses: 200, 401, 403, 422 ### GET /api/v1/time-entries/billable-expenses List billable expenses Vendor bill costs available to on-bill to a customer invoice. Responses: 200, 401, 403, 422 ### DELETE /api/v1/time-entries/{time_entry_id} Delete time entry Soft-delete (deactivate) a time entry. Parameters: - time_entry_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/time-entries/{time_entry_id} Get time entry Get a single time entry. Parameters: - time_entry_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/time-entries/{time_entry_id} Update time entry Update a time entry. All fields optional. Parameters: - time_entry_id (path, string, required) Request body (TimeEntryUpdateRequest): - entry_date (string · date, optional) - duration_minutes (integer, optional) - description (string, optional) - person_name (string, optional) - customer_id (string, optional) - project_id (string, optional) - catalog_item_id (string, optional) - billable (boolean, optional) - rate_cents (integer, optional) - status (string, optional) - is_active (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ## todos ### GET /api/v1/todos List user todos List todos for the authenticated user with cursor pagination. Parameters: - completed (query, boolean, optional): Filter by completion status - entity_type (query, string, optional): Only todos linked to this kind of record (e.g. business_note) - entity_id (query, string, optional): Only todos linked to this record id - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/todos Create a todo Create a personal or business-scoped todo for the current user. Request body (UserTodoCreateRequest): - title (string, required) - description (string, optional) - business_id (string, optional) - due_date (string · date-time, optional) - reminder_at (string · date-time, optional) - priority (TodoPrioritySchema, optional) → TodoPrioritySchema - entity_type (string, optional) - entity_id (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/todos/{todo_id} Delete a todo Soft-delete a todo. Parameters: - todo_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/todos/{todo_id} Get a todo Retrieve a single todo by ID. Parameters: - todo_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/todos/{todo_id} Update a todo Partially update a todo's fields. Parameters: - todo_id (path, string, required) Request body (UserTodoUpdateRequest): - title (string, optional) - description (string, optional) - due_date (string · date-time, optional) - reminder_at (string · date-time, optional) - priority (TodoPrioritySchema, optional) - entity_type (string, optional) - entity_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/todos/{todo_id}/complete Complete a todo Mark a todo as completed. Parameters: - todo_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/todos/{todo_id}/uncomplete Uncomplete a todo Mark a completed todo as pending again. Parameters: - todo_id (path, string, required) Responses: 201, 401, 403, 404, 422 ## transaction-clarifications ### GET /api/v1/transaction-clarifications List transaction clarifications (client) List questions your bookkeeper has asked about your transactions. Parameters: - status (query, string, optional): Filter by status: open, answered, resolved - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional) - include_total_count (query, boolean, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/transaction-clarifications/count Open clarification count (client) Number of unanswered questions for the sidebar badge. Responses: 200, 401, 403, 422 ### GET /api/v1/transaction-clarifications/firm List clarifications (firm) List all transaction questions across the firm's businesses. Parameters: - firm_id (query, string, optional): Advisory firm ID - business_id (query, string, optional): Filter by business - status (query, string, optional): Filter by status - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional) - include_total_count (query, boolean, optional) Responses: 200, 401, 403, 422 ### GET /api/v1/transaction-clarifications/firm/count Open clarification count (firm) Number of unanswered questions across the firm. Parameters: - firm_id (query, string, optional): Advisory firm ID Responses: 200, 401, 403, 422 ### POST /api/v1/transaction-clarifications/firm/transactions/{transaction_id} Ask the client about a transaction (firm) Attach a question to a transaction for the client to answer. Parameters: - transaction_id (path, string, required) - business_id (query, string, optional): Business that owns the transaction Request body (CreateClarificationRequest): - question (string, required) - options (array · string, optional) - request_type (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/transaction-clarifications/firm/{clarification_id}/resolve Resolve a clarification (firm) Close the loop after applying the client's answer. Parameters: - clarification_id (path, string, required) - firm_id (query, string, optional): Advisory firm ID Responses: 201, 401, 403, 404, 422 ### POST /api/v1/transaction-clarifications/{clarification_id}/answer Answer a clarification (client) Provide an answer to a question your bookkeeper asked. Parameters: - clarification_id (path, string, required) Request body (AnswerClarificationRequest): - answer (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/transaction-clarifications/{clarification_id}/receipt Attach a receipt to a clarification (client) Upload the receipt or invoice for the transaction your bookkeeper asked about. The file is attached to that transaction. Parameters: - clarification_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ## transactions — Bank transactions — sync, categorize, review, and reconcile. ### GET /api/v1/transactions List transactions Retrieve bank transactions with filtering by date, ledger, source account, counter ledger, journal entry, or tags. Parameters: - id (query, array · string, optional): Filter by specific transaction UUIDs - ledger_id (query, array · string, optional): Filter by bank account ledger UUIDs - opposing_ledger_id (query, string, optional): Filter by opposing ledger UUID (the category/expense ledger from journal entry line entries) - source_account_id (query, array · string, optional): Filter by external source account IDs (bank accounts from Plaid) - tag_id (query, array · string, optional): Filter by assigned tag UUIDs - journal_entry_id (query, string, optional): Filter by associated journal entry UUID - start_date (query, string · date-time, optional): Include transactions from this date (ISO 8601) - end_date (query, string · date-time, optional): Include transactions up to this date (ISO 8601) - search (query, string, optional): Search transactions by description or counterparty name (case-insensitive partial match) - amount_direction (query, string, optional): Filter by amount direction: 'inflow' for positive amounts (money in), 'outflow' for negative amounts (money out) - only_uncategorized (query, boolean, optional): Filter to show only uncategorized transactions (those without a journal entry or linked to system uncategorized ledgers) - missing_counterparty (query, boolean, optional): Filter to show only transactions with no counterparty assigned (empty or NULL). Useful for surfacing wires / miscellaneous deposits that the auto-detection pipeline intentionally left blank for the bookkeeper to fill in. - counterparty (query, string, optional): Only transactions whose counterparty is exactly this name (case-insensitive). Names come from `GET /counterparty-naming/names`. Mirrored on the export. - review_status (query, string, optional): Filter by review status. Accepts 'reviewed', 'unreviewed', or a comma-separated combination. Must mirror the same flag on the export endpoint so the visible list and the exported file stay in sync. - reconciled (query, boolean, optional): Filter by reconciliation state. `true` returns only reconciled transactions, `false` only unreconciled. Omit for all. - posted_status (query, string, optional): Filter by bank posting status: 'posted' (cleared activity that affects the books) or 'pending' (unsettled authorizations, read-only awareness layer). Omit to return both. - source (query, string, optional): Filter by transaction origin: 'plaid', 'ramp', 'bulk_upload', 'manual', 'xero', 'quickbooks', or a comma-separated combination. Omit to return every source. - has_attachments (query, boolean, optional): Filter by attached receipts / documents. `true` returns only transactions with at least one attachment, `false` only those with none (missing receipts). Omit for all. - receipt_status (query, string, optional): Filter by receipt tracking status: 'attached', 'exempt', 'not_required', 'requested' or 'missing', or a comma-separated combination. Applies the business's receipt policy, so 'missing' means needs a receipt and has none. Mirrored on the export. - card_holder (query, string, optional): Only the given cardholder's transactions (a Ramp employee, or the card member a bank reports on a multi-card account), by name exactly as `GET /transactions/card-holders` lists it (case-insensitive). Mirrored on the export. - rule_id (query, string, optional): Only transactions whose current category this bank rule chose (each row's `categorized_by.rule_id`). - review_queue (query, string, optional): One slice of the review queue: 'uncategorized', 'auto_categorized' (categorized by a rule, pattern or AI) or 'has_match' (a pending invoice/bill payment suggestion). Use with `review_status=unreviewed`; counts via `GET /transactions/review-queue`. - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/transactions Create transaction Manually create a transaction record (not synced from bank). Request body (TransactionCreateRequest): - amount (integer, optional) - currency (string, optional) - datetime (string · date, optional) - description (string, optional) - source_account_id (string, optional) - reconciled (boolean, optional) Responses: 201, 400, 401, 403, 422 ### PATCH /api/v1/transactions/batch Edit many transactions, a different change per row Apply a different edit to each of up to 500 transactions in one request: per row ``description`` (alias ``memo``), ``ledger_id`` (category), ``counterparty`` and ``review_status``. Every row is validated first; one invalid row rejects the whole request with 400 and nothing changes. Applying is then isolated per row, so a row that fails at write time is reported without undoing the others (``partial``). ``remember`` saves counterparty renames for the business, with the payment-processor guard. ``dry_run`` validates and reports per row without writing. Request body (TransactionBulkEditRequest): - rows (array · TransactionBulkEditRow, required) → TransactionBulkEditRow - remember (boolean, optional) - dry_run (boolean, optional) - plan_hash (string, optional) Responses: 200, 400, 401, 403, 422 ### PATCH /api/v1/transactions/batch/category Batch update category Batch update category for multiple transactions. Updates the opposing line entries' ledger to the specified ledger, effectively recategorizing the transactions. Request body (TransactionBulkUpdateCategoryRequest): - transaction_ids (array · string, required) - ledger_id (string, required) - create_rules (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### PATCH /api/v1/transactions/batch/counterparty Batch update counterparty Set the counterparty name for multiple transactions at once. With ``remember`` the name is also saved as a rename for the business's other transactions under the same registry entry or raw name (see ``POST /counterparty-naming/rename-impact`` for the count first); the response reports ``rows_renamed``, ``aliases_created`` and ``other_rows_relabelled``. Request body (TransactionBulkUpdateCounterpartyRequest): - transaction_ids (array · string, required) - counterparty (string, required) - remember (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/transactions/batch/delete Delete selected transactions Permanently delete manual/bulk-uploaded transactions, or soft-delete (hide) Plaid transactions on the DayZero local engine, by explicit IDs. Request body (TransactionBulkDeleteRequest): - transaction_ids (array · string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/transactions/batch/mark-reviewed-by-filter Mark machine-categorized transactions reviewed by filter Mark every unreviewed transaction a machine categorized (bank rule, counterparty rule, merchant pattern, history, AI) that matches a filter as reviewed: by who categorized it, a confidence floor, counterparties, an amount ceiling or a date range. Rows a person categorized, transfers and uncategorized rows are never selected. `dry_run` returns the count and a sample. The ids-based `PATCH /batch/review-status` is unchanged. Request body (TransactionReviewByFilterRequest): - categorized_by (array · string, optional) - min_confidence (number, optional) - counterparties (array · string, optional) - min_amount_cents (integer, optional) - max_amount_cents (integer, optional) - date_from (string · date, optional) - date_to (string · date, optional) - limit (integer, optional) - dry_run (boolean, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/transactions/batch/mark-reviewed-by-period Mark all unreviewed transactions in a period as reviewed Bulk-mark every unreviewed transaction whose date falls within [period_start, period_end] as reviewed. Used by the monthly close checklist's 'Mark all reviewed' CTA. Request body (TransactionMarkReviewedByPeriodRequest): - period_start (string · date, required) - period_end (string · date, required) Responses: 201, 400, 401, 403, 422 ### PATCH /api/v1/transactions/batch/receipt-exempt Mark transactions as not needing a receipt Exempt transactions from receipt tracking (bank fees, transfers, anything that will never have a receipt), or clear the exemption. Request body (ReceiptExemptRequest): - transaction_ids (array · string, required) - exempt (boolean, optional) - reason (string, optional) Responses: 200, 400, 401, 403, 422 ### POST /api/v1/transactions/batch/receipt-requests Request receipts from the client Ask the client for the receipts behind a batch of transactions. Transactions that already have a receipt, are marked exempt, or already carry an open request are skipped, so it is safe to repeat. Firm staff only: the business must be managed through an advisory firm. Request body (BulkReceiptRequest): - transaction_ids (array · string, required) - note (string, optional) Responses: 201, 400, 401, 403, 422 ### PATCH /api/v1/transactions/batch/reconciliation-status Batch update reconciliation status Mark multiple transactions as reconciled or unreconciled. Request body (TransactionMarkReconciledRequest): - transaction_ids (array · string, optional) - reconciled (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### PATCH /api/v1/transactions/batch/review-status Batch update review status Mark multiple transactions as reviewed or unreviewed in one request. Request body (TransactionMarkReviewedRequest): - transaction_ids (array · string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/transactions/bulk Bulk create transactions Create multiple manual transactions in a single request. Request body (BulkTransactionCreateRequest): - transactions (array · TransactionCreateRequest, required) → TransactionCreateRequest Responses: 201, 400, 401, 403, 422 ### POST /api/v1/transactions/bulk-upload Bulk upload transactions to new source account Upload historical transactions from a CSV/Excel file to a new source account. Request body (BulkTransactionUploadRequest): - ledger_id (string, optional) - ledger_name (string, optional) - source_account_name (string, optional) - business_personal (string, optional) - invert_transaction_amounts (boolean, optional) - s3_key (string, required) - start_date (string · date, optional) - end_date (string · date, optional) - check_duplicates (boolean, optional) - duplicate_match_fields (array · string, optional) - skip_categorization (boolean, optional) - generate_bank_rules (boolean, optional) - currency (string, optional) - editable (boolean, optional) - type (string, optional) - description (string, optional) - status (string, optional) - debit_credit (string, optional) - sort_code (string, optional) - sub_type (string, optional) - report_cash_flow (boolean, optional) - financial_account_type (string, optional) - parent_id (string, optional) - column_mapping (object, optional) - only_missing_from_diff (boolean, optional) - include_row_numbers (array · integer, optional) - date_tolerance_days (integer, optional) - status_column (string, optional) - exclude_statuses (array · string, optional) - allow_unmatched_categories (boolean, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/transactions/bulk-upload/diff Compare a bank/card export with a ledger Read-only. Compares an uploaded bank or credit-card export (CSV/Excel) with Request body (LedgerDiffRequest): - s3_key (string, required) - ledger_id (string, required) - start_date (string · date, optional) - end_date (string · date, optional) - column_mapping (object, optional) - date_tolerance_days (integer, optional) - status_column (string, optional) - exclude_statuses (array · string, optional) - invert_transaction_amounts (boolean, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/transactions/bulk-upload/from-statement Extract transactions from a statement Read a statement (PDF, image, CSV or Excel) with the statement parser and write Request body (StatementExtractRequest): - s3_key (string, required) - ledger_id (string, required) - include_pending (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/transactions/bulk-upload/headers Get CSV/Excel column headers for mapping Return the column headers, sample rows, and a suggested mapping for a previously Request body (BulkUploadHeadersRequest): - s3_key (string, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/transactions/bulk-upload/paste Upload pasted transaction text Accept raw CSV/TSV text (e.g. copied from a bank export or spreadsheet) and Request body (PasteTransactionTextRequest): - pasted_text (string, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/transactions/bulk-upload/preview Preview bulk transaction upload Preview and validate a CSV/Excel file before uploading transactions. Request body (BulkTransactionUploadPreviewRequest): - s3_key (string, required) - start_date (string · date, optional) - end_date (string · date, optional) - check_duplicates (boolean, optional) - ledger_id (string, optional) - financial_account_type (string, optional) - column_mapping (object, optional) Responses: 201, 400, 401, 403, 422 ### GET /api/v1/transactions/bulk-upload/template Download bulk transaction upload CSV template Get a sample CSV template with the expected columns for bulk transaction upload. Responses: 200, 401, 403, 422 ### DELETE /api/v1/transactions/by-date-range Delete transactions by date range Permanently delete every transaction for the current business whose date falls between ``start_date`` and ``end_date`` (inclusive). Journal entries that become orphaned are deleted along with their line entries. This action is irreversible. Parameters: - start_date (query, string · date, required): Inclusive start date (YYYY-MM-DD). Transactions on or after this date are deleted. - end_date (query, string · date, required): Inclusive end date (YYYY-MM-DD). Transactions on or before this date are deleted. - ledger_id (query, string, optional): Optional ledger ID to restrict the deletion to a single bank account. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/transactions/by-date-range/preview Preview a delete-by-date-range Read-only blast-radius preview for ``DELETE /transactions/by-date-range``: how many transactions and journal entries would be removed, how many are reconciled or linked to invoice/bill payments, amount totals, a per-ledger breakdown, and whether the range is blocked by a closed accounting period. Nothing is modified. Parameters: - start_date (query, string · date, required): Inclusive start date (YYYY-MM-DD). - end_date (query, string · date, required): Inclusive end date (YYYY-MM-DD). - ledger_id (query, string, optional): Optional ledger ID to restrict the preview to a single bank account. Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/transactions/card-holders Cardholders The cardholders behind synced transactions: employees on card-program (Ramp) rows, with each card's last 4, and the card members a bank reports on an account that carries several cards (AMEX supplementary cards, Chase master accounts). Those all post under one ledger or one account mask, so the ledger list cannot tell them apart; this is what the Transactions page's Cardholder filter offers. Responses: 200, 401, 403, 422 ### POST /api/v1/transactions/categorize-all AI-categorize all uncategorized transactions Triggers the full AI categorization workflow (Temporal) which processes all uncategorized transactions using bank rules, historical patterns, and LLM categorization. High-confidence results are auto-applied and bank rules are created for future transactions. Returns immediately with a workflow ID. Responses: 201, 400, 401, 403, 422 ### POST /api/v1/transactions/enrich-from-export Enrich transactions from a detailed bank export Match the rows of a bank "account activity" export to transactions already in a Request body (EnrichFromExportRequest): - s3_key (string, required) - ledger_id (string, required) - dry_run (boolean, optional) - overwrite_user_edits (boolean, optional) - column_mapping (object, optional) - date_tolerance_days (integer, optional) - set_counterparty (boolean, optional) - append_description (boolean, optional) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/transactions/recategorize-by-counterparty Recategorize all transactions for a counterparty Move all uncategorized transactions for a given counterparty to the specified ledger. Request body (RecategorizeByCounterpartyRequest): - counterparty (string, required) - ledger_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/transactions/receipt-coverage Receipt coverage How well a period's expenses are backed by receipts, under the business's receipt policy: how many owe one, how many have one, how many were requested from the client, and how many are still missing. Parameters: - start_date (query, string · date-time, optional): Include transactions from this date (ISO 8601) - end_date (query, string · date-time, optional): Include transactions up to this date (ISO 8601) Responses: 200, 401, 403, 422 ### GET /api/v1/transactions/receipt-policy Get receipt tracking policy Which transactions need a receipt (expenses at or above the threshold) and how often the client is reminded about open requests. Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/transactions/receipt-policy Update receipt tracking policy Set the expense threshold above which a receipt is expected, turn receipt tracking off, or tune client reminders. Request body (ReceiptPolicyModel): - enabled (boolean, optional) - threshold_cents (integer, optional) - reminder_days (integer, optional) - max_reminders (integer, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/transactions/review-queue Review queue counts How many transactions are waiting for review, and how many of those are uncategorized, auto-categorized, or have a pending invoice/bill match. List one slice with `GET /transactions?review_status=unreviewed&review_queue=`. Parameters: - start_date (query, string · date-time, optional): Include transactions from this date (ISO 8601) - end_date (query, string · date-time, optional): Include transactions up to this date (ISO 8601) - source (query, string, optional): Only these origins ('plaid', 'ramp', ..., comma-separated). Responses: 200, 400, 401, 403, 422 ### GET /api/v1/transactions/sources Transaction sources in use The sources this business has transactions from (bank feed, card program, CSV upload, manual entry, accounting-system import), with a count each. The Transactions page's Source filter offers only these, so a business is not shown integrations it never linked. Responses: 200, 401, 403, 422 ### POST /api/v1/transactions/suggest-categories Category suggestions Suggest ledger categories for uncategorized transactions. By default only fast pattern-matching layers run (<1 s). Pass include_ai=true to also run LLM categorization for transactions the pattern layers could not resolve. Parameters: - limit (query, integer, optional) - only_uncategorized (query, boolean, optional) - include_ai (query, boolean, optional) Responses: 201, 401, 403, 422 ### POST /api/v1/transactions/suggested-matches/batch Suggested matches for a batch of transactions Score a batch of bank transactions against open invoices (for money in) and open bills (for money out) and return ranked suggested matches, QBO-style. Used to render the inline 'N matches found' badge for the visible page of the Transactions list. Results are ephemeral (no suggestion records are persisted). Request body (BulkSuggestedMatchesRequest): - transaction_ids (array · string, required) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/transactions/suggested-matches/dismiss Dismiss a suggested match Hide a specific invoice or bill suggestion for a bank transaction. Dismissed pairs are excluded from future inline suggested-match scoring until restored. Request body (DismissSuggestedMatchRequest): - transaction_id (string, required) - type (string, required) - target_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/transactions/{transaction_id} Delete or hide transaction Permanently delete a manual/CSV-imported transaction, or soft-delete (hide) a Plaid- or Xero-synced transaction on the DayZero local engine. Parameters: - transaction_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/transactions/{transaction_id} Get transaction Retrieve a specific transaction with all details. Parameters: - transaction_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/transactions/{transaction_id} Update transaction Update a transaction's description, counterparty, review status and other editable fields. A field that is not listed is rejected with 400, never ignored. Parameters: - transaction_id (path, string, required) Request body (TransactionUpdateRequest): - amount (integer, optional) - datetime (string · date, optional) - description (string, optional) - counterparty (string, optional) - remember (boolean, optional) - meta (object, optional) - categorization_method (string, optional) - posted_status (string, optional) - review_status (string, optional) - opposing_line_entry_ids (array · string, optional) - personal (boolean, optional) - journal_entry_id (string, optional) - external_source_account_id (string, optional) - ledger_id (string, optional) - reconciled (boolean, optional) - invoice_id (string, optional) - assigned_to_user_id (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/transactions/{transaction_id}/allocations Get transaction allocations Return how much of a transaction has been allocated to invoices/bills and the remaining unallocated balance. All amounts in cents. Parameters: - transaction_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PATCH /api/v1/transactions/{transaction_id}/attachment Attach file to transaction Upload and attach a document file (receipt, invoice, etc.) to a transaction. Parameters: - transaction_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/transactions/{transaction_id}/attachments/import-ramp Import receipts from Ramp For a transaction synced from Ramp, fetch the receipts the cardholder uploaded in Ramp and attach them here. Idempotent: receipts attached by an earlier import are skipped. Parameters: - transaction_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/transactions/{transaction_id}/attachments/{attachment_id} Remove attachment from transaction Detach a receipt or supporting document from a transaction. The file itself is retained in storage; only the link is removed. Parameters: - transaction_id (path, string, required) - attachment_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### POST /api/v1/transactions/{transaction_id}/attachments/{attachment_id}/extract Read receipt details from an attachment Read an attached receipt and capture its merchant, date, totals (subtotal, tax, tip) and itemized lines onto the attachment. Safe to call again to re-read. Parameters: - transaction_id (path, string, required) - attachment_id (path, string, required) Responses: 201, 401, 403, 404, 422 ### POST /api/v1/transactions/{transaction_id}/restore Restore a hidden transaction Un-hide a previously soft-deleted Plaid or Xero transaction on the DayZero local accounting engine. Plaid rows get their auto journal entry re-created immediately; Xero rows get theirs rebuilt from the source data on the next Xero sync. Parameters: - transaction_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### PATCH /api/v1/transactions/{transaction_id}/split Split a transaction across categories Rebuild a transaction's journal entry so its single category leg becomes multiple category legs (e.g. 70% COGS / 30% Sales Tax). Allocations may be percentages, fixed amounts, or a remainder line; the resulting legs always balance against the bank leg. Parameters: - transaction_id (path, string, required) Request body (TransactionSplitRequest): - split (array · SplitAllocation, required) → SplitAllocation Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/transactions/{transaction_id}/suggested-matches Suggested matches for a transaction Return ranked suggested matches for a single bank transaction. Income transactions are matched against open invoices; expense transactions against open bills. Matches are scored by amount, date proximity, memo, and counterparty similarity. Parameters: - transaction_id (path, string, required) - limit (query, integer, optional): Max suggested matches Responses: 200, 401, 403, 404, 422 ## transfer-review ### GET /api/v1/transfer-review Transactions that look wrongly booked as transfers Transactions in Transfers Between Accounts whose own data does not say transfer (no Plaid transfer or card-payment category, no transfer or card-payment wording), newest first. Each names the row it was most likely paired with, any learned rule that keeps routing the vendor to Transfers, and `after`: what marking it not a transfer would do. Parameters: - limit (query, integer, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/transfer-review/not-a-transfer Mark transactions as not a transfer Moves the transactions out of Transfers Between Accounts, switches off the learned transfer rules for their vendors, and categorizes them again: bank rules, decisions and counterparty defaults always book; history and pattern matches book only while auto-categorize is on (otherwise they are held as suggestions to confirm). Rows left in Uncategorized are marked unreviewed. Transfer detection never pairs them again. Rows in a closed period or split across several categories are skipped. Undo with `POST /automation-runs/{run_id}/undo`. Request body (NotATransferRequest): - transaction_ids (array · string, required) Responses: 200, 400, 401, 403, 422 ## trust ### GET /api/v1/trust/scorecard Trust scorecard for a month The month's grade and the facts behind it: who categorized the transactions, what the automations changed and reverted, approvals, the close, anomalies and journal-entry provenance. Computed from the live tables and stored as the month's snapshot. Parameters: - month (query, string, optional): YYYY-MM; default the current month Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/trust/scorecard/history Trust scorecard history Headline numbers for the last N months, newest first, from the stored snapshots. A month with no snapshot yet is computed and stored. Parameters: - months (query, integer, optional): Months to return Responses: 200, 401, 403, 404, 422 ### POST /api/v1/trust/scorecard/share Create a public scorecard link Mint a token-protected public URL that shows this business's trust scorecard read-only: the grade, the cards and the history, never a transaction, an amount or a name. The raw token is returned here **exactly once**. Omit `expires_in_hours` for a link that lasts until revoked. Admins only: a link is a standing anonymous grant. Request body (CreateTrustShareRequest): - expires_in_hours (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/trust/scorecard/shares List scorecard share links Every link, active and revoked, newest first; tokens are never re-emitted. Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/trust/scorecard/shares/{share_id} Revoke a scorecard share link The public page 404s immediately. Idempotent for a revoked link. Parameters: - share_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## trust-public ### GET /api/v1/public/trust/{token} Public trust scorecard viewer (unauthenticated) Resolve a share token to a business's trust scorecard: the current month's grade, the cards and the 12-month history. Returns 404 for unknown, expired or revoked tokens, indistinguishably. Rate-limited per IP and cached for 60 seconds. Parameters: - token (path, string, required) Responses: 200, 404, 422, 429 ## user — User profile and preferences. ### GET /api/v1/users List users List users with optional filtering. Pass x-business-id header or business_id for business-scoped view; firm_id for firm-wide view. Parameters: - search (query, string, optional): Search users by name or email - id (query, string, optional): Filter by user UUID - email (query, string, optional) - business_id (query, string, optional) - firm_id (query, string, optional) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending - x-firm-id (header, string, optional) Responses: 200, 401, 403, 422 ### POST /api/v1/users Create user Create a new user account in the system. Request body (UserCreate): - email (string · email, required) - first_name (string, optional) - last_name (string, optional) - photo_url (string, optional) - onboarded (boolean, optional) - props (object, optional) Responses: 201, 400, 403, 409, 422 ### GET /api/v1/users/me/last-business Get last-selected business Return the authenticated user's last-selected business and firm IDs. Responses: 200, 401, 404, 422 ### PUT /api/v1/users/me/last-business Set last-selected business Persist the authenticated user's last-selected business and optional firm ID. Request body (LastBusinessUpdate): - business_id (string, required) - firm_id (string, optional) Responses: 200, 400, 401, 404, 422 ### GET /api/v1/users/me/mfa-status Get MFA enforcement status Return whether MFA is required and satisfied for the authenticated user based on Clerk session claims and firm policy. Responses: 200, 401, 422 ### DELETE /api/v1/users/{user_id} Delete user Permanently delete a user and all their business associations. Requires a JSON body with 'confirm_password' — the calling user's own account password. Parameters: - user_id (path, string · uuid, required) Request body (UserDeleteRequest): - confirm_password (string · password, optional) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/users/{user_id} Get user Retrieve a specific user's profile by their UUID. Parameters: - user_id (path, string · uuid, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/users/{user_id} Update user Update a user's profile information. Parameters: - user_id (path, string, required) Request body (UserUpdate): - first_name (string, optional) - last_name (string, optional) - photo_url (string, optional) - onboarded (boolean, optional) - props (object, optional) Responses: 200, 400, 401, 403, 404, 422 ## vendor-bill-requests ### GET /api/v1/vendor-bill-requests List vendor bill-request links All links for the business, newest first. Raw tokens are never returned. Responses: 200, 401, 403, 422 ### POST /api/v1/vendor-bill-requests Create a vendor bill-request link Mint a public URL a vendor or contractor can use to submit a bill without an account. The raw URL is returned once and cannot be recovered later; only its hash is stored. Request body (VendorBillRequestLinkCreateRequest): - vendor_id (string, optional) - label (string, optional) - expires_in_days (integer, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/vendor-bill-requests/{link_id} Revoke a vendor bill-request link Stop accepting submissions through the link. The public form returns 404 after. Parameters: - link_id (path, string, required) Responses: 200, 401, 403, 404, 422 ## vendor-bill-requests-public ### GET /api/v1/public/bill-requests/{token} Vendor bill-request form metadata (unauthenticated) Resolve a bill-request token to what the submit form needs: business name, pre-bound vendor (if any), label, and required fields. Returns 404 for unknown, expired, or revoked tokens — the three are indistinguishable on purpose. Rate-limited per IP. Parameters: - token (path, string, required) Responses: 200, 404, 422, 429 ### POST /api/v1/public/bill-requests/{token} Submit a bill through a bill-request link (unauthenticated) Multipart form: submitter_name, submitter_email, amount (dollars), optional invoice_number / due_date / description, and the invoice file (PDF, PNG, or JPG). Creates a draft bill for the manager to confirm or deny. 409 when the invoice looks like a duplicate. Rate-limited per IP and per link. Parameters: - token (path, string, required) Responses: 201, 400, 404, 409, 422, 429 ## vendor-contracts — Vendor contract tracking with renewal alerts and spend analysis. ### GET /api/v1/vendor-contracts List vendor contracts List all vendor contracts/MSAs for the business. Parameters: - vendor_id (query, string, optional): Filter by vendor UUID - status (query, string, optional): Filter by status: draft, active, expired, terminated - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/vendor-contracts Create vendor contract Create a new vendor contract/MSA. Request body (VendorContractCreateRequest): - name (string, required) - vendor_id (string, required) - status (string, optional) - effective_date (string · date, optional) - expiration_date (string · date, optional) - contracted_amount_cents (integer, optional) - billing_frequency (string, optional) - terms_summary (string, optional) - s3_key (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/vendor-contracts/analyze AI contract analysis Get AI-powered vendor contract analysis. Responses: 201, 401, 403, 422 ### DELETE /api/v1/vendor-contracts/{contract_id} Delete vendor contract Delete a vendor contract. Parameters: - contract_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/vendor-contracts/{contract_id} Get vendor contract Get details of a specific vendor contract. Parameters: - contract_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/vendor-contracts/{contract_id} Update vendor contract Update an existing vendor contract. Parameters: - contract_id (path, string, required) Request body (VendorContractUpdateRequest): - name (string, optional) - status (string, optional) - effective_date (string · date, optional) - expiration_date (string · date, optional) - contracted_amount_cents (integer, optional) - billing_frequency (string, optional) - terms_summary (string, optional) - s3_key (string, optional) Responses: 200, 400, 401, 403, 404, 422 ## vendor-credits ### GET /api/v1/vendor-credits List vendor credits List all vendor credits for the business with optional filtering. Parameters: - vendor_id (query, string, optional): Filter by vendor ID - status (query, VendorCreditStatusEnum, optional): Filter by status - has_remaining_balance (query, boolean, optional): Only show credits with remaining balance - search (query, string, optional): Search by vendor credit number (e.g. VC-0001) - cursor (query, string, optional): Pagination cursor - limit (query, integer, optional): Page size Responses: 200, 401, 403, 422 ### POST /api/v1/vendor-credits Create vendor credit Create a new vendor credit in draft status. Request body (VendorCreditCreate): - vendor_id (string, required) - amount_cents (integer, required) - reason (VendorCreditReasonEnum, optional) → VendorCreditReasonEnum - description (string, optional) - bill_id (string, optional) - ledger_id (string, optional) - issue_date (string · date, optional) - line_items (array · VendorCreditLineItem, optional) - allocation_lines (array · JournalEntryLineItem, optional) - internal_notes (string, optional) - vendor_credit_number (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### GET /api/v1/vendor-credits/vendors/{vendor_id}/credits Get vendor available credits Get summary of available vendor credits for a vendor. Parameters: - vendor_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### DELETE /api/v1/vendor-credits/{vendor_credit_id} Delete vendor credit Delete a vendor credit. Applied credits are removed from linked bills and those bills are recalculated. Void credits cannot be deleted. Parameters: - vendor_credit_id (path, string, required) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/vendor-credits/{vendor_credit_id} Get vendor credit Get a specific vendor credit by ID. Parameters: - vendor_credit_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/vendor-credits/{vendor_credit_id} Update vendor credit Update a draft vendor credit. Parameters: - vendor_credit_id (path, string, required) Request body (VendorCreditUpdate): - amount_cents (integer, optional) - reason (VendorCreditReasonEnum, optional) - description (string, optional) - bill_id (string, optional) - ledger_id (string, optional) - issue_date (string · date, optional) - line_items (array · VendorCreditLineItem, optional) - allocation_lines (array · JournalEntryLineItem, optional) - internal_notes (string, optional) - vendor_credit_number (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### POST /api/v1/vendor-credits/{vendor_credit_id}/apply Apply vendor credit to bill Apply a portion or all of a vendor credit to a bill. Parameters: - vendor_credit_id (path, string, required) Request body (VendorCreditApplicationCreate): - bill_id (string, required) - amount_cents (integer, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/vendor-credits/{vendor_credit_id}/issue Issue vendor credit Issue a draft vendor credit, making it available for application to bills. Parameters: - vendor_credit_id (path, string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/vendor-credits/{vendor_credit_id}/journal-entry Generate vendor credit journal entry Post the issue journal entry for a vendor credit that has none linked (Dr offset account, Cr Vendor Credit Balance). Parameters: - vendor_credit_id (path, string, required) Request body (VendorCreditJournalEntryGenerateRequest): - ledger_id (string, optional) - journal_entry_date (string · date, optional) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/vendor-credits/{vendor_credit_id}/journal-entry/link Attach journal entry to vendor credit Link an existing journal entry to a vendor credit. Parameters: - vendor_credit_id (path, string, required) Request body (JournalEntryLinkRequest): - journal_entry_id (string, required) Responses: 201, 400, 401, 403, 404, 409, 422 ### POST /api/v1/vendor-credits/{vendor_credit_id}/unapply Un-apply vendor credit from bill Remove (un-link) a vendor credit from a bill, restoring balances. Parameters: - vendor_credit_id (path, string, required) Request body (VendorCreditUnapply): - bill_id (string, required) Responses: 201, 400, 401, 403, 404, 422 ### POST /api/v1/vendor-credits/{vendor_credit_id}/void Void vendor credit Void a vendor credit. Only allowed for unapplied (draft or issued) credits. Parameters: - vendor_credit_id (path, string, required) Request body (VendorCreditVoid): - reason (string, required) Responses: 201, 400, 401, 403, 404, 422 ## vendors — Vendor management — accounts payable counterparties. ### GET /api/v1/vendors List vendors Retrieve all suppliers/vendors for the business. Parameters: - search (query, string, optional): Fuzzy search vendors by name (uses trigram matching) - status (query, string, optional): Filter by status: active, inactive, or blocked - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 422 ### POST /api/v1/vendors Create vendor Add a new supplier/vendor. Request body (VendorCreateRequest): - name (string, required) - email (string · email, optional) - address (string, optional) - phone (string, optional) - tax_id (string, optional) - website (string, optional) - notes (string, optional) - credit_limit_cents (integer, optional) - default_payment_term_id (string, optional) - status (CounterpartyStatus, optional) → CounterpartyStatus - category (string, optional) Responses: 201, 400, 401, 403, 422 ### POST /api/v1/vendors/bulk-upload Bulk upload vendors from CSV Upload a CSV file to create multiple vendors at once. Duplicate emails are skipped. Returns created/skipped counts and per-row errors. Responses: 201, 400, 401, 403, 422 ### GET /api/v1/vendors/bulk-upload/template Download bulk vendor upload CSV template Get a sample CSV template with the expected columns for bulk vendor upload. Responses: 200, 401, 403, 422 ### GET /api/v1/vendors/check-duplicates Check for duplicate vendors Check if a vendor already exists using name, email, tax ID similarity. Parameters: - name (query, string, required): Vendor name to check - email (query, string, optional): Email to check - tax_id (query, string, optional): Tax ID to check - exclude_id (query, string, optional): Vendor ID to exclude (for updates) Responses: 200, 401, 403, 422 ### DELETE /api/v1/vendors/{id} Delete vendor Soft delete a vendor record. The vendor is marked as deleted and hidden from list endpoints, but remains retrievable by ID so existing references on bills and other records stay intact. Parameters: - id (path, string, required) Responses: 200, 401, 403, 404, 409, 422 ### GET /api/v1/vendors/{id} Get vendor Retrieve a specific vendor by ID. Parameters: - id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/vendors/{id} Update vendor Update vendor contact information. Parameters: - id (path, string, required) Request body (VendorUpdateRequest): - name (string, optional) - email (string · email, optional) - address (string, optional) - phone (string, optional) - tax_id (string, optional) - website (string, optional) - notes (string, optional) - credit_limit_cents (integer, optional) - default_payment_term_id (string, optional) - status (CounterpartyStatus, optional) - category (string, optional) Responses: 200, 400, 401, 403, 404, 422 ### GET /api/v1/vendors/{vendor_id}/contacts List vendor contacts Retrieve all contacts for a vendor. Parameters: - vendor_id (path, string, required) - cursor (query, string, optional): Cursor for pagination - limit (query, integer, optional): Pagination limit - direction (query, string, optional): Pagination direction: 'next' or 'prev' - include_total_count (query, boolean, optional): Whether to include total count (expensive - avoid if possible) - sort_by (query, string, optional): Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None. - descending (query, boolean, optional): Sort direction: true for descending (newest/largest first), false for ascending Responses: 200, 401, 403, 404, 422 ### POST /api/v1/vendors/{vendor_id}/contacts Create vendor contact Add a new contact to a vendor. Parameters: - vendor_id (path, string, required) Request body (EntityContactCreateRequest): - name (string, required) - email (string · email, optional) - phone (string, optional) - role (string, optional) - is_primary (boolean, optional) - notes (string, optional) Responses: 201, 400, 401, 403, 404, 422 ### DELETE /api/v1/vendors/{vendor_id}/contacts/{contact_id} Delete vendor contact Delete a vendor contact. Parameters: - vendor_id (path, string, required) - contact_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### GET /api/v1/vendors/{vendor_id}/contacts/{contact_id} Get vendor contact Retrieve a specific vendor contact. Parameters: - vendor_id (path, string, required) - contact_id (path, string, required) Responses: 200, 401, 403, 404, 422 ### PUT /api/v1/vendors/{vendor_id}/contacts/{contact_id} Update vendor contact Update an existing vendor contact. Parameters: - vendor_id (path, string, required) - contact_id (path, string, required) Request body (EntityContactUpdateRequest): - name (string, optional) - email (string · email, optional) - phone (string, optional) - role (string, optional) - is_primary (boolean, optional) - notes (string, optional) Responses: 200, 400, 401, 403, 404, 422