# Dataset routes: update, delete

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

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

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

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

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

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

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Dataset. |
| `name` | `string` | No | The name of the Product. |
| `promise` | `text` | No | What the Customer can rely on. |
| `records` | `integer` | No | How many Things it holds. |
| `refreshedAt` | `datetime` | No | When its Sources were last read. |

**Returns**

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

**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/ratebook.dev/datasets/dataset_UDQXk0KsJB \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"records":1}'
```

```json
{
  "api": "https://api.sb/ratebook.dev",
  "dataset": {
    "$id": "https://api.sb/ratebook.dev/datasets/dataset_UDQXk0KsJB",
    "$type": "Dataset",
    "name": "Ratebook",
    "promise": "A rate for any US address in under 100 milliseconds.",
    "status": "draft",
    "records": 1
  },
  "action": {
    "$id": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq",
    "operation": "Dataset.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq"
  }
}
```

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

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

Path: `id`. Emits `Dataset.deleted`.

**Inputs**

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

**Returns**

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

**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/ratebook.dev/datasets/dataset_UDQXk0KsJB \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/ratebook.dev",
  "dataset": {
    "$id": "https://api.sb/ratebook.dev/datasets/dataset_UDQXk0KsJB",
    "$type": "Dataset",
    "name": "Ratebook",
    "promise": "A rate for any US address in under 100 milliseconds.",
    "status": "draft"
  },
  "action": {
    "$id": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq",
    "operation": "Dataset.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq"
  }
}
```