# Deal routes: update, delete

URL: /code/api/deal/records-update · Id: `page:code/api/deal/records-update`

> The Deal Verbs update, delete as api.sb routes, with inputs, result, refusals and an example.

Reference for [Deal](/business/nouns/deal), one group of [Deal routes](/code/api/deal).

### Deal.update
Changes the given properties of a Deal. [Verb page](/business/nouns/deal/update?interface=api).

```text
PATCH /{namespace}/deals/{id}
```

Path: `id`. Body, as JSON: the other inputs. Emits `Deal.updated`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Deal. |
| `value` | `money` | No | What the Deal is worth if won. |
| `owner` | [Worker](/business/nouns/worker) | No | The Worker who runs it. |
| `closesOn` | `date` | No | The date the buyer expects to decide. |
| `nextStep` | `text` | No | The next dated step agreed with the buyer. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `deal` | [Deal](/business/nouns/deal) | Yes | The Deal. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X PATCH https://api.sb/leaseline.app/deals/deal_NgACZ6DcII \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value":{"amount":29,"currency":"USD"}}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "deal": {
    "$id": "https://api.sb/leaseline.app/deals/deal_NgACZ6DcII",
    "$type": "Deal",
    "status": "Open",
    "value": {
      "amount": 29,
      "currency": "USD"
    }
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Deal.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Deal.delete
Deletes a Deal: a soft delete that keeps its history, undone by `Thing.restore`. [Verb page](/business/nouns/deal/delete?interface=api).

```text
DELETE /{namespace}/deals/{id}
```

Path: `id`. Emits `Deal.deleted`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Deal. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `deal` | [Deal](/business/nouns/deal) | Yes | The Deal. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X DELETE https://api.sb/leaseline.app/deals/deal_NgACZ6DcII \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "deal": {
    "$id": "https://api.sb/leaseline.app/deals/deal_NgACZ6DcII",
    "$type": "Deal",
    "status": "Open"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Deal.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```