# Collection routes: update, delete

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

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

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

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

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

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

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Collection. |
| `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. |

**Returns**

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

**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/collections/collection_txTK8QorKn \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":{}}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "collection": {
    "$id": "https://api.sb/leaseline.app/collections/collection_txTK8QorKn",
    "$type": "Collection",
    "id": "Example id",
    "type": [
      "noun_v0akLUrXCN"
    ],
    "query": {}
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Collection.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

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

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

Path: `id`. Emits `Collection.deleted`.

**Inputs**

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

**Returns**

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

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

```json
{
  "api": "https://api.sb/leaseline.app",
  "collection": {
    "$id": "https://api.sb/leaseline.app/collections/collection_txTK8QorKn",
    "$type": "Collection",
    "id": "Example id",
    "type": [
      "noun_v0akLUrXCN"
    ]
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Collection.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```