# Portfolio routes: update, delete

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

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

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

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

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

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

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Portfolio. |
| `type` | list of [Noun](/business/nouns/noun) | No | The Nouns this Thing is an instance of. |
| `outside` | `json` | No | The ids this Thing has in outside tools, one per Integration, so a re-run matches instead of duplicating. |
| `query` | `json` | No | The saved query that defines a dynamic Collection. |
| `membership` | `string` | No | How each member belongs: `held`, `owned`, `contracted`, or `made`. |

**Returns**

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

**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/portfolios/portfolio_zkvUnP8LwY \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"membership":"held"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "portfolio": {
    "$id": "https://api.sb/leaseline.app/portfolios/portfolio_zkvUnP8LwY",
    "$type": "Portfolio",
    "id": "Example id",
    "type": [
      "noun_v0akLUrXCN"
    ],
    "membership": "held"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Portfolio.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

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

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

Path: `id`. Emits `Portfolio.deleted`.

**Inputs**

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

**Returns**

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

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

```json
{
  "api": "https://api.sb/leaseline.app",
  "portfolio": {
    "$id": "https://api.sb/leaseline.app/portfolios/portfolio_zkvUnP8LwY",
    "$type": "Portfolio",
    "id": "Example id",
    "type": [
      "noun_v0akLUrXCN"
    ]
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Portfolio.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```