{"openapi":"3.1.0","info":{"title":"POST /api/v1/credit/lines","version":"1.0.0","description":"Open a credit line"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/lines":{"post":{"tags":["credit"],"summary":"Open a credit line","description":"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).","operationId":"create_credit_line","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditLineCreateRequest"}}}},"responses":{"201":{"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":"create_credit_line_api_v1_credit_lines_post"}}},"components":{"schemas":{"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."},"CreditLineCreateRequest":{"properties":{"program_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Program Id","description":"Program to open under. Falls back to the default."},"external_line_id":{"anyOf":[{"type":"string","maxLength":128},{"type":"null"}],"title":"External Line Id","description":"Your id for the line, unique within your business. An open that repeats one already in use returns that line as it stands and writes nothing, so a timed-out open can be sent again."},"external_merchant_id":{"anyOf":[{"type":"string","maxLength":128},{"type":"null"}],"title":"External Merchant Id"},"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."},"credit_limit_cents":{"type":"integer","minimum":0.0,"title":"Credit Limit Cents","description":"Approved card spend limit."},"term_days":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Term Days","description":"30, 45, 60, or 90 (D-03). Applies to each transaction from its own posting date. Defaults to the program's first option."},"rate_bps":{"anyOf":[{"type":"integer","maximum":10000.0,"minimum":0.0},{"type":"null"}],"title":"Rate Bps"},"disbursement_fee_bps":{"anyOf":[{"type":"integer","maximum":500.0,"minimum":0.0},{"type":"null"}],"title":"Disbursement Fee Bps","description":"0-500 bps (0%-5%). Inherits the program default when omitted."},"cycle_anchor_day":{"anyOf":[{"type":"integer","maximum":31.0,"minimum":1.0},{"type":"null"}],"title":"Cycle Anchor Day"},"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). Shown on the dashboard metadata row."},"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; bank-matched settlement watches it and AutoPay needs it."},"autopay_enabled":{"type":"boolean","title":"Autopay Enabled","description":"Emit credit.autopay.due once for each loan when it falls due, or on the next sweep for a loan already past due (the partner debits).","default":false},"merchant_email":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Merchant Email","description":"Where statements and borrower notices go. None sends 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. Required at open when 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. Required at open when the program's `compliance.enabled` is true."},"merchant_address":{"anyOf":[{"$ref":"#/components/schemas/MerchantAddress"},{"type":"null"}],"description":"The merchant's registered address. Required at open when the program's `compliance.enabled` is true."},"card":{"anyOf":[{"$ref":"#/components/schemas/LineOpenCardRequest"},{"type":"null"}],"description":"Issue a card with the line. Only under a program with `card_management: dayzero` and `issuing_enabled: true` (else `400 CREDIT_551`, and no line is opened). Once the line is open DayZero issues the card as `POST /credit/cards` would, with the program's MCC allow list; the response carries `card`, or `card_issue_error` when the issuer refused it, in which case the line stays open and the card can be issued later with `POST /credit/cards`."}},"additionalProperties":false,"type":"object","required":["credit_limit_cents"],"title":"CreditLineCreateRequest","description":"Open a line on approval (§14, call 1).\n\nUnspecified terms inherit the program's defaults, so a partner that\nruns one set of commercial terms sends only the merchant and limit."},"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)."},"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."},"LineOpenCardRequest":{"properties":{"cardholder_provider_user_id":{"anyOf":[{"type":"string","maxLength":128,"minLength":1},{"type":"null"}],"title":"Cardholder Provider User Id","description":"Deprecated. The card is issued to the program's issuing identity (`ramp_cardholder_user_id`), so the request names no cardholder; a value sent is ignored when the program has one."},"display_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Display Name","description":"The card's label at the issuer. Defaults to the merchant's legal name, so the partner can tell its cards apart in its own account."},"card_type":{"type":"string","enum":["virtual","physical"],"title":"Card Type","description":"Virtual (the default) or physical.","default":"virtual"},"spend_interval":{"type":"string","enum":["TOTAL","DAILY","WEEKLY","MONTHLY","QUARTERLY","YEARLY","ANNUAL"],"title":"Spend Interval","description":"Interval the spend ceiling resets on. TOTAL (the default) is a lifetime limit, which is what the available-credit push assumes.","default":"TOTAL"},"transaction_limit_cents":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Transaction Limit Cents","description":"Per-transaction cap. None for no cap."}},"additionalProperties":false,"type":"object","title":"LineOpenCardRequest","description":"A card to issue with the line, on a program whose cards DayZero issues.\n\nIssued through the same path as ``POST /credit/cards``: the spend ceiling\ndefaults to the line's available credit and the category allow list to\nthe program's."},"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":[]}]}