{"openapi":"3.1.0","info":{"title":"PATCH /api/v1/credit/lines/{credit_line_id}","version":"1.0.0","description":"Update a credit line"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/lines/{credit_line_id}":{"patch":{"tags":["credit"],"summary":"Update a credit line","description":"Change the repayment account, AutoPay, the credit limit, or the status.\n\nSupplying ``credit_limit_cents`` re-approves the line: it emits\n``credit.line.limit_changed`` and pushes the new available credit to\nthe issuer. This is the write behind Request More Funding.\n\nSupplying ``status`` needs ``reason`` and emits\n``credit.line.suspended``, ``credit.line.reinstated`` or\n``credit.line.closed``. Activating a pending line whose disclosure\nawaits the merchant's acknowledgement needs ``acknowledgement_override``\nfrom an operator.","operationId":"update_credit_line","parameters":[{"name":"credit_line_id","in":"path","required":true,"schema":{"type":"string","title":"Credit Line Id"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditLineUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_CreditLineResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"update_credit_line_api_v1_credit_lines__credit_line_id__patch"}}},"components":{"schemas":{"AcknowledgementOverride":{"properties":{"reason":{"type":"string","maxLength":255,"minLength":1,"title":"Reason","description":"Why the line opens before the merchant acknowledges its disclosure. Recorded on the disclosure, in the audit trail and on `credit.disclosure.overridden`."}},"additionalProperties":false,"type":"object","required":["reason"],"title":"AcknowledgementOverride","description":"Activate a pending line without the merchant's acknowledgement."},"CardIssuanceStatusEnum":{"type":"string","enum":["requested","active","suspended","terminated","failed"],"title":"CardIssuanceStatusEnum","description":"Lifecycle of a card we issued on a merchant's behalf.\n\nMirrors the issuer's own fund/card states so a reconciliation sweep\ncan compare ours against theirs without a translation table."},"CreditLineResponse":{"properties":{"id":{"type":"string","title":"Id"},"program_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Program Id"},"external_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Line Id"},"external_merchant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Merchant Id"},"previous_external_merchant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Previous External Merchant Id","description":"`external_merchant_id` before its last change, if it changed."},"external_merchant_id_changed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"External Merchant Id Changed At","description":"When `external_merchant_id` last changed (UTC)."},"merchant_business_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Business Id","description":"The borrower's own DayZero business, when the line is linked to one. Underwriting assessments for the line measure it."},"status":{"$ref":"#/components/schemas/CreditLineStatusEnum"},"status_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status Reason","description":"Reason given with the last status change."},"status_changed_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Status Changed On","description":"Date of the last status change (UTC)."},"suspended_via":{"anyOf":[{"type":"string","enum":["collections","operator"]},{"type":"null"}],"title":"Suspended Via","description":"Who holds a suspended line suspended: `collections` (a `suspend_line` stage of the collections ladder, which reinstates the line when the merchant catches up) or `operator` (the console or the API; only an operator reinstates it). Null when the line is not suspended, or for a suspension made before this was recorded that the record could not place, which collections never lifts."},"lending_model":{"$ref":"#/components/schemas/LendingModel","default":"per_transaction"},"credit_limit_cents":{"type":"integer","title":"Credit Limit Cents"},"as_of_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"As Of Date","description":"Financial position date from the authoritative credit clock, including sandbox overrides."},"used_credit_cents":{"type":"integer","title":"Used Credit Cents","description":"Unpaid principal after refunds on open and disputed purchases; fees and interest do not use credit.","default":0},"over_by_cents":{"type":"integer","title":"Over By Cents","description":"Used principal above the credit limit, floored at zero.","default":0},"current_balance_cents":{"type":"integer","title":"Current Balance Cents","description":"Total Balance: everything owed across every open loan, including transactions since the last month-end close (§7.1). Under cycle_draw programs: the sum across closed, unpaid cycles."},"total_balance_cents":{"type":"integer","title":"Total Balance Cents","description":"Same figure as current_balance_cents, by its FRD v2 name.","default":0},"statement_balance_cents":{"type":"integer","title":"Statement Balance Cents","description":"What moved onto the most recent statement at close (§7.1).","default":0},"unbilled_cents":{"type":"integer","title":"Unbilled Cents","description":"Outstanding on loans originated since the last close.","default":0},"past_due_cents":{"type":"integer","title":"Past Due Cents","description":"Outstanding on past-due loans that are not on hold.","default":0},"on_hold_cents":{"type":"integer","title":"On Hold Cents","description":"Outstanding on loans on hold for a dispute or a void. Part of Total Balance; not part of amount due or past due.","default":0},"credit_balance_cents":{"type":"integer","title":"Credit Balance Cents","description":"Carried-forward credit from refunds or overpayments (D-14).","default":0},"available_credit_cents":{"type":"integer","title":"Available Credit Cents","description":"Limit minus unpaid principal after refunds. Never negative. Zero whenever the line cannot spend: while it is `pending` (not open yet), `suspended`, or `closed`."},"utilisation_bps":{"type":"integer","title":"Utilisation Bps","description":"Balance over limit, in basis points."},"open_loan_count":{"type":"integer","title":"Open Loan Count","default":0},"term_days":{"type":"integer","title":"Term Days"},"rate_bps":{"type":"integer","title":"Rate Bps"},"disbursement_fee_bps":{"type":"integer","title":"Disbursement Fee Bps"},"start_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Start Date","description":"The signing date: the effective date named in the merchant's Credit Agreement. Not the approval date, the countersign date, or the first draw (D-18)."},"linked_account_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Linked Account Name"},"linked_account_mask":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Linked Account Mask"},"merchant_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Email"},"merchant_legal_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Legal Name","description":"The merchant's legal entity name."},"merchant_state":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant State","description":"Two-letter US state, DC or territory code."},"merchant_address":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Merchant Address","description":"The merchant's registered address."},"autopay_enabled":{"type":"boolean","title":"Autopay Enabled"},"open_cycle_activity_cents":{"type":"integer","title":"Open Cycle Activity Cents","description":"Per-transaction: outstanding on loans created since the last close — part of Total Balance from the moment they post, and not yet on a statement. Cycle-draw: open-cycle settlements.","default":0},"amount_due_cents":{"type":"integer","title":"Amount Due Cents","description":"What remains of the most recent statement's balance, less the part of it on loans on hold.","default":0},"next_due_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Next Due Date","description":"Earliest upcoming due date among loans not on hold, else the earliest past due."},"statement_due_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Statement Due Date","description":"Due date of the most recent statement, fixed at close: the earliest loan due date on it on or after the close day, else the close date (D-41)."},"as_of":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"As Of","description":"When these figures were computed. Every balance payload carries one so a client can label stale data (§10.11)."},"delinquency_stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Delinquency Stage","description":"Collections stage this line has reached, from the program ladder (D-31). Null when nothing is past due."},"delinquency_days":{"type":"integer","title":"Delinquency Days","description":"Days past due on the oldest past-due loan. 0 when current.","default":0},"card_management":{"type":"string","enum":["dayzero","partner"],"title":"Card Management","description":"Copied from the program: dayzero provisions cards and pushes spend limits; partner registers issuer cards and receives limit-changed events (D-51).","default":"dayzero"},"issuing_provider":{"type":"string","enum":["ramp","brex","stripe_issuing","lithic","external","mock"],"title":"Issuing Provider","description":"Copied from the program so the cards tab does not list programs.","default":"ramp"},"card":{"anyOf":[{"$ref":"#/components/schemas/IssuedCardResponse"},{"type":"null"}],"description":"The card issued with the line, when `POST /credit/lines` carried `card` and the issuer minted it (a repeat of that call returns it too). Null on every other read."},"card_issue_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Card Issue Error","description":"Why the card asked for on open was not issued (the error code and message, e.g. the issuer's refusal). The line is open regardless; issue the card with `POST /credit/cards`."}},"type":"object","required":["id","status","credit_limit_cents","current_balance_cents","available_credit_cents","utilisation_bps","term_days","rate_bps","disbursement_fee_bps","autopay_enabled"],"title":"CreditLineResponse","description":"Dashboard cards and metadata row (§4).\n\n``available_credit_cents`` and ``utilisation_bps`` are returned rather\nthan derived so the card, the statement band, and the payoff quote\ncannot disagree (§10.2)."},"CreditLineStatusEnum":{"type":"string","enum":["pending","active","suspended","closed"],"title":"CreditLineStatusEnum","description":"Lifecycle of a credit line itself (distinct from cycle state)."},"CreditLineUpdateRequest":{"properties":{"linked_account_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Linked Account Name","description":"Display name of the merchant's repayment account."},"linked_account_mask":{"anyOf":[{"type":"string","maxLength":8},{"type":"null"}],"title":"Linked Account Mask","description":"Last digits of the repayment account."},"plaid_account_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Plaid Account Id","description":"The merchant's Plaid account the repayments leave from."},"autopay_enabled":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Autopay Enabled","description":"Switch AutoPay due events on or off for the line."},"merchant_email":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Merchant Email","description":"Where statements and borrower notices go."},"merchant_business_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Business Id","description":"The borrower's own DayZero business, when it keeps its books here. An underwriting assessment for the line measures this business. Must be a business the caller can access."},"external_merchant_id":{"anyOf":[{"type":"string","maxLength":128,"minLength":1},{"type":"null"}],"title":"External Merchant Id","description":"Change your merchant identifier on the line. The value it replaces is kept as `previous_external_merchant_id`, with who changed it and when; payer and card mapping references and payout names still match the previous value. The merchant's bank connections and feeds on the program follow the new value. Another open (not closed) line of the same program with the same value is `409` `CREDIT_901`. Cannot be cleared: `null` changes nothing."},"merchant_legal_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Merchant Legal Name","description":"The merchant's legal entity name, as printed on disclosures. Cannot be cleared while the program's `compliance.enabled` is true."},"merchant_state":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Merchant State","description":"Two-letter US state, DC or territory code of the merchant. Selects the disclosure template. Cannot be cleared while the program's `compliance.enabled` is true."},"merchant_address":{"anyOf":[{"$ref":"#/components/schemas/MerchantAddress"},{"type":"null"}],"description":"The merchant's registered address. Cannot be cleared while the program's `compliance.enabled` is true."},"status":{"anyOf":[{"$ref":"#/components/schemas/CreditLineStatusEnum"},{"type":"null"}],"description":"Move the line between pending, active, suspended and closed. A change needs `reason`. Suspending, reinstating (suspended back to active) and closing emit `credit.line.suspended`, `credit.line.reinstated` and `credit.line.closed`. Closing is refused for an API token when the program's `limit_change_policy` is `console_only`. Sending the status the line already has changes nothing. Activating a `pending` line pushes its available credit to the issuer (or emits `credit.line.limit_changed` for partner-managed cards); while its disclosure awaits the merchant's acknowledgement it is refused (`CREDIT_617`) unless an operator sends `acknowledgement_override`."},"reason":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Reason","description":"Why the status changed. Required with a status change; carried on the event and returned as `status_reason` on the line."},"acknowledgement_override":{"anyOf":[{"$ref":"#/components/schemas/AcknowledgementOverride"},{"type":"null"}],"description":"Activate a `pending` line whose disclosure awaits the merchant's acknowledgement without it. Operators in the console only: an API token sending it is `403` (`CREDIT_618`). The disclosure becomes `overridden` with who, when and `reason`, and `credit.disclosure.overridden` is emitted. Ignored on any other status change, or when nothing awaits acknowledgement."},"reason_code":{"anyOf":[{"type":"string","enum":["credit_risk","delinquency","fraud","merchant_request","administrative"]},{"type":"null"}],"title":"Reason Code","description":"Optional category of a suspension or closure: `credit_risk`, `delinquency`, `fraud`, `merchant_request` or `administrative`. On a program with adverse-action notices on, the first three record an adverse action."},"credit_limit_cents":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Credit Limit Cents","description":"Re-approved limit, in cents. This is the write behind Request More Funding (§6.1) and behind a risk-led reduction. Changing it emits `credit.line.limit_changed` and pushes the new available credit to the issuer, so the card starts declining at the new limit. A reduction below the current balance is allowed — available credit floors at zero and existing loans keep their own terms. Follows the program's `limit_change_policy`: under `approval_required` every caller gets `409` (submit a limit-change request instead); under `console_only` an API token gets `403`."},"limit_change_reason":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Limit Change Reason","description":"Why the limit moved. Carried on the event and the ledger so an increase can be traced to the decision behind it."}},"additionalProperties":false,"type":"object","title":"CreditLineUpdateRequest","description":"Change the repayment account, AutoPay, the limit, or the status (§6)."},"IssuedCardResponse":{"properties":{"id":{"type":"string","title":"Id"},"credit_line_id":{"type":"string","title":"Credit Line Id"},"provider":{"type":"string","title":"Provider"},"provider_fund_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider Fund Id"},"provider_card_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider Card Id"},"status":{"$ref":"#/components/schemas/CardIssuanceStatusEnum"},"card_type":{"type":"string","title":"Card Type"},"display_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Display Name"},"last_four":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Four"},"expiration":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expiration"},"cardholder_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cardholder Name","description":"The name given when a partner registered the card. Null for a card DayZero issued: the issuer holds the cardholder (D-35)."},"spend_limit_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Spend Limit Cents"},"requested_spend_limit_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Requested Spend Limit Cents","description":"Operator lifetime cap; null means automatic allocation of shared line headroom."},"issuer_sync_status":{"type":"string","title":"Issuer Sync Status","description":"queued, pushed or failed. Queued controls are not yet issuer-confirmed; failure_reason explains failures.","default":"queued"},"spend_interval":{"type":"string","title":"Spend Interval"},"transaction_limit_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Transaction Limit Cents"},"allowed_mcc_codes":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Allowed Mcc Codes"},"blocked_mcc_codes":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Blocked Mcc Codes"},"auto_lock_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Auto Lock Date"},"issued_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Issued At"},"suspended_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Suspended At"},"suspended_via":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Suspended Via","description":"Who suspended the card: `borrower_portal` (the merchant, from the hosted portal), `collections` (a delinquency stage) or `operator` (the console or API). Null when the card is not suspended."},"terminated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Terminated At"},"last_synced_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Synced At"},"failure_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Failure Reason"},"managed_by":{"type":"string","title":"Managed By","default":"dayzero"}},"type":"object","required":["id","credit_line_id","provider","status","card_type","spend_interval"],"title":"IssuedCardResponse","description":"An issued card, as we hold it.\n\nNo PAN, no CVV, no cardholder PII beyond a display name — those never\ntransit DayZero by design (§5)."},"LendingModel":{"type":"string","enum":["per_transaction","cycle_draw"],"title":"LendingModel","description":"What the unit of borrowing is.\n\n* ``per_transaction`` — every posted card transaction originates its\n  own loan with its own term, due date, fee, and daily accrual after\n  the due date. The monthly statement is a presentation wrapper and\n  the moment accrued interest is applied. This is the Tie model\n  (FRD v2 §10.5, D-01).\n* ``cycle_draw`` — settlements accumulate into a monthly cycle that\n  resolves into one draw at close, carrying one term, one due date,\n  and one interest figure. The credit-card model FRD v1 specified.\n\nA program picks one. Lines inherit it, and every engine branch keys\non it, so a second partner on the other model is a row, not a build."},"MerchantAddress":{"properties":{"line1":{"type":"string","maxLength":255,"title":"Line1","description":"Street address."},"line2":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Line2","description":"Suite, floor or unit."},"city":{"type":"string","maxLength":128,"title":"City","description":"City."},"state":{"anyOf":[{"type":"string","maxLength":2},{"type":"null"}],"title":"State","description":"Two-letter state code; normally the line's `merchant_state`."},"postal_code":{"type":"string","maxLength":16,"title":"Postal Code","description":"ZIP or postal code."},"country":{"type":"string","maxLength":2,"title":"Country","description":"Two-letter country code.","default":"US"}},"additionalProperties":false,"type":"object","required":["line1","city","postal_code"],"title":"MerchantAddress","description":"The merchant's registered address, as the disclosure prints it."},"SuccessEnvelope_CreditLineResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/CreditLineResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[CreditLineResponse]"},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}