# Problem routes: update, delete

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

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

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

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

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

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

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Problem. |
| `statement` | `text` | No | The struggle, in the words of the ICP. |
| `costPerPeriod` | `json` | No | What the Problem costs the ICP per period: hours times wage, or the spend on what they hire today. |
| `address` | `json` | No | The opportunity map cell it sits on: an occupation, a task it performs, and an industry. |
| `moment` | `text` | No | The moment the job starts, with the observable trigger that marks it. |
| `progress` | `text` | No | The progress the ICP wants, from the state before to the state after. |
| `hiredToday` | `json` | No | What the ICP hires for the job today, by kind and cost: software, a Service, their own hands, or nothing. |

**Returns**

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

**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/problems/problem_UzvXXfKsJB \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"statement":"Tracks lease renewals for small property managers."}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "problem": {
    "$id": "https://api.sb/leaseline.app/problems/problem_UzvXXfKsJB",
    "$type": "Problem",
    "statement": "Tracks lease renewals for small property managers."
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Problem.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

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

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

Path: `id`. Emits `Problem.deleted`.

**Inputs**

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

**Returns**

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

**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/problems/problem_UzvXXfKsJB \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "problem": {
    "$id": "https://api.sb/leaseline.app/problems/problem_UzvXXfKsJB",
    "$type": "Problem",
    "statement": "Tracks lease renewals for small property managers."
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Problem.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```