# Goal routes: update, delete

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

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

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

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

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

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

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Goal. |
| `objective` | `text` | No | The qualitative outcome. |
| `horizon` | `string` | No | One of `day`, `week`, `quarter`, `year`, or `three-years`. |

**Returns**

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

**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/goals/goal_L9PBQQhfuF \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"horizon":"day"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "goal": {
    "$id": "https://api.sb/leaseline.app/goals/goal_L9PBQQhfuF",
    "$type": "Goal",
    "objective": "Example objective",
    "horizon": "day"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Goal.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

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

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

Path: `id`. Emits `Goal.deleted`.

**Inputs**

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

**Returns**

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

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

```json
{
  "api": "https://api.sb/leaseline.app",
  "goal": {
    "$id": "https://api.sb/leaseline.app/goals/goal_L9PBQQhfuF",
    "$type": "Goal",
    "objective": "Example objective"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Goal.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```