# Close a deal

End a deal in one act: move it to a terminal status, record whether it was won, lost or declined with the reason and a closing note, and create the follow-up task — all in one transaction, so a refused half leaves the deal where it was. A decline must say why, and a decline also EMAILS the merchant that reason through the workspace's own decline template once the close has committed; send notifyMerchant false for silence, or notifyTemplateId to pick the words. The send can never fail the close — no address on file, an opted-out contact or a refused rail all come back in notSentBecause beside a closing that landed. Use it instead of a bare status change whenever the deal is actually over.

Access class: `def:read`.

## Endpoint

`POST /v1/definitions/{key}/rows/{rowId}/close`

## Parameters

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

## Request body

Content type: `application/json`.

```json
{
  "body": {
    "cells": {},
    "force": true,
    "note": "string",
    "notifyMerchant": true,
    "notifyTemplateId": 1,
    "outcome": "string",
    "reason": "string",
    "reasonCode": "string",
    "stage": "string",
    "status": "string",
    "task": {
      "assigneeUserId": 1,
      "description": "string",
      "dueAt": "string",
      "priority": "string",
      "taskType": "string",
      "title": "string"
    }
  },
  "params": {
    ":key": "string",
    ":rowId": ""
  },
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "closing": {
      "closedAt": "string",
      "closedBy": 1,
      "createdAt": "string",
      "dealRowId": "",
      "id": "",
      "note": "string",
      "outcome": "string",
      "reason": "string",
      "reasonCode": "string",
      "stage": "string",
      "status": "string",
      "taskId": 1,
      "updatedAt": "string"
    },
    "notSentBecause": "string",
    "notice": {
      "at": "string",
      "body": "string",
      "conversationId": 1,
      "medium": "string",
      "messageId": 1,
      "recipient": "string",
      "templateId": 1
    },
    "row": {
      "archived_at": "string",
      "assignees": {},
      "cells": {},
      "createdBy": "string",
      "display": {},
      "externalId": "",
      "groupId": "",
      "id": "",
      "position": 1,
      "source": "string"
    },
    "task": {
      "assigneeAccountId": "",
      "assigneeUserId": 1,
      "blockedByTaskId": 1,
      "calendarEventId": "",
      "cancellationReason": "string",
      "cancelledAt": "string",
      "completedAt": "string",
      "completedByUserId": 1,
      "createdAt": "string",
      "createdByKind": "string",
      "createdByUserId": 1,
      "customerActionRequired": true,
      "customerVisible": true,
      "description": "string",
      "detail": {},
      "dueAt": "string",
      "entityId": 1,
      "entityKind": "string",
      "escalated": true,
      "escalatedAt": "string",
      "escalationCount": 1,
      "id": 1,
      "nodeId": "",
      "outcome": "string",
      "outcomeNotes": "string",
      "parentTaskId": 1,
      "priority": "string",
      "requestedDocumentType": "string",
      "slaBreachAt": "string",
      "slaBreached": true,
      "slaWarned": true,
      "slaWarningAt": "string",
      "source": "string",
      "startedAt": "string",
      "status": "string",
      "tags": [
        "string"
      ],
      "taskType": "string",
      "threadId": 1,
      "title": "string",
      "updatedAt": "string",
      "workflowExecutionId": 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"
}
```
