# Add an underwriting rule

Add one rule to a set's draft: a condition in the formula grammar over the namespace (stmt.*, tax.*, credit.*, extract.*, deal.*), an outcome for when it does not hold (pass, fail or review), a reason template and a weight. The condition is parsed here, so a malformed one is refused rather than erroring on every deal later. Publish to make it run.

Access class: `workspace:admin`.

## Endpoint

`POST /v1/workspace/underwriting/rule-sets/{setId}/rules`

## Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| setId | path | string | Yes |

## Request body

Content type: `application/json`.

```json
{
  "body": {
    "active": true,
    "condition": "string",
    "key": "string",
    "name": "string",
    "outcome": "string",
    "reasonTemplate": "string",
    "sortOrder": 1,
    "sourceText": "string",
    "weight": 1
  },
  "params": {
    ":setId": ""
  },
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "active": true,
    "condition": "string",
    "createdAt": "string",
    "id": 1,
    "key": "string",
    "name": "string",
    "outcome": "string",
    "reasonTemplate": "string",
    "setId": 1,
    "sortOrder": 1,
    "sourceText": "string",
    "updatedAt": "string",
    "weight": 1
  }
}
```

### 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"
}
```
