# Add a document to a deal's contract

Renders one document against a deal and stores it, pinned to the template version it was built from. `kind` names the document (or `templateId` a specific template), and `terms` supplies values the template asks for beyond the record's own cells — placeholders are filled from the row's cells keyed by slugged column label, plus the workspace name and the caller's email. A placeholder nothing filled is a 422 that NAMES the missing ones rather than issuing a paper with a hole in it; an unknown kind is a 400 and a stranger's template a 404.

Access class: `def:read`.

## Endpoint

`POST /v1/definitions/{key}/rows/{rowId}/contract/documents`

## Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| key | path | string | Yes |
| rowId | path | string | Yes |

## Request body

Content type: `application/json`.

```json
{
  "body": {
    "kind": "string",
    "templateId": "",
    "terms": {
      "fee_percentage": "string"
    }
  },
  "params": {
    ":key": "string",
    ":rowId": ""
  },
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "body": "string",
    "bodyFormat": "string",
    "id": "",
    "kind": "string",
    "renderedAt": "string",
    "renderedBy": 1,
    "rowId": "",
    "substitutions": {},
    "templateId": "",
    "templateVersion": 1,
    "title": "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"
}
```
