# Raise a repayment schedule

Creates a repayment schedule on a deal and, when asked, writes its whole instalment run. Body: `startDate` is required; `dealRowId` (the deal record on our own board) or `facilityId` says what it is for, plus `scheduleNumber`, `currency`, `fundedAmountMinor`, `totalPaybackMinor`, `paymentAmountMinor`, `originationFeeMinor`, `otherFeesMinor`, `factorRate`, `interestRate`, `totalPayments`, `paymentFrequency` (daily_ach, daily, weekly, bi_weekly, monthly), `paymentMethod` (ach, wire, check, card, revenue_split, manual, other), `offerId`, `contractId`, `fundingRecordId`, `internalNotes`, and `generatePayments` to write the instalments now. Money is MINOR UNITS — dollars in `paymentAmountMinor` are wrong by a hundredfold. Every instalment is the payment amount and the last absorbs the remainder, so the run sums to the payback exactly; a payment count and amount that overshoot the payback are refused rather than stored. Completing a deal's funding raises a schedule on its own, so reach for this when a schedule is being set up by hand.

Access class: `workspace`.

## Endpoint

`POST /v1/payment-schedules`

## Request body

Content type: `application/json`.

```json
{
  "body": {
    "contractId": 1,
    "currency": "string",
    "dealRowId": "",
    "facilityId": 1,
    "factorRate": "string",
    "fundedAmountMinor": 1,
    "fundingRecordId": 1,
    "generatePayments": true,
    "interestRate": "string",
    "internalNotes": "string",
    "offerId": 1,
    "originationFeeMinor": 1,
    "otherFeesMinor": 1,
    "paymentAmountMinor": 1,
    "paymentFrequency": "string",
    "paymentMethod": "string",
    "scheduleNumber": "string",
    "startDate": "string",
    "totalPaybackMinor": 1,
    "totalPayments": 1
  },
  "params": {},
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "actualEndDate": "string",
    "collectionRate": "string",
    "completedAt": "string",
    "consecutiveMissed": 1,
    "contractId": 1,
    "createdAt": "string",
    "currency": "string",
    "daysDelinquent": 1,
    "dealRowId": "",
    "detail": {},
    "expectedEndDate": "string",
    "facilityId": 1,
    "factorRate": "string",
    "fundedAmountMinor": 1,
    "fundingRecordId": 1,
    "id": 1,
    "interestRate": "string",
    "internalNotes": "string",
    "isDelinquent": true,
    "lastModifiedReason": "string",
    "modificationsCount": 1,
    "nextPaymentDate": "string",
    "offerId": 1,
    "originationFeeMinor": 1,
    "otherFeesMinor": 1,
    "pausedAt": "string",
    "paymentAmountMinor": 1,
    "paymentFrequency": "string",
    "paymentMethod": "string",
    "paymentsMade": 1,
    "paymentsRemaining": 1,
    "paymentsWaived": 1,
    "scheduleNumber": "string",
    "startDate": "string",
    "status": "string",
    "totalCollectedMinor": 1,
    "totalMissedMinor": 1,
    "totalOutstandingMinor": 1,
    "totalPaybackMinor": 1,
    "totalPayments": 1,
    "updatedAt": "string"
  }
}
```

### default

a refusal: `{"error": "<what a person needs to read>"}`. 401 no credential, 402 the plan does not include this, 403 the seat does not, 404 the thing does not exist or is not yours to see.

Content type: `application/json`.

```json
{
  "error": "string"
}
```
