# POST /api/v1/credit/lines

> Open a credit line

- **Tag:** credit
- **Operation ID:** `create_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).

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Request body

Schema: `CreditLineCreateRequest`

- `program_id` (string) — Program to open under. Falls back to the default.
- `external_line_id` (string) — 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` (string)
- `merchant_business_id` (string) — 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` (integer · required) — Approved card spend limit.
- `term_days` (integer) — 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` (integer)
- `disbursement_fee_bps` (integer) — 0-500 bps (0%-5%). Inherits the program default when omitted.
- `cycle_anchor_day` (integer)
- `start_date` (string · date) — 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` (string) — Display name of the merchant's repayment account.
- `linked_account_mask` (string) — Last digits of the repayment account.
- `plaid_account_id` (string) — The merchant's Plaid account the repayments leave from; bank-matched settlement watches it and AutoPay needs it.
- `autopay_enabled` (boolean) — 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).
- `merchant_email` (string) — Where statements and borrower notices go. None sends nothing.
- `merchant_legal_name` (string) — The merchant's legal entity name, as printed on disclosures. Required at open when the program's `compliance.enabled` is true.
- `merchant_state` (string) — 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` (MerchantAddress) — The merchant's registered address. Required at open when the program's `compliance.enabled` is true.
- `card` (LineOpenCardRequest) — 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`.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_CreditLineResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (CreditLineResponse)

### 400 — Bad Request - Invalid input

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 401 — Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 403 — Forbidden - Insufficient permissions

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 404 — Not Found - Resource does not exist

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 422 — Validation Error

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/credit/lines' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "credit_limit_cents": 0
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/credit/lines', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "credit_limit_cents": 0
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {'credit_limit_cents': 0}

response = httpx.post("https://api.ondayzero.com/api/v1/credit/lines", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/credit/create-credit-line
- OpenAPI slice: https://www.ondayzero.com/docs/reference/credit/create-credit-line/openapi.json
- Other endpoints in **credit**: https://www.ondayzero.com/docs/reference/credit (markdown bundle: https://www.ondayzero.com/docs/reference/credit.md, OpenAPI: https://www.ondayzero.com/docs/reference/credit/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
