# Add a deal to the ledger

Records the agreed economics of a funded deal — the row every "collected", "outstanding" and "available" figure is then computed from. Body: `dealDate` (required, `YYYY-MM-DD`) and the deal it mirrors, which must be `facilityId` or `dealRowId` (a deal record on our own board) or the request is refused; then `lenderId`, `merchantId`, `reference`, `currency`, `fundedAmountMinor`, `commissionMinor`, `psfMinor`, `clawbackWindowDays`, `slaDays`, `notes`. Money is integer minor units. Only what was AGREED is stored here; who is owed a share of it is a separate call to `post_accounting_deal-splits`, and commission with no stake behind it surfaces as a `no_splits` exception.

Access class: `workspace`.

## Endpoint

`POST /v1/accounting/deals`

## Request body

Content type: `application/json`.

```json
{
  "body": {
    "clawbackWindowDays": 1,
    "commissionMinor": 1,
    "currency": "string",
    "dealDate": "string",
    "dealRowId": "",
    "facilityId": 1,
    "fundedAmountMinor": 1,
    "lenderId": 1,
    "merchantId": 1,
    "notes": "string",
    "psfMinor": 1,
    "reference": "string",
    "slaDays": 1
  },
  "params": {},
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "clawbackAmountMinor": 1,
    "clawbackWindowDays": 1,
    "commissionMinor": 1,
    "createdAt": "string",
    "currency": "string",
    "dealDate": "string",
    "dealRowId": "",
    "defaultAmountMinor": 1,
    "defaultedInWindow": true,
    "defaultedOn": "string",
    "detail": {},
    "facilityId": 1,
    "fundedAmountMinor": 1,
    "grossRevenueMinor": 1,
    "holdReason": "string",
    "holdReleasedAt": "string",
    "holdStartedAt": "string",
    "holdState": "string",
    "id": 1,
    "lenderId": 1,
    "merchantId": 1,
    "notes": "string",
    "psfMinor": 1,
    "reference": "string",
    "rollup": {
      "agingDays": 1,
      "clawbackOpenMinor": 1,
      "clawbackRecoveredMinor": 1,
      "collectedMinor": 1,
      "commissionCollectedMinor": 1,
      "costsMinor": 1,
      "outstandingMinor": 1,
      "pastSla": true,
      "psfCollectedMinor": 1
    },
    "slaDays": 1,
    "status": "string",
    "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"
}
```
